Bug 119241 - Xsession/xinitrc shouldn't source backup and dir files in xinitrc.d/
Xsession/xinitrc shouldn't source backup and dir files in xinitrc.d/
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: xinitrc (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Mike A. Harris
:
Depends On:
Blocks: FC2Blocker
  Show dependency treegraph
 
Reported: 2004-03-26 18:47 EST by Jens Petersen
Modified: 2007-11-30 17:10 EST (History)
1 user (show)

See Also:
Fixed In Version: 3.40-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-05-07 10:16:47 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Jens Petersen 2004-03-26 18:47:10 EST
Description of problem:
I noticed that the Xsession and xinitrc scripts
source *all* executables in xinitrc.d/.  This is
pretty annoying if you happen to edit one of the
files with emacs and then test it.

How reproducible:
every time

Steps to Reproduce:
1. cd /etc/X11/xinit/xinitrc.d
2. cp -p xinput xinput~ (alternatively edit the file with emacs)
3. Start a new X session from gdm say.
  
Actual results:
Both xinput and xinput~ get source'd.

Expected results:
Only xinput to be sourced.

Additional info:
I think /etc/profile gets this right with:

for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
    	. $i
    fi
done

I noticed this problem because of the missing "]" in line 25
of xinput. ;)
Comment 1 Jens Petersen 2004-03-26 20:43:37 EST
Also it tries to execute subdirectories too...
Comment 2 Mike A. Harris 2004-04-02 02:25:55 EST
Making this block FC2
Comment 3 Jens Petersen 2004-04-09 02:24:53 EDT
Another way of inducing backup files, is if one modifies say
xinput, and then upgrade xinitrc: then rpm will generate
xinput.rpmnew, which will get sources along with (after?) xinput...

Mike, do you agree requiring a ".sh" suffix for scripts is a good
way to fix this, or is there a better way?
Comment 4 Mike A. Harris 2004-04-09 07:02:10 EDT
Yeah, I think the .sh method is the proper solution.  I don't see
how else you could do it foolproof.   *.sh makes it explicit that
anything needs to be named with a specific extension to get
executed, and has the benefit of backup files, etc. getting ignored.

It has the drawback that any other packages which drop files in
there, which aren't already named *.sh, will get ignored too.

Perhaps we should make the loop:

for file in /etc/X11/xinit/xinitrc.d/* ; do
    if echo $file | grep -q "\.sh$" ; then
        . $file
    else
        echo "warning: $file does not end in .sh extension, ignoring"
    fi
done

Perhaps the warning should go to stderr.

What do you think of the above?

Comment 5 Mike A. Harris 2004-04-09 07:05:17 EDT
The only other way, would be to ignore specific backup extensions,
but that's not foolproof, as there is no standard.
Comment 6 Jens Petersen 2004-04-09 11:46:59 EDT
Yeah, I like your solution in comment 4.
I think that is fine.
Comment 8 Mike A. Harris 2004-05-07 10:16:47 EDT
Fixed in xinitrc-3.40-1
Comment 9 Martijn Vernooij 2004-06-11 04:23:47 EDT
Note that you also have to change the other packages so they contain
.sh scripts instead of saying:

warning: /etc/X11/xinit/xinitrc.d/xinput does not end in .sh
extension, ignoring

Note You need to log in before you can comment on or make changes to this bug.