Index: [thread] [date] [subject] [author]
  From: Andrew Apted <ajapted@netspace.net.au>
  To  : ggi-develop@eskimo.com
  Date: Fri, 5 Feb 1999 11:45:10 +1100

Re: Problems with Linux_kbd & 2.2.0-pre9 (fwd)

Marcus writes:

>  Well, this code should do it in that case too:
>  
>  	if (neednewvt && geteuid() && setsid() < 0) {
>  		int i;
>  		int pid = getpid();
>  		int ppgid = getpgid(getppid());
>  
>  		/* We're not running as root and setsid() failed, so we try
>  		   to set our process group ID that of our parrent. */
>  		setpgid(pid, ppgid);
>  		if (setsid() < 0) {
>  			/* We propably have a child process... */
>  			for (i = 1; i < 5; i++) {
>  				if (getpgid(pid + i) == pid) {
>  					setpgid(pid + i, ppgid);
>  				}
>  			}
>  			if (setsid() < 0) {
>  				/* That failed too. Now we scan the entire
>  				   process space after possible childs.
>  				   (This takes 32ms on a P225, so we can live
>  				   with doing this once at startup time...) */
>  				for (i = 2; i < PID_MAX; i++) {
>  					if (getpgid(i) == pid) {
>  						setpgid(i, ppgid);
>  					}
>  				}
>  				/* Last chance, if this fails we probably
>  				   can't switch VTs below. */
>  				setsid();
>  			}
>  		}
>  	}
  
Yeah it aint pretty, but if it works then we might as well use it.

>  Btw, there are some other issues here, which are not only related
>  to LibGGI:
>  
>  The console(4) manpage suggests that /dev/tty<n> should be owned
>  by root.tty and have permissions 0622. If that is followed you
>  can allocate a new VT just fine (because all the vtswitching stuff
>  can still be done if you open with O_WRONLY), but the opening the
>  keyboard will fail as we obviously need read permission for that.
  
My ttys seem to be owned by me.  Doesn't `login' chown them ?

>  Also, having permissions 0622 means that any user with an account
>  on the machine can switch consoles even if he's logged in remotely.

Interesting, I wonder if the kernel folks are aware of that.

Cheers,
_____________________________________________  ____
                                               \  /
  Andrew Apted   <andrew@ggi-project.org>       \/
 

Index: [thread] [date] [subject] [author]