Listing 4: Code fragment modifying getty
#ifdef SECURE_LOGIN
# define PATH_LOGIN "/bin/snklogin"
#else
# define PATH_LOGIN "/bin/login"
#endif
.
.
.
#ifdef SECURE_LOGIN
largs = addarg(0, "snklogin");
if (tty=ttyname(0)) {
largs = addarg(largs, "-h");
if (strstr(tty, "ttys"))
largs = addarg(largs, "dialup line");
else if (strstr(tty, "ttyp"))
largs = addarg(largs, "network");
else
largs = addarg(largs, "unknown location");
largs = addarg(largs, "-i");
largs = addarg(largs, tty);
} else {
largs = addarg(largs, "-h");
largs = addarg(largs, "unknown location");
}
largs = addarg(largs, "-c");
largs = addarg(largs, "remote");
largs = addarg(largs, user);
#else
/* Parse the input line from the user,
breaking it at white spaces. */
largs = addarg(0, "login");
parse(user,largs);
#endif
/* Exec "login". */
execv(PATH_LOGIN,largs);
D1("%s %s not executable.",PATH_LOGIN,dbgtime());
exit(1);
|