Not Necessarily a Bug (but worth reading)

Barry Shein root at bu-cs.UUCP
Mon Sep 23 11:32:57 AEST 1985


A gotcha in the shell that almost caused me further permanent brain-damage:

Not Necessarily a Description:

/bin/sh in SYSVR2 will look for the character 'r' *anywhere* in it's
argv[0] when it starts up and, upon finding one, will run in restricted
mode.

Not Necessarily a Repeat-by:

Write a program which forks off a shell with it's stdin/stdout/stderr
attached to pipes, decide to put a different name and the file name from
the command line the parent program got as a string in argv[0] for the
exec() so it looks pretty when someone 'ps's us. Watch user's complain
as it mysteriously fails and does strange things for some commands
passed to it depending on the original file name given to the parent.
Begin babbling incoherently till you start to see the reason why.  This
is especially fun if it's an oft run system command and not your program
to start with and if the source is >25,000 lines of code and sdb keeps
core-dumping when you try to trace things.

Not Necessarily a Fix:

Don't monkey around with argv[0] when starting up a shell, certainly
don't put arbitrary user text into argv[0] or a fortune or some such,
better to just let it be "sh" if that's what you meant.

	-Barry Shein, Boston University

Not Necessarily a Quote:

	"And I alone survived to tell this tale"



More information about the Net.bugs.usg mailing list