Double-login "bug"

There is a curious little "bug" that has been in Puppy right from the beginning, that causes a double-login.

When you power-up your pup and get a desktop, you are logged in once. If you then exit to the prompt (via "Exit to prompt" in the "Shutdown" menu, or hit CTRL-ALT-BACKSPACE), you get dropped down to the console, but you also get logged in a second time.

This has never bothered us, well I don't think it has. But, I am thinking how to fix it...

The problem comes about by this line in /etc/profile:

exec xwin

This line transfers control to /usr/bin/xwin, which in turn launches the desktop. When there is an exit from X, there is then a return to xwin, which then exits and there is a return to /etc/profile.

Now this is the problem: /etc/profile is really being used in an unnatural way. It never completes, instead there is a transfer to xwin. When there is finally an exit from xwin, /etc/profile completes, but this somehow causes a second login to occur ( the auto-root-login runs, see /etc/inittab).

I recall that Patriot considered this and other bootup/shutdown issues in some depth awhile back.

Well, there is one possible "fix". Instead of "exec xwin" in /etc/profile, have "xwin &". This allows /etc/profile to complete.

However, when there is an exit to prompt from X, it looks strange as the cursor is there but no prompt before it. A fix for this is to have "echo -n '# '" just before exit from xwin.

I might implement this fix in Woof, still thinking about it.


Posted on 4 Aug 2011, 18:30


Comments:

Posted on 4 Aug 2011, 19:27 by Sage
Double-login "bug"
Normally find this quite useful when changing resolution, etc. It doesn't seem to re-log-in when there's an issue, eg with resolution, no picture, etc.


Posted on 4 Aug 2011, 19:35 by BarryK
Double-login fix ok
I have been testing it, the fix seems ok, so have put it into Woof. The modified files are /etc/profile and /usr/bin/xwin.

Note that xwin only echoes '# ' the first time that it exits. Subsequent exits do not have the double-login problem (as it has already occurred, at least before I fixed it).

Note, the reason that I was aware of the double-login was after the changeover from using 'autologinroot' to 'mingetty' -- the latter rewrites the screen every time it logs in, so the second login wipes previous text that was on the console.
You can also put in code to count how many times /etc/profile executes, and you will see that it jumps to 2 after first exit from X.


Posted on 5 Aug 2011, 4:01 by GCMartin
Is this related to hostname issue
Did the PM I sent to you inspire this or is this a coincidence?


Posted on 5 Aug 2011, 4:41 by Dougal
Hmm
This is not clear to me:
"When there is finally an exit from xwin, /etc/profile completes, but this somehow causes a second login to occur ( the auto-root-login runs, see /etc/inittab). "

When you do an "exec", /etc/profile terminates -- xwin takes over its PID... and if you run "ps ax" you won't see any process for /etc/profile.

Besides that, xwin shouldn't exit -- maybe that's where your problem is: exiting from xwin should be done with "exec /bin/sh".
(I modified my scripts a while a go to minimize the number of processes just hanging around waiting for children to complete -- I always use "exec" when possible.)


Posted on 5 Aug 2011, 8:00 by BarryK
Re hostname issue
GCMartin,
No, I haven't looked at that yet.

Dougal,
My understanding is that when /etc/profile runs, /bin/sh is already running. My arrangement will cause a fallback to that shell when xwin exits. Putting "exec /bin/sh" in xwin will launch a second /bin/sh.



Posted on 5 Aug 2011, 8:06 by BarryK
More instances of 'sh'
Dougal,
Also, with your arrangement, xwin runs "exec /bin/sh" so you launch another shell. But if the user then types "xwin" to restart X, they will be launching xwin ...then if they exit X again, yet another shell will run, and so they will accumulate.

I am running my "fixed" system right now, so can't test the above.


Posted on 5 Aug 2011, 13:57 by GCMartin
relationship of what you're doing
My PM to you is about what happens with a logout command when exiting desktop to a prompt.

I believe there is a relationship. Would you glance at it when you get a moment. If may give you some ideas about Puppy behavior.

Hope this helps.


