Cleanup our toolies, remove unneeded code; handle reply values.
authorWilfried Goesgens <dothebart@citadel.org>
Wed, 7 Sep 2011 14:57:14 +0000 (14:57 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Wed, 7 Sep 2011 15:05:14 +0000 (15:05 +0000)
citadel/utils/chkpw.c
citadel/utils/chkpwd.c
citadel/utils/getmail.c

index 9adabaca500586db5243e8883d2a7ae5e0afd4af..fb37fc86206fd72654bcddd0eb1313631286444c 100644 (file)
@@ -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);
index 6182e7ac71090d8cd202d5ffd902f7b92be07d75..024406349b4cd4682fb14fd1dceab588f0b47733 100644 (file)
 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);
index 087ee034fa4a3f4e1259f504ce1c73ffd43d26ec..ee606bb2af1ec6cede3fcd021a2e26fb4325e58f 100644 (file)
 
 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);
 }