Uniquely identifying a user: is it possible?
Karl Fox
karl at MorningStar.Com
Sun Jan 14 02:47:31 AEST 1990
My UNIX-PC (3.51+Development) *does* have getpgrp(). I tried this quick
hack and haven't been able to make it fail yet. It works while su'd,
nohup'ed and totally redirected.
# include <sys/types.h>
# include <utmp.h>
# define SO "\033[7m"
# define SE "\033[m"
main()
{
extern struct utmp *getutent();
register int pgrp = getpgrp();
register struct utmp *up;
while (up = getutent())
printf("%s%8s %4s %12s %5d %d %d/%d%s\n",
pgrp == up -> ut_pid ? SO : "",
up -> ut_user,
up -> ut_id,
up -> ut_line,
up -> ut_pid,
up -> ut_type,
up -> ut_exit.e_termination,
up -> ut_exit.e_exit,
pgrp == up -> ut_pid ? SE : "");
}
--
Karl Fox, Morning Star Technologies karl at MorningStar.Com
More information about the Unix-pc.general
mailing list