Changeset 87 in openpam


Ignore:
Timestamp:
Mar 5, 2002, 2:20:26 PM (16 years ago)
Author:
Dag-Erling Smørgrav
Message:

Move most of the dynamic loader code into a separate file, and add
support for module versioning. OpenPAM will prefer a PAM module with
the same version number as the library itself to one with no version
number at all.

Sponsored by: DARPA, NAI Labs

Location:
trunk
Files:
1 added
4 edited

Legend:

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

    r86 r87  
    3232 * SUCH DAMAGE.
    3333 *
    34  * $P4: //depot/projects/openpam/include/security/openpam.h#10 $
     34 * $P4: //depot/projects/openpam/include/security/openpam.h#11 $
    3535 */
    3636
     
    178178typedef struct pam_module pam_module_t;
    179179struct pam_module {
    180         const char      *path;
     180        char            *path;
    181181        pam_func_t       func[PAM_NUM_PRIMITIVES];
    182182        void            *dlh;
     
    202202#define PAM_EXTERN static
    203203#define PAM_MODULE_ENTRY(name)                                          \
    204 static struct pam_module _pam_module = { name PAM_SOEXT, {              \
     204static char _pam_name[] = name PAM_SOEXT;                               \
     205static struct pam_module _pam_module = { _pam_name, {                   \
    205206    pam_sm_authenticate, pam_sm_setcred, pam_sm_acct_mgmt,              \
    206207    pam_sm_open_session, pam_sm_close_session, pam_sm_chauthtok },      \
  • trunk/lib/Makefile

    r86 r87  
    3232# SUCH DAMAGE.
    3333#
    34 # $P4: //depot/projects/openpam/lib/Makefile#10 $
     34# $P4: //depot/projects/openpam/lib/Makefile#11 $
    3535#
    3636
     
    4242NO_WERROR        = yes
    4343CFLAGS          += -I${.CURDIR}/../include
     44CFLAGS          += -DLIB_MAJ=${SHLIB_MAJOR}
    4445
    4546SRCS             =
    4647SRCS            += openpam_dispatch.c
     48SRCS            += openpam_dynamic.c
    4749SRCS            += openpam_findenv.c
    4850SRCS            += openpam_get_option.c
  • trunk/lib/openpam_impl.h

    r86 r87  
    3232 * SUCH DAMAGE.
    3333 *
    34  * $P4: //depot/projects/openpam/lib/openpam_impl.h#9 $
     34 * $P4: //depot/projects/openpam/lib/openpam_impl.h#10 $
    3535 */
    3636
     
    105105pam_module_t   *openpam_static(const char *);
    106106#endif
     107pam_module_t   *openpam_dynamic(const char *);
    107108
    108109#endif
  • trunk/lib/openpam_load.c

    r86 r87  
    3232 * SUCH DAMAGE.
    3333 *
    34  * $P4: //depot/projects/openpam/lib/openpam_load.c#9 $
     34 * $P4: //depot/projects/openpam/lib/openpam_load.c#10 $
    3535 */
    3636
     
    5555
    5656/*
    57  * Load a dynamic module, or locate a static one.  Keep a list of
    58  * previously found modules to speed up the process.
     57 * Locate a matching dynamic or static module.  Keep a list of previously
     58 * found modules to speed up the process.
    5959 */
    6060
     
    6363{
    6464        pam_module_t *module;
    65         void *dlh;
    66         int i;
    6765
    6866        /* check cache first */
     
    7270
    7371        /* nope; try to load */
    74         if ((dlh = dlopen(path, RTLD_NOW)) == NULL) {
    75                 openpam_log(PAM_LOG_ERROR, "dlopen(): %s", dlerror());
    76         } else {
    77                 if ((module = calloc(1, sizeof *module)) == NULL)
    78                         goto buf_err;
    79                 if ((module->path = strdup(path)) == NULL)
    80                         goto buf_err;
    81                 module->dlh = dlh;
    82                 for (i = 0; i < PAM_NUM_PRIMITIVES; ++i)
    83                         module->func[i] = dlsym(dlh, _pam_sm_func_name[i]);
    84         }
     72        module = openpam_dynamic(path);
    8573        openpam_log(PAM_LOG_DEBUG, "%s dynamic %s",
    8674            (module == NULL) ? "no" : "using", path);
     
    10290        ++module->refcount;
    10391        return (module);
    104  buf_err:
    105         openpam_log(PAM_LOG_ERROR, "malloc(): %m");
    106         dlclose(dlh);
    107         free(module);
    108         return (NULL);
    10992}
    11093
     
    137120        if (module->next != NULL)
    138121                module->next->prev = module->prev;
     122        free(module->path);
    139123        free(module);
    140124}
Note: See TracChangeset for help on using the changeset viewer.