2,4c2,4 < * $Id: krb.c,v 1.2 1992/01/15 09:58:30 epeisach Exp miki $ < * $Source: /mit/patriot/devel/src/rkinit/rkinitd/RCS/krb.c,v $ < * $Author: epeisach $ --- > * $Id: krb.c,v 1.10 1994/05/26 15:13:59 cfields Exp $ > * $Source: /afs/dev.mit.edu/source/src80/athena/bin/rkinit.76/rkinitd/RCS/krb.c,v $ > * $Author: cfields $ 10c10 < static char *rcsid = "$Id: krb.c,v 1.2 1992/01/15 09:58:30 epeisach Exp miki $"; --- > static char *rcsid = "$Id: krb.c,v 1.10 1994/05/26 15:13:59 cfields Exp $"; 17c17 < #include --- > #include 18a19,24 > #ifdef SYSV > #include > #endif > #ifdef sun > #include > #endif 22,24c28 < #ifdef HESIOD < #include < #endif --- > 28,31c32 < #include < #ifdef SYSV < #include < #endif --- > 230c231 < memcpy(key, auth_dat.session, sizeof(key)); --- > bcopy(auth_dat.session, key, sizeof(key)); 242c243 < memcpy(cip->dat, msg_data.app_data, msg_data.app_length); --- > bcopy(msg_data.app_data, cip->dat, msg_data.app_length); 257c258 < #endif --- > #endif 261,262d261 < struct passwd *pwnam; /* For access_check and uid */ < 274a274 > struct passwd *pwnam; /* For access_check and uid */ 277,281d276 < #ifdef HESIOD < int used_hesiod = FALSE; < char **glist; < char *msg; < #endif 286,303d280 < #ifdef HESIOD < pwnam = hes_getpwnam(username); < if ((pwnam == NULL) || pwnam->pw_dir[0] == 0) { < if (hes_error() == HES_ER_NOTFOUND) { < sprintf(errmsg, "Unknown user name entered (no hesiod information for \"%s\")", username); < return(FAILURE); < } else { < sprintf(errmsg, "Unable to find account information due to network failure. Try again later."); < return(FAILURE); < } < } else < user_id = pwnam -> pw_uid; < if(add_to_passwd(pwnam)) { < sprintf(errmsg, "An unexpected error occurred while entering you in the local password file."); < return(FAILURE); < } else used_hesiod++; < < #else 306d282 < #endif 309,328d284 < #ifdef HESIOD < if(used_hesiod) { < char *add_to_group(); < glist = hes_resolve(username, "grplist"); < if (glist && glist[0]) { < /* add_to_group() will corrupt the list, so was save a copy first */ < strcpy(errbuf, glist[0]); < if (msg = add_to_group(username, glist[0])) { < strcpy(errbuf,msg); < return(FAILURE); < } < strcpy(glist[0], errbuf); < } else { < /* error about no groups... */ < } < } < #endif < < #ifndef HESIOD < /* This is moved after the attach.... */ 341d296 < 359,360c314 < < if (kstatus != KSUCCESS) { --- > if (kstatus != KSUCCESS) { 369,445c323 < } < < #endif < /* < * Set real uid to owner of ticket file. The library takes care < * of making the appropriate change. < */ < #ifndef SOLARIS < /* Solaris does not have setruid, but will use setuid after srvtab has < been read */ < if (setruid(pwnam->pw_uid) < 0) { < sprintf(errmsg, "Failure setting ruid to %d: %s\n", pwnam->pw_uid, < sys_errlist[errno]); < strcpy(errbuf, errmsg); < error(); < return(FAILURE); < } < #endif < return(RKINIT_SUCCESS); < } < < #ifdef HESIOD < #ifdef __STDC__ < static int attach_user(char *aname, char *inst, char *realm, < char *username, char *errmsg) < #else < static int attach_user(aname, inst, realm, username, errmsg) < char *aname; < char *inst; < char *realm; < char *username; < char *errmsg; < #endif /* __STDC__ */ < { < < AUTH_DAT auth_dat; < char *msg, *attachhomedir(); < < int kstatus = KSUCCESS; < < SBCLEAR(auth_dat); < < if (seteuid(0) < 0) { < sprintf(errmsg, "Failure setting euid to 0: %s\n", < sys_errlist[errno]); < strcpy(errbuf, errmsg); < error(); < return(FAILURE); < } < < if (msg = attachhomedir(pwnam)) { < strcpy(errmsg, msg); < return(FAILURE); < } < < if (seteuid(pwnam->pw_uid) < 0) { < sprintf(errmsg, "Failure setting euid to %d: %s\n", pwnam->pw_uid, < sys_errlist[errno]); < strcpy(errbuf, errmsg); < error(); < return(FAILURE); < } < < strcpy(auth_dat.pname, aname); < strcpy(auth_dat.pinst, inst); < strcpy(auth_dat.prealm, realm); < kstatus = kuserok(&auth_dat, username); < if (kstatus != KSUCCESS) { < sprintf(errmsg, "%s has not allowed you to log in with", username); < if (strlen(auth_dat.pinst)) < sprintf(errmsg, "%s %s.%s", errmsg, auth_dat.pname, < auth_dat.pinst); < else < sprintf(errmsg, "%s %s", errmsg, auth_dat.pname); < sprintf(errmsg, "%s@%s tickets.", errmsg, auth_dat.prealm); < return(FAILURE); < } --- > } 464d341 < #endif 530,536d406 < #ifdef HESIOD < if ((status = attach_user(info.aname, info.inst, info.realm, < info.username, errmsg)) != RKINIT_SUCCESS) { < rpc_send_error(errmsg); < exit(0); < } else < #endif