[785] in Kerberos-V5-bugs

home help back first fref pref prev next nref lref last post

krb5B4-2/src/appl/mailquery

daemon@ATHENA.MIT.EDU (Randall S. Winchester)
Wed Sep 28 00:18:58 1994

From: "Randall S. Winchester" <rsw@Glue.umd.edu>
Date: Wed, 28 Sep 1994 00:18:41 -0400
To: krb5-bugs@MIT.EDU


I noticed that when running mailquery that it would popper would
move the file $user to .$user.temp and leave it their owned by root.

I ran trace on mailquery, and the MH msgchk that did not have this problem.

Mailquery did this;
.....
write (3, "STAT\r\n", 6) = 6
read (3, "+OK 4 9776\r\n", 4096) = 12
write (2, "<--- +OK 4 9776\n", 16) = <--- +OK 4 9776
16
ioctl (1, 0x40125401, 0xf7ffeb2c) = 0
write (1, "4 messages (9776 bytes) on host ".., 52) = 4 messages (9776 bytes) on host bacchus.eng.umd.edu
52
close (0) = 0
close (1) = 0
close (2) = 0
close (3) = 0
close (3) = -1 EBADF (Bad file number)
exit (0) = ?

Msgchk does this;
.....
write (6, "STAT\r\n", 6) = 6
read (5, "+OK 9 16512\r\n", 4096) = 13
write (6, "QUIT\r\n", 6) = 6
read (5, "+OK Pop server at bacchus.eng.um".., 4096) = 52
close (5) = 0
close (6) = 0
ioctl (1, 0x40125401, 0xf7ffdb4c) = 0
write (1, "You have 9 messages (16512 bytes".., 57) = You have 9 messages (16512 bytes) on bacchus.eng.umd.edu
57
close (0) = 0
close (1) = 0
close (2) = 0
exit (0) = ?


There are two things here. The obvious missing "QUIT", and the close of the
filedescriptor on program exit. Fixing the first gave me the file back as $user,
calling fclose() gave me $user owned by $user and not root. I also dup'ed the
filediscriptor to get ride of the "close (3) = -1 EBADF (Bad file number)".

diff -c  mailquery.c mailquery.c.orig
*** mailquery.c Tue Sep 27 23:57:39 1994
--- mailquery.c.orig    Tue Sep 27 23:57:48 1994
***************
*** 168,178 ****
              exit (1);
      }
  
-     if (pop_quit() == NOTOK) {
-             error(Errmsg);
-             exit (1);
-     }
- 
      if (verbose)
        printf("%d messages (%d bytes) on host %s\n", nmsgs, nbytes, mhost);
  
--- 168,173 ----


diff -c poplib.c poplib.c.orig 
*** poplib.c    Tue Sep 27 23:57:26 1994
--- poplib.c.orig       Tue Sep 27 23:57:55 1994
***************
*** 34,40 ****
  #endif
  #ifdef KPOP
  #ifdef KRB4
- #include <krb_types.h>
  #include <krb.h>
  #endif
  #ifdef KRB5
--- 34,39 ----
***************
*** 64,70 ****
      register struct servent *sp;
      int lport = IPPORT_RESERVED - 1;
      struct sockaddr_in sin;
!     int s, t;
      char *get_errmsg();
      char response[1024];
      char *routine;
--- 63,69 ----
      register struct servent *sp;
      int lport = IPPORT_RESERVED - 1;
      struct sockaddr_in sin;
!     int s;
      char *get_errmsg();
      char response[1024];
      char *routine;
***************
*** 211,228 ****
  #endif /* KRB5 */
  #endif /* KPOP */
  
-     if ((t = dup(s)) == NOTOK) {
-         sprintf(Errmsg, "error during dup:  %s", get_errmsg());
-         close(s);
-         return(NOTOK);
-     }
- 
      sfi = fdopen(s, "r");
!     sfo = fdopen(t, "w");
      if (sfi == NULL || sfo == NULL) {
        sprintf(Errmsg, "error in fdopen: %s", get_errmsg());
        close(s);
-       close(t);
        return(NOTOK);
      }
  
--- 210,220 ----
  #endif /* KRB5 */
  #endif /* KPOP */
  
      sfi = fdopen(s, "r");
!     sfo = fdopen(s, "w");
      if (sfi == NULL || sfo == NULL) {
        sprintf(Errmsg, "error in fdopen: %s", get_errmsg());
        close(s);
        return(NOTOK);
      }
  
***************
*** 314,344 ****
      }
  }
  
- pop_quit()
- {
-     char buf[1024];
- 
-     if (pop_debug) fprintf(stderr, "---> QUIT\n");
-     if (putline("QUIT", Errmsg, sfo) == NOTOK) return(NOTOK);
- 
-     if (getline(buf, sizeof buf, sfi) != OK) {
-         strcpy(Errmsg, buf);
-         return(NOTOK);
-     }
- 
-     if (pop_debug) fprintf(stderr, "<--- %s\n", buf);
-     if (*buf != '+') {
-         strcpy(Errmsg, buf);
-         return(NOTOK);
-     } else {
-         sscanf(buf, "+OK %s", buf);
-         fclose (sfi);
-         fclose (sfo);
-         return(OK);
-     }
- }
- 
- 
  pop_retr(msgno, action, arg)
  int msgno;
  int (*action)();
--- 306,311 ----
***************
*** 372,384 ****
              }
            break;
        case DONE:
-             fclose (sfi);
-             fclose (sfo);
            return (OK);
        case NOTOK:
            strcpy(Errmsg, buf);
-             fclose (sfi);
-             fclose (sfo);
            return (NOTOK);
        }
      }
--- 339,347 ----



home help back first fref pref prev next nref lref last post