From feb542114454b1f979c025ede9474f53b6715bce Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Wed, 7 Sep 2011 14:57:14 +0000 Subject: [PATCH] Cleanup our toolies, remove unneeded code; handle reply values. --- citadel/utils/chkpw.c | 14 +++++++++++++- citadel/utils/chkpwd.c | 5 ++--- citadel/utils/getmail.c | 27 --------------------------- 3 files changed, 15 insertions(+), 31 deletions(-) diff --git a/citadel/utils/chkpw.c b/citadel/utils/chkpw.c index 9adabaca5..fb37fc862 100644 --- a/citadel/utils/chkpw.c +++ b/citadel/utils/chkpw.c @@ -51,9 +51,21 @@ static int validpw(uid_t uid, const char *pass) int rv; rv = write(chkpwd_write_pipe[1], &uid, sizeof(uid_t)); + if (rv == -1) { + printf( "Communicatino with chkpwd broken: %s\n", strerror(errno)); + return 0; + } + rv = write(chkpwd_write_pipe[1], pass, 256); + if (rv == -1) { + printf( "Communicatino with chkpwd broken: %s\n", strerror(errno)); + return 0; + } rv = read(chkpwd_read_pipe[0], buf, 4); - + if (rv == -1) { + printf( "Communicatino with chkpwd broken: %s\n", strerror(errno)); + return 0; + } if (!strncmp(buf, "PASS", 4)) { printf("pass\n"); return(1); diff --git a/citadel/utils/chkpwd.c b/citadel/utils/chkpwd.c index 6182e7ac7..024406349 100644 --- a/citadel/utils/chkpwd.c +++ b/citadel/utils/chkpwd.c @@ -37,13 +37,12 @@ int main(void) { uid_t uid; - size_t siz; char buf[SIZ]; while (1) { buf[0] = '\0'; - siz = read(0, &uid, sizeof(uid_t)); /* uid */ - siz = read(0, buf, 256); /* password */ + read(0, &uid, sizeof(uid_t)); /* uid */ + read(0, buf, 256); /* password */ if (buf[0] == '\0') return (0); diff --git a/citadel/utils/getmail.c b/citadel/utils/getmail.c index 087ee034f..ee606bb2a 100644 --- a/citadel/utils/getmail.c +++ b/citadel/utils/getmail.c @@ -53,32 +53,6 @@ static CtdlIPC *ipc = NULL; -/* - * make sure only one copy of sendcommand runs at a time, using lock files - */ -int set_lockfile(void) -{ - FILE *lfp; - int onppid; - int rv; - - if ((lfp = fopen(LOCKFILE, "r")) != NULL) { - rv = fscanf(lfp, "%d", &onppid); - fclose(lfp); - if (!kill(onppid, 0) || errno == EPERM) - return 1; - } - lfp = fopen(LOCKFILE, "w"); - fprintf(lfp, "%ld\n", (long) getpid()); - fclose(lfp); - return (0); -} - -void remove_lockfile(void) -{ - unlink(LOCKFILE); -} - /* * Why both cleanup() and nq_cleanup() ? Notice the alarm() call in * cleanup() . If for some reason sendcommand hangs waiting for the server @@ -88,7 +62,6 @@ void remove_lockfile(void) */ void nq_cleanup(int e) { - remove_lockfile(); exit(e); } -- 2.30.2