/* -*-c-*-
*
- * $Id: client.c,v 1.7 2001/02/22 09:07:54 mdw Exp $
+ * $Id: client.c,v 1.12 2003/10/15 09:29:38 mdw Exp $
*
* Client for TrIPE
*
/*----- Revision history --------------------------------------------------*
*
* $Log: client.c,v $
+ * Revision 1.12 2003/10/15 09:29:38 mdw
+ * Cosmetic fix to changelog comment.
+ *
+ * Revision 1.11 2003/07/13 11:19:49 mdw
+ * Incompatible protocol fix! Include message type code under MAC tag to
+ * prevent cut-and-paste from key-exchange messages to general packet
+ * transport.
+ *
+ * Revision 1.10 2003/05/17 10:59:19 mdw
+ * Put a newline in the pidfile.
+ *
+ * Revision 1.9 2002/01/13 14:57:18 mdw
+ * Track @lbuf@ changes in mLib.
+ *
+ * Revision 1.8 2001/06/19 22:09:37 mdw
+ * Move the program name to the right place when constructing the arguments
+ * to pass to a new server.
+ *
* Revision 1.7 2001/02/22 09:07:54 mdw
* Write a pidfile on request, and delete it when finished.
*
fprintf(logfp, "%s %s: %s\n", buf, cat, msg);
}
-static void cline(char *p, void *b)
+static void cline(char *p, size_t len, void *b)
{
char *q;
if (!p) {
die(EXIT_FAILURE, "unexpected output `%s %s'", q, p);
}
-static void sline(char *p, void *b)
+static void sline(char *p, size_t len, void *b)
{
if (!p) {
if (!(f & f_uclose))
puts(p);
}
-static void uline(char *p, void *b)
+static void uline(char *p, size_t len, void *b)
{
- size_t sz;
if (!p) {
selbuf_destroy(b);
shutdown(fd, 1);
f |= f_uclose;
} else {
- sz = strlen(p);
- p[sz] = '\n';
- write(fd, p, sz + 1);
+ p[len] = '\n';
+ write(fd, p, len + 1);
}
}
#endif
sigaction(SIGCHLD, &sa, 0);
- DA_UNSHIFT(&spawnopts, (char *)spawnpath);
DA_UNSHIFT(&spawnopts, (char *)sock);
DA_UNSHIFT(&spawnopts, "-a");
DA_UNSHIFT(&spawnopts, "-d.");
+ DA_UNSHIFT(&spawnopts, (char *)spawnpath);
DA_PUSH(&spawnopts, 0);
if (socketpair(PF_UNIX, SOCK_STREAM, 0, pfd))
die(EXIT_FAILURE, "error from socketpair: %s", strerror(errno));
close(pfd[0]);
if (logfp)
fclose(logfp);
+ if (pidfp)
+ fclose(pidfp);
closelog();
if (f & f_daemon)
u_detach();
die(EXIT_FAILURE, "error becoming daemon: %s", strerror(errno));
}
if (pidfp) {
- fprintf(pidfp, "%li", (long)getpid());
+ fprintf(pidfp, "%li\n", (long)getpid());
fclose(pidfp);
}