From owner-freebsd-questions Fri Jan 7 23:28:48 2000 Delivered-To: freebsd-questions@freebsd.org Received: from dorifer.heim3.tu-clausthal.de (dorifer.heim3.tu-clausthal.de [139.174.243.252]) by hub.freebsd.org (Postfix) with ESMTP id 467BF14BDA for ; Fri, 7 Jan 2000 23:28:45 -0800 (PST) (envelope-from olli@dorifer.heim3.tu-clausthal.de) Received: (from olli@localhost) by dorifer.heim3.tu-clausthal.de (8.9.3/8.9.3) id IAA04151; Sat, 8 Jan 2000 08:28:44 +0100 (CET) (envelope-from olli) Date: Sat, 8 Jan 2000 08:28:44 +0100 (CET) Message-Id: <200001080728.IAA04151@dorifer.heim3.tu-clausthal.de> From: Oliver Fromme To: freebsd-questions@FreeBSD.ORG Reply-To: freebsd-questions@FreeBSD.ORG Subject: Re: su and aliases question X-Newsgroups: list.freebsd-questions In-Reply-To: <854tm0$1pfa$1@atlantis.rz.tu-clausthal.de> User-Agent: tin/1.4.1-19991201 ("Polish") (UNIX) (FreeBSD/3.4-19991219-STABLE (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Jonathon McKitrick wrote in list.freebsd-questions: > OK, just to make sure: when i have logged into my user account, it > executes all those zsh scripts, assuming i run from a console login. Now, > when i run 'su -m' it should simply give me the UID of root and leave > everything alone, correct? Not quite. This is how "su" works: In UNIX, it is not possible to change the UID of a running non- root process to root, in general. (There are exceptions, but they don't matter in this context.) Therefore, the "su" command cannot simply change the UID of your existing shell to root. Instead, "su" is a set-uid-root binary (type ``ls -l =su'' and see the s-bit). When it is exec'ed, it runs as root rigth from the start. It then asks you for the root password -- if it doesn't match, "su" exits and you're back at your normal user shell. If you entered the right password, "su" in turn exec's a new shell, which inherits owenerships from the parent "su", i.e. the new shell is running as root. When you exit this root shell, you're again back at your normal user shell. The command line options of "su" specify how to start that new shell exactly (see ``man su'' for a lot of details). If you use the "-m" option, it will ignored root's login shell and use the login shell of the user who invoked "su", and it will not change any environment variables, neither the cwd. > Does it start a new invocation of zsh? Yes. > I just > don't understand why none of the aliaes or other commands are executed > when i 'su -m'. Commands from your ~/.zshenv _should_ be executed. That file will be read by _every_ invokation of zsh, no matter what (unless you have a very strange, non-standard zsh installa- tion). Also, commands from your ~/.zshrc should be executed for every invokation of an interactive zsh (which a root shell clearly is when executed from "su"). If it doesn't work for you, I'd recommend to place a few "echo" commands at appropriate places, to find out what's wrong. For example, insert the line echo "starting .zshrc, PID = $$, EUID = $EUID" right at the top of your ~/.zshrc, and append the line echo "finished .zshrc" at the end. You can do similar things with your other ~/.z* startup scripts, just for debugging (don't forget to remove them afterwards, because it might confuse programs such as rcp and scp). The above "echo" commands will help you find out if the files are read by your root shell at all. Regards Oliver -- Oliver Fromme, Leibnizstr. 18/61, 38678 Clausthal, Germany (Info: finger userinfo:olli@dorifer.heim3.tu-clausthal.de) "In jedem Stück Kohle wartet ein Diamant auf seine Geburt" (Terry Pratchett) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message