Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 360672 Details for
Bug 481236
LiveCD tries to start X once for every tty
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch 3
0003-livecdfs-update.sh-Use-bash-login-to-spawn-startx.patch (text/plain), 3.26 KB, created by
Matt Turner
on 2013-10-11 22:09:09 UTC
(
hide
)
Description:
patch 3
Filename:
MIME Type:
Creator:
Matt Turner
Created:
2013-10-11 22:09:09 UTC
Size:
3.26 KB
patch
obsolete
>From b9edd7819340c4414b083b4109b3f6967b487723 Mon Sep 17 00:00:00 2001 >From: "W. Trevor King" <wking@tremily.us> >Date: Wed, 6 Mar 2013 12:02:59 -0500 >Subject: [PATCH 3/3] livecdfs-update.sh: Use `bash --login` to spawn startx > >Starting a "login" version of Bash via `su` is tricky. The naive: > > su - ${first_user} -c startx > >fails because `su - ...` clears a number of environment variables (so >the prefixed `source /etc/profile` doesn't accomplish anything), but >Bash isn't started with the `--login` option, so it doesn't source >/etc/profile internally. From bash(1): > > A login shell is one whose first character of argument zero is a -, > or one started with the --login option. > ... > An interactive shell is one started without non-option arguments and > without the -c option whose standard input and error are both > connected to terminals (as determined by isatty(3)), or one started > with the -i option... > ... > When bash is invoked as an interactive login shell, or as a > non-interactive shell with the --login option, it first reads and > executes commands from the file /etc/profile, if that file exists. > After reading that file, it looks for ~/.bash_profile, > ~/.bash_login, and ~/.profile, in that order, and reads and executes > commands from the first one that exists and is readable. The > --noprofile option may be used when the shell is started to inhibit > this behavior. > >In order to get the login-style profile loading with a non-interactive >`su` invocation, you need to use something like: > > echo "${command}" | su - "${user}" > >This starts a login shell and pipes the command in via stdin, which >seems to fake Bash into thinking its running from an interactive >terminal. Not the most elegant, but the other implementations I can >think of are even worse: > > su - "${user}" -c "bash --login -c ${command}" > su - "${user}" -c 'source /etc/profile && > (source .bash_profile || ...) && ${command}" > >The old expression was broken anyway due to unescaped ampersands in >the sed expression. From sed(1): > > s/regexp/replacement/ > Attempt to match regexp against the pattern space. If successful, > replace that portion matched with replacement. The replacement > may contain the special character & to refer to that portion of > the pattern space which matched, and the special escapes \1 > through \9 to refer to the corresponding matching sub-expressions > in the regexp. > >This means that the old expression (with unescaped ampersands) lead >to: > > source /etc/profile ##STARTX##STARTX su - ${first_user} -c startx > >with ${first_user} expanded. This commented out startx, so it was >never run. > >Reviewed-by: Matt Turner <mattst88@gmail.com> >--- > targets/support/livecdfs-update.sh | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > >diff --git a/targets/support/livecdfs-update.sh b/targets/support/livecdfs-update.sh >index f8eb425..2b41f9d 100644 >--- a/targets/support/livecdfs-update.sh >+++ b/targets/support/livecdfs-update.sh >@@ -377,9 +377,7 @@ esac > # We want the first user to be used when auto-starting X > if [ -e /etc/startx ] > then >- sed -i \ >- "s:##STARTX:source /etc/profile && su - ${first_user} -c startx:" \ >- /root/.bashrc >+ sed -i "s:##STARTX:echo startx | su - '${first_user}':" /root/.bashrc > fi > > if [ -e /lib/rcscripts/addons/udev-start.sh ] >-- >1.8.3.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 481236
:
359492
|
360668
|
360670
| 360672