[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [email] Re: SOLARIS: su - user not passing cmd args
> I haven't read the documentation at all, but that's quite similar in many
> ways to what I would expect.
Indeed. It is very easy to expect what has been demonstrated to be the case.
> In the case:
> su - user -c 'cmd arg1 arg2 arg3' arg4 arg5 arg6 arg7
> -c is being passed one argument "cmd arg1 arg2 arg3"
> so it will run cmd with arg1 arg2 arg3.
Are you *sure* "-c" *should* only be passed one argument?
What would be your compelling reason the others *have* to be passed to "su"?
The documentation clearly indicates all other arguments have the same purpose -
to be passed to the subsequent shell. And yet strangely, there's different behavior.
> Arg4 arg5 arg6 and arg7 are being processed by SU not passed to the "cmd"
> and thus should behave differently.
This is not intuitive. You're postulating based on the results I've posted.
After-the-fact conjecture is quite easily obtained.
> As for how they're behaving, I have no
> idea since I haven't looked at documentation or even run the command.
Here's what it says:
Any additional arguments given on the command line are
passed to the new shell. When using programs such as sh, an
arg of the form "-c string" executes string using the shell
and an arg of -r gives the user a restricted shell.
and
To execute command with the temporary environment and per-
missions of user bin, type:
example% su - bin -c "command args"
What's not clear is an explicit statement that the "-c" argument always takes
exactly one parameter. And if that's true, how is that *different* than not
using the "-c" argument at all? Besides the obvious *observed* behavior.
"It works the way it works" is not exactly useful information, documented or
not.
Now, with all of that said, what appears to be the "solution" is to not
use the "-c" option at all, and just give the command. With this behavior,
one would think that perhaps a note about NOT combining the "su - user" form
with the "-c" argument, and that one should use either
su - user cmd arg1 arg2 ...
or
su user -c "cmd arg1 arg2 ..."
and not to combine the two.
Or just flat out deprecating the "-c" form. IMHO, the best solution.
The only utility I can see for the "-c" usage is if you want expansion for
the command line to take place in the subshell. But this is not prominently
noted anywhere in the docs about the *extremely limited usefulness* of this
feature. i.e. if you *do* need it it's great, but it gets too much prominence
for the 0.000001 percent utility it offers in the very, very rare case that
you need it. The direct result of this is its inappropriate use and overuse
(as we've discovered here).
Mike/
---------------------------------------------
http://www.valuenet.net
-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.