[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ash, apt, dselect == problems



Shaleh <shaleh@livenet.net> 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
#!/bin/sh
exec 2>>/tmp/shtrace.$$
echo "Starting $0:" >&2
for x in "$@"; do echo ">>>$x<<<"; done >&2
set -vx
exec /bin/sh.real "$@"
^D
# /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

-- 
Raul


--  
To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: