Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 283599 - x11-apps/xinit: /etc/X11/startDM.sh needs /bin/bash, not /bin/sh
Summary: x11-apps/xinit: /etc/X11/startDM.sh needs /bin/bash, not /bin/sh
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo X packagers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-03 18:03 UTC by Raffaello D. Di Napoli
Modified: 2009-09-10 05:37 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Changes #!/bin/sh to #!/bin/bash (startDM.sh-explicit-bash-dependency.patch,386 bytes, patch)
2009-09-03 18:07 UTC, Raffaello D. Di Napoli
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Raffaello D. Di Napoli 2009-09-03 18:03:43 UTC
I installed app-shells/dash as a replacement for bash in scripts (mostly for memory footprint); as a part of the process, I also replaced the /bin/sh symlink to one pointing to /bin/dash.

I assumed most of Gentoo has been checked for undeclared dependencies on bash; while I was right, I did find two scripts which use bash but declare /bin/sh instead.
One I’m still tracking down (it doesn’t get to call any ebegin/einfo before aborting), the other I found out to be /etc/X11/startDM.sh, installed by x11-apps/xinit.

I believe this dependency should be made explicit.

Reproducible: Always

Steps to Reproduce:
1. emerge app-shells/dash
2. ln -fs dash /bin/sh
3. reboot

Actual Results:  
(other init messages)
* Setting up gdm
/etc/init.d/functions.sh: 7: source: not found
/etc/init.d/functions.sh: 10: declare: not found
...
(more errors from sourcing functions.sh into a non-bash script)

Expected Results:  
* Setting up gdm
(Xorg starts, gdm starts)

emerge --info
Portage 2.1.6.13 (default/linux/x86/2008.0, gcc-4.3.2, glibc-2.9_p20081201-r2, 2.6.30-gentoo-r4 i686)
=================================================================
System uname: Linux-2.6.30-gentoo-r4-i686-Intel-R-_Core-TM-2_Duo_CPU_T5550_@_1.83GHz-with-gentoo-1.12.11.1
Timestamp of tree: Tue, 25 Aug 2009 21:45:01 +0000
app-shells/bash:     3.2_p39
dev-java/java-config: 2.1.8-r1
dev-lang/python:     2.6.2-r1
sys-apps/baselayout: 1.12.11.1
sys-apps/sandbox:    1.6-r2
sys-devel/autoconf:  2.13, 2.63-r1
sys-devel/automake:  1.9.6-r2, 1.10.2
sys-devel/binutils:  2.18-r3
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   1.5.26
virtual/os-headers:  2.6.27-r2
ACCEPT_KEYWORDS="x86"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O3 -march=core2 -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-O3 -march=core2 -pipe"
DISTDIR="/store/portage/distfiles"
FEATURES="distlocks fixpackages parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="ftp://ftp.ussg.iu.edu/pub/linux/gentoo                 ftp://ftp.unina.it/pub/linux/distributions/gentoo"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1"
LINGUAS="it"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.namerica.gentoo.org/gentoo-portage"
USE="X aalib acl acpi alsa bash-completion berkdb branding bzip2 cairo cdda cddb cdr cli cracklib crypt cxx dbus dga dri dvd dvdr encode exif fbcon ffmpeg fontconfig ftp fuse gd gdbm gif gimp gnome gnome-keyring gnutls gpm gstreamer gtk hal hddtemp iconv ieee1394 isdnlog java javascript jpeg jpeg2k lame lcms lm_sensors lzma matroska mime mmap mmx mng mp3 mp4 mpeg mudflap nautilus ncurses nfs nls nptl nptlonly nsplugin offensive ogg opengl openmp pam pch pcmcia pcre pdf perl png posix pppd python readline reflection samba sdl session sharedmem smp sockets spell spl sse sse2 sse3 ssl svg sysfs syslog sysvipc taglib tcpd threads tiff truetype unicode usb v4l v4l2 vorbis wifi x86 xattr xorg xpm xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="evdev keyboard mouse synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="it" QEMU_SOFTMMU_TARGETS="arm i386 x86_64" USERLAND="GNU" VIDEO_CARDS="intel"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LC_ALL, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Raffaello D. Di Napoli 2009-09-03 18:07:53 UTC
Created attachment 203065 [details, diff]
Changes #!/bin/sh to #!/bin/bash

This solves the problem.
Comment 2 Rémi Cardona (RETIRED) gentoo-dev 2009-09-04 14:42:51 UTC
I think I'd rather make the script dash/posix compliant rather than force the dep on bash.

If you could write a patch to do that, I'll gladly commit it here and upstream.

Thanks
Comment 3 Raffaello D. Di Napoli 2009-09-04 19:59:39 UTC
Well, that was my first thought, but I then noticed that the dependency on bash is brought in by sourcing /etc/init.d/functions.sh, which is heavily bash-dependent. While I am willing and planning to make functions.sh bash-free, that’s a major work I can’t find much time for these days.
So, until functions.sh is made bash-free, I’d rather consider changing the shebang line in startDM.sh.
Comment 4 Rémi Cardona (RETIRED) gentoo-dev 2009-09-04 20:07:04 UTC
(In reply to comment #3)
> Well, that was my first thought, but I then noticed that the dependency on bash
> is brought in by sourcing /etc/init.d/functions.sh, which is heavily
> bash-dependent. While I am willing and planning to make functions.sh bash-free,
> that’s a major work I can’t find much time for these days.
> So, until functions.sh is made bash-free, I’d rather consider changing the
> shebang line in startDM.sh.

Or, does startDM.sh really need functions.sh? If so, we'll just change the shebang :)

Thanks
Comment 5 Raffaello D. Di Napoli 2009-09-05 06:01:46 UTC
(In reply to comment #4)
> Or, does startDM.sh really need functions.sh? If so, we'll just change the
> shebang :)

Okay, I checked more carefully. It does depend on functions.sh both directly and indirectly, by sourcing /lib/rcscripts/sh/rc-services.sh, which sources functions.sh and depends on bash itself.
Of the few commands executed by startDM.sh, almost all of them are defined in rc-services.sh, and a few from functions.sh.

So I think startDM.sh will be POSIX compliant only when the whole rc scripts system will be purified from bash-isms.
Comment 6 Tomáš Chvátal (RETIRED) gentoo-dev 2009-09-07 11:13:44 UTC
That wont happen.
Openrc will be using bash.
From what i can see the .sh script itself is posix ok.
Comment 7 Raffaello D. Di Napoli 2009-09-07 15:56:24 UTC
(In reply to comment #6)
> That wont happen.
> Openrc will be using bash.

Well, then any script sourcing any of its files should declare explicit bash dependency, shouldn’t it?
Comment 8 Raffaello D. Di Napoli 2009-09-10 05:37:41 UTC
(In reply to comment #6)
> That wont happen.
> Openrc will be using bash.
> From what i can see the .sh script itself is posix ok.

Actually, from what I was told in another bug report (#284221), OpenRC pulled in by baselayout-2 *is* bash-free, so I emerged it and I got (among everything else) a functions.sh that doesn’t need bash, so now startDM.sh is indeed entirely POSIX compliant.

I’m marking this bug as invalid, as that’s what one of you guys did with the other bug I filed on the same subject.