Bug 679 - sudo -i ignores empty arguments
sudo -i ignores empty arguments
Status: ASSIGNED
Product: Sudo
Classification: Unclassified
Component: Sudo
1.8.9
PC Linux
: low low
Assigned To: Todd C. Miller
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-01-11 16:21 MST by morloch
Modified: 2017-04-12 08:38 MDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description morloch 2015-01-11 16:21:26 MST
Here is an example bash script that I would like to run using `sudo -i`:

    #!/bin/bash
    
    echo "arg 1: $1"
    echo "arg 2: $2"

When I run this command normally with one empty argument, it runs as expected:

    $ /tmp/args.sh "" two
    arg 1:
    arg 2: two

With plain sudo, I get the expected result:

    $ sudo /tmp/args.sh "" two
    arg 1:
    arg 2: two

However if I use `-i` (to pick up the user's shell and login scripts), suddenly the first argument disappears:

    $ sudo -i /tmp/args.sh "" two
    arg 1: two
    arg 2:

Current workarounds are:

* writing `/tmp/args.sh "" two` to a file and then executing that with `sudo -i`

* run: sudo -i bash -c '/tmp/args.sh "" two'

Stack Overflow: http://stackoverflow.com/questions/27892812/passing-empty-arguments-to-sudo-i