site  contact  subhomenews

Double-login "bug"

August 04, 2011 — BarryK
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.

Comments

Double-login "bug"


Double-login fix ok
Username: BarryK
"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.

Hmm
Username: Dougal
"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.)

Re hostname issue
Username: BarryK
"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.

More instances of 'sh'
Username: BarryK
"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.

relationship of what you're doing
Username: GCMartin
"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.

exec xwin
Username: Dougal
"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...

I Don't Like The Prompt Workaround
Username: abushcrafter
"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: [code]<Sat Aug 06><01:30:47>~ 1>>> [/code] In "/etc/profile.local" [code] #!/bin/sh # How abushcrafter likes his prompt. export PS1="e[32;40m<d><t>e[0me[33;40mwe[0mne[32;40m#e[0m[e[36;1m]>>> [e[0m]n"[/code]

fastestX
Username: technosaurus
"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)

udevd and delayedrun * X
Username: technosaurus
"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>

inittab
Username: linuxcbon
"xwin shouldn't be in /etc/profile X is started by /etc/inittab id:5:initdefault:

inittab
Username: BarryK
"linuxcbon, Busybox doesn't support runlevels. The "5" designates a runlevel. I don't know how to do it with Busybox.

Double-login fix reverted
Username: BarryK
"I have reverted the "fix". I don't know why, but it upsets 'dialog'. Window displays but keyboard non-functional.

another solution
Username: linuxcbon
"Another solution is ~/.bash_profile [code]startx[/code]

Workaround for double-login
Username: BarryK
"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/archive/blog2/201202/waryracy-5227-53beta1.html

xwin from inittab
Username: K Godt
"came across accidentally : My /etc/inittab : [code]#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[/code] 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 [code]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[72Ge[1;32m""done""e[0;39m" alias modprobe='modprobe -b' #case Xorg loads kernel drivers if [ "$HOME" = "/" ] ; then export HOME=/root;fi[/code] 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 ...

Re inittab
Username: BarryK
"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!

Thats ok with something new
Username: K Godt
"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 : [code]#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 "[/code] 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 !


Tags: woof