]> diplodocus.org Git - nmh/blob - docs/historical/mh-jun-1982/Extras/libg/gtluid.c
Replaced use of snprintf() with memcpy()/memmove().
[nmh] / docs / historical / mh-jun-1982 / Extras / libg / gtluid.c
1 #ifdef COMMENT
2 Proprietary Rand Corporation, 1981.
3 Further distribution of this software
4 subject to the terms of the Rand
5 license agreement.
6 #endif
7
8 #include "../h/stat.h"
9 /* this subr returns owner of tty attached to file handle # 2 */
10 /* on harv/unix, this may not be the real uid, because */
11 /* we have the command "alias" which spawns a sub-shell with */
12 /* a new real uid. luid (login uid) is used by the harvard shell */
13 /* to find the "save.txt" file (via getpath(getluid())) for $a - $z */
14 /* shell macros, and elsewhere by certain accounting routines. */
15
16 getluid()
17 {
18 struct inode ibuf;
19 if (fstat(2,&ibuf) < 0 &&
20 fstat(1,&ibuf) < 0) return(getruid());
21 if ((ibuf.i_mode & IFMT) != IFCHR) return(getruid());
22 return(ibuf.i_uid&0377);
23 }