Home | History | Annotate | Line # | Download | only in su
su.c revision 1.9
      1  1.1      cgd /*
      2  1.1      cgd  * Copyright (c) 1988 The Regents of the University of California.
      3  1.1      cgd  * All rights reserved.
      4  1.1      cgd  *
      5  1.1      cgd  * Redistribution and use in source and binary forms, with or without
      6  1.1      cgd  * modification, are permitted provided that the following conditions
      7  1.1      cgd  * are met:
      8  1.1      cgd  * 1. Redistributions of source code must retain the above copyright
      9  1.1      cgd  *    notice, this list of conditions and the following disclaimer.
     10  1.1      cgd  * 2. Redistributions in binary form must reproduce the above copyright
     11  1.1      cgd  *    notice, this list of conditions and the following disclaimer in the
     12  1.1      cgd  *    documentation and/or other materials provided with the distribution.
     13  1.1      cgd  * 3. All advertising materials mentioning features or use of this software
     14  1.1      cgd  *    must display the following acknowledgement:
     15  1.1      cgd  *	This product includes software developed by the University of
     16  1.1      cgd  *	California, Berkeley and its contributors.
     17  1.1      cgd  * 4. Neither the name of the University nor the names of its contributors
     18  1.1      cgd  *    may be used to endorse or promote products derived from this software
     19  1.1      cgd  *    without specific prior written permission.
     20  1.1      cgd  *
     21  1.1      cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     22  1.1      cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23  1.1      cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24  1.1      cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     25  1.1      cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     26  1.1      cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     27  1.1      cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     28  1.1      cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     29  1.1      cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     30  1.1      cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     31  1.1      cgd  * SUCH DAMAGE.
     32  1.1      cgd  */
     33  1.1      cgd 
     34  1.1      cgd #ifndef lint
     35  1.1      cgd char copyright[] =
     36  1.1      cgd "@(#) Copyright (c) 1988 The Regents of the University of California.\n\
     37  1.1      cgd  All rights reserved.\n";
     38  1.1      cgd #endif /* not lint */
     39  1.1      cgd 
     40  1.1      cgd #ifndef lint
     41  1.6  mycroft /*static char sccsid[] = "from: @(#)su.c	5.26 (Berkeley) 7/6/91";*/
     42  1.9      cgd static char rcsid[] = "$Id: su.c,v 1.9 1994/02/12 07:06:07 cgd Exp $";
     43  1.1      cgd #endif /* not lint */
     44  1.1      cgd 
     45  1.1      cgd #include <sys/param.h>
     46  1.1      cgd #include <sys/time.h>
     47  1.1      cgd #include <sys/resource.h>
     48  1.1      cgd #include <syslog.h>
     49  1.1      cgd #include <stdio.h>
     50  1.7      jtc #include <stdlib.h>
     51  1.1      cgd #include <pwd.h>
     52  1.1      cgd #include <grp.h>
     53  1.1      cgd #include <string.h>
     54  1.1      cgd #include <unistd.h>
     55  1.1      cgd #include <paths.h>
     56  1.1      cgd 
     57  1.1      cgd #ifdef KERBEROS
     58  1.1      cgd #include <kerberosIV/des.h>
     59  1.1      cgd #include <kerberosIV/krb.h>
     60  1.1      cgd #include <netdb.h>
     61  1.1      cgd 
     62  1.1      cgd #define	ARGSTR	"-Kflm"
     63  1.1      cgd 
     64  1.1      cgd int use_kerberos = 1;
     65  1.1      cgd #else
     66  1.1      cgd #define	ARGSTR	"-flm"
     67  1.1      cgd #endif
     68  1.1      cgd 
     69  1.2      sef extern char *crypt();
     70  1.7      jtc int chshell();
     71  1.2      sef 
     72  1.7      jtc int
     73  1.1      cgd main(argc, argv)
     74  1.1      cgd 	int argc;
     75  1.1      cgd 	char **argv;
     76  1.1      cgd {
     77  1.1      cgd 	extern char **environ;
     78  1.1      cgd 	extern int errno, optind;
     79  1.1      cgd 	register struct passwd *pwd;
     80  1.1      cgd 	register char *p, **g;
     81  1.1      cgd 	struct group *gr;
     82  1.1      cgd 	uid_t ruid, getuid();
     83  1.1      cgd 	int asme, ch, asthem, fastlogin, prio;
     84  1.1      cgd 	enum { UNSET, YES, NO } iscsh = UNSET;
     85  1.8  mycroft 	char *user, *shell, *avshell, *username, *cleanenv[10], **np;
     86  1.8  mycroft 	char shellbuf[MAXPATHLEN], avshellbuf[MAXPATHLEN];
     87  1.2      sef 	char *getpass(), *getenv(), *getlogin(), *ontty();
     88  1.1      cgd 
     89  1.1      cgd 	asme = asthem = fastlogin = 0;
     90  1.1      cgd 	while ((ch = getopt(argc, argv, ARGSTR)) != EOF)
     91  1.1      cgd 		switch((char)ch) {
     92  1.1      cgd #ifdef KERBEROS
     93  1.1      cgd 		case 'K':
     94  1.1      cgd 			use_kerberos = 0;
     95  1.1      cgd 			break;
     96  1.1      cgd #endif
     97  1.1      cgd 		case 'f':
     98  1.1      cgd 			fastlogin = 1;
     99  1.1      cgd 			break;
    100  1.1      cgd 		case '-':
    101  1.1      cgd 		case 'l':
    102  1.1      cgd 			asme = 0;
    103  1.1      cgd 			asthem = 1;
    104  1.1      cgd 			break;
    105  1.1      cgd 		case 'm':
    106  1.1      cgd 			asme = 1;
    107  1.1      cgd 			asthem = 0;
    108  1.1      cgd 			break;
    109  1.1      cgd 		case '?':
    110  1.1      cgd 		default:
    111  1.1      cgd 			(void)fprintf(stderr, "usage: su [%s] [login]\n",
    112  1.1      cgd 			    ARGSTR);
    113  1.1      cgd 			exit(1);
    114  1.1      cgd 		}
    115  1.1      cgd 	argv += optind;
    116  1.1      cgd 
    117  1.1      cgd 	errno = 0;
    118  1.1      cgd 	prio = getpriority(PRIO_PROCESS, 0);
    119  1.1      cgd 	if (errno)
    120  1.1      cgd 		prio = 0;
    121  1.1      cgd 	(void)setpriority(PRIO_PROCESS, 0, -2);
    122  1.1      cgd 	openlog("su", LOG_CONS, 0);
    123  1.1      cgd 
    124  1.1      cgd 	/* get current login name and shell */
    125  1.1      cgd 	ruid = getuid();
    126  1.1      cgd 	username = getlogin();
    127  1.1      cgd 	if (username == NULL || (pwd = getpwnam(username)) == NULL ||
    128  1.1      cgd 	    pwd->pw_uid != ruid)
    129  1.1      cgd 		pwd = getpwuid(ruid);
    130  1.1      cgd 	if (pwd == NULL) {
    131  1.1      cgd 		fprintf(stderr, "su: who are you?\n");
    132  1.1      cgd 		exit(1);
    133  1.1      cgd 	}
    134  1.1      cgd 	username = strdup(pwd->pw_name);
    135  1.1      cgd 	if (asme)
    136  1.1      cgd 		if (pwd->pw_shell && *pwd->pw_shell)
    137  1.1      cgd 			shell = strcpy(shellbuf,  pwd->pw_shell);
    138  1.1      cgd 		else {
    139  1.1      cgd 			shell = _PATH_BSHELL;
    140  1.1      cgd 			iscsh = NO;
    141  1.1      cgd 		}
    142  1.1      cgd 
    143  1.1      cgd 	/* get target login information, default to root */
    144  1.1      cgd 	user = *argv ? *argv : "root";
    145  1.2      sef 	np = *argv ? argv : argv-1;
    146  1.2      sef 
    147  1.1      cgd 	if ((pwd = getpwnam(user)) == NULL) {
    148  1.1      cgd 		fprintf(stderr, "su: unknown login %s\n", user);
    149  1.1      cgd 		exit(1);
    150  1.1      cgd 	}
    151  1.1      cgd 
    152  1.1      cgd 	if (ruid) {
    153  1.1      cgd #ifdef KERBEROS
    154  1.1      cgd 	    if (!use_kerberos || kerberos(username, user, pwd->pw_uid))
    155  1.1      cgd #endif
    156  1.1      cgd 	    {
    157  1.1      cgd 		/* only allow those in group zero to su to root. */
    158  1.1      cgd 		if (pwd->pw_uid == 0 && (gr = getgrgid((gid_t)0)))
    159  1.1      cgd 			for (g = gr->gr_mem;; ++g) {
    160  1.1      cgd 				if (!*g) {
    161  1.1      cgd 					(void)fprintf(stderr,
    162  1.1      cgd 			    "su: you are not in the correct group to su %s.\n",
    163  1.1      cgd 					    user);
    164  1.1      cgd 					exit(1);
    165  1.1      cgd 				}
    166  1.1      cgd 				if (!strcmp(username, *g))
    167  1.1      cgd 					break;
    168  1.1      cgd 		}
    169  1.1      cgd 		/* if target requires a password, verify it */
    170  1.1      cgd 		if (*pwd->pw_passwd) {
    171  1.1      cgd 			p = getpass("Password:");
    172  1.1      cgd 			if (strcmp(pwd->pw_passwd, crypt(p, pwd->pw_passwd))) {
    173  1.1      cgd 				fprintf(stderr, "Sorry\n");
    174  1.1      cgd 				syslog(LOG_AUTH|LOG_WARNING,
    175  1.1      cgd 					"BAD SU %s to %s%s", username,
    176  1.1      cgd 					user, ontty());
    177  1.1      cgd 				exit(1);
    178  1.1      cgd 			}
    179  1.1      cgd 		}
    180  1.1      cgd 	    }
    181  1.1      cgd 	}
    182  1.1      cgd 
    183  1.1      cgd 	if (asme) {
    184  1.1      cgd 		/* if asme and non-standard target shell, must be root */
    185  1.1      cgd 		if (!chshell(pwd->pw_shell) && ruid) {
    186  1.1      cgd 			(void)fprintf(stderr,
    187  1.1      cgd 				"su: permission denied (shell).\n");
    188  1.1      cgd 			exit(1);
    189  1.1      cgd 		}
    190  1.1      cgd 	} else if (pwd->pw_shell && *pwd->pw_shell) {
    191  1.1      cgd 		shell = pwd->pw_shell;
    192  1.1      cgd 		iscsh = UNSET;
    193  1.1      cgd 	} else {
    194  1.1      cgd 		shell = _PATH_BSHELL;
    195  1.1      cgd 		iscsh = NO;
    196  1.1      cgd 	}
    197  1.1      cgd 
    198  1.9      cgd 	if (p = rindex(shell, '/'))
    199  1.9      cgd 		avshell = p+1;
    200  1.9      cgd 	else
    201  1.9      cgd 		avshell = shell;
    202  1.9      cgd 
    203  1.1      cgd 	/* if we're forking a csh, we want to slightly muck the args */
    204  1.9      cgd 	if (iscsh == UNSET)
    205  1.8  mycroft 		iscsh = strcmp(avshell, "csh") ? NO : YES;
    206  1.1      cgd 
    207  1.1      cgd 	/* set permissions */
    208  1.1      cgd 	if (setgid(pwd->pw_gid) < 0) {
    209  1.1      cgd 		perror("su: setgid");
    210  1.1      cgd 		exit(1);
    211  1.1      cgd 	}
    212  1.1      cgd 	if (initgroups(user, pwd->pw_gid)) {
    213  1.1      cgd 		(void)fprintf(stderr, "su: initgroups failed.\n");
    214  1.1      cgd 		exit(1);
    215  1.1      cgd 	}
    216  1.1      cgd 	if (setuid(pwd->pw_uid) < 0) {
    217  1.1      cgd 		perror("su: setuid");
    218  1.1      cgd 		exit(1);
    219  1.1      cgd 	}
    220  1.1      cgd 
    221  1.1      cgd 	if (!asme) {
    222  1.1      cgd 		if (asthem) {
    223  1.1      cgd 			p = getenv("TERM");
    224  1.8  mycroft 			cleanenv[0] = NULL;
    225  1.1      cgd 			environ = cleanenv;
    226  1.8  mycroft 			(void)setenv("PATH", _PATH_DEFPATH, 1);
    227  1.1      cgd 			(void)setenv("TERM", p, 1);
    228  1.1      cgd 			if (chdir(pwd->pw_dir) < 0) {
    229  1.1      cgd 				fprintf(stderr, "su: no directory\n");
    230  1.1      cgd 				exit(1);
    231  1.1      cgd 			}
    232  1.1      cgd 		}
    233  1.5      jtc 		if (asthem || pwd->pw_uid)
    234  1.1      cgd 			(void)setenv("USER", pwd->pw_name, 1);
    235  1.1      cgd 		(void)setenv("HOME", pwd->pw_dir, 1);
    236  1.1      cgd 		(void)setenv("SHELL", shell, 1);
    237  1.1      cgd 	}
    238  1.1      cgd 
    239  1.1      cgd 	if (iscsh == YES) {
    240  1.1      cgd 		if (fastlogin)
    241  1.1      cgd 			*np-- = "-f";
    242  1.1      cgd 		if (asme)
    243  1.1      cgd 			*np-- = "-m";
    244  1.1      cgd 	}
    245  1.1      cgd 
    246  1.8  mycroft 	if (asthem) {
    247  1.8  mycroft 		avshellbuf[0] = '-';
    248  1.8  mycroft 		strcpy(avshellbuf+1, avshell);
    249  1.8  mycroft 		avshell = avshellbuf;
    250  1.8  mycroft 	} else if (iscsh == YES) {
    251  1.8  mycroft 		/* csh strips the first character... */
    252  1.8  mycroft 		avshellbuf[0] = '_';
    253  1.8  mycroft 		strcpy(avshellbuf+1, avshell);
    254  1.8  mycroft 		avshell = avshellbuf;
    255  1.8  mycroft 	}
    256  1.8  mycroft 
    257  1.8  mycroft 	*np = avshell;
    258  1.1      cgd 
    259  1.1      cgd 	if (ruid != 0)
    260  1.1      cgd 		syslog(LOG_NOTICE|LOG_AUTH, "%s to %s%s",
    261  1.1      cgd 		    username, user, ontty());
    262  1.1      cgd 
    263  1.1      cgd 	(void)setpriority(PRIO_PROCESS, 0, prio);
    264  1.1      cgd 
    265  1.1      cgd 	execv(shell, np);
    266  1.1      cgd 	(void)fprintf(stderr, "su: %s not found.\n", shell);
    267  1.1      cgd 	exit(1);
    268  1.1      cgd }
    269  1.1      cgd 
    270  1.7      jtc int
    271  1.1      cgd chshell(sh)
    272  1.1      cgd 	char *sh;
    273  1.1      cgd {
    274  1.1      cgd 	register char *cp;
    275  1.1      cgd 	char *getusershell();
    276  1.1      cgd 
    277  1.1      cgd 	while ((cp = getusershell()) != NULL)
    278  1.1      cgd 		if (!strcmp(cp, sh))
    279  1.1      cgd 			return (1);
    280  1.1      cgd 	return (0);
    281  1.1      cgd }
    282  1.1      cgd 
    283  1.1      cgd char *
    284  1.1      cgd ontty()
    285  1.1      cgd {
    286  1.1      cgd 	char *p, *ttyname();
    287  1.1      cgd 	static char buf[MAXPATHLEN + 4];
    288  1.1      cgd 
    289  1.1      cgd 	buf[0] = 0;
    290  1.1      cgd 	if (p = ttyname(STDERR_FILENO))
    291  1.1      cgd 		sprintf(buf, " on %s", p);
    292  1.1      cgd 	return (buf);
    293  1.1      cgd }
    294  1.1      cgd 
    295  1.1      cgd #ifdef KERBEROS
    296  1.1      cgd kerberos(username, user, uid)
    297  1.1      cgd 	char *username, *user;
    298  1.1      cgd 	int uid;
    299  1.1      cgd {
    300  1.1      cgd 	extern char *krb_err_txt[];
    301  1.1      cgd 	KTEXT_ST ticket;
    302  1.1      cgd 	AUTH_DAT authdata;
    303  1.1      cgd 	struct hostent *hp;
    304  1.1      cgd 	register char *p;
    305  1.1      cgd 	int kerno;
    306  1.1      cgd 	u_long faddr;
    307  1.1      cgd 	char lrealm[REALM_SZ], krbtkfile[MAXPATHLEN];
    308  1.1      cgd 	char hostname[MAXHOSTNAMELEN], savehost[MAXHOSTNAMELEN];
    309  1.1      cgd 	char *ontty(), *krb_get_phost();
    310  1.1      cgd 
    311  1.1      cgd 	if (krb_get_lrealm(lrealm, 1) != KSUCCESS)
    312  1.1      cgd 		return (1);
    313  1.1      cgd 	if (koktologin(username, lrealm, user) && !uid) {
    314  1.1      cgd 		(void)fprintf(stderr, "kerberos su: not in %s's ACL.\n", user);
    315  1.1      cgd 		return (1);
    316  1.1      cgd 	}
    317  1.1      cgd 	(void)sprintf(krbtkfile, "%s_%s_%d", TKT_ROOT, user, getuid());
    318  1.1      cgd 
    319  1.1      cgd 	(void)setenv("KRBTKFILE", krbtkfile, 1);
    320  1.1      cgd 	(void)krb_set_tkt_string(krbtkfile);
    321  1.1      cgd 	/*
    322  1.1      cgd 	 * Set real as well as effective ID to 0 for the moment,
    323  1.1      cgd 	 * to make the kerberos library do the right thing.
    324  1.1      cgd 	 */
    325  1.1      cgd 	if (setuid(0) < 0) {
    326  1.1      cgd 		perror("su: setuid");
    327  1.1      cgd 		return (1);
    328  1.1      cgd 	}
    329  1.1      cgd 
    330  1.1      cgd 	/*
    331  1.1      cgd 	 * Little trick here -- if we are su'ing to root,
    332  1.1      cgd 	 * we need to get a ticket for "xxx.root", where xxx represents
    333  1.1      cgd 	 * the name of the person su'ing.  Otherwise (non-root case),
    334  1.1      cgd 	 * we need to get a ticket for "yyy.", where yyy represents
    335  1.1      cgd 	 * the name of the person being su'd to, and the instance is null
    336  1.1      cgd 	 *
    337  1.1      cgd 	 * We should have a way to set the ticket lifetime,
    338  1.1      cgd 	 * with a system default for root.
    339  1.1      cgd 	 */
    340  1.1      cgd 	kerno = krb_get_pw_in_tkt((uid == 0 ? username : user),
    341  1.1      cgd 		(uid == 0 ? "root" : ""), lrealm,
    342  1.1      cgd 	    	"krbtgt", lrealm, DEFAULT_TKT_LIFE, 0);
    343  1.1      cgd 
    344  1.1      cgd 	if (kerno != KSUCCESS) {
    345  1.1      cgd 		if (kerno == KDC_PR_UNKNOWN) {
    346  1.1      cgd 			fprintf(stderr, "principal unknown: %s.%s@%s\n",
    347  1.1      cgd 				(uid == 0 ? username : user),
    348  1.1      cgd 				(uid == 0 ? "root" : ""), lrealm);
    349  1.1      cgd 			return (1);
    350  1.1      cgd 		}
    351  1.1      cgd 		(void)fprintf(stderr, "su: unable to su: %s\n",
    352  1.1      cgd 		    krb_err_txt[kerno]);
    353  1.1      cgd 		syslog(LOG_NOTICE|LOG_AUTH,
    354  1.1      cgd 		    "BAD Kerberos SU: %s to %s%s: %s",
    355  1.1      cgd 		    username, user, ontty(), krb_err_txt[kerno]);
    356  1.1      cgd 		return (1);
    357  1.1      cgd 	}
    358  1.1      cgd 
    359  1.1      cgd 	if (chown(krbtkfile, uid, -1) < 0) {
    360  1.1      cgd 		perror("su: chown:");
    361  1.1      cgd 		(void)unlink(krbtkfile);
    362  1.1      cgd 		return (1);
    363  1.1      cgd 	}
    364  1.1      cgd 
    365  1.1      cgd 	(void)setpriority(PRIO_PROCESS, 0, -2);
    366  1.1      cgd 
    367  1.1      cgd 	if (gethostname(hostname, sizeof(hostname)) == -1) {
    368  1.1      cgd 		perror("su: gethostname");
    369  1.1      cgd 		dest_tkt();
    370  1.1      cgd 		return (1);
    371  1.1      cgd 	}
    372  1.1      cgd 
    373  1.1      cgd 	(void)strncpy(savehost, krb_get_phost(hostname), sizeof(savehost));
    374  1.1      cgd 	savehost[sizeof(savehost) - 1] = '\0';
    375  1.1      cgd 
    376  1.1      cgd 	kerno = krb_mk_req(&ticket, "rcmd", savehost, lrealm, 33);
    377  1.1      cgd 
    378  1.1      cgd 	if (kerno == KDC_PR_UNKNOWN) {
    379  1.1      cgd 		(void)fprintf(stderr, "Warning: TGT not verified.\n");
    380  1.1      cgd 		syslog(LOG_NOTICE|LOG_AUTH,
    381  1.1      cgd 		    "%s to %s%s, TGT not verified (%s); %s.%s not registered?",
    382  1.1      cgd 		    username, user, ontty(), krb_err_txt[kerno],
    383  1.1      cgd 		    "rcmd", savehost);
    384  1.1      cgd 	} else if (kerno != KSUCCESS) {
    385  1.1      cgd 		(void)fprintf(stderr, "Unable to use TGT: %s\n",
    386  1.1      cgd 		    krb_err_txt[kerno]);
    387  1.1      cgd 		syslog(LOG_NOTICE|LOG_AUTH, "failed su: %s to %s%s: %s",
    388  1.1      cgd 		    username, user, ontty(), krb_err_txt[kerno]);
    389  1.1      cgd 		dest_tkt();
    390  1.1      cgd 		return (1);
    391  1.1      cgd 	} else {
    392  1.1      cgd 		if (!(hp = gethostbyname(hostname))) {
    393  1.1      cgd 			(void)fprintf(stderr, "su: can't get addr of %s\n",
    394  1.1      cgd 			    hostname);
    395  1.1      cgd 			dest_tkt();
    396  1.1      cgd 			return (1);
    397  1.1      cgd 		}
    398  1.1      cgd 		(void)bcopy((char *)hp->h_addr, (char *)&faddr, sizeof(faddr));
    399  1.1      cgd 
    400  1.1      cgd 		if ((kerno = krb_rd_req(&ticket, "rcmd", savehost, faddr,
    401  1.1      cgd 		    &authdata, "")) != KSUCCESS) {
    402  1.1      cgd 			(void)fprintf(stderr,
    403  1.1      cgd 			    "su: unable to verify rcmd ticket: %s\n",
    404  1.1      cgd 			    krb_err_txt[kerno]);
    405  1.1      cgd 			syslog(LOG_NOTICE|LOG_AUTH,
    406  1.1      cgd 			    "failed su: %s to %s%s: %s", username,
    407  1.1      cgd 			     user, ontty(), krb_err_txt[kerno]);
    408  1.1      cgd 			dest_tkt();
    409  1.1      cgd 			return (1);
    410  1.1      cgd 		}
    411  1.1      cgd 	}
    412  1.1      cgd 	return (0);
    413  1.1      cgd }
    414  1.1      cgd 
    415  1.1      cgd koktologin(name, realm, toname)
    416  1.1      cgd 	char *name, *realm, *toname;
    417  1.1      cgd {
    418  1.1      cgd 	register AUTH_DAT *kdata;
    419  1.1      cgd 	AUTH_DAT kdata_st;
    420  1.1      cgd 
    421  1.1      cgd 	kdata = &kdata_st;
    422  1.1      cgd 	bzero((caddr_t) kdata, sizeof(*kdata));
    423  1.1      cgd 	(void)strcpy(kdata->pname, name);
    424  1.1      cgd 	(void)strcpy(kdata->pinst,
    425  1.1      cgd 	    ((strcmp(toname, "root") == 0) ? "root" : ""));
    426  1.1      cgd 	(void)strcpy(kdata->prealm, realm);
    427  1.1      cgd 	return (kuserok(kdata, toname));
    428  1.1      cgd }
    429  1.1      cgd #endif
    430