Changeset 672 in openpam for trunk/lib/libpam
- Timestamp:
- Mar 17, 2013, 7:42:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/libpam/openpam_dynamic.c
r662 r672 54 54 #include "openpam_impl.h" 55 55 #include "openpam_asprintf.h" 56 #include "openpam_ctype.h" 56 57 #include "openpam_dlfunc.h" 57 58 … … 177 178 pam_module_t *module; 178 179 char modpath[PATH_MAX]; 179 const char **path; 180 const char **path, *p; 181 int has_so, has_ver; 180 182 int dot, len; 181 183 … … 198 200 199 201 /* 202 * Check for .so and version sufixes 203 */ 204 p = strchr(modname, '\0'); 205 has_ver = has_so = 1; 206 while (is_digit(*p)) 207 --p; 208 if (*p == '.' && *++p != '\0') { 209 /* found a numeric suffix */ 210 has_ver = 1; 211 /* assume that .so is either present or unneeded */ 212 has_so = 1; 213 } else if (*p == '\0' && p >= modname + sizeof PAM_SOEXT && 214 strcmp(p - sizeof PAM_SOEXT + 1, PAM_SOEXT) == 0) { 215 /* found .so suffix */ 216 has_so = 1; 217 } 218 219 /* 200 220 * Complicated case: search for the module in the usual places. 201 221 */ … … 205 225 * note of where the suffix begins so we can cut it off later. 206 226 */ 207 len = snprintf(modpath, sizeof modpath, "%s/%s%n.%d", 208 *path, modname, &dot, LIB_MAJ); 227 if (has_ver) 228 len = snprintf(modpath, sizeof modpath, "%s/%s%n", 229 *path, modname, &dot); 230 else if (has_so) 231 len = snprintf(modpath, sizeof modpath, "%s/%s%n.%d", 232 *path, modname, &dot, LIB_MAJ); 233 else 234 len = snprintf(modpath, sizeof modpath, "%s/%s%s%n.%d", 235 *path, modname, PAM_SOEXT, &dot, LIB_MAJ); 236 /* check for overflow */ 209 237 if (len < 0 || (unsigned int)len >= sizeof modpath) { 210 238 errno = ENOENT; … … 214 242 if ((module = try_module(modpath)) != NULL) 215 243 return (module); 216 if (errno == ENOENT ) {244 if (errno == ENOENT && modpath[dot] != '\0') { 217 245 /* no luck, try the unversioned path */ 218 246 modpath[dot] = '\0';
Note: See TracChangeset
for help on using the changeset viewer.