Posted on 6 Aug 2011, 5:28 by Dougal
exec xwin
Barry, my mistake: I just looked in my xwin and what I do is exit to the shell.
I think what I was thinking about was the "exec xwin" that used to be in the xorgwizard...



Posted on 6 Aug 2011, 8:31 by abushcrafter
I Don't Like The Prompt Workaround
The workaround for the prompt is no good to those of us that have customised our prompt. So it is not a "#".

Here is mine:
<Sat Aug 06><01:30:47>~

1>>>



In "/etc/profile.local"

#!/bin/sh

# How abushcrafter likes his prompt.
export PS1="\e[32;40m<\d><\t>\e[0m\e[33;40m\w\e[0m\n\e[32;40m\#\e[0m\[\e[36;1m\]>>> \[\e[0m\]\n"



Posted on 6 Aug 2011, 20:25 by technosaurus
fastestX
I have written 2 tiny c apps that start X as fast as possible with almost no overhead

the first I just call "x"
if called w/ parameters it forks Xvesa <params>
if called w/o parameters it just runs Xorg
then a program waitfordisplay until X is up
then it runs jwm -display :0
finally kills Xorg/Xvesa after jwm exits
time to start jwm with Xvesa is ~0.1 seconds on 1.6Ghz cpu

the code and binaries are here
http://www.murga-linux.com/puppy/viewtopic.php?t=51478
... may need extra code for a .xinitrc replacement

btw command.c in jwm executes programs using the shell for no apparent reason ... causing an extra MB of overhead for each program ... there is a macro in that code that could replace it (previously I have patched it with system(cmd); but apparently fork+exec is more secure)


Posted on 6 Aug 2011, 20:45 by technosaurus
udevd and delayedrun * X
part of the reason I wrote those programs was the multiple instances of udevd and delayedrun when exiting and using startx (besides wanting 1/25th the overhead and the fastest possible start time)

fix needs something like?
[ `ps|grep udevd|grep -v grep` ] && udevd ...

it was easy to just modify the .xinitrc as the jwm <StartupCommand>


Posted on 6 Aug 2011, 21:57 by linuxcbon
inittab
xwin shouldn't be in /etc/profile
X is started by /etc/inittab
id:5:initdefault:



Posted on 7 Aug 2011, 2:01 by BarryK
inittab
linuxcbon,
Busybox doesn't support runlevels. The "5" designates a runlevel. I don't know how to do it with Busybox.



Posted on 7 Aug 2011, 4:48 by Dougal
Busybox doesn't support runlevels
Barry, that's been fixed a long time ago... but Puppy just doesn't work with runlevels and probably not worth changing.


Posted on 7 Aug 2011, 21:43 by BarryK
Double-login fix reverted
I have reverted the "fix".

I don't know why, but it upsets 'dialog'. Window displays but keyboard non-functional.



Posted on 7 Aug 2011, 24:04 by linuxcbon
another solution
Another solution is ~/.bash_profile
startx




Posted on 21 Feb 2012, 16:05 by BarryK
Workaround for double-login
The saga continues. If I just run "xwin" in /etc/profile, instead of "exec xwin", another shell gets launched and xwin runs, but when xwin quits (that is, exit from X), /etc/profile will terminate also and there is a drop down to the original login shell -- that is, the double-shell bug is gone.

The latest Woof at 2012-02-21, Wary/Racy builds 5.2.2.7, have this change, except that I also moved the execution of "xwin" to /root/.profile -- I just wanted /etc/profile to be cleaner, set environment variables only, considering the it gets included in /root/.bashrc.

See blog post:
http://bkhome.org/blog/?viewDetailed=02705



Posted on 29 Mar 2012, 8:12 by K Godt
xwin from inittab
came across accidentally :
My /etc/inittab :
#busybox init /etc/initab syntax:

#device(without '/dev/'):runlevel:feature:command
::sysinit:/etc/rc.d/rc.sysinit
::ctrlaltdel:/sbin/reboot

tty1:3:respawn:/sbin/getty -n -l /bin/autologinroot 38400 tty1
tty2:2:respawn:/sbin/getty -n -l /bin/autologinroot 38400 tty2
tty3:5:respawn:/sbin/getty 38400 tty3
tty4:5:respawn:/sbin/getty 38400 tty4

tty1:3:once:/usr/bin/xwin

vc/8:1235:respawn:/etc/init/vc8
vc/9:1235:respawn:/etc/init/vc9

where /etc/init/vc8 are scripts lo tail dmesg and xerrs.log to console8+9 .

This starts ,
the whole boot/rc.sysinit i am
whoani root
but my HOME is '/'
before a login .
So i got me the whole /root/* also on / :)

To work around it i modified xwin to

echo -n "Waiting for kernel-drivers completely loaded..."

while [ "`pidof pup_event_backend_modprobe`" ];do
sleep 2s;done
while [ "`pidof rc.services`" ];do
sleep 2s;done
echo -e "\e[72G\e[1;32m""done""\e[0;39m"

alias modprobe='modprobe -b' #case Xorg loads kernel drivers

if [ "$HOME" = "/" ] ; then
export HOME=/root;fi


i have also set the interpreter to
#!/bin/bash --login

And don't know if it is necessary .
Will test to revert it .

I am running that above code for some weeks now without big problems .

The prompt i have to watch for,too now if exit from X :)

For what i can tell is that xwin & i was experimenting with something like rc.lauch_win called from inittab,
too and had similar prompt occurrences, which i could not solve satisfactorily either ...





Posted on 29 Mar 2012, 16:44 by BarryK
Re inittab
Karl,
That is interesting that you have got it working ok. I did consider something like that awhile back, but I was very uncertain about it and didn't try to implement anything.

Well, I don't want to make any fundamental changes for now, as Wary/Racy is at RC1.

However, after I release Wary/Racy 5.3, I'm thinking of implementing one of the alternatives to init and inittab. Dougal and I were discussing this recently. I would like to experiment with something that is specifically designed for extensibility -- for example, could handle launching xwin any way we want (kind of like what runlevels does, but there are some interesting alternatives out there).

In fact, I'm itching to do this. I have got to make a big push to get Wary/Racy released, so that I can get onto this!



Posted on 30 Mar 2012, 13:42 by K Godt
Thats ok with something new
Thinking further i think i would need a "#!/bin/bash --login" to run /etc/profile for the LANG settings at least .

I have tested the exit to prompt and that worked quite good because the login got started after xwin finished an got me the normal P1 prompt .

I was thinking of having a graphical login like xorgwizard test X with a simple gui like there .

Could grep the users from /etc/shadow and present them .

I felt that the xorgwizard test X was a little boring and came up with something heavy :

#gpicview /usr/share/doc/puppylogo96.png &

#viewnior /usr/share/doc/puppylogo96.png &
#pngtopnm /usr/share/doc/puppylogo96.png >/usr/share/doc/puppylogo96.pnm #needs >
pngtopnm /usr/share/doc/puppylogo96.png >/tmp/puppylogo96.pnm
pnmtops /tmp/puppylogo96.pnm >/tmp/puppylogo96.ps
ps2pdf /tmp/puppylogo96.ps /tmp/puppylogo96.pdf
pdftoppm /tmp/puppylogo96.pdf >/tmp/puppylogo96.ppm
ppmquant 14 /tmp/puppylogo96.ppm >/tmp/puppylogo96d14.ppm
ppmtogif /tmp/puppylogo96d14.ppm >/tmp/puppylogo96d14.gif
gifsicle --crop 530,717+720x540 /tmp/puppylogo96d14.gif >/tmp/puppylogo640.gif
gifX=640;gifY=480;gifX=$XTEST;gifY=$YTEST
gifsicle --resize ${gifX}x${gifY} /tmp/puppylogo640.gif >/tmp/puppylogo.gif
gifview /tmp/puppylogo.gif &
sleep 2s
rm -f /tmp/puppylogo*
xmessage -font "8x16" -center -timeout 20 -buttons "OK:10" -default OK "

for xinitrc_test .

Running Racy 5.2.2 frugal from a nasty mp3 player that as soon as usb-storage gets initialized says :NO GO further -> dropped out to rdsh :
Replugged it,
pfix=rdsh ./init
exec switch
worked great to leave the sh console to switch PID 1 from /bin/sh to /sbin/init !