Changeset 491 in openpam for trunk


Ignore:
Timestamp:
Nov 12, 2011, 12:12:32 AM (7 years ago)
Author:
Dag-Erling Smørgrav
Message:

Reorganize the headers and centralize the string tables.

Location:
trunk/lib
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Makefile.am

    r490 r491  
    88
    99noinst_HEADERS = \
     10        openpam_constants.h \
     11        openpam_debug.h \
    1012        openpam_impl.h \
    1113        openpam_strlcmp.h \
     
    1517        openpam_borrow_cred.c \
    1618        openpam_configure.c \
     19        openpam_constants.c \
    1720        openpam_dispatch.c \
    1821        openpam_dynamic.c \
  • trunk/lib/openpam_configure.c

    r488 r491  
    5050#include "openpam_impl.h"
    5151#include "openpam_strlcmp.h"
    52 
    53 const char *pam_facility_name[PAM_NUM_FACILITIES] = {
    54         [PAM_ACCOUNT]           = "account",
    55         [PAM_AUTH]              = "auth",
    56         [PAM_PASSWORD]          = "password",
    57         [PAM_SESSION]           = "session",
    58 };
    59 
    60 const char *pam_control_flag_name[PAM_NUM_CONTROL_FLAGS] = {
    61         [PAM_BINDING]           = "binding",
    62         [PAM_OPTIONAL]          = "optional",
    63         [PAM_REQUIRED]          = "required",
    64         [PAM_REQUISITE]         = "requisite",
    65         [PAM_SUFFICIENT]        = "sufficient",
    66 };
    6752
    6853static int openpam_load_chain(pam_handle_t *, const char *, pam_facility_t);
  • trunk/lib/openpam_impl.h

    r482 r491  
    4141#include <security/openpam.h>
    4242
    43 extern const char *pam_func_name[PAM_NUM_PRIMITIVES];
    44 extern const char *pam_sm_func_name[PAM_NUM_PRIMITIVES];
    45 extern const char *pam_err_name[PAM_NUM_ERRORS];
    46 extern const char *pam_item_name[PAM_NUM_ITEMS];
    47 
    4843extern int openpam_debug;
    4944
     
    7267} pam_facility_t;
    7368
     69/*
     70 * Module chains
     71 */
    7472typedef struct pam_chain pam_chain_t;
    7573struct pam_chain {
     
    8179};
    8280
     81/*
     82 * Service policies
     83 */
     84#if defined(OPENPAM_EMBEDDED)
     85typedef struct pam_policy pam_policy_t;
     86struct pam_policy {
     87        const char      *service;
     88        pam_chain_t     *chains[PAM_NUM_FACILITIES];
     89};
     90extern pam_policy_t *pam_embedded_policies[];
     91#endif
     92
     93/*
     94 * Module-specific data
     95 */
    8396typedef struct pam_data pam_data_t;
    8497struct pam_data {
     
    89102};
    90103
     104/*
     105 * PAM context
     106 */
    91107struct pam_handle {
    92108        char            *service;
     
    108124
    109125#ifdef NGROUPS_MAX
     126/*
     127 * Saved credentials
     128 */
    110129#define PAM_SAVED_CRED "pam_saved_cred"
    111130struct pam_saved_cred {
     
    117136#endif
    118137
     138/*
     139 * Default policy
     140 */
    119141#define PAM_OTHER       "other"
    120142
     143/*
     144 * Internal functions
     145 */
    121146int              openpam_configure(pam_handle_t *, const char *);
    122147int              openpam_dispatch(pam_handle_t *, int, int);
     
    132157#define FREE(p) do { free((p)); (p) = NULL; } while (0)
    133158
    134 #ifdef OPENPAM_DEBUG
    135 #define ENTER() openpam_log(PAM_LOG_DEBUG, "entering")
    136 #define ENTERI(i) do { \
    137         int i_ = (i); \
    138         if (i_ > 0 && i_ < PAM_NUM_ITEMS) \
    139                 openpam_log(PAM_LOG_DEBUG, "entering: %s", pam_item_name[i_]); \
    140         else \
    141                 openpam_log(PAM_LOG_DEBUG, "entering: %d", i_); \
    142 } while (0)
    143 #define ENTERN(n) do { \
    144         int n_ = (n); \
    145         openpam_log(PAM_LOG_DEBUG, "entering: %d", n_); \
    146 } while (0)
    147 #define ENTERS(s) do { \
    148         const char *s_ = (s); \
    149         if (s_ == NULL) \
    150                 openpam_log(PAM_LOG_DEBUG, "entering: NULL"); \
    151         else \
    152                 openpam_log(PAM_LOG_DEBUG, "entering: '%s'", s_); \
    153 } while (0)
    154 #define RETURNV() openpam_log(PAM_LOG_DEBUG, "returning")
    155 #define RETURNC(c) do { \
    156         int c_ = (c); \
    157         if (c_ >= 0 && c_ < PAM_NUM_ERRORS) \
    158                 openpam_log(PAM_LOG_DEBUG, "returning %s", pam_err_name[c_]); \
    159         else \
    160                 openpam_log(PAM_LOG_DEBUG, "returning %d!", c_); \
    161         return (c_); \
    162 } while (0)
    163 #define RETURNN(n) do { \
    164         int n_ = (n); \
    165         openpam_log(PAM_LOG_DEBUG, "returning %d", n_); \
    166         return (n_); \
    167 } while (0)
    168 #define RETURNP(p) do { \
    169         const void *p_ = (p); \
    170         if (p_ == NULL) \
    171                 openpam_log(PAM_LOG_DEBUG, "returning NULL"); \
    172         else \
    173                 openpam_log(PAM_LOG_DEBUG, "returning %p", p_); \
    174         return (p_); \
    175 } while (0)
    176 #define RETURNS(s) do { \
    177         const char *s_ = (s); \
    178         if (s_ == NULL) \
    179                 openpam_log(PAM_LOG_DEBUG, "returning NULL"); \
    180         else \
    181                 openpam_log(PAM_LOG_DEBUG, "returning '%s'", s_); \
    182         return (s_); \
    183 } while (0)
    184 #else
    185 #define ENTER()
    186 #define ENTERI(i)
    187 #define ENTERN(n)
    188 #define ENTERS(s)
    189 #define RETURNV() return
    190 #define RETURNC(c) return (c)
    191 #define RETURNN(n) return (n)
    192 #define RETURNP(p) return (p)
    193 #define RETURNS(s) return (s)
    194 #endif
     159#include "openpam_constants.h"
     160#include "openpam_debug.h"
    195161
    196162#endif
  • trunk/lib/openpam_load.c

    r477 r491  
    4747
    4848#include "openpam_impl.h"
    49 
    50 const char *pam_func_name[PAM_NUM_PRIMITIVES] = {
    51         "pam_authenticate",
    52         "pam_setcred",
    53         "pam_acct_mgmt",
    54         "pam_open_session",
    55         "pam_close_session",
    56         "pam_chauthtok"
    57 };
    58 
    59 const char *pam_sm_func_name[PAM_NUM_PRIMITIVES] = {
    60         "pam_sm_authenticate",
    61         "pam_sm_setcred",
    62         "pam_sm_acct_mgmt",
    63         "pam_sm_open_session",
    64         "pam_sm_close_session",
    65         "pam_sm_chauthtok"
    66 };
    6749
    6850/*
  • trunk/lib/pam_get_item.c

    r460 r491  
    4545
    4646#include "openpam_impl.h"
    47 
    48 const char *pam_item_name[PAM_NUM_ITEMS] = {
    49         "(NO ITEM)",
    50         "PAM_SERVICE",
    51         "PAM_USER",
    52         "PAM_TTY",
    53         "PAM_RHOST",
    54         "PAM_CONV",
    55         "PAM_AUTHTOK",
    56         "PAM_OLDAUTHTOK",
    57         "PAM_RUSER",
    58         "PAM_USER_PROMPT",
    59         "PAM_REPOSITORY",
    60         "PAM_AUTHTOK_PROMPT",
    61         "PAM_OLDAUTHTOK_PROMPT",
    62         "PAM_HOST",
    63 };
    6447
    6548/*
  • trunk/lib/pam_strerror.c

    r460 r491  
    4545
    4646#include "openpam_impl.h"
    47 
    48 const char *pam_err_name[PAM_NUM_ERRORS] = {
    49         "PAM_SUCCESS",
    50         "PAM_OPEN_ERR",
    51         "PAM_SYMBOL_ERR",
    52         "PAM_SERVICE_ERR",
    53         "PAM_SYSTEM_ERR",
    54         "PAM_BUF_ERR",
    55         "PAM_CONV_ERR",
    56         "PAM_PERM_DENIED",
    57         "PAM_MAXTRIES",
    58         "PAM_AUTH_ERR",
    59         "PAM_NEW_AUTHTOK_REQD",
    60         "PAM_CRED_INSUFFICIENT",
    61         "PAM_AUTHINFO_UNAVAIL",
    62         "PAM_USER_UNKNOWN",
    63         "PAM_CRED_UNAVAIL",
    64         "PAM_CRED_EXPIRED",
    65         "PAM_CRED_ERR",
    66         "PAM_ACCT_EXPIRED",
    67         "PAM_AUTHTOK_EXPIRED",
    68         "PAM_SESSION_ERR",
    69         "PAM_AUTHTOK_ERR",
    70         "PAM_AUTHTOK_RECOVERY_ERR",
    71         "PAM_AUTHTOK_LOCK_BUSY",
    72         "PAM_AUTHTOK_DISABLE_AGING",
    73         "PAM_NO_MODULE_DATA",
    74         "PAM_IGNORE",
    75         "PAM_ABORT",
    76         "PAM_TRY_AGAIN",
    77         "PAM_MODULE_UNKNOWN",
    78         "PAM_DOMAIN_UNKNOWN"
    79 };
    8047
    8148/*
Note: See TracChangeset for help on using the changeset viewer.