Problem with getuid() -- same as geteuid()?!
Maarten Litmaath
maart at cs.vu.nl
Thu Feb 8 10:49:08 AEST 1990
In article <1844 at clyde.concordia.ca>,
smw at 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 at cs.vu.nl, uunet!mcsun!botter!maart
More information about the Comp.unix.questions
mailing list