ftp.nice.ch/peanuts/GeneralData/Usenet/news/1989/CSN-89.tar.gz#/comp-sys-next/1989/Jan-Apr/csh+the-NeXTs

This is csh+the-NeXTs in view mode; [Up]


Date: Sun 14-Feb-1989 22:48:06 From: Unknown Subject: Re: csh & the NeXTs In article <17953@vax5.CIT.CORNELL.EDU> jhc@Vax5.CIT.Cornell.EDU (James H. Cloos, Jr.) writes: > >On another tangent, I would like to execute some commands on login iff I've >loged in remotely, but don't know how to check this in .login. I have the >following basic form: >if (remote-login) then > [execute some commands here] > if (no-one-else-on) > [execute some more commands here] > endif >endif > >where remote-login is true if I've rlogged in or telneted in, and >no-one-else-on is true if anyone else who is logged in has also logged in >via rlogin or telnet. (Ie, the [execute some more commands here] line(s) >should not run if someone is logged in at the machine itself.) Is there any >way to determine these from w/in a csh script? > >Thanks for any help. > >-JimC One of our NeXTs is available for faculty to evaluate. In order to make it easy to log into, we placed a guest account on it w/o a password. Unfortunately, there are some maladjusted individuals that like to attack computers -- especially those with guest accounts w/o passwords -- over the net. In order to prevent people from using telnet/rlogin/rsh to sign on the guest account and still allow guest at the console to bring up a terminal/csh, I use the following as guest's shell: VVVVVVVVVVVVVVVVVVVVVVV /usr/local/lib/securecsh VVVVVVVVVVVVVVVVVVVVVVVVV #!/bin/csh -f # # get the user name of the parent of this process # set ppid=`ps -l $$ | awk '{ if ($3 == "'$$'") print $4}'` set parent=`ps -u $ppid | awk '{ if ($2 == "'$ppid'") print $1}'` # # see if the user brought up the shell (OK) or if it was created by # the system (telnetd/rlogind -- not OK) # if ($parent == $USER) then setenv SHELL /bin/csh setenv PATH /usr/local/lib exec -csh else echo Network access to the $USER account is not allowed. echo Access to this machine is for authorized users only. sleep 4 endif ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ It checks the user name of the parent process and if it the parent is the same as the user, then the user started the shell after already logging in (at the console) and everything is ok. If the user name and the parent process' name are different, then the parent process is probably a root process (telnetd, rlogind, ...) and I don't want them around. -csh is actually a symbolic link in /usr/local/lib that points to /bin/csh. In order for csh to run your .login, it (argv[0]) must be called as -csh. Yes, it's a kludge. No question about it. Jim, I'm sure that this could be modified to do whatever you want. If this is part of a .login or .cshrc and not a shell, then the exec stuff can be tossed. The part about checking if anyone else is on can be implemented by using wc or awk on the output of users or who. Net, If you've get a better solution, I'm interested. I would have simply modified the NeXT login, 'cept I don't have the source (sorry about that). Mark >From: mmeyer@mcdurb.Urbana.Gould.COM
Date: Sun 15-Feb-1989 18:57:27 From: Unknown Subject: Re: csh & the NeXTs In article <17953@vax5.CIT.CORNELL.EDU> jhc@Vax5.CIT.Cornell.EDU (James H. Cloos, Jr.) writes: >On another tangent, I would like to execute some commands on login iff I've >loged in remotely, but don't know how to check this in .login. Here's what I do to get the opposite effect, which you should be able to alter to suit your needs. I have certain commands that I *don't* want to be executed for remote logins. So, I have the following lines at the top of .login: # Find out if this is an rlogin: tty | egrep /dev/ttyp > /dev/null set NOTNET = $status $NOTNET is true if it's not an rlogin. I use its value in subsequent 'if' statements in .login; I even check it in .logout to skip things like fortune when I'm just closing an rlogin session. >From: owen@gt-eedsp.UUCP (Owen Adair)
Date: Sun 16-Feb-1989 22:47:41 From: Unknown Subject: Re: csh & the NeXTs Another interesting thing to do is write a program of the form: main() { <stuff to do before the workspace runs> if (!fork()) execl("/bootdisk/NeXT/Apps/Workspace","-LoginProgram","YES",0); else { wait(&junk); <stuff to do after the workspace runs> } } You then use dwrite to tell the login process you want to run this instead of Workspace when you log in to the console: dwrite loginwindow Workspace /usr/local/bin/foo Now, you get control BEFORE and AFTER the Workspace runs. I use a program of this type on our public access machines, to reset the files in the guest account to a friendly state (all the right things on the dock, etc.). There is also a "LoginHook" switch you can add to the console entry in /etc/ttys to give control before the Workspace is run; this one I haven't yet tried.
Date: Sun 17-Feb-1989 21:24:24 From: Unknown Subject: Re: csh & the NeXTs In article <451@garcon.cso.uiuc.edu>, dorner@pequod.cso.uiuc.edu (Steve Dorner) writes about a way to create a program that will be launched at login time instead of the Workspace manager. That program can initialize, call the WM, and do wrapup functions. Steve's approach works nicely. Coupled with Christopher Lane's bright program, it enables one to have a poor man's screen dimmer/brightener at logoff/logon time. There's one "gotcha": the Workspace manager that the program runs loses contact with the console and you cannot use the Console item of its Utilities submenu. I'm a bit surprised, since that WM process is started by a fork/execl and should inherit the file descriptors of the program that started it. How does the WM access the console? Vic Abell >From: paul@phoenix.Princeton.EDU (Paul Lansky)

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Marcel Waldvogel and Netfuture.ch.