From: Ian Jackson Date: Tue, 22 Mar 2016 13:38:08 +0000 (+0000) Subject: cgi-fcgi-perl: wip, check_garbage X-Git-Tag: archive/debian/5.0.0~73 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=commitdiff_plain;h=be991945625d6a938d5be417adcf5d9fe393e647 cgi-fcgi-perl: wip, check_garbage --- diff --git a/cprogs/cgi-fcgi-perl.c b/cprogs/cgi-fcgi-perl.c index 58a858a..83bd962 100644 --- a/cprogs/cgi-fcgi-perl.c +++ b/cprogs/cgi-fcgi-perl.c @@ -214,6 +214,23 @@ static void find_socket_path(void) { socket_path = m_asprintf("%s/g%s",run_base,ident); } +static bool check_garbage(void) { + struct stat sock_stab, cmd_stab; + int r; + + r = lstat(socket_path, &sock_stab); + if (r) { + if ((errno == ENOENT)) + return 0; /* well, no garbage then */ + err(127,"stat socket (%s)",socket_path); + } + + r = lstat(command, &cmd_stab); + if (r) err(127,"lstat command (%s)",command); + + return 0; +} + int main(int argc, const char *const *argv) { myopt(&argv, cmdinfos); @@ -223,6 +240,8 @@ int main(int argc, const char *const *argv) { find_socket_path(); + check_garbage(); + printf(">%s<\n",socket_path); exit(0);