Changeset 87 in openpam for trunk/lib/openpam_load.c


Ignore:
Timestamp:
Mar 5, 2002, 2:20:26 PM (19 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.