New user .login file && a question

Wayne Mesard mesard at bbn.com
Wed Aug 24 01:57:41 AEST 1988


When adding new users to my system I give them a ~/.login file which
forces them to change their password the first time they login.  After
they do this, the ~/.login modifes itself to strip out the first-time-
only stuff.  I.e. all the lines containing the string "FIRST_LOGIN" get
removed.  This is all straight forward, but pretty useful nonetheless,
so I've included it below for all who are interested.

Now, my question is that I originally, had the self-modifying stuff (the
grep and cp) in the middle of the file (immediately after the while loop)
thinking that the shell would keep the file open until it was done
reading it.  Well, no such luck.  It only got a few lines past the
cp (presumably to the end of the disk block?).

What gives?  Why would csh lose it's place in what I expected to be an
unlink'ed but not yet forgotten file?

Thanks in advance for enlightening me.

---CLIP---------------------------SNIP----------------------------CLIP---
onintr -                                                     #FIRST_LOGIN
   < SYS ADMINS:  Put the commands that you want everyone to have >
   < in their default ~/.login files here.  E.g. setenv PATH,     >
   < terminal-type setting, etc.                                  >
echo  -----                                                  #FIRST_LOGIN
echo Since this is your first time logging onto $HOST,       #FIRST_LOGIN
echo you should change your password to something which      #FIRST_LOGIN
echo you will remember and that others are not likely to     #FIRST_LOGIN
echo discover.  The security of this machine is your         #FIRST_LOGIN
echo responsibility!                                         #FIRST_LOGIN
echo  -----                                                  #FIRST_LOGIN
set oldenpw = `grep $user /etc/passwd | cut -d: -f2`         #FIRST_LOGIN
passwd                                                       #FIRST_LOGIN
while ($oldenpw == `grep $user /etc/passwd | cut -d: -f2`)   #FIRST_LOGIN
    echo Try again.  You MUST change your password.          #FIRST_LOGIN
    passwd                                                   #FIRST_LOGIN
end                                                          #FIRST_LOGIN
echo  -----                                                  #FIRST_LOGIN
echo Thank you for your cooperation.  If you forget your     #FIRST_LOGIN
echo password in the future, your system administrator       #FIRST_LOGIN
echo can assign you a new one.  Welcome aboard.              #FIRST_LOGIN
echo  -----                                                  #FIRST_LOGIN
echo                                                         #FIRST_LOGIN
onintr                                                       #FIRST_LOGIN

/usr/games/fortune
grep -v "FIRST_LOGIN" ~/.login > /tmp/$user.login            #FIRST_LOGIN
cp /tmp/$user.login ~/.login                                 #FIRST_LOGIN
---CLIP---------------------------SNIP----------------------------CLIP---

-- 
unsigned *Wayne_Mesard();        MESARD at BBN.COM           BBN, Cambridge, MA

           I can't imitate the President.
                                          -George Bush



More information about the Comp.unix.wizards mailing list