diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-03-14 12:50:10 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-03-14 12:50:10 +0000 |
commit | 1128870a98a5ad6d6c0448519e383630a515f6a8 (patch) | |
tree | 2d6ab251bdcaabc7c5de618cdd188edcacc773a4 /pam_sql | |
parent | 8600d3bc0e2b1ac6afffd86105703989a1def4d3 (diff) | |
download | pam-modules-1128870a98a5ad6d6c0448519e383630a515f6a8.tar.gz pam-modules-1128870a98a5ad6d6c0448519e383630a515f6a8.tar.bz2 |
* lib/parseopt.c: New file.
* lib/Makefile.am (libgraypam_la_SOURCES): Add parseopt.c
* lib/graypam.h (gray_parseopt, gray_wait_debug_fun): New
functions
(CNTL_DEBUG_LEV, CNTL_SET_DEBUG_LEV): Removed.
* lib/log.c (gray_wait_debug): New functions.
* pam_fshadow/pam_fshadow.c, pam_sql/pam_sql.c,
pam_regex/pam_regex.c, pam_log/pam_log.c: Use gray_parseopt for
command line parsing.
git-svn-id: file:///svnroot/pam-modules/trunk@67 56984be4-0537-0410-a56c-fcb268c96130
Diffstat (limited to 'pam_sql')
-rw-r--r-- | pam_sql/pam_sql.c | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/pam_sql/pam_sql.c b/pam_sql/pam_sql.c index 6f54c7d..6bc4241 100644 --- a/pam_sql/pam_sql.c +++ b/pam_sql/pam_sql.c @@ -36,40 +36,25 @@ static int verify_user_pass(const char *username, const char *password); #define CNTL_AUTHTOK 0x0010 static int cntl_flags; +static long debug_level; char *config_file = SYSCONFDIR "/pam_sql.conf"; +struct pam_opt pam_opt[] = { + { PAM_OPTSTR(debug), pam_opt_long, &debug_level }, + { PAM_OPTSTR(debug), pam_opt_const, &debug_level, 1 }, + { PAM_OPTSTR(audit), pam_opt_bitmask, &cntl_flags, CNTL_AUDIT }, + { PAM_OPTSTR(waitdebug), pam_opt_null, NULL, 0, gray_wait_debug_fun }, + { PAM_OPTSTR(use_authtok), pam_opt_bitmask, &cntl_flags, + CNTL_AUTHTOK }, + { PAM_OPTSTR(config_file), pam_opt_string, &config_file }, + { NULL } +}; + static void _pam_parse(int argc, const char **argv) { - int ctrl=0; - gray_log_init(0, MODULE_NAME, LOG_AUTHPRIV); - - /* step through arguments */ - for (ctrl=0; argc-- > 0; ++argv) { - - /* generic options */ - - if (!strncmp(*argv,"debug",5)) { - ctrl |= CNTL_DEBUG; - if ((*argv)[5] == '=') - CNTL_SET_DEBUG_LEV(ctrl,atoi(*argv+6)); - else - CNTL_SET_DEBUG_LEV(ctrl,1); - } else if (!strcmp(*argv, "audit")) - ctrl |= CNTL_AUDIT; - else if (!strncmp(*argv, "waitdebug", 9)) - WAITDEBUG(*argv + 9); - else if (!strcmp(*argv,"use_authtok")) - ctrl |= CNTL_AUTHTOK; - else if (!strncmp(*argv, "config=", 7)) - config_file = (char*) (*argv + 7); - else { - _pam_log(LOG_ERR,"unknown option: %s", - *argv); - } - } - cntl_flags = ctrl; + gray_parseopt(pam_opt, argc, argv); } |