LOGNAME, USER variables under Xenix
cliff bedore
cliffb at cjbsys.bdb.com
Wed May 1 10:26:32 AEST 1991
In article <1991Apr26.231504.9581 at bilver.uucp> bill at bilver.uucp (Bill Vermillion) writes:
>In article <4731 at peora.sdc.ccur.com> tran at peora.sdc.ccur.com (Nhan Tran) writes:
>
>> When I log in Xenix, running /bin/sh, the environment variable LOGNAME
>>and USER are not set. And Xenix doesn't have whoami command.
>
>Xenix does have a whoami command, except is typed who am i three
>words.
>
>
>--
>Bill Vermillion - UUCP: uunet!tarpit!bilver!bill
> : bill at bilver.UUCP
The problem is that when you su, who am i gives your login name not root.
There is a whoami program available. I've included it as a shar file
Cliff
:
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: whoami.c
# Wrapped by schenk at cpsc.UCalgary.CA on Thu Jan 3 23:11:35 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'whoami.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'whoami.c'\"
else
echo shar: Extracting \"'whoami.c'\" \(1326 characters\)
sed "s/^X//" >'whoami.c' <<'END_OF_FILE'
X/*
X * Copyright (c) 1988 Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms are permitted
X * provided that the above copyright notice and this paragraph are
X * duplicated in all such forms and that any documentation,
X * advertising materials, and other materials related to such
X * distribution and use acknowledge that the software was developed
X * by the University of California, Berkeley. The name of the
X * University may not be used to endorse or promote products derived
X * from this software without specific prior written permission.
X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X */
X
X#ifndef lint
Xchar copyright[] =
X"@(#) Copyright (c) 1988 Regents of the University of California.\n\
X All rights reserved.\n";
X#endif /* not lint */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)whoami.c 5.3 (Berkeley) 6/29/88";
X#endif /* not lint */
X
X#include <sys/types.h>
X#include <pwd.h>
X
Xmain()
X{
X struct passwd *p, *getpwuid();
X int uid;
X
X uid = geteuid();
X if (!(p = getpwuid(uid))) {
X printf("whoami: no login associated with uid %u.\n", uid);
X exit(1);
X }
X printf("%s\n", p->pw_name);
X exit(0);
X}
END_OF_FILE
if test 1326 -ne `wc -c <'whoami.c'`; then
echo shar: \"'whoami.c'\" unpacked with wrong size!
fi
# end of 'whoami.c'
fi
echo shar: End of shell archive.
exit 0
-------------------------------------------------------------------------------
Eric Schenk Department of Computer Science, University of Calgary
schenk at cpsc.ucalgary.ca Just another graduate slave.
-------------------------------------------------------------------------------
More information about the Comp.unix.xenix.sco
mailing list