Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site bu-cs.UUCP Path: utzoo!linus!philabs!cmcl2!harvard!bu-cs!root From: root@bu-cs.UUCP (Barry Shein) Newsgroups: net.bugs.usg Subject: Not Necessarily a Bug (but worth reading) Message-ID: <668@bu-cs.UUCP> Date: Sun, 22-Sep-85 21:32:57 EDT Article-I.D.: bu-cs.668 Posted: Sun Sep 22 21:32:57 1985 Date-Received: Wed, 25-Sep-85 10:04:22 EDT Organization: Boston Univ Comp. Sci. Lines: 32 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"