root@conexch.UUCP (Larry Dighera) (05/16/88)
In article <243@oha.UUCP> tony@oha.UUCP (Tony Olekshy) writes: >In <3595@psuvax1.psu.edu> okunewck@gondor.cs.psu.edu (Phil OKunewick) writes: >> >> Therefore, I want something that will tell my operator "Do not do it this >> way you fool" if he tries to dump in multi-user mode. > >We are running Xenix V here, and Xenix V uses /.profile before $HOME/.profile I think Tony means /etc/profile not /.profile. /.profile is traditionally root's $HOME/.profile. >only when starting the top-level single-user-mode sh. I have placed: > > SU_MODE=1; export SU_MODE > >in /.profile only, so I can always determine if I am in single user mode just >by examining "$SU_MODE". If your system lets you determine if you are in >single user mode during the shell startup script then you can use this too. What happens when the 'init s' or 'init 1' is issued? I don't think Tony's fix is general enough for Phil's problem. The normal way for a Sys V user to determine which run level state the system is in, is to do a 'who -r'. Surely this could be exploited for Phil's purpose, although his original article didn't indicate what version of Unix is being run at his site. Who's -r option isn't supported yet in SCO's Xenix, but should be soon. Hope this helps. Larry Dighera -- USPS: The Consultants' Exchange, PO Box 12100, Santa Ana, CA 92712 TELE: (714) 842-6348: BBS (N81); (714) 842-5851: Xenix guest account (E71) UUCP: conexch Any ACU 2400 17148425851 ogin:-""-ogin:-""-ogin: nuucp UUCP: ...!ucbvax!ucivax!icnvax!conexch!root || ...!trwrb!ucla-an!conexch!root
rogers@ofc.Columbia.NCR.COM (H. L. Rogers) (05/17/88)
In article <340@conexch.UUCP> root@conexch.UUCP (Larry Dighera) writes: > >The normal way for a Sys V user to determine which run level state the system >is in, is to do a 'who -r'. True, but since there is no 'standard' which specifies the system state for a particular run level number, a user program (application?) risks portability problems from vendor to vendor. Does anyone know of any standards work to abstract the numerical run level for Un*x systems? -- ------------ HL Rogers (hl.rogers@ncrcae.Columbia.NCR.COM)
mjy@sdti.UUCP (Michael J. Young) (05/18/88)
In article <166@ofc.Columbia.NCR.COM> rogers@ofc.UUCP (H. L. Rogers) writes: >In article <340@conexch.UUCP> root@conexch.UUCP (Larry Dighera) writes: >>The normal way for a Sys V user to determine which run level state the system >>is in, is to do a 'who -r'. >True, but since there is no 'standard' which specifies the system state for >a particular run level number, a user program (application?) risks >portability problems from vendor to vendor. Does anyone know of any >standards work to abstract the numerical run level for Un*x systems? I don't know of a standard way, but this should work for System V at least. No flames for style or accuracy. Not a shar. --------------------- cut here ---------------- cut here ------------------- # include <stdio.h> # include <sys/types.h> # include <utmp.h> extern struct utmp *getutid (); extern void utmpname (); int main (){ struct utmp *buf; /* will hold utmp entry */ struct utmp buf2; /* dummy entry to hold search type */ /* * look for an entry in the utmp file that is of type RUN_LVL. * The ut_line member of this entry will contain the string * "run-level %c", where %c is [sS1-6]. */ buf2.ut_type = RUN_LVL; utmpname ("/etc/utmp"); /* not really necessary */ if ((buf = getutid (&buf2)) == NULL){ perror ("rlvl: could not find RUN_LVL entry in /etc/utmp"); exit (1); } else { printf ("%c\n", buf->ut_line[10]); } exit (0); } -- Mike Young - Software Development Technologies, Inc., Sudbury MA 01776 UUCP : {decvax,harvard,linus,mit-eddie}!necntc!necis!mrst!sdti!mjy Internet : mjy%sdti.uucp@harvard.harvard.edu Tel: +1 617 443 5779 "Bill & Opus in '88" -- Consider the alternatives!