[Bug 626629] New: /usr/sbin/Check -- wrong shebang line
http://bugzilla.novell.com/show_bug.cgi?id=626629 http://bugzilla.novell.com/show_bug.cgi?id=626629#c0 Summary: /usr/sbin/Check -- wrong shebang line Classification: openSUSE Product: openSUSE 11.3 Version: Final Platform: x86-64 OS/Version: openSUSE 11.3 Status: NEW Severity: Normal Priority: P5 - None Component: Other AssignedTo: bnc-team-screening@forge.provo.novell.com ReportedBy: torsten.foertsch@gmx.net QAContact: qa@suse.de Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.1 SUSE/6.0.443.0 (KHTML, like Gecko) Chrome/6.0.443.0 Safari/534.1 /usr/sbin/Check reads: #!/bin/sh ... . /etc/profile "$0" will be "/usr/bin/Check" in this case even while /etc/profile is executed. Now /etc/profile reads: ... is=$(readlink /proc/$$/exe) ... because /bin/sh is a symlink to /bin/bash that yields "/bin/bash". Then "$is" is matched against "*/bash" and if so "$0" is consulted to distiguish between "sh" and "bash". This check reads: case "$0" in sh|-sh|*/sh) is=sh ;; esac ;; Now, because "$0" is "/usr/sbin/Check" "$is" still holds "bash" after the check. Later on /etc/profile reads "$HOME/.bashrc". Unfortunately, if called as "sh" instead of "bash" its syntax slightly changes. For example a-b () { :; } is a valid function definition in bash but fails in sh. So, if the user calling /usr/sbin/Check while rebuilding for example an opensuse source rpm his .bashrc is consulted but the bash runs in sh-mode. Hence "rpmbuild --rebuild" may fail due to the $HOME/.bashrc of an arbitrary user. One possible solution is to change the shebang line in /usr/sbin/Check to #!/bin/bash Another solution is to put more intelligence into the code to tell apart bash and sh in /etc/profile. Reproducible: Always Steps to Reproduce: 1. create a .bashrc for a normal user (not root!) containing "a-b () { :; }" 2. call as this user /usr/sbin/check 3. Actual Results: backup@opi:~> /usr/sbin/Check /home/backup/.bashrc: line 1: `a-b': not a valid identifier Expected Results: backup@opi:~> /usr/sbin/Check Check does not work for normal users. -- Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
http://bugzilla.novell.com/show_bug.cgi?id=626629 http://bugzilla.novell.com/show_bug.cgi?id=626629#c1 --- Comment #1 from Torsten Foertsch <torsten.foertsch@gmx.net> 2010-07-29 18:08:45 UTC --- How about this function to distiguish sh from bash? is_bash () { (x-y () { :; }) 2>/dev/null } It can be used as: if is_bash; then echo "bash"; else echo "no bash"; fi -- Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
http://bugzilla.novell.com/show_bug.cgi?id=626629 http://bugzilla.novell.com/show_bug.cgi?id=626629#c yang xiaoyu <xyyang@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |xyyang@novell.com AssignedTo|bnc-team-screening@forge.pr |ro@novell.com |ovo.novell.com | -- Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
http://bugzilla.novell.com/show_bug.cgi?id=626629 http://bugzilla.novell.com/show_bug.cgi?id=626629#c2 Ruediger Oertel <ro@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |NEEDINFO InfoProvider| |werner@novell.com --- Comment #2 from Ruediger Oertel <ro@novell.com> 2010-07-30 08:38:45 UTC --- sounds like a more generic issue than just from Check ... werner: can you have a look ? -- Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
http://bugzilla.novell.com/show_bug.cgi?id=626629 http://bugzilla.novell.com/show_bug.cgi?id=626629#c3 Dr. Werner Fink <werner@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |werner@novell.com InfoProvider|werner@novell.com |torsten.foertsch@gmx.net --- Comment #3 from Dr. Werner Fink <werner@novell.com> 2010-07-30 08:48:35 UTC --- Hmmm ... we have not only /bin/sh linked to /bin/bash also we have around the ash, the dash, the pdksh, the ksh, maybe the ksh93, the pcksh, and the zsh. All test codes should *not* trigger an error nor an error messages if sourced. Please try to replace case "$0" in sh|-sh|*/sh) is=sh ;; esac ;; with read -t 1 a r </proc/$$/cmdline case "$a" in sh|-sh|*/sh) is=sh ;; esac ;; -- Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
http://bugzilla.novell.com/show_bug.cgi?id=626629 http://bugzilla.novell.com/show_bug.cgi?id=626629#c4 Torsten Foertsch <torsten.foertsch@gmx.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEEDINFO |NEW InfoProvider|torsten.foertsch@gmx.net | --- Comment #4 from Torsten Foertsch <torsten.foertsch@gmx.net> 2010-07-30 11:08:26 UTC --- to tell apart sh from bash (if they are linked) it will work. But dash and ash don't know about -t in read. Why do you read with a timeout here, anyway? In what cases can read from /proc/PID/cmdline take longer than a second? Also dash's read command does not stop reading at the NULL byte: 0 r2@opi ~/tmp$ cat ./x.sh #!/bin/dash read a r </proc/$$/cmdline echo "a: $a" echo "r: $r" 0 r2@opi ~/tmp$ ./x.sh a: /bin/dash./x.sh r: 0 r2@opi ~/tmp$ you see $a contains the whole cmdline, $r is empty. Now, I have restored the shebang line in /usr/sbin/Check to #!/bin/sh. Further, my /etc/profile now reads: .. if ! is=$(readlink /proc/$$/exe 2>/dev/null) ; then case "$0" in *pcksh) is=ksh ;; *) is=sh ;; esac fi case "$is" in */bash) is=bash read a r </proc/self/cmdline case "$a" in sh|-sh|*/sh) is=sh ;; esac unset a r ;; */ash) is=ash ;; */dash) is=ash ;; */ksh) is=ksh ;; */ksh93) is=ksh ;; */pdksh) is=ksh ;; */*pcksh) is=ksh ;; */zsh) is=zsh ;; */*) is=sh ;; esac .. This combination also works. -- Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=626629 https://bugzilla.novell.com/show_bug.cgi?id=626629#c5 Ruediger Oertel <ro@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|ro@novell.com |werner@novell.com --- Comment #5 from Ruediger Oertel <ro@novell.com> 2010-11-10 11:57:20 UTC --- werner: can you please handle this one, I just have no clue here ... ;) -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=626629 https://bugzilla.novell.com/show_bug.cgi?id=626629#c6 Dr. Werner Fink <werner@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #6 from Dr. Werner Fink <werner@novell.com> 2010-11-10 12:11:07 UTC --- Make /usr/sbin/Check a bash script -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
http://bugzilla.novell.com/show_bug.cgi?id=626629 http://bugzilla.novell.com/show_bug.cgi?id=626629#c7 --- Comment #7 from Bernhard Wiedemann <bwiedemann@suse.com> --- This is an autogenerated message for OBS integration: This bug (626629) was mentioned in https://build.opensuse.org/request/show/52729 Factory / aaa_base -- You are receiving this mail because: You are on the CC list for the bug.
participants (1)
-
bugzilla_noreply@novell.com