script & lock

Paul De Bra debra at alice.UUCP
Wed Dec 28 08:19:50 AEST 1988


In article <17972 at adm.BRL.MIL> drears at ardec.arpa (Dennis G. Rears (FSAC)) writes:
>  This happens on a VAX 8600 running ULTRIK but does not happen on
>Goulds or Pyramids.   I have a lock program I wrote several years
>ago.  When I run it on top of /usr/ucb/script I get a Bus Error when I
>type in my password.  Any idea why?  Here is the program lock:
>...
>	uname = getlogin();  /* What happens if the UTMP file is screwed? */

You might want to check on this. script may confuse getlogin. The 4.3 manual
says:

If getlogin is called within a process that is not attached to a terminal,
or if there is no entry in /etc/utmp for the process's terminal, getlogin
returns a NULL pointer (0).

The manual further suggests:

A reasonable procedure for determining the login name is to first call
getlogin and if it fails, to call getpwuid(getuid()).

>		oldpass = getpass("");

script may or may not let you turn on/off the echo... after all the standard
output of the program goes to script, not to the terminal... (I may be wrong
on this one, my unix doesn't have script)

One last comment: I would replace the strcmp calls by strncmp. You never know
when you will get a bogus Unix version that forgets to 0-terminate a name
from utmp or passwd when it is 8 characters long.

Paul.
-- 
------------------------------------------------------
|debra at research.att.com   | uunet!research!debra     |
------------------------------------------------------



More information about the Comp.unix.wizards mailing list