Bug 235930

Summary: bad wildcard handling
Product: [Fedora] Fedora Reporter: David Woodhouse <dwmw2>
Component: pm-utilsAssignee: Till Maas <opensource>
Status: CLOSED DUPLICATE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: opensource, pjones, pknirsch
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-12-24 12:41:09 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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 ***