Changeset 443 in openpam for trunk


Ignore:
Timestamp:
Oct 22, 2011, 1:01:39 AM (8 years ago)
Author:
Dag-Erling Smørgrav
Message:

We already have PAM_USER, PAM_RUSER and PAM_RHOST. Add PAM_HOST for
the sake of completeness. It is automatically set in pam_start(3).

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/security/pam_constants.h

    r437 r443  
    127127        PAM_AUTHTOK_PROMPT              =  11,          /* OpenPAM extension */
    128128        PAM_OLDAUTHTOK_PROMPT           =  12,          /* OpenPAM extension */
     129        PAM_HOST                        =  13,          /* OpenPAM extension */
    129130        PAM_NUM_ITEMS                                   /* OpenPAM extension */
    130131};
  • trunk/lib/pam_get_item.c

    r437 r443  
    5959        "PAM_REPOSITORY",
    6060        "PAM_AUTHTOK_PROMPT",
    61         "PAM_OLDAUTHTOK_PROMPT"
     61        "PAM_OLDAUTHTOK_PROMPT",
     62        "PAM_HOST",
    6263};
    6364
     
    8889        case PAM_CONV:
    8990        case PAM_USER_PROMPT:
     91        case PAM_REPOSITORY:
    9092        case PAM_AUTHTOK_PROMPT:
    9193        case PAM_OLDAUTHTOK_PROMPT:
    92         case PAM_REPOSITORY:
     94        case PAM_HOST:
    9395                *item = pamh->item[item_type];
    9496                RETURNC(PAM_SUCCESS);
     
    140142 *              The prompt to use when asking the applicant for an
    141143 *              expired authentication token prior to changing it.
     144 *      =PAM_HOST:
     145 *              The name of the host the application runs on.
    142146 *
    143147 * See =pam_start for a description of =struct pam_conv.
  • trunk/lib/pam_set_item.c

    r437 r443  
    8080        case PAM_AUTHTOK_PROMPT:
    8181        case PAM_OLDAUTHTOK_PROMPT:
     82        case PAM_HOST:
    8283                if (*slot != NULL)
    8384                        osize = strlen(*slot) + 1;
  • trunk/lib/pam_start.c

    r437 r443  
    4141
    4242#include <stdlib.h>
     43#include <string.h>
     44#include <unistd.h>
    4345
    4446#include <security/pam_appl.h>
    4547
    4648#include "openpam_impl.h"
     49
     50#ifdef _SC_HOST_NAME_MAX
     51#define HOST_NAME_MAX sysconf(_SC_HOST_NAME_MAX)
     52#else
     53#define HOST_NAME_MAX 1024
     54#endif
    4755
    4856/*
     
    5967        pam_handle_t **pamh)
    6068{
     69        char hostname[HOST_NAME_MAX + 1];
    6170        struct pam_handle *ph;
    6271        int r;
     
    6675                RETURNC(PAM_BUF_ERR);
    6776        if ((r = pam_set_item(ph, PAM_SERVICE, service)) != PAM_SUCCESS)
     77                goto fail;
     78        if (gethostname(hostname, sizeof hostname) != 0)
     79                strlcpy(hostname, "localhost", sizeof hostname);
     80        if ((r = pam_set_item(ph, PAM_HOST, hostname)) != PAM_SUCCESS)
    6881                goto fail;
    6982        if ((r = pam_set_item(ph, PAM_USER, user)) != PAM_SUCCESS)
Note: See TracChangeset for help on using the changeset viewer.