*
* Validate a user via kerberos.
*/
-static int sudo_krb_validate_user(pw_ent, pass)
- struct passwd *pw_ent;
+static int sudo_krb_validate_user(pw, pass)
+ struct passwd *pw;
char *pass;
{
char realm[REALM_SZ];
* wipe out other kerberos tickets.
*/
(void) sprintf(tkfile, "%s/tkt%ld", _PATH_SUDO_TIMEDIR,
- (long) pw_ent->pw_uid);
+ (long) pw->pw_uid);
(void) krb_set_tkt_string(tkfile);
/*
* the ruid and euid to be the same here so we setuid to root.
*/
set_perms(PERM_ROOT, 0);
- k_errno = krb_get_pw_in_tkt(pw_ent->pw_name, "", realm, "krbtgt", realm,
+ k_errno = krb_get_pw_in_tkt(pw->pw_name, "", realm, "krbtgt", realm,
DEFAULT_TKT_LIFE, pass);
/*
/* allocate space for new prompt */
np_size = op_len + strlen(challenge) + 7;
if (!(new_prompt = (char *) malloc(np_size))) {
- perror("malloc");
(void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
exit(1);
}
if (np_size < op_len + strlen(challenge) + 7) {
np_size = op_len + strlen(challenge) + 7;
if (!(new_prompt = (char *) realloc(new_prompt, np_size))) {
- perror("malloc");
(void) fprintf(stderr, "%s: cannot allocate memory!\n",
Argv[0]);
exit(1);
/* allocate space for new prompt */
np_size = op_len + strlen(challenge) + 7;
if (!(new_prompt = (char *) malloc(np_size))) {
- perror("malloc");
(void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
exit(1);
}
if (np_size < op_len + strlen(challenge) + 7) {
np_size = op_len + strlen(challenge) + 7;
if (!(new_prompt = (char *) realloc(new_prompt, np_size))) {
- perror("malloc");
(void) fprintf(stderr, "%s: cannot allocate memory!\n",
Argv[0]);
exit(1);
if (subst) {
if ((new_prompt = (char *) malloc(len + 1)) == NULL) {
- perror("malloc");
(void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
exit(1);
}
* SHELL evariable or the passwd(5) entry (in that order).
*/
-static char *sudo_getshell(pw_ent)
- struct passwd *pw_ent;
+static char *sudo_getshell(pw)
+ struct passwd *pw;
{
char *pw_shell;
if ((pw_shell = getenv("SHELL")) == NULL)
- pw_shell = pw_ent -> pw_shell;
+ pw_shell = pw -> pw_shell;
#ifdef _PATH_BSHELL
/* empty string "" means bourne shell */
* sudo_getepw()
*
* This function returns the encrypted password for the user described
- * by pw_ent. If there is a shadow password it is returned, else the
+ * by pw. If there is a shadow password it is returned, else the
* normal UN*X password is returned instead.
*/
-static char *sudo_getepw(pw_ent)
- struct passwd *pw_ent;
+static char *sudo_getepw(pw)
+ struct passwd *pw;
{
/* if there is a function to check for shadow enabled, use it... */
#ifdef HAVE_ISCOMSEC
if (!iscomsec())
- return(pw_ent->pw_passwd);
+ return(pw->pw_passwd);
#endif /* HAVE_ISCOMSEC */
#ifdef HAVE_ISSECURE
if (!issecure())
- return(pw_ent->pw_passwd);
+ return(pw->pw_passwd);
#endif /* HAVE_ISSECURE */
#ifdef HAVE_GETPRPWNAM
{
- struct pr_passwd *spw_ent;
+ struct pr_passwd *spw;
- spw_ent = getprpwnam(pw_ent->pw_name);
- if (spw_ent != NULL && spw_ent->ufld.fd_encrypt != NULL) {
+ spw = getprpwnam(spw->pw_name);
+ if (spw != NULL && spw->ufld.fd_encrypt != NULL) {
# ifdef __alpha
- crypt_type = spw_ent -> ufld.fd_oldcrypt;
+ crypt_type = spw -> ufld.fd_oldcrypt;
# endif /* __alpha */
- return(spw_ent -> ufld.fd_encrypt);
+ return(spw -> ufld.fd_encrypt);
}
}
#endif /* HAVE_GETPRPWNAM */
#ifdef HAVE_GETSPNAM
{
- struct spwd *spw_ent;
+ struct spwd *spw;
- if ((spw_ent = getspnam(pw_ent -> pw_name)) && spw_ent -> sp_pwdp)
- return(spw_ent -> sp_pwdp);
+ if ((spw = getspnam(pw -> pw_name)) && spw -> sp_pwdp)
+ return(spw -> sp_pwdp);
}
#endif /* HAVE_GETSPNAM */
#ifdef HAVE_GETSPWUID
{
- struct s_passwd *spw_ent;
+ struct s_passwd *spw;
- if ((spw_ent = getspwuid(pw_ent -> pw_uid)) && spw_ent -> pw_passwd)
- return(spw_ent -> pw_passwd);
+ if ((spw = getspwuid(pw -> pw_uid)) && spw -> pw_passwd)
+ return(spw -> pw_passwd);
}
#endif /* HAVE_GETSPWUID */
#ifdef HAVE_GETPWANAM
{
- struct passwd_adjunct *spw_ent;
+ struct passwd_adjunct *spw;
- if ((spw_ent = getpwanam(pw_ent -> pw_name)) && spw_ent -> pwa_passwd)
- return(spw_ent -> pwa_passwd);
+ if ((spw = getpwanam(pw -> pw_name)) && spw -> pwa_passwd)
+ return(spw -> pwa_passwd);
}
#endif /* HAVE_GETPWANAM */
#ifdef HAVE_GETAUTHUID
{
- AUTHORIZATION *spw_ent;
+ AUTHORIZATION *spw;
- if ((spw_ent = getauthuid(pw_ent -> pw_uid)) && spw_ent -> a_password)
- return(spw_ent -> a_password);
+ if ((spw = getauthuid(pw -> pw_uid)) && spw -> a_password)
+ return(spw -> a_password);
}
#endif /* HAVE_GETAUTHUID */
/* Fall back on normal passwd */
- return(pw_ent->pw_passwd);
+ return(pw->pw_passwd);
}
struct passwd *sudo_getpwuid(uid)
uid_t uid;
{
- struct passwd *pw_ent, *local_pw_ent;
+ struct passwd *pw, *local_pw;
- if ((pw_ent = getpwuid(uid)) == NULL)
+ if ((pw = getpwuid(uid)) == NULL)
return(NULL);
- /* allocate space for a local copy of pw_ent */
- local_pw_ent = (struct passwd *) malloc(sizeof(struct passwd));
- if (local_pw_ent == NULL) {
- perror("malloc");
+ /* allocate space for a local copy of pw */
+ local_pw = (struct passwd *) malloc(sizeof(struct passwd));
+ if (local_pw == NULL) {
(void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
exit(1);
}
/*
* Copy the struct passwd and the interesting strings...
*/
- (void) memcpy(local_pw_ent, pw_ent, sizeof(struct passwd));
+ (void) memcpy(local_pw, pw, sizeof(struct passwd));
- local_pw_ent->pw_name = (char *) strdup(pw_ent->pw_name);
- if (local_pw_ent->pw_name == NULL) {
- perror("malloc");
+ local_pw->pw_name = (char *) strdup(pw->pw_name);
+ if (local_pw->pw_name == NULL) {
(void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
exit(1);
}
- local_pw_ent->pw_dir = (char *) strdup(pw_ent->pw_dir);
- if (local_pw_ent->pw_dir == NULL) {
- perror("malloc");
+ local_pw->pw_dir = (char *) strdup(pw->pw_dir);
+ if (local_pw->pw_dir == NULL) {
(void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
exit(1);
}
/* pw_shell is a special case since we overide with $SHELL */
- local_pw_ent->pw_shell = (char *) strdup(sudo_getshell(pw_ent));
- if (local_pw_ent->pw_shell == NULL) {
- perror("malloc");
+ local_pw->pw_shell = (char *) strdup(sudo_getshell(pw));
+ if (local_pw->pw_shell == NULL) {
(void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
exit(1);
}
/* pw_passwd gets a shadow password if applicable */
- local_pw_ent->pw_passwd = (char *) strdup(sudo_getepw(pw_ent));
- if (local_pw_ent->pw_passwd == NULL) {
- perror("malloc");
+ local_pw->pw_passwd = (char *) strdup(sudo_getepw(pw));
+ if (local_pw->pw_passwd == NULL) {
(void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
exit(1);
}
- return(local_pw_ent);
+ return(local_pw);
}