/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <ctype.h>
#include <setjmp.h>
#include <utmpx.h>
#include <pwd.h>
#include <time.h>
#include <sys/resource.h>
#include <rpc/pmap_clnt.h>
#include <netdb.h>
#include <locale.h>
#include <zone.h>
#include <signal.h>
/*
*
* allow super users to tell users and remind users
* of iminent shutdown of unix
* and shut it down automatically
* and even reboot or halt the machine if they desire
*/
#define SECONDS
struct hostlist {
char *host;
} *hostlist;
extern char *malloc();
extern char *ctime();
extern char *strcpy();
extern char *strncat();
int sint;
int stogo;
int doreboot = 0;
int halt = 0;
int fast = 0;
#ifdef DEBUG
#else
#endif
struct interval {
int stogo;
int sint;
} interval[] = {
};
static void timeout(void);
static void gethostlist(void);
static void finish(char *, char *, int);
static void rprintf(char *, char *);
static void doitfast(void);
get_initpid(void)
{
exit(1);
}
return (init_pid);
}
int
{
int i;
char *f;
char *ts;
int h, m;
int first;
void finish_sig();
extern char *strcat();
char *shutdown_program;
char *shutdown_action;
int fd;
#if !defined(TEXT_DOMAIN)
#endif
(void) textdomain(TEXT_DOMAIN);
if (shutter == 0)
shutter = "???";
while (i = *f++) {
switch (i) {
case 'k':
killflg = 0;
continue;
case 'n':
nosync = nosyncflag;
continue;
case 'f':
fast = 1;
continue;
case 'r':
doreboot = 1;
continue;
case 'h':
halt = 1;
continue;
default:
i);
}
}
}
if (argc < 1) {
}
gettext("shutdown: Incompatible switches '-r' & '-h'\n"));
"", 1);
}
gettext("shutdown: Incompatible switches '-f' & '-n'\n"));
"", 1);
}
if (geteuid()) {
}
gethostlist();
mesg[0] = '\0';
i = 0;
while (argc-- > 0) {
break; /* no more room for the message */
}
if (i != 0)
h = m/60;
m %= 60;
if (h > 0)
#ifndef DEBUG
#endif
#ifndef DEBUG
if (i = fork()) {
exit(0);
}
#else
#endif
f = "";
first = 1;
if (doreboot) {
shutdown_action = "reboot";
} else if (halt) {
shutdown_action = "halt";
} else {
shutdown_action = "shutdown";
}
for (;;) {
nlflag = 0;
}
f = "FINAL ";
setutxent();
/*
* don't write to pty's unless they're rlogin sessions
*/
continue;
continue;
(void) alarm(5);
/* check if device is really a tty */
term);
(void) alarm(0);
continue;
} else {
gettext("%.*s in utmpx is not a tty\n"),
(void) alarm(0);
continue;
}
}
#ifdef DEBUG
#else
#endif
{
(void) alarm(0);
(void) alarm(5);
#ifdef DEBUG
#else
#endif
(void) alarm(0);
}
}
} /* while */
endutxent();
if (stogo <= 0) {
if (*mesg)
else
sleep(2);
if (!killflg) {
}
if (fast)
doitfast();
#ifndef DEBUG
if (shutdown_program != NULL) {
"-l", nosync, (char *)0);
} else {
if (geteuid() == 0) {
sleep(5);
}
if (getzoneid() == GLOBAL_ZONEID) {
(void) system(
}
sleep(20);
}
#else
if (shutdown_program) {
if (fast)
else
} else {
(void) printf("kill -INT 1");
if (fast)
else
(void) printf("\n");
}
#endif
}
first = 0;
}
/* NOTREACHED */
}
static time_t
getsdt(char *s)
{
char c;
int c_count;
if (strcmp(s, "now") == 0)
return (nowtime);
if (*s == '+') {
++s;
t = 0;
c = *s++;
if (!isdigit(c)) {
if (c_count == 1) {
goto badform;
} else {
break;
}
}
t = t * 10 + c - '0';
}
if (t <= 0)
t = 5;
t *= 60;
return (tim);
}
t = 0;
t = t * 10 + *s++ - '0';
if (*s == ':')
s++;
if (t > 23)
goto badform;
tim = t*60;
t = 0;
while (isdigit(*s))
t = t * 10 + *s++ - '0';
if (t > 59)
goto badform;
tim += t;
tim *= 60;
/* before now or after midnight */
}
return (0);
/* NOTREACHED */
}
static void
{
char *ts;
if (delay > 8)
while (delay % 5)
delay++;
} else if (delay > 0) {
} else
if (*mesg)
}
}
static void
doitfast(void)
{
}
}
static void
{
char *ts;
char *bufp;
if (delay > 8)
while (delay % 5)
delay++;
"\007\007\t*** %sShutdown message for %s from %s@%s ***\r\n\n",
ts+11);
} else if (delay > 0) {
} else {
hostname);
}
if (*mesg)
}
}
static void
{
int err;
#ifdef DEBUG
#endif
(char *)NULL)) {
#ifdef DEBUG
#endif
}
}
static void
{
if (*mesg)
}
}
void
finish_sig(void)
{
}
static void
{
}
static void
timeout(void)
{
}
static void
gethostlist(void)
{
int s;
/*
* check for portmapper
*/
if (s < 0)
return;
return;
(void) close(s);
/*
* First try tcp, then drop back to udp if
* tcp is unavailable (an old version of mountd perhaps)
* Using tcp is preferred because it can handle
* arbitrarily long export lists.
*/
"tcp");
clnt_pcreateerror("shutdown warning");
}
return;
}
}
return;
}
goto again;
again:;
}
}
/*
* Don't want to wait for usual portmapper timeout you get with
* callrpc or clnt_call, so use rmtcall instead. Use timeout
* of 8 secs, based on the per try timeout of 3 secs for rmtcall
*/
int
{
return ((int)RPC_UNKNOWNHOST);
server_addr.sin_port = 0;
rpctimeout.tv_usec = 0;
}