Changeset 403 in openpam for trunk


Ignore:
Timestamp:
Nov 28, 2007, 12:29:08 PM (11 years ago)
Author:
Dag-Erling Smørgrav
Message:

Get rid of the module cache; it serves little purpose, and makes OpenPAM
thread-unsafe.

Location:
trunk
Files:
2 edited

Legend:

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

    r401 r403  
    259259        pam_func_t       func[PAM_NUM_PRIMITIVES];
    260260        void            *dlh;
    261         int              refcount;
    262         pam_module_t    *prev;
    263         pam_module_t    *next;
    264261};
    265262
  • trunk/lib/openpam_load.c

    r320 r403  
    6161};
    6262
    63 static pam_module_t *modules;
    64 
    6563/*
    66  * Locate a matching dynamic or static module.  Keep a list of previously
    67  * found modules to speed up the process.
     64 * Locate a matching dynamic or static module.
    6865 */
    6966
     
    7370        pam_module_t *module;
    7471
    75         /* check cache first */
    76         for (module = modules; module != NULL; module = module->next)
    77                 if (strcmp(module->path, path) == 0)
    78                         goto found;
    79 
    80         /* nope; try to load */
    8172        module = openpam_dynamic(path);
    8273        openpam_log(PAM_LOG_DEBUG, "%s dynamic %s",
     
    9586                return (NULL);
    9687        }
    97         openpam_log(PAM_LOG_DEBUG, "adding %s to cache", module->path);
    98         module->next = modules;
    99         if (module->next != NULL)
    100                 module->next->prev = module;
    101         module->prev = NULL;
    102         modules = module;
    103  found:
    104         ++module->refcount;
    10588        return (module);
    10689}
     
    117100        if (module == NULL)
    118101                return;
    119         --module->refcount;
    120         if (module->refcount > 0)
    121                 /* still in use */
    122                 return;
    123         if (module->refcount < 0) {
    124                 openpam_log(PAM_LOG_ERROR, "module %s has negative refcount",
    125                     module->path);
    126                 module->refcount = 0;
    127         }
    128102        if (module->dlh == NULL)
    129103                /* static module */
    130104                return;
    131105        dlclose(module->dlh);
    132         if (module->prev != NULL)
    133                 module->prev->next = module->next;
    134         if (module->next != NULL)
    135                 module->next->prev = module->prev;
    136         if (module == modules)
    137                 modules = module->next;
    138106        openpam_log(PAM_LOG_DEBUG, "releasing %s", module->path);
    139107        FREE(module->path);
Note: See TracChangeset for help on using the changeset viewer.