Gerard Beekmans wrote:
The shadow version of "su" does support the -c option providing you an
option to pass command line arguments to 'su.'
From its man page (based on shadow-4.0.14):
Additional arguments may be provided after the username, in which case
they are supplied to the userĀ“s login shell. In particular, an argument
of -c will cause the next argument to be treated as a command by most
command interpreters. The command will be executed by the shell
specified in /etc/passwd for the target user.
And to demonstrate it works as advertised:
[EMAIL PROTECTED]:~$ touch /root/testfile
touch: cannot touch `/root/testfile': Permission denied
[EMAIL PROTECTED]:~$ su -c "touch /root/testfile"
Password: ************
And '/root/testfile' is created after running this.
I believe "su" from the shadow package does work as expected, unless I
totally missed something, Richard?
Are you doing this using the su in shadow 4.0.14? As far as I can see,
that form of su -c no longer works in shadow 4.0.14. You have to use "su
[username] -c [command]". I don't know if it's deliberate or a bug, but
that's how it is in the latest version of shadow, at least for me.
--
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page