Path: utzoo!attcan!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: Problem with getuid() -- same as geteuid()?! Message-ID: <5339@star.cs.vu.nl> Date: 7 Feb 90 23:49:08 GMT References: <1836@clyde.concordia.ca> <1837@clyde.concordia.ca> <5315@star.cs.vu.nl> <1844@clyde.concordia.ca> Sender: news@cs.vu.nl Reply-To: maart@cs.vu.nl (Maarten Litmaath) Organization: VU Informatika, Amsterdam, the Netherlands Lines: 42 In article <1844@clyde.concordia.ca>, smw@maxwell.Concordia.CA ( Steven Winikoff ) writes: \... \> char *getenv(), *lprname = getenv("LPRNAME"); \... \>...where `my_lpr' is: \> \> #!/bin/sh \> \> exec 3>&1 Dup(2) file descriptor 3 from 1. \> test -t 0 && exec < /dev/null If stdin is a terminal, connect stdin to /dev/null. \> (/usr/ucb/lpr ${1+"$@"} | cat >&3) 2>&1 | cat >&2 Feed lpr's stdout to the first cat, whose stdout is dupped to the original (saved) stdout; feed lpr's stderr to the second cat (mjum), whose droppings go to the original stderr. Now none of lpr's stdin/stdout/stderr points to a terminal, so lpr will use getpwuid(getuid()), as getlogin() fails. Piece of cake, right? \I'm not quite sure I understand your code. Who sets LPRNAME? In "my_lpr", \what gets exec'd in line 2? Please excuse my ignorance, I'm only a wizard \wanna-be! Each user himself should set LPRNAME (.profile/.login) and change it accordingly after a su (it's easy to write a wrapper for su which sets LPRNAME beforehand). You could use USER or LOGNAME, but beware: there are programs which expect those to contain *login names* (e.g. inews). :-( \... \Love your .sig! Thanks. -- The meek get the earth, Henry the moon, the rest of us have other plans. | Maarten Litmaath @ VU Amsterdam: maart@cs.vu.nl, uunet!mcsun!botter!maart