Re: ash, apt, dselect == problems
Shaleh <firstname.lastname@example.org> wrote:
> section I get "read: arg count" and an exit status of 2. So it seems
> that a part of apt, dpkg, or dselect is calling a bash-ism. Suggestions
> on how I can track down what it is?
Warning: overkill alert. If you already know the identity of the
script, skip down to the bottom.
One, start dpkg like this:
strace -o /tmp/dpkgtrace -ff dpkg ....
This has two disadvantages: one you're working at a very low level (you
can grep for the error message in those files, then look at the exec args
and process ids to work backwards, but it's still pretty low level).
Also, exec of suid and sgid scripts tend to fail under strace (unless
their parent process was root, so that probably won't be a problem here).
The other way is to replace /bin/sh with something else:
# cd /bin
# cp -a sh sh.real
# cat >sh.test; chmod 755 sh.test
echo "Starting $0:" >&2
for x in "$@"; do echo ">>>$x<<<"; done >&2
exec /bin/sh.real "$@"
# /bin/sh -c 'echo testing...'
# dpkg ....
# mv sh.real sh
This has the disadvantage of eating stderr (anything that you'd normally
see gets logged) which might make some things fail (if they were trying
to interpret stderr from something run by /bin/sh) and it generates
debugging information on stuff that's happening at the same time. Also,
if you wind up rebooting before you restore /bin/sh things will come
up rather slowly (and maybe fill up /tmp, depending on your machine).
But you get to actually see what commands are being executed, even where
there's no exec calls.
Of, if you know what the problem script is, just run that script with
whatever arguments it has, perhaps using /bin/ash -vxc scriptname
To UNSUBSCRIBE, email to email@example.com
with a subject of "unsubscribe". Trouble? Contact firstname.lastname@example.org