[PATCH] Allow per-user setup script be run by login

Denis Vlasenko vda.linux at googlemail.com
Mon Jul 10 07:51:55 UTC 2006


On Monday 10 July 2006 00:36, Jason Schoon wrote:
> > > I'm using busybox login. When I log in as non-root,
> > > I can use /dev/ttyNN device I am logged on (of course),
> > > but cannot use /dev/vcs[a]NN devices which hold screen
> > > buffer data. I need to be able to do it.
> > > util-linux's login chown+chmod's those devices for me.
> > >
> > > Is there any solution for busybox login?
> >
> > Okay, maybe this patch will be deemed insufficiently ugly
> > to reject. (/me crosses fingers...)
> >
> > With this patch I can point LOGIN_PRE_SUID_SCRIPT to
> > the script like this:
> >
> > #!/bin/sh
> > ttyname=`ttyname`
> > ttybase=`echo "$ttyname" | sed 's/[0-9]*$//'`
> > ttytail=${ttyname:${#ttybase}}
> > if test "$ttybase" = "/dev/tty"; then
> >     chown "$LOGIN_USER": "/dev/vcs$ttytail" "/dev/vcsa$ttytail"
> >     chmod 0600 "/dev/vcs$ttytail" "/dev/vcsa$ttytail"
> > fi
> >
> > This will achieve what I want, and is generic enough
> > when compared to adding /dev/vcs[a] support into the login itself.
> 
> I'm a bit confused, and not near the code right now.  Is this something that
> happens before you would have a chance to call something like a .profile for
> the user to fix this up?

This allows admin to instruct login to run and wait for a child (typically
shell script) after login authenticated the user (read: we know username,
homedir, shell, etc) but before login actually setuid()s to $UID.
IOW: script is run with root privileges. It allows me to do a
chown/chmod on /dev/something. /etc/profile and/or .profile
are run as user -> I cannot chown/chmod /dev/something.
--
vda



More information about the busybox mailing list