Delete old ticket file in addition to wiping if there is one.
authordm <dm@openbsd.org>
Wed, 12 Feb 1997 00:56:10 +0000 (00:56 +0000)
committerdm <dm@openbsd.org>
Wed, 12 Feb 1997 00:56:10 +0000 (00:56 +0000)
kerberosIV/krb/in_tkt.c

index 6bea0ff..6213181 100644 (file)
@@ -64,7 +64,7 @@ in_tkt(pname, pinst)
     metoo = geteuid();
     if (lstat(file,&buf) == 0) {
        if (buf.st_uid != me || !(buf.st_mode & S_IFREG) ||
-           buf.st_mode & 077) {
+           buf.st_mode & 077 || buf.st_nlink != 1) {
            if (krb_debug)
                fprintf(stderr,"Error initializing %s",file);
            return(KFAILURE);
@@ -76,14 +76,12 @@ in_tkt(pname, pinst)
        bzero(charbuf, sizeof(charbuf));
 
        for (i = 0; i < buf.st_size; i += sizeof(charbuf))
-           if (write(fd, charbuf, sizeof(charbuf)) != sizeof(charbuf)) {
-               (void) fsync(fd);
-               (void) close(fd);
-               goto out;
-           }
+           if (write(fd, charbuf, sizeof(charbuf)) != sizeof(charbuf))
+             break;
        
        (void) fsync(fd);
        (void) close(fd);
+       (void) unlink (file);
     }
  out:
     /* arrange so the file is owned by the ruid