[net.unix-wizards] 4.2 oddity -- SLOGIN flag in proc.h

scc%computer-lab.cambridge.ac.uk@ucl-cs.arpa (Stephen Crawley) (08/11/85)

While writing a program which uses various bits of information from
the proc table, I found the following oddity.

The <sys/proc.h> header file contains the following line :-

#define	SLOGIN	0x0800000	/* a login process (legit child of init) */

However, ps -axl indicates that this bit is not set for any processes.
Indeed, grepping /sys/sys confirmed that SLOGIN isn't referenced anywhere.
While making sure that the flag gets set would seem to be straight forward,
I'm not convinced that it would be stunningly useful.  [ What would be
more useful would be if the login shell pid were recorded in /etc/utmp! ]

I was wondering what this all means.  Is this something that the 4.2
implementors dropped as being a bad idea?  Or something that didn't get 
finished in time?  Are all login processes under 4.2 illegitimate??  :-) :-)

			Stephen C. Crawley

ARPA:	scc%cl.cam.ac.uk@ucl-cs.ARPA  SMail: Cambridge Univ. Computer Lab.,
JANET:	scc@uk.ac.cam.cl                     Corn Exchange Street,
UUCP:	{ukc,kcl-cs}!cl-jenny!scc	     Cambridge CB2 3QG, 
PHONE:	+44 223 352 435                      England.

p.s. No prizes for guessing what the program is supposed to do.

jjg@security.UUCP (Jeff Glass) (08/13/85)

In article <607@brl-tgr.ARPA> scc%computer-lab.cambridge.ac.uk@ucl-cs.arpa (Stephen Crawley) writes:
> The <sys/proc.h> header file contains the following line :-
> 
> #define	SLOGIN	0x0800000	/* a login process (legit child of init) */
> 
> However, ps -axl indicates that this bit is not set for any processes.
> Indeed, grepping /sys/sys confirmed that SLOGIN isn't referenced anywhere.
> While making sure that the flag gets set would seem to be straight forward,
> I'm not convinced that it would be stunningly useful.  [ What would be
> more useful would be if the login shell pid were recorded in /etc/utmp! ]

I think this method would be superior to the way that {c,}sh now find that
they are login shells (checking if argv[0][0] == '-').  at least one security
hole takes advantage of this.

I also think Stephen's suggestion (putting the pid in utmp) is pretty neat.

/jeff
-- 
  security!jjg@mitre-bedford.ARPA				(MIL)
 {allegra,ihnp4,utzoo,philabs,uw-beaver}!linus!security!jjg	(UUCP)

kre@ucbvax.ARPA (Robert Elz) (08/14/85)

In article <607@brl-tgr.ARPA>, scc%computer-lab.cambridge.ac.uk@ucl-cs.arpa (Stephen Crawley) writes:
> The <sys/proc.h> header file contains the following line :-
> 
> #define	SLOGIN	0x0800000	/* a login process (legit child of init) */
> 
> However, ps -axl indicates that this bit is not set for any processes.

Well, I hope its not set (on your, or any 4.2bsd or 4.3bsd system)
but I assure you that it is set on my system (Melbourne Australia).

> While making sure that the flag gets set would seem to be straight forward,
> I'm not convinced that it would be stunningly useful. 

Well, it has its uses on my system - its related to the scheduling
stuff that we have that requires the kernel to be able to detect
when a user logs out (so it can send data to a daemon process
waiting to record information about scheduling, so when he logs in
again, minutes/hours/days/months later, things can be restored to
their previous values (this is a gross simplification)).

The flag is retained in proc.h so that no-one else will "accidentally"
re-use the bit (or the name).  Someday, perhaps, in the distant future,
the Melbourne stuff might become a config option in 4.x bsd, just
like the disc quota stuff is at the minute.

Robert Elz			kre@munnari.oz			(Australia)
				seismo!munnari!kre		(uucp)
				kre%munnari.oz@seimso.css.gov	(arpa)
		(temporarily)	ucvbax!kre or kre@ucbvax.berkeley.edu

ps: I believe that I said much of this before, not very long ago...