Update pstat, reboot, shutdown, update, vipw, virus.
This commit is contained in:
@@ -93,7 +93,7 @@ char *re_comp();
|
||||
void *sbrk(int incr);
|
||||
int sethostid();
|
||||
void setusershell();
|
||||
void sync();
|
||||
void sync(void);
|
||||
unsigned int ualarm();
|
||||
void usleep();
|
||||
int pause(void);
|
||||
@@ -155,6 +155,7 @@ int getpagesize(void);
|
||||
int symlink(const char *target, const char *linkpath);
|
||||
int vhangup(void);
|
||||
int mknod(const char *, mode_t, dev_t);
|
||||
int reboot(int howto);
|
||||
|
||||
#ifndef _VA_LIST_
|
||||
# ifdef __GNUC__
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include <nlist.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
char *fcore = "/dev/kmem";
|
||||
char *fmem = "/dev/mem";
|
||||
@@ -54,7 +56,18 @@ int totflg;
|
||||
int allflg;
|
||||
int kflg;
|
||||
|
||||
main(argc, argv)
|
||||
static void usage(void);
|
||||
static void dofile(void);
|
||||
static void doinode(void);
|
||||
static void doproc(void);
|
||||
static void dotty(void);
|
||||
static void dousr(void);
|
||||
static void doswap(void);
|
||||
static void putf(long v, char n);
|
||||
static void dottytype(char *name, int type);
|
||||
static void ttyprt(struct tty *atp, int line);
|
||||
|
||||
int main(argc, argv)
|
||||
char **argv;
|
||||
{
|
||||
register char *argp;
|
||||
@@ -147,12 +160,12 @@ char **argv;
|
||||
doswap();
|
||||
}
|
||||
|
||||
usage()
|
||||
void usage()
|
||||
{
|
||||
printf("usage: pstat -[aikptfsT] [-u [ubase]] [core]\n");
|
||||
}
|
||||
|
||||
doinode()
|
||||
void doinode()
|
||||
{
|
||||
register struct inode *ip;
|
||||
struct inode *xinode;
|
||||
@@ -207,7 +220,7 @@ doinode()
|
||||
printf("%6d,%3d", major(ip->i_rdev), minor(ip->i_rdev));
|
||||
else
|
||||
printf("%10ld", ip->i_size);
|
||||
printf(" %08x", ip->i_fs);
|
||||
printf(" %p", ip->i_fs);
|
||||
printf("\n");
|
||||
}
|
||||
free(xinode);
|
||||
@@ -225,9 +238,7 @@ getuint(loc)
|
||||
return (word);
|
||||
}
|
||||
|
||||
putf(v, n)
|
||||
long v;
|
||||
char n;
|
||||
void putf(long v, char n)
|
||||
{
|
||||
if (v)
|
||||
printf("%c", n);
|
||||
@@ -235,12 +246,12 @@ putf(v, n)
|
||||
printf(" ");
|
||||
}
|
||||
|
||||
doproc()
|
||||
void doproc()
|
||||
{
|
||||
struct proc *xproc;
|
||||
u_int nproc, aproc;
|
||||
register struct proc *pp;
|
||||
register loc, np;
|
||||
register int loc, np;
|
||||
|
||||
nproc = getuint((off_t)nl[SNPROC].n_value);
|
||||
xproc = (struct proc *)calloc(nproc, sizeof (struct proc));
|
||||
@@ -286,8 +297,8 @@ doproc()
|
||||
printf(" %8x", pp->p_saddr);
|
||||
printf(" %8x", pp->p_daddr);
|
||||
printf(" %6x", pp->p_dsize+pp->p_ssize);
|
||||
printf(" %8x", pp->p_wchan);
|
||||
printf(" %8x", pp->p_link);
|
||||
printf(" %p", pp->p_wchan);
|
||||
printf(" %p", pp->p_link);
|
||||
printf(" %8.1lx", pp->p_sigmask);
|
||||
printf("\n");
|
||||
}
|
||||
@@ -297,7 +308,7 @@ doproc()
|
||||
static int ttyspace = 64;
|
||||
static struct tty *tty;
|
||||
|
||||
dotty()
|
||||
void dotty()
|
||||
{
|
||||
if ((tty = (struct tty *)malloc(ttyspace * sizeof(*tty))) == 0) {
|
||||
printf("pstat: out of memory\n");
|
||||
@@ -306,7 +317,7 @@ dotty()
|
||||
dottytype("cn", SKL);
|
||||
}
|
||||
|
||||
dottytype(name, type)
|
||||
void dottytype(name, type)
|
||||
char *name;
|
||||
{
|
||||
register struct tty *tp;
|
||||
@@ -318,7 +329,7 @@ char *name;
|
||||
ttyprt(tty, 0);
|
||||
}
|
||||
|
||||
ttyprt(atp, line)
|
||||
void ttyprt(atp, line)
|
||||
struct tty *atp;
|
||||
{
|
||||
register struct tty *tp;
|
||||
@@ -327,7 +338,7 @@ struct tty *atp;
|
||||
tp = atp;
|
||||
|
||||
printf("%4d%4d", tp->t_rawq.c_cc, tp->t_canq.c_cc);
|
||||
printf("%4d %12.1lo %8x %4d %4d ", tp->t_outq.c_cc, tp->t_flags,
|
||||
printf("%4d %12.1lo %p %4d %4d ", tp->t_outq.c_cc, tp->t_flags,
|
||||
tp->t_addr, tp->t_delct, tp->t_col);
|
||||
putf(tp->t_state&TS_TIMEOUT, 'T');
|
||||
putf(tp->t_state&TS_WOPEN, 'W');
|
||||
@@ -346,24 +357,24 @@ struct tty *atp;
|
||||
printf("%6d\n", tp->t_pgrp);
|
||||
}
|
||||
|
||||
dousr()
|
||||
void dousr()
|
||||
{
|
||||
struct user U;
|
||||
long *ip;
|
||||
register i, j;
|
||||
register int i, j;
|
||||
|
||||
lseek(fm, ubase, 0);
|
||||
read(fm, &U, sizeof(U));
|
||||
printf("procp\t%p\n", U.u_procp);
|
||||
printf("frame\t%p\n", U.u_frame);
|
||||
printf("comm\t%s\n", U.u_comm);
|
||||
printf("arg\t%p %p %p %p %p %p\n", U.u_arg[0], U.u_arg[1],
|
||||
printf("arg\t%08x %08x %08x %08x %08x %08x\n", U.u_arg[0], U.u_arg[1],
|
||||
U.u_arg[2], U.u_arg[3], U.u_arg[4], U.u_arg[5]);
|
||||
printf("qsave\t");
|
||||
for (i = 0; i < sizeof (label_t) / sizeof (int); i++)
|
||||
printf("%p ", U.u_qsave.val[i]);
|
||||
printf("%08x ", U.u_qsave.val[i]);
|
||||
printf("\n");
|
||||
printf("rval\t%p\n", U.u_rval);
|
||||
printf("rval\t%08x\n", U.u_rval);
|
||||
printf("error\t%d\n", U.u_error);
|
||||
printf("uids\t%d,%d,%d,%d,%d\n", U.u_uid, U.u_svuid, U.u_ruid,
|
||||
U.u_svgid, U.u_rgid);
|
||||
@@ -388,7 +399,7 @@ dousr()
|
||||
printf("signal");
|
||||
for (i = 0; i < NSIG; i++) {
|
||||
if (i%8 == 0) printf("\t");
|
||||
printf("%.1x ", U.u_signal[i]);
|
||||
printf("%p ", U.u_signal[i]);
|
||||
if (i%8 == 7) printf("\n");
|
||||
}
|
||||
if (i%8) printf("\n");
|
||||
@@ -404,13 +415,13 @@ dousr()
|
||||
printf("oldmask\t%.1lx\n", U.u_oldmask);
|
||||
printf("code\t%08x\n", U.u_code);
|
||||
printf("psflags\t%d\n", U.u_psflags);
|
||||
printf("ss_base\t%.1x ss_size %.1x ss_flags %.1x\n",
|
||||
printf("ss_base\t%p ss_size %.1x ss_flags %.1x\n",
|
||||
U.u_sigstk.ss_base, U.u_sigstk.ss_size, U.u_sigstk.ss_flags);
|
||||
printf("ofile");
|
||||
for (i = 0; i < NOFILE; i++)
|
||||
{
|
||||
if (i%8 == 0) printf("\t");
|
||||
printf("%.1x ", U.u_ofile[i]);
|
||||
printf("%p ", U.u_ofile[i]);
|
||||
if (i%8 == 7) printf("\n");
|
||||
}
|
||||
if (i%8) printf("\n");
|
||||
@@ -423,9 +434,9 @@ dousr()
|
||||
}
|
||||
if (i%8) printf("\n");
|
||||
printf("lastfile\t%d\n", U.u_lastfile);
|
||||
printf("cdir\t%.1x\n", U.u_cdir);
|
||||
printf("rdir\t%.1x\n", U.u_rdir);
|
||||
printf("ttyp\t%.1x\n", U.u_ttyp);
|
||||
printf("cdir\t%p\n", U.u_cdir);
|
||||
printf("rdir\t%p\n", U.u_rdir);
|
||||
printf("ttyp\t%p\n", U.u_ttyp);
|
||||
printf("ttyd\t%d,%d\n", major(U.u_ttyd), minor(U.u_ttyd));
|
||||
printf("cmask\t%.1x\n", U.u_cmask);
|
||||
printf("ru\t");
|
||||
@@ -441,8 +452,8 @@ dousr()
|
||||
printf("timer\t%ld %ld %ld %ld\n", U.u_timer[0].it_interval,
|
||||
U.u_timer[0].it_value, U.u_timer[1].it_interval,
|
||||
U.u_timer[1].it_value);
|
||||
printf("start\t%08x\n", U.u_start);
|
||||
printf("prof\t%.1x %u %u %u\n", U.u_prof.pr_base, U.u_prof.pr_size,
|
||||
printf("start\t%08lx\n", U.u_start);
|
||||
printf("prof\t%p %u %u %u\n", U.u_prof.pr_base, U.u_prof.pr_size,
|
||||
U.u_prof.pr_off, U.u_prof.pr_scale);
|
||||
printf("rlimit cur\t");
|
||||
for (i = 0; i < RLIM_NLIMITS; i++)
|
||||
@@ -467,10 +478,10 @@ dousr()
|
||||
minor(U.u_ncache.nc_dev));
|
||||
}
|
||||
|
||||
oatoi(s)
|
||||
int oatoi(s)
|
||||
char *s;
|
||||
{
|
||||
register v;
|
||||
int v;
|
||||
|
||||
v = 0;
|
||||
while (*s)
|
||||
@@ -478,11 +489,11 @@ char *s;
|
||||
return(v);
|
||||
}
|
||||
|
||||
dofile()
|
||||
void dofile()
|
||||
{
|
||||
struct file *xfile;
|
||||
register struct file *fp;
|
||||
register nf;
|
||||
register int nf;
|
||||
u_int loc, afile;
|
||||
static char *dtypes[] = { "???", "inode", "socket", "pipe" };
|
||||
|
||||
@@ -513,7 +524,7 @@ dofile()
|
||||
if (fp->f_type <= DTYPE_PIPE)
|
||||
printf("%-8.8s", dtypes[fp->f_type]);
|
||||
else
|
||||
printf("8d", fp->f_type);
|
||||
printf("%8d", fp->f_type);
|
||||
putf((long)fp->f_flag&FREAD, 'R');
|
||||
putf((long)fp->f_flag&FWRITE, 'W');
|
||||
putf((long)fp->f_flag&FAPPEND, 'A');
|
||||
@@ -525,7 +536,7 @@ dofile()
|
||||
putf((long)fp->f_flag&FDEFER, 'd');
|
||||
printf(" %3d", fp->f_count);
|
||||
printf(" %3d", fp->f_msgcount);
|
||||
printf(" %08x", fp->f_data);
|
||||
printf(" %p", fp->f_data);
|
||||
if (fp->f_offset < 0)
|
||||
printf(" 0x%lx\n", fp->f_offset);
|
||||
else
|
||||
@@ -534,7 +545,7 @@ dofile()
|
||||
free(xfile);
|
||||
}
|
||||
|
||||
doswap()
|
||||
void doswap()
|
||||
{
|
||||
u_int nswap, used;
|
||||
int i, num;
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <pwd.h>
|
||||
#include <sysexits.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/reboot.h>
|
||||
@@ -20,7 +22,9 @@
|
||||
|
||||
#define OPTS "lqnhdarsfRD"
|
||||
|
||||
main(argc, argv)
|
||||
static void markdown(void);
|
||||
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
@@ -30,12 +34,12 @@ main(argc, argv)
|
||||
char *myname; /* name we were invoked as */
|
||||
char args[20], *ap; /* collected arguments for syslog */
|
||||
int i;
|
||||
char *rindex();
|
||||
|
||||
if (myname = rindex(argv[0], '/'))
|
||||
if ((myname = rindex(argv[0], '/')))
|
||||
myname++;
|
||||
else
|
||||
myname = argv[0];
|
||||
|
||||
if (strcmp(myname, "halt") == 0)
|
||||
howto = RB_HALT;
|
||||
else if (strcmp(myname, "fasthalt") == 0)
|
||||
@@ -155,7 +159,6 @@ main(argc, argv)
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Make shutdown entry in /usr/adm/utmp.
|
||||
*/
|
||||
@@ -164,7 +167,7 @@ main(argc, argv)
|
||||
|
||||
#define SCPYN(a, b) strncpy(a, b, sizeof(a))
|
||||
|
||||
markdown()
|
||||
void markdown()
|
||||
{
|
||||
struct utmp wtmp;
|
||||
register int f = open(_PATH_WTMP, O_WRONLY|O_APPEND);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/param.h>
|
||||
@@ -37,8 +38,6 @@
|
||||
|
||||
char hostname[MAXHOSTNAMELEN];
|
||||
|
||||
time_t getsdt();
|
||||
|
||||
struct utmp utmp;
|
||||
int sint;
|
||||
long stogo;
|
||||
@@ -82,6 +81,10 @@ struct interval {
|
||||
|
||||
char *shutter;
|
||||
|
||||
static time_t getsdt(char *s);
|
||||
static void nolog(time_t sdt);
|
||||
static void doitfast(void);
|
||||
|
||||
void finish(sig)
|
||||
int sig;
|
||||
{
|
||||
@@ -96,13 +99,13 @@ void timeout(sig)
|
||||
longjmp(alarmbuf, 1);
|
||||
}
|
||||
|
||||
warning(term, sdt, now, type)
|
||||
void warning(term, sdt, now, type)
|
||||
FILE *term;
|
||||
time_t sdt, now;
|
||||
char *type;
|
||||
{
|
||||
char *ts;
|
||||
register delay = sdt - now;
|
||||
register int delay = sdt - now;
|
||||
|
||||
if (delay > 8)
|
||||
while (delay % 5)
|
||||
@@ -125,11 +128,11 @@ warning(term, sdt, now, type)
|
||||
fprintf(term, "System going down IMMEDIATELY\r\n");
|
||||
}
|
||||
|
||||
main(argc,argv)
|
||||
int main(argc,argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
register i, ufd;
|
||||
register int i, ufd;
|
||||
register char *f;
|
||||
char *ts;
|
||||
time_t sdt;
|
||||
@@ -147,7 +150,7 @@ main(argc,argv)
|
||||
openlog("shutdown", 0, LOG_AUTH);
|
||||
argc--, argv++;
|
||||
while (argc > 0 && (f = argv[0], *f++ == '-')) {
|
||||
while (i = *f++) switch (i) {
|
||||
while ((i = *f++)) switch (i) {
|
||||
case 'k':
|
||||
killflg = 0;
|
||||
continue;
|
||||
@@ -209,7 +212,7 @@ main(argc,argv)
|
||||
(void) setpriority(PRIO_PROCESS, 0, PRIO_MIN);
|
||||
(void) fflush(stdout);
|
||||
#ifndef DEBUG
|
||||
if (i = fork()) {
|
||||
if ((i = fork())) {
|
||||
printf("[pid %d]\n", i);
|
||||
exit(0);
|
||||
}
|
||||
@@ -365,9 +368,10 @@ badform:
|
||||
printf("Bad time format\n");
|
||||
finish(0);
|
||||
/*NOTREACHED*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
doitfast()
|
||||
void doitfast()
|
||||
{
|
||||
register FILE *fastd;
|
||||
|
||||
@@ -377,7 +381,7 @@ doitfast()
|
||||
}
|
||||
}
|
||||
|
||||
nolog(sdt)
|
||||
void nolog(sdt)
|
||||
time_t sdt;
|
||||
{
|
||||
register FILE *nologf;
|
||||
|
||||
@@ -34,12 +34,17 @@
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
main()
|
||||
void mysync()
|
||||
{
|
||||
(void)sync();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
struct itimerval value;
|
||||
sigset_t set;
|
||||
void mysync();
|
||||
|
||||
daemon(0, 0);
|
||||
|
||||
@@ -58,9 +63,3 @@ main()
|
||||
sigsuspend(&set);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
void
|
||||
mysync()
|
||||
{
|
||||
(void)sync();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <sys/file.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/wait.h>
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
@@ -29,10 +30,17 @@
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <paths.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
char *passwd, *temp;
|
||||
|
||||
main()
|
||||
static void stop(int val);
|
||||
static int edit(void);
|
||||
static int check(FILE *tfp);
|
||||
static int prompt(void);
|
||||
static int makedb(char *file);
|
||||
|
||||
int main()
|
||||
{
|
||||
register int n, fd_passwd, fd;
|
||||
struct rlimit rlim;
|
||||
@@ -143,7 +151,7 @@ syserr: (void)fprintf(stderr, "vipw: %s: %s; ",
|
||||
exit(0);
|
||||
}
|
||||
|
||||
check(tfp)
|
||||
int check(tfp)
|
||||
FILE *tfp;
|
||||
{
|
||||
long id;
|
||||
@@ -190,7 +198,7 @@ check(tfp)
|
||||
if (!(p = strsep(&bp, ":"))) /* shell */
|
||||
goto general;
|
||||
if (root && *p) /* empty == /bin/sh */
|
||||
for (setusershell();;)
|
||||
for (setusershell();;) {
|
||||
if (!(sh = getusershell())) {
|
||||
(void)fprintf(stderr,
|
||||
"vipw: warning, unknown root shell.\n");
|
||||
@@ -198,6 +206,7 @@ check(tfp)
|
||||
}
|
||||
else if (!strcmp(p, sh))
|
||||
break;
|
||||
}
|
||||
if (strsep(&bp, ":")) { /* too many */
|
||||
general: (void)fprintf(stderr, "vipw: corrupted entry");
|
||||
bad: (void)fprintf(stderr, "; line #%d.\n", lcnt);
|
||||
@@ -208,7 +217,7 @@ bad: (void)fprintf(stderr, "; line #%d.\n", lcnt);
|
||||
return(0);
|
||||
}
|
||||
|
||||
makedb(file)
|
||||
int makedb(file)
|
||||
char *file;
|
||||
{
|
||||
int status, pid, w;
|
||||
@@ -221,13 +230,13 @@ makedb(file)
|
||||
return(w == -1 || status);
|
||||
}
|
||||
|
||||
edit()
|
||||
int edit()
|
||||
{
|
||||
int status, pid, w;
|
||||
char *p, *editor;
|
||||
|
||||
if (editor = getenv("EDITOR")) {
|
||||
if (p = rindex(editor, '/'))
|
||||
if ((editor = getenv("EDITOR"))) {
|
||||
if ((p = rindex(editor, '/')))
|
||||
++p;
|
||||
else
|
||||
p = editor;
|
||||
@@ -244,7 +253,7 @@ edit()
|
||||
return(w == -1 || status);
|
||||
}
|
||||
|
||||
prompt()
|
||||
int prompt()
|
||||
{
|
||||
register int c;
|
||||
|
||||
@@ -259,7 +268,7 @@ prompt()
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
stop(val)
|
||||
void stop(val)
|
||||
int val;
|
||||
{
|
||||
(void)fprintf(stderr, "%s unchanged.\n", passwd);
|
||||
|
||||
@@ -3,8 +3,8 @@ include $(TOPSRC)/target.mk
|
||||
|
||||
CFLAGS += -Wall -Werror -Os
|
||||
|
||||
virus: virus.c
|
||||
$(CC) $(LDFLAGS) -o virus.elf virus.c $(LIBS) -ltermcap
|
||||
virus: virus.o
|
||||
$(LD) $(LDFLAGS) -o virus.elf virus.o $(LIBS) -ltermcap
|
||||
$(SIZE) virus.elf
|
||||
$(ELF2AOUT) virus.elf $@
|
||||
|
||||
|
||||
@@ -100,5 +100,6 @@ int getfsstat(struct statfs *buf, int bufsize, unsigned flags);
|
||||
int getmntinfo(struct statfs **mntbufp, int flags);
|
||||
int statfs(const char *path, struct statfs *buf);
|
||||
int mount(const char *source, const char *target, int mountflags);
|
||||
int umount(const char *target);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user