Bug 235930 - bad wildcard handling
Summary: bad wildcard handling
Status: CLOSED DUPLICATE of bug 302401
Alias: None
Product: Fedora
Classification: Fedora
Component: pm-utils
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Till Maas
QA Contact:
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-04-10 20:55 UTC by David Woodhouse
Modified: 2007-12-24 12:41 UTC (History)
3 users (show)

(edit)
Clone Of:
(edit)
Last Closed: 2007-12-24 12:41:09 UTC


Attachments (Terms of Use)

Description David Woodhouse 2007-04-10 20:55:01 UTC
find_sleepd_file() in /usr/lib/pm-utils/functions has the following:

find_sleepd_files()
{
        flist="/etc/pm/sleep.d/*[^~] /usr/lib/pm-utils/sleep.d/*[^~]"
        bases=$(for file in $flist ; do echo $(basename $file) ; done | sort -n)
 

If /etc/pm/sleep.d is empty, then $flist is, literally, "/etc/pm/sleep.d/*[^~]".
We go through the 'for file in $flist' loop precisely once, with $file set to
the same. $(basename $file) evaluates to '*[^~]' and the 'echo' command prints
the filename of every file in the current directory.

Let's just hope that the first filename printed by echo isn't the name of a
program which will do nasty things... :)

Comment 1 Till Maas 2007-09-03 15:18:06 UTC
Do you have a suggestion, how to fix this? Would this be ok?
flist="$(/bin/ls /etc/pm/sleep.d/*[^~] /usr/lib/pm-utils/sleep.d/*[^~] 2>/dev/null)"

Comment 2 Till Maas 2007-09-24 19:51:08 UTC
shopt -s nullglob seems to be the best option here.

Comment 3 Till Maas 2007-12-24 12:41:09 UTC

*** This bug has been marked as a duplicate of 302401 ***


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