Changeset 201 in openpam for trunk


Ignore:
Timestamp:
Feb 7, 2003, 4:04:39 PM (16 years ago)
Author:
Dag-Erling Smørgrav
Message:

If a set of saved credentials already exists when we are called, log
a debugging message and fail.

If the effective uid is non-zero but identical to the target uid,
save the current credentials and return without doing anything else.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/openpam_borrow_cred.c

    r187 r201  
    3232 * SUCH DAMAGE.
    3333 *
    34  * $P4: //depot/projects/openpam/lib/openpam_borrow_cred.c#3 $
     34 * $P4: //depot/projects/openpam/lib/openpam_borrow_cred.c#4 $
    3535 */
    3636
     
    5858        int r;
    5959
    60         ENTER();
    61         if (geteuid() != 0)
     60        ENTERI(pwd->pw_uid);
     61        r = pam_get_data(pamh, PAM_SAVED_CRED, (const void **)&scred);
     62        if (r == PAM_SUCCESS && scred != NULL) {
     63                openpam_log(PAM_LOG_DEBUG,
     64                    "already operating under borrowed credentials");
     65                RETURNC(PAM_SYSTEM_ERR);
     66        }
     67        if (geteuid() != 0 && geteuid() != pwd->pw_uid) {
     68                openpam_log(PAM_LOG_DEBUG, "called with non-zero euid: %d",
     69                    (int)geteuid());
    6270                RETURNC(PAM_PERM_DENIED);
     71        }
    6372        scred = calloc(1, sizeof *scred);
    6473        if (scred == NULL)
     
    7786                RETURNC(r);
    7887        }
     88        if (geteuid() == pwd->pw_uid)
     89                RETURNC(PAM_SUCCESS);
    7990        if (initgroups(pwd->pw_name, pwd->pw_gid) == -1 ||
    8091              setegid(pwd->pw_gid) == -1 || seteuid(pwd->pw_uid) == -1) {
Note: See TracChangeset for help on using the changeset viewer.