Fixing bash script bogosity - help?

Martin Langhoff martin.langhoff at gmail.com
Tue Apr 28 11:59:18 EDT 2009


On Tue, Apr 28, 2009 at 4:30 PM, Martin Langhoff
<martin.langhoff at gmail.com> wrote:
> On Tue, Apr 28, 2009 at 3:28 PM, Bert Freudenberg <bert at freudenbergs.de> wrote:
>> $ su root -c '/bin/echo "$@"' /bin/echo one two three
>
> Interesting - seems to work as
>
>    runuser root -c '/bin/touch "$@"' /bin/touch "one two" "thre\"ee"
>
> but for some reason it doesn't work on my script. Any ideas on how to
> apply this to the runuser line on the ejabberdctl script?

The plot thickens.

Both sudo and runuser do pass parameters to the shell, but no
parameter that looks like an option is accepted. So

  # this works
  runuser root -c '/bin/touch "$@"' /bin/touch "one two" "thre\"ee"
  # this does not work -
   runuser root -c '/bin/touch "$@"' /bin/touch "one two" -d

escaping the parameter doesn't help (it merely touches a literal "\-d"
filename) and the double-dash "parameters end here" convention is
ignored as well.

So I'd say runuser has a greedy getopt that doesn't know when it's had
enough :-)

Ahhh, grumble. Maybe it works better on newer Fedoras?



m
-- 
 martin.langhoff at gmail.com
 martin at laptop.org -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff



More information about the Devel mailing list