[Server-devel] Fixing bash script bogosity - help?
Ignacio Vazquez-Abrams
ivazqueznet at gmail.com
Tue Apr 28 07:01:51 EDT 2009
On Tue, 2009-04-28 at 12:38 +0200, Martin Langhoff wrote:
> On Tue, Apr 28, 2009 at 12:03 PM, Ignacio Vazquez-Abrams
> <ivazqueznet at gmail.com> wrote:
> > But if you're willing to let go of this futile quest to keep $CMD a
> > string then you'll find that it can be done:
>
> Your example doesn't work. I don't care about keeping $CMD as a
> string, I think you are misunderstanding the problem. We need to build
> it as a string to provide it as a single parameter value. This is
> because we want to run the command with all properly escaped params
> under runuser.
Which part of the following doesn't work?
ctl()
{
ERL_COMMAND=(
"$ERL"
"$NAME" ejabberctl
-noinput
-pa "$EJABBER_EBIN"
-s ejabber_ctl -extra "$ERLANG_NODE" "$@"
)
W=`whoami`
if [ "$W" != "ejabberd" ]; then
/sbin/runuser -s /bin/bash - ejabberd -c "${ERL_COMMAND[@]}"
result=$?
else
bash -c "${ERL_COMMAND[@]}"
result=$?
fi
# replace remainder of function here
}
--
Ignacio Vazquez-Abrams <ivazqueznet at gmail.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://lists.laptop.org/pipermail/server-devel/attachments/20090428/419553d9/attachment.pgp
More information about the Server-devel
mailing list