1*8278Scomay static char sccsid[] = "@(#)mach.c 4.2 (Berkeley) 10/02/82";
28187Smckusick
38187Smckusick /* sccs id variable */
48187Smckusick static char *mach_sid = "@(#)mach.c 1.6";
58187Smckusick /*
68187Smckusick
78187Smckusick This file is meant to handle all the machine
88187Smckusick dependencies in the network code.
98187Smckusick Everything is conditionally compiled.
108187Smckusick
118187Smckusick It can be uses w/o network stuff to simulate
128187Smckusick v7 for other programs, too.
138187Smckusick */
148187Smckusick # include <stdio.h>
158187Smckusick # include "mach.h"
168187Smckusick
178187Smckusick char shomedir[100];
188187Smckusick
198187Smckusick int debugflg;
208187Smckusick
218187Smckusick /* the CC and SRC machines have the submit() call */
228187Smckusick # ifndef CC
238187Smckusick # ifndef SRC
submit(a)248187Smckusick submit(a) {}
25*8278Scomay # endif
26*8278Scomay # endif
278187Smckusick
288187Smckusick # ifdef FUID
setgid()298187Smckusick setgid() {};
30*8278Scomay # endif
318187Smckusick
328187Smckusick /*
338187Smckusick Set the owner uid/gid of a file.
348187Smckusick On v7, this is done by the chown command
358187Smckusick with three args - (file, uid, gid).
368187Smckusick On Vanilla V6 this is done using the
378187Smckusick top byte of the second parameter as the gid byte.
388187Smckusick On Berkeley Funny uids on V6, no gid is specified.
398187Smckusick */
mchown(sfn,uid,gid)408187Smckusick mchown(sfn,uid,gid)
418187Smckusick char *sfn;
428187Smckusick int uid;
438187Smckusick int gid;
448187Smckusick {
458187Smckusick # ifndef V6
468187Smckusick chown(sfn,uid,gid);
47*8278Scomay # else
488187Smckusick # ifndef FUID
498187Smckusick uid = uidmask(uid);
508187Smckusick uid = ((gid&0377) << 8) | (uid & 0377);
51*8278Scomay # endif
528187Smckusick chown(sfn,uid);
538187Smckusick if(debugflg)
548187Smckusick fprintf(stderr, "chown %s to %d(%o)\n",sfn,uid,uid);
55*8278Scomay # endif
568187Smckusick }
578187Smckusick
588187Smckusick
598187Smckusick /*
608187Smckusick SnFromuid(uid)
618187Smckusick
628187Smckusick The login name corresponding to uid.
638187Smckusick Reads the password file.
648187Smckusick Successive calls overwrite the static string returned.
658187Smckusick Returns NULL if error.
668187Smckusick */
SnFromUid(uid)678187Smckusick char *SnFromUid(uid)
688187Smckusick register int uid;
698187Smckusick {
708187Smckusick register struct passwd *pwd;
718187Smckusick static int ouid = -1;
728187Smckusick static char oresult[20] = "";
738187Smckusick uid = uidmask(uid);
748187Smckusick if(uid == ouid)
758187Smckusick return(oresult);
768187Smckusick # ifdef HPASSWD
778187Smckusick if(getname(uid,oresult) == 0){
788187Smckusick ouid = uid;
798187Smckusick return(oresult);
808187Smckusick }
81*8278Scomay # endif
828187Smckusick pwd = getpwuid(uid);
838187Smckusick if(pwd != NULL){
848187Smckusick strcpy(oresult,pwd->pw_name);
858187Smckusick ouid = uid;
868187Smckusick return(oresult);
878187Smckusick }
888187Smckusick return(NULL);
898187Smckusick }
uidfromsn(sn)908187Smckusick uidfromsn(sn)
918187Smckusick register char *sn;
928187Smckusick {
938187Smckusick register int him = -1;
948187Smckusick register struct passwd *pwd;
958187Smckusick # ifdef HPASSWD
968187Smckusick him = getuserid(sn);
97*8278Scomay # endif
988187Smckusick if(him == -1){
998187Smckusick pwd = getpwnam(sn);
1008187Smckusick if(pwd != NULL)him = guid(pwd->pw_uid,pwd->pw_gid);
1018187Smckusick }
1028187Smckusick return(him);
1038187Smckusick }
1048187Smckusick
1058187Smckusick /* handle the regular unix and local mods difference for user id's */
1068187Smckusick /* this call returns the 1 word uid = to what getuid will return */
guid(uid,gid)107*8278Scomay guid(uid,gid){
1088187Smckusick uid = uidmask(uid);
1098187Smckusick # ifdef FUID
1108187Smckusick return((uid & 0377) | (gid << 8));
111*8278Scomay # else
1128187Smckusick return(uid);
113*8278Scomay # endif
114*8278Scomay }
1158187Smckusick
1168187Smckusick # ifdef OLDTTY
isatty(i)1178187Smckusick isatty(i){
1188187Smckusick return(ttyn(i) != 'x');
1198187Smckusick }
ttyname(i)1208187Smckusick char *ttyname(i){ /* return NULL if not TTY */
1218187Smckusick char c;
1228187Smckusick static char ttystr[] = "/dev/ttyx";
1238187Smckusick c = ttyn(i);
1248187Smckusick ttystr[8] = c;
1258187Smckusick return(c == 'x' ? NULL : ttystr);
1268187Smckusick }
127*8278Scomay # endif
1288187Smckusick
1298187Smckusick # ifdef CCTTY
1308187Smckusick # undef ttyname()
myttyname(i)1318187Smckusick char *myttyname(i){ /* return NULL for non tty */
1328187Smckusick static char s[15],*p;
1338187Smckusick p = ttyname(i);
1348187Smckusick if(p == NULL)return(NULL);
1358187Smckusick strcpy(s,"/dev/");
1368187Smckusick strcat(s,p);
1378187Smckusick return(s);
1388187Smckusick }
1398187Smckusick # define ttyname(S) myttyname(S)
140*8278Scomay # endif
1418187Smckusick
1428187Smckusick /* expand control chars in string s */
expandcc(s)1438187Smckusick expandcc(s)
1448187Smckusick register char *s; {
1458187Smckusick char stemp[100];
1468187Smckusick register char *p;
1478187Smckusick
1488187Smckusick if(s == NULL)return;
1498187Smckusick strcpy(stemp,s);
1508187Smckusick p = stemp;
1518187Smckusick while(*p){
1528187Smckusick if(!isprint(*p)){
1538187Smckusick *s++ = '^';
1548187Smckusick *s++ = *p++ + 0140;
1558187Smckusick }
1568187Smckusick else *s++ = *p++;
1578187Smckusick }
1588187Smckusick }
1598187Smckusick
1608187Smckusick /* get passwd from passwdf */
1618187Smckusick getpwdf(pwd)
1628187Smckusick struct passwd *pwd; {
1638187Smckusick # ifdef PASSWDF
1648187Smckusick # ifndef TESTING
1658187Smckusick register char *p, *q;
1668187Smckusick char buf1[BUFSIZ], found;
1678187Smckusick FILE *pw;
1688187Smckusick debug("reading passwdf\n");
1698187Smckusick pwd->pw_passwd[0] = 0;
1708187Smckusick pw = fopen("/etc/passwdf","r");
1718187Smckusick if(pw == NULL) return;
1728187Smckusick found = 0;
1738187Smckusick while(fgets(buf1,BUFSIZ,pw) != NULL){
1748187Smckusick for(p=buf1; *p && *p != ':'; p++);
1758187Smckusick *p = 0;
1768187Smckusick if(strcmp(buf1,pwd->pw_name) == 0){
1778187Smckusick found = 1;
1788187Smckusick break;
1798187Smckusick }
1808187Smckusick }
1818187Smckusick fclose(pw);
1828187Smckusick if(!found)return;
1838187Smckusick q = ++p;
1848187Smckusick for(;*p && *p != ':';p++);
1858187Smckusick *p = 0;
1868187Smckusick strcpy(pwd->pw_passwd,q);
1878187Smckusick /*
1888187Smckusick debug("user %s passwd %s %s",pwd->pw_name,pwd->pw_passwd);
1898187Smckusick */
190*8278Scomay # endif
191*8278Scomay # endif
1928187Smckusick }
1938187Smckusick /*
1948187Smckusick getutmp()
1958187Smckusick return a pointer to the system utmp structure associated with
1968187Smckusick terminal sttyname, e.g. "/dev/tty3"
1978187Smckusick Is version independent-- will work on v6 systems
1988187Smckusick return NULL if error
1998187Smckusick */
getutmp(sttyname)2008187Smckusick struct utmp *getutmp(sttyname)
2018187Smckusick char *sttyname;
2028187Smckusick {
2038187Smckusick # ifdef OLDTTY
2048187Smckusick struct v6utmp {
2058187Smckusick char v6ut_name[8];
2068187Smckusick char v6ut_tty;
2078187Smckusick char v6ut_fill;
2088187Smckusick long v6ut_time;
2098187Smckusick int v6ut_fl1;
2108187Smckusick } v6utmpstr;
211*8278Scomay # endif
2128187Smckusick static struct utmp utmpstr;
2138187Smckusick FILE *fdutmp;
2148187Smckusick
2158187Smckusick debug("reading utmp\n");
2168187Smckusick if(sttyname == NULL || sttyname[0] == 0)return(NULL);
2178187Smckusick
2188187Smckusick fdutmp = fopen("/etc/utmp","r");
2198187Smckusick if(fdutmp == NULL)return(NULL);
2208187Smckusick
2218187Smckusick # ifndef OLDTTY
2228187Smckusick while(fread(&utmpstr,1,sizeof utmpstr,fdutmp) == sizeof utmpstr)
2238187Smckusick if(strcmp(utmpstr.ut_line,sttyname+5) == 0){
2248187Smckusick fclose(fdutmp);
2258187Smckusick return(&utmpstr);
2268187Smckusick }
227*8278Scomay # else
2288187Smckusick while(fread(&v6utmpstr,1,sizeof v6utmpstr,fdutmp) == sizeof v6utmpstr)
2298187Smckusick if(v6utmpstr.v6ut_tty == sttyname[8]){
2308187Smckusick strcpy(utmpstr.ut_name,v6utmpstr.v6ut_name);
2318187Smckusick strcpy(utmpstr.ut_line,"ttyx");
2328187Smckusick utmpstr.ut_line[3] = v6utmpstr.v6ut_tty;
2338187Smckusick utmpstr.ut_time = v6utmpstr.v6ut_time;
2348187Smckusick fclose(fdutmp);
2358187Smckusick return(&utmpstr);
2368187Smckusick }
237*8278Scomay # endif
2388187Smckusick fclose(fdutmp);
2398187Smckusick return(NULL);
2408187Smckusick }
2418187Smckusick
2428187Smckusick /*
2438187Smckusick these are all the v7 routines not available on the v6 machines
2448187Smckusick */
2458187Smckusick
2468187Smckusick # ifdef V6
2478187Smckusick
2488187Smckusick char **environ; /* global environment pointer */
2498187Smckusick
ioctl(a,b,c)2508187Smckusick ioctl(a,b,c){
2518187Smckusick return(0); /* always succeeds */
2528187Smckusick }
atol(s)2538187Smckusick long atol(s)
2548187Smckusick register char *s; {
2558187Smckusick long i = 0;
2568187Smckusick while('0' <= *s && *s <= '9')
2578187Smckusick i = i * 10 + (*s++ - '0');
2588187Smckusick return(i);
2598187Smckusick }
gettime()2608187Smckusick long gettime(){
2618187Smckusick long tt;
2628187Smckusick time(&tt);
2638187Smckusick return(tt);
2648187Smckusick }
getsize(str)2658187Smckusick long getsize(str)
2668187Smckusick struct stat *str; {
2678187Smckusick long wk;
2688187Smckusick wk = ((long)(str->st_size0 & 0377)) << 16;
2698187Smckusick wk += (long)((unsigned)str->st_size1);
2708187Smckusick return(wk);
2718187Smckusick }
2728187Smckusick /*
2738187Smckusick getenv("HOME")
2748187Smckusick
2758187Smckusick always returns home directory.
2768187Smckusick returns NULL if there is error.
2778187Smckusick */
getenv()2788187Smckusick char *getenv(){
2798187Smckusick register char *shdir = NULL;
2808187Smckusick register struct passwd *pwd;
2818187Smckusick register int it;
2828187Smckusick if(shomedir[0] != 0)return(shomedir);
2838187Smckusick # ifdef BERKELEY
2848187Smckusick /* hget only works on Berkeley machines */
2858187Smckusick it = ttyn(2);
2868187Smckusick # ifdef OLDTTY
2878187Smckusick if(it == 'x')it = ttyn(1);
2888187Smckusick if(it == 'x')it = ttyn(0);
2898187Smckusick if(it != 'x' && hget(it) == 0)shdir = hgethome();
290*8278Scomay # endif
2918187Smckusick # ifdef CCTTY
2928187Smckusick if(it == -1)it = ttyn(1);
2938187Smckusick if(it == -1)it = ttyn(0);
2948187Smckusick if(it != -1 && hget(it) == 0)shdir = hgethome();
295*8278Scomay # endif
296*8278Scomay # endif
2978187Smckusick if(shdir == NULL){
2988187Smckusick pwd = PwdCurrent();
2998187Smckusick if(pwd != NULL)shdir = pwd->pw_dir;
3008187Smckusick }
3018187Smckusick if(shdir != NULL)strcpy(shomedir,shdir);
3028187Smckusick return(shdir);
3038187Smckusick }
3048187Smckusick
3058187Smckusick /* doesn't handle split passwd files */
3068187Smckusick struct passwd *
getpwuid(uid)3078187Smckusick getpwuid(uid)
3088187Smckusick register uid;
3098187Smckusick {
3108187Smckusick register struct passwd *p;
3118187Smckusick struct passwd *getpwent();
3128187Smckusick
3138187Smckusick uid = uidmask(uid);
3148187Smckusick setpwent();
3158187Smckusick while( (p = getpwent()) && guid(p->pw_uid,p->pw_gid) != uid );
3168187Smckusick endpwent();
3178187Smckusick return(p);
3188187Smckusick }
3198187Smckusick
3208187Smckusick static char PASSWD[] = "/etc/passwd";
3218187Smckusick static char EMPTY[] = "";
3228187Smckusick static FILE *pwf = NULL;
3238187Smckusick static char line[BUFSIZ+1];
3248187Smckusick static struct passwd passwd;
3258187Smckusick
setpwent()3268187Smckusick setpwent()
3278187Smckusick {
3288187Smckusick debug("reading passwd\n");
3298187Smckusick if( pwf == NULL )
3308187Smckusick pwf = fopen( PASSWD, "r" );
3318187Smckusick else
3328187Smckusick rewind( pwf );
3338187Smckusick }
3348187Smckusick
endpwent()3358187Smckusick endpwent()
3368187Smckusick {
3378187Smckusick if( pwf != NULL ){
3388187Smckusick fclose( pwf );
3398187Smckusick pwf = NULL;
3408187Smckusick }
3418187Smckusick }
3428187Smckusick
3438187Smckusick static char *
pwskip(p)3448187Smckusick pwskip(p)
3458187Smckusick register char *p;
3468187Smckusick {
3478187Smckusick while( *p && *p != ':' )
3488187Smckusick ++p;
3498187Smckusick if( *p ) *p++ = 0;
3508187Smckusick return(p);
3518187Smckusick }
3528187Smckusick
3538187Smckusick struct passwd *
getpwent()3548187Smckusick getpwent()
3558187Smckusick {
3568187Smckusick register char *p;
3578187Smckusick
3588187Smckusick if (pwf == NULL) {
3598187Smckusick if( (pwf = fopen( PASSWD, "r" )) == NULL )
3608187Smckusick return(0);
3618187Smckusick }
3628187Smckusick p = fgets(line, BUFSIZ, pwf);
3638187Smckusick if (p==NULL)
3648187Smckusick return(0);
3658187Smckusick passwd.pw_name = p;
3668187Smckusick p = pwskip(p);
3678187Smckusick passwd.pw_passwd = p;
3688187Smckusick p = pwskip(p);
3698187Smckusick passwd.pw_uid = atoi(p);
3708187Smckusick passwd.pw_uid = uidmask(passwd.pw_uid);
3718187Smckusick p = pwskip(p);
3728187Smckusick passwd.pw_gid = atoi(p);
3738187Smckusick passwd.pw_quota = 0;
3748187Smckusick passwd.pw_comment = EMPTY;
3758187Smckusick p = pwskip(p);
3768187Smckusick passwd.pw_gecos = p;
3778187Smckusick p = pwskip(p);
3788187Smckusick passwd.pw_dir = p;
3798187Smckusick p = pwskip(p);
3808187Smckusick passwd.pw_shell = p;
3818187Smckusick while(*p && *p != '\n') p++;
3828187Smckusick *p = '\0';
3838187Smckusick return(&passwd);
3848187Smckusick }
3858187Smckusick
3868187Smckusick struct passwd *
getpwnam(name)3878187Smckusick getpwnam(name)
3888187Smckusick char *name;
3898187Smckusick {
3908187Smckusick register struct passwd *p;
3918187Smckusick struct passwd *getpwent();
3928187Smckusick
3938187Smckusick setpwent();
3948187Smckusick while( (p = getpwent()) && strcmp(name,p->pw_name) );
3958187Smckusick endpwent();
3968187Smckusick return(p);
3978187Smckusick }
3988187Smckusick /*
3998187Smckusick getlogin()
4008187Smckusick
4018187Smckusick Return current user name by looking at /etc/utmp (calls getutmp()).
4028187Smckusick Returns NULL if not found.
4038187Smckusick */
getlogin()4048187Smckusick char *getlogin()
4058187Smckusick {
4068187Smckusick register struct utmp *putmp;
4078187Smckusick register char *s;
4088187Smckusick char sttyname[30];
4098187Smckusick
4108187Smckusick if(isatty(2))strcpy(sttyname,ttyname(2));
4118187Smckusick else if(isatty(0))strcpy(sttyname,ttyname(0));
4128187Smckusick else if(isatty(1))strcpy(sttyname,ttyname(1));
4138187Smckusick else return(NULL);
4148187Smckusick
4158187Smckusick putmp = getutmp(sttyname);
4168187Smckusick if(putmp == NULL)return(NULL);
4178187Smckusick s = putmp->ut_name;
4188187Smckusick while(*s != 0 && *s != ' ')s++;
4198187Smckusick *s = 0;
4208187Smckusick if(putmp->ut_name[0] == 0)return(NULL);
4218187Smckusick return(putmp->ut_name);
4228187Smckusick }
4238187Smckusick /*
4248187Smckusick * Unix routine to do an "fopen" on file descriptor
4258187Smckusick * The mode has to be repeated because you can't query its
4268187Smckusick * status
4278187Smckusick */
4288187Smckusick
4298187Smckusick FILE *
fdopen(fd,mode)4308187Smckusick fdopen(fd, mode)
4318187Smckusick register char *mode;
4328187Smckusick {
4338187Smckusick extern int errno;
4348187Smckusick register FILE *iop;
4358187Smckusick extern FILE *_lastbuf;
4368187Smckusick
4378187Smckusick for (iop = _iob; iop->_flag&(_IOREAD|_IOWRT); iop++)
4388187Smckusick if (iop >= _lastbuf)
4398187Smckusick return(NULL);
4408187Smckusick iop->_cnt = 0;
4418187Smckusick iop->_file = fd;
4428187Smckusick if (*mode != 'r') {
4438187Smckusick iop->_flag |= _IOWRT;
4448187Smckusick if (*mode == 'a')
4458187Smckusick lseek(fd, 0L, 2);
4468187Smckusick } else
4478187Smckusick iop->_flag |= _IOREAD;
4488187Smckusick return(iop);
4498187Smckusick }
system(s)4508187Smckusick system(s)
4518187Smckusick char *s;
4528187Smckusick {
4538187Smckusick int status, pid, w;
4548187Smckusick register int (*istat)(), (*qstat)();
4558187Smckusick
4568187Smckusick while((pid = fork()) == -1)sleep(2);
4578187Smckusick if (pid == 0) {
4588187Smckusick execl("/bin/sh", "sh", "-c", s, 0);
4598187Smckusick _exit(127);
4608187Smckusick }
4618187Smckusick istat = signal(SIGINT, SIG_IGN);
4628187Smckusick qstat = signal(SIGQUIT, SIG_IGN);
4638187Smckusick while ((w = wait(&status)) != pid && w != -1)
4648187Smckusick ;
4658187Smckusick if (w == -1)
4668187Smckusick status = -1;
4678187Smckusick signal(SIGINT, istat);
4688187Smckusick signal(SIGQUIT, qstat);
4698187Smckusick return(status);
4708187Smckusick }
4718187Smckusick
4728187Smckusick char *
getpass(prompt)4738187Smckusick getpass(prompt)
4748187Smckusick char *prompt;
4758187Smckusick {
4768187Smckusick struct sgttyb ttyb;
4778187Smckusick int flags;
4788187Smckusick register char *p;
4798187Smckusick register c;
4808187Smckusick FILE *fi = NULL;
4818187Smckusick static char pbuf[9];
4828187Smckusick int (*signal())();
4838187Smckusick int (*sig)();
4848187Smckusick
4858187Smckusick /* modified because Cory needs super-user to stty /dev/tty */
4868187Smckusick if ((fi = fopen("/dev/tty", "r")) == NULL)
4878187Smckusick fi = stdin;
4888187Smckusick else
4898187Smckusick setbuf(fi, (char *)NULL);
4908187Smckusick if(gtty(fileno(fi),&ttyb) < 0){
4918187Smckusick pbuf[0] = 0;
4928187Smckusick return(pbuf);
4938187Smckusick }
4948187Smckusick /*
4958187Smckusick if(gtty(0,&ttyb) >= 0)fi = stdin;
4968187Smckusick else if(gtty(2,&ttyb) >= 0)fi = stderr;
4978187Smckusick else {
4988187Smckusick pbuf[0] = 0;
4998187Smckusick return(pbuf);
5008187Smckusick }
5018187Smckusick */
5028187Smckusick sig = signal(SIGINT, SIG_IGN);
5038187Smckusick flags = ttyb.sg_flags;
5048187Smckusick ttyb.sg_flags &= ~ECHO;
5058187Smckusick if(stty(fileno(fi), &ttyb) < 0) perror("stty:");
5068187Smckusick fprintf(stderr, prompt);
5078187Smckusick for (p=pbuf; (c = getc(fi))!='\n' && c!=EOF;) {
5088187Smckusick if (p < &pbuf[8])
5098187Smckusick *p++ = c;
5108187Smckusick }
5118187Smckusick *p = '\0';
5128187Smckusick fprintf(stderr, "\n");
5138187Smckusick ttyb.sg_flags = flags;
5148187Smckusick stty(fileno(fi), &ttyb);
5158187Smckusick signal(SIGINT, sig);
5168187Smckusick if (fi != stdin)
5178187Smckusick fclose(fi);
5188187Smckusick return(pbuf);
5198187Smckusick }
5208187Smckusick /*
5218187Smckusick * Compare strings (at most n bytes): s1>s2: >0 s1==s2: 0 s1<s2: <0
5228187Smckusick */
5238187Smckusick
strncmp(s1,s2,n)5248187Smckusick strncmp(s1, s2, n)
5258187Smckusick register char *s1, *s2;
5268187Smckusick register n;
5278187Smckusick {
5288187Smckusick
5298187Smckusick while (--n >= 0 && *s1 == *s2++)
5308187Smckusick if (*s1++ == '\0')
5318187Smckusick return(0);
5328187Smckusick return(n<0 ? 0 : *s1 - *--s2);
5338187Smckusick }
5348187Smckusick
5358187Smckusick /* set the umask, ignore in v6 */
5368187Smckusick
umask(n)5378187Smckusick umask(n){}
5388187Smckusick
5398187Smckusick /* end of non-vax v7 routines */
540*8278Scomay # endif
5418187Smckusick /*
5428187Smckusick PwdCurrent()
5438187Smckusick
5448187Smckusick Read the password file and return pwd to
5458187Smckusick entry for current user.
5468187Smckusick Return NULL if error.
5478187Smckusick
5488187Smckusick This code is a little screwed up because of the conventions
5498187Smckusick regarding the state of the utmp file after someone su's--
5508187Smckusick either to root or to another person.
5518187Smckusick The final decision was to return getpwuid(getuid) if
5528187Smckusick the machine has one login name per userid,
5538187Smckusick and if there are multiple login names per userid, to
5548187Smckusick search the passwd file for the getlogin() name and return
5558187Smckusick the passwd file entry for that.
5568187Smckusick If there is no utmp entry, just use the userid.
5578187Smckusick This means that people who su on machine with multiple
5588187Smckusick user-id's will get the passwd entry for the account recorded
5598187Smckusick in the utmp file, not their current userid.
5608187Smckusick */
5618187Smckusick struct passwd *
PwdCurrent()5628187Smckusick PwdCurrent()
5638187Smckusick {
5648187Smckusick register struct passwd *pwd;
5658187Smckusick register char *sn;
5668187Smckusick
5678187Smckusick # ifdef MULTNAMS
5688187Smckusick sn = getlogin();
5698187Smckusick if(sn != NULL && sn[0] != 0 && sn[0] != ' '){
5708187Smckusick pwd = getpwnam(sn);
5718187Smckusick if(pwd != NULL)return(pwd);
5728187Smckusick }
573*8278Scomay # endif
5748187Smckusick
5758187Smckusick return(getpwuid(uidmask(getuid())));
5768187Smckusick }
5778187Smckusick /*VARARGS0*/
debug(s,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,t)5788187Smckusick debug(s,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,t)
5798187Smckusick char *s; {
5808187Smckusick if(debugflg){
5818187Smckusick printf(s,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,t);
5828187Smckusick putchar('\n');
5838187Smckusick }
5848187Smckusick }
585