SCCS-vsn: sbin/reboot/halt.c 5.3
SCCS-vsn: sbin/reboot/reboot.c 5.3
- * Copyright (c) 1980 Regents of the University of California.
+ * Copyright (c) 1980,1986 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#endif not lint
#ifndef lint
#endif not lint
#ifndef lint
-static char sccsid[] = "@(#)halt.c 5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)halt.c 5.3 (Berkeley) %G%";
#include <sys/reboot.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/reboot.h>
#include <sys/types.h>
#include <sys/time.h>
#include <errno.h>
#include <signal.h>
#include <errno.h>
#include <signal.h>
main(argc, argv)
int argc;
main(argc, argv)
int argc;
char *ttyn = (char *)ttyname(2);
register i;
register qflag = 0;
char *ttyn = (char *)ttyname(2);
register i;
register qflag = 0;
+ char *user, *getlogin();
+ struct passwd *pw, *getpwuid();
openlog("halt", 0, LOG_AUTH);
howto = RB_HALT;
openlog("halt", 0, LOG_AUTH);
howto = RB_HALT;
+ user = getlogin();
+ if (user == (char *)0 && (pw = getpwuid(getuid())))
+ user = pw->pw_name;
+ if (user == (char *)0)
+ user = "root";
+ syslog(LOG_CRIT, "halted by %s", user);
+
signal(SIGHUP, SIG_IGN); /* for network connections */
if (kill(1, SIGTSTP) == -1) {
fprintf(stderr, "reboot: can't idle init\n");
exit(1);
}
signal(SIGHUP, SIG_IGN); /* for network connections */
if (kill(1, SIGTSTP) == -1) {
fprintf(stderr, "reboot: can't idle init\n");
exit(1);
}
if (!qflag) for (i = 1; ; i++) {
if (kill(-1, SIGKILL) == -1) {
if (!qflag) for (i = 1; ; i++) {
if (kill(-1, SIGKILL) == -1) {
- fprintf(stderr, "CAUTION: some process(es) wouldn't die\n");
+ fprintf(stderr,
+ "CAUTION: some process(es) wouldn't die\n");
break;
}
setalarm(2 * i);
pause();
}
break;
}
setalarm(2 * i);
pause();
}
- if ((howto & RB_NOSYNC) == 0)
- syslog(LOG_CRIT, "halted");
- if (!qflag) {
- if ((howto & RB_NOSYNC)==0) {
- markdown();
- sync();
- sync();
- }
+ if (!qflag && (howto & RB_NOSYNC) == 0) {
+ markdown();
+ sync();
- * Copyright (c) 1980 Regents of the University of California.
+ * Copyright (c) 1980,1986 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#endif not lint
#ifndef lint
#endif not lint
#ifndef lint
-static char sccsid[] = "@(#)reboot.c 5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)reboot.c 5.3 (Berkeley) %G%";
#include <sys/reboot.h>
#include <errno.h>
#include <signal.h>
#include <sys/reboot.h>
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/time.h>
main(argc, argv)
int argc;
main(argc, argv)
int argc;
register i;
register ok = 0;
register qflag = 0;
register i;
register ok = 0;
register qflag = 0;
+ char *user, *getlogin();
+ struct passwd *pw, *getpwuid();
openlog("reboot", 0, LOG_AUTH);
argc--, argv++;
openlog("reboot", 0, LOG_AUTH);
argc--, argv++;
+ user = getlogin();
+ if (user == (char *)0 && (pw = getpwuid(getuid())))
+ user = pw->pw_name;
+ if (user == (char *)0)
+ user = "root";
+ syslog(LOG_CRIT, "halted by %s", user);
+
signal(SIGHUP, SIG_IGN); /* for remote connections */
if (kill(1, SIGTSTP) == -1) {
fprintf(stderr, "reboot: can't idle init\n");
exit(1);
}
signal(SIGHUP, SIG_IGN); /* for remote connections */
if (kill(1, SIGTSTP) == -1) {
fprintf(stderr, "reboot: can't idle init\n");
exit(1);
}
if (!qflag) for (i = 1; ; i++) {
if (kill(-1, SIGKILL) == -1) {
if (!qflag) for (i = 1; ; i++) {
if (kill(-1, SIGKILL) == -1) {
- fprintf(stderr, "CAUTION: some process(es) wouldn't die\n");
+ fprintf(stderr,
+ "CAUTION: some process(es) wouldn't die\n");
break;
}
setalarm(2 * i);
pause();
}
break;
}
setalarm(2 * i);
pause();
}
- if ((howto & RB_NOSYNC) == 0)
- syslog(LOG_CRIT, "halted for reboot");
- if (!qflag) {
- if (!(howto & RB_NOSYNC)) {
- markdown();
- sync();
- sync();
- }
+ if (!qflag && (howto & RB_NOSYNC) == 0) {
+ markdown();
+ sync();