mirror of
https://git.freebsd.org/src.git
synced 2026-01-16 23:02:24 +00:00
shutdown(8): refuse to run if /var/run/noshutdown is present
Reviewed by: bapt, kevans, olce Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D50166
This commit is contained in:
parent
5ab906195b
commit
7fb88c20ec
2 changed files with 36 additions and 5 deletions
|
|
@ -36,7 +36,7 @@
|
|||
.Nm
|
||||
.Op Fl
|
||||
.Oo
|
||||
.Fl c | Fl h | Fl p |
|
||||
.Fl c | Fl f | Fl h | Fl p |
|
||||
.Fl r | Fl k
|
||||
.Oc
|
||||
.Oo
|
||||
|
|
@ -71,6 +71,12 @@ At the present time, only systems with BMC supported by the
|
|||
driver that implement this functionality support this flag.
|
||||
The amount of time the system is off is dependent on the device
|
||||
that implements this feature.
|
||||
.It Fl f
|
||||
The
|
||||
.Nm
|
||||
command ignores the presence of the
|
||||
.Pa /var/run/noshutdown
|
||||
file.
|
||||
.It Fl h
|
||||
The system is halted at the specified
|
||||
.Ar time .
|
||||
|
|
@ -206,6 +212,12 @@ file that
|
|||
.Nm
|
||||
created will be removed automatically.
|
||||
.Pp
|
||||
If the
|
||||
.Pa /var/run/noshutdown
|
||||
file is present,
|
||||
.Nm
|
||||
exits without executing any action on the system.
|
||||
.Pp
|
||||
When run without options, the
|
||||
.Nm
|
||||
utility will place the system into single user mode at the
|
||||
|
|
@ -219,11 +231,18 @@ is equivalent to running:
|
|||
shutdown -p now
|
||||
.Ed
|
||||
.Sh FILES
|
||||
.Bl -tag -width /var/run/nologin -compact
|
||||
.Bl -tag -width /var/run/noshutdown -compact
|
||||
.It Pa /var/run/nologin
|
||||
tells
|
||||
.Xr login 1
|
||||
not to let anyone log in
|
||||
.It Pa /var/run/noshutdown
|
||||
prevents
|
||||
.Nm
|
||||
from initiating an action on the system.
|
||||
Can be overridden with the
|
||||
.Fl f
|
||||
option.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
Reboot the system in 30 minutes and display a warning message on the terminals
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include <sys/param.h>
|
||||
#include <sys/boottrace.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
|
|
@ -79,7 +80,8 @@ static struct interval {
|
|||
#undef S
|
||||
|
||||
static time_t offset, shuttime;
|
||||
static int docycle, dohalt, dopower, doreboot, killflg, mbuflen, oflag;
|
||||
static int docycle, dohalt, dopower, doreboot, ign_noshutdown,
|
||||
killflg, mbuflen, oflag;
|
||||
static char mbuf[BUFSIZ];
|
||||
static const char *nosync, *whom;
|
||||
|
||||
|
|
@ -100,6 +102,7 @@ main(int argc, char **argv)
|
|||
{
|
||||
char *p, *endp;
|
||||
struct passwd *pw;
|
||||
struct stat st;
|
||||
int arglen, ch, len, readstdin;
|
||||
bool dowarn;
|
||||
|
||||
|
|
@ -133,7 +136,7 @@ main(int argc, char **argv)
|
|||
goto poweroff;
|
||||
}
|
||||
|
||||
while ((ch = getopt(argc, argv, "-chknopqr")) != -1)
|
||||
while ((ch = getopt(argc, argv, "-cfhknopqr")) != -1)
|
||||
switch (ch) {
|
||||
case '-':
|
||||
readstdin = 1;
|
||||
|
|
@ -141,6 +144,9 @@ main(int argc, char **argv)
|
|||
case 'c':
|
||||
docycle = 1;
|
||||
break;
|
||||
case 'f':
|
||||
ign_noshutdown = 1;
|
||||
break;
|
||||
case 'h':
|
||||
dohalt = 1;
|
||||
break;
|
||||
|
|
@ -216,6 +222,12 @@ poweroff:
|
|||
}
|
||||
mbuflen = strlen(mbuf);
|
||||
|
||||
if (!ign_noshutdown && stat(_PATH_NOSHUTDOWN, &st) == 0) {
|
||||
(void)printf("Shutdown cannot be done, " _PATH_NOSHUTDOWN
|
||||
" is present\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if (offset) {
|
||||
BOOTTRACE("Shutdown at %s", ctime(&shuttime));
|
||||
(void)printf("Shutdown at %.24s.\n", ctime(&shuttime));
|
||||
|
|
@ -593,7 +605,7 @@ usage(const char *cp)
|
|||
if (cp != NULL)
|
||||
warnx("%s", cp);
|
||||
(void)fprintf(stderr,
|
||||
"usage: shutdown [-] [-c | -h | -p | -r | -k] [-o [-n]] [-q] time [warning-message ...]\n"
|
||||
"usage: shutdown [-] [-c | -f | -h | -p | -r | -k] [-o [-n]] [-q] time [warning-message ...]\n"
|
||||
" poweroff\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue