we go to LAST_ACK even if data is outstanding, so watch for window
[unix-history] / usr / src / usr.sbin / vipw / vipw.c
index 4344c25..0d082b5 100644 (file)
@@ -1,6 +1,18 @@
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)vipw.c     4.4 (Berkeley) %G%";
-#endif
+char copyright[] =
+"@(#) Copyright (c) 1980 Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif not lint
+
+#ifndef lint
+static char sccsid[] = "@(#)vipw.c     5.1 (Berkeley) %G%";
+#endif not lint
 
 #include <sys/types.h>
 #include <sys/stat.h>
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -13,12 +25,12 @@ static char sccsid[] = "@(#)vipw.c  4.4 (Berkeley) %G%";
 /*
  * Password file editor with locking.
  */
 /*
  * Password file editor with locking.
  */
-char   *temp = "/etc/ptmp";
-char   *temp_pag = "/etc/ptmp.pag";
-char   *temp_dir = "/etc/ptmp.dir";
-char   *passwd = "/etc/passwd";
-char   *passwd_pag = "/etc/passwd.pag";
-char   *passwd_dir = "/etc/passwd.dir";
+char   temp[] = "/etc/ptmp";
+char   temp_pag[] = "/etc/ptmp.pag";
+char   temp_dir[] = "/etc/ptmp.dir";
+char   passwd[] = "/etc/passwd";
+char   passwd_pag[] = "/etc/passwd.pag";
+char   passwd_dir[] = "/etc/passwd.dir";
 char   buf[BUFSIZ];
 char   *getenv();
 char   *index();
 char   buf[BUFSIZ];
 char   *getenv();
 char   *index();
@@ -31,9 +43,9 @@ main(argc, argv)
        FILE *ft, *fp;
        char *editor;
 
        FILE *ft, *fp;
        char *editor;
 
+       signal(SIGHUP, SIG_IGN);
        signal(SIGINT, SIG_IGN);
        signal(SIGQUIT, SIG_IGN);
        signal(SIGINT, SIG_IGN);
        signal(SIGQUIT, SIG_IGN);
-       signal(SIGHUP, SIG_IGN);
        setbuf(stderr, NULL);
        umask(0);
        fd = open(temp, O_WRONLY|O_CREAT|O_EXCL, 0644);
        setbuf(stderr, NULL);
        umask(0);
        fd = open(temp, O_WRONLY|O_CREAT|O_EXCL, 0644);
@@ -118,7 +130,7 @@ main(argc, argv)
                        if (cp == 0)
                                break;
                        /* login directory */
                        if (cp == 0)
                                break;
                        /* login directory */
-                       if (strncmp(++cp, "/:"))
+                       if (strncmp(++cp, "/:", 2))
                                break;
                        cp += 2;
                        if (*cp && strcmp(cp, "/bin/sh") &&
                                break;
                        cp += 2;
                        if (*cp && strcmp(cp, "/bin/sh") &&
@@ -144,6 +156,8 @@ main(argc, argv)
                            passwd);
        }
 bad:
                            passwd);
        }
 bad:
+       unlink(temp_pag);
+       unlink(temp_dir);
        unlink(temp);
        exit(1);
 }
        unlink(temp);
        exit(1);
 }