Fix bug when moving tableau pile to empty slot (don't allow it).
[unix-history] / usr / src / usr.bin / su / su.c
index 6bb382b..3ab051e 100644 (file)
@@ -1,10 +1,23 @@
+/*
+ * 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
+char copyright[] =
+"@(#) Copyright (c) 1980 Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif not lint
+
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)su.c        4.9 (Berkeley) %G%";
-#endif
+static char sccsid[] = "@(#)su.c       5.3 (Berkeley) %G%";
+#endif not lint
 
 #include <stdio.h>
 #include <pwd.h>
 #include <grp.h>
 
 #include <stdio.h>
 #include <pwd.h>
 #include <grp.h>
+#include <syslog.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/resource.h>
@@ -33,6 +46,8 @@ main(argc,argv)
        char buf[1000];
        FILE *fp;
 
        char buf[1000];
        FILE *fp;
 
+       openlog("su", LOG_ODELAY, LOG_AUTH);
+
 again:
        if (argc > 1 && strcmp(argv[1], "-f") == 0) {
                fastlogin++;
 again:
        if (argc > 1 && strcmp(argv[1], "-f") == 0) {
                fastlogin++;
@@ -82,24 +97,16 @@ again:
        if (strcmp(pwd->pw_passwd, crypt(password, pwd->pw_passwd)) != 0) {
                fprintf(stderr, "Sorry\n");
                if (pwd->pw_uid == 0) {
        if (strcmp(pwd->pw_passwd, crypt(password, pwd->pw_passwd)) != 0) {
                fprintf(stderr, "Sorry\n");
                if (pwd->pw_uid == 0) {
-                       FILE *console = fopen("/dev/console", "w");
-                       if (console != NULL) {
-                               fprintf(console, "BADSU: %s %s\r\n",
+                       syslog(LOG_CRIT, "BAD SU %s on %s",
                                        getlogin(), ttyname(2));
                                        getlogin(), ttyname(2));
-                               fclose(console);
-                       }
                }
                exit(2);
        }
 ok:
        endpwent();
        if (pwd->pw_uid == 0) {
                }
                exit(2);
        }
 ok:
        endpwent();
        if (pwd->pw_uid == 0) {
-               FILE *console = fopen("/dev/console", "w");
-               if (console != NULL) {
-                       fprintf(console, "SU: %s %s\r\n",
-                               getlogin(), ttyname(2));
-                       fclose(console);
-               }
+               syslog(LOG_NOTICE, "%s on %s", getlogin(), ttyname(2));
+               closelog();
        }
        if (setgid(pwd->pw_gid) < 0) {
                perror("su: setgid");
        }
        if (setgid(pwd->pw_gid) < 0) {
                perror("su: setgid");