Commit cc9ac172 cc9ac172317396f3220dc72d27932596d6c4a9ee by Sergey Poznyakoff

Removed pam- and sql-specific stuff

1 parent 33737423
...@@ -46,21 +46,8 @@ ...@@ -46,21 +46,8 @@
46 #include <argcv.h> 46 #include <argcv.h>
47 #include <mu_asprintf.h> 47 #include <mu_asprintf.h>
48 48
49 #ifdef HAVE_MYSQL
50 # include "../MySql/MySql.h"
51 #endif
52
53 #define ARG_LOG_FACILITY 1 49 #define ARG_LOG_FACILITY 1
54 #define ARG_SQL_GETPWNAM 2 50 #define ARG_LOCK_FLAGS 2
55 #define ARG_SQL_GETPWUID 3
56 #define ARG_SQL_GETPASS 4
57 #define ARG_SQL_HOST 5
58 #define ARG_SQL_USER 6
59 #define ARG_SQL_PASSWD 7
60 #define ARG_SQL_DB 8
61 #define ARG_SQL_PORT 9
62 #define ARG_PAM_SERVICE 10
63 #define ARG_LOCK_FLAGS 11
64 51
65 const char *argp_program_bug_address = "<" PACKAGE_BUGREPORT ">"; 52 const char *argp_program_bug_address = "<" PACKAGE_BUGREPORT ">";
66 53
...@@ -108,32 +95,6 @@ static struct argp_option mu_logging_argp_option[] = { ...@@ -108,32 +95,6 @@ static struct argp_option mu_logging_argp_option[] = {
108 { NULL, 0, NULL, 0, NULL, 0 } 95 { NULL, 0, NULL, 0, NULL, 0 }
109 }; 96 };
110 97
111 /* Options used by programs that use extended authentication mechanisms. */
112 static struct argp_option mu_auth_argp_option[] = {
113 #ifdef USE_LIBPAM
114 { "pam-service", ARG_PAM_SERVICE, "STRING", 0,
115 "Use STRING as PAM service name", 0},
116 #endif
117 #ifdef HAVE_MYSQL
118 {"sql-getpwnam", ARG_SQL_GETPWNAM, "QUERY", 0,
119 "SQL query to retrieve a passwd entry based on username", 0},
120 {"sql-getpwuid", ARG_SQL_GETPWUID, "QUERY", 0,
121 "SQL query to retrieve a passwd entry based on UID", 0},
122 {"sql-getpass", ARG_SQL_GETPASS, "QUERY", 0,
123 "SQL query to retrieve a password from the database", 0},
124 {"sql-host", ARG_SQL_HOST, "HOSTNAME", 0,
125 "Name or IP of MySQL server to connect to", 0},
126 {"sql-user", ARG_SQL_USER, "NAME", 0,
127 "SQL user name", 0},
128 {"sql-passwd", ARG_SQL_PASSWD, "STRING", 0,
129 "SQL connection password", 0},
130 {"sql-db", ARG_SQL_DB, "STRING", 0,
131 "Name of the database to connect to", 0},
132 {"sql-port", ARG_SQL_PORT, "NUMBER", 0,
133 "Port to use", 0},
134 #endif
135 { NULL, 0, NULL, 0, NULL, 0 }
136 };
137 98
138 /* Options used by programs that become daemons. */ 99 /* Options used by programs that become daemons. */
139 static struct argp_option mu_daemon_argp_option[] = { 100 static struct argp_option mu_daemon_argp_option[] = {
...@@ -227,18 +188,6 @@ struct argp_child mu_logging_argp_child = { ...@@ -227,18 +188,6 @@ struct argp_child mu_logging_argp_child = {
227 0 188 0
228 }; 189 };
229 190
230 struct argp mu_auth_argp = {
231 mu_auth_argp_option,
232 mu_common_argp_parser,
233 };
234
235 struct argp_child mu_auth_argp_child = {
236 &mu_auth_argp,
237 0,
238 "Authentication options",
239 0
240 };
241
242 struct argp mu_daemon_argp = { 191 struct argp mu_daemon_argp = {
243 mu_daemon_argp_option, 192 mu_daemon_argp_option,
244 mu_daemon_argp_parser, 193 mu_daemon_argp_parser,
...@@ -301,21 +250,6 @@ static char license_text[] = ...@@ -301,21 +250,6 @@ static char license_text[] =
301 " along with this program; if not, write to the Free Software\n" 250 " along with this program; if not, write to the Free Software\n"
302 " Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n"; 251 " Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n";
303 252
304 #ifdef HAVE_MYSQL
305 char *sql_getpwnam_query;
306 char *sql_getpass_query;
307 char *sql_getpwuid_query;
308 char *sql_host = MHOST;
309 char *sql_user = MUSER;
310 char *sql_passwd = MPASS;
311 char *sql_db = MDB;
312 char *sql_socket = MSOCKET;
313 int sql_port = MPORT;
314 #endif
315 #ifdef USE_LIBPAM
316 char *pam_service = NULL;
317 #endif
318
319 static error_t 253 static error_t
320 mu_common_argp_parser (int key, char *arg, struct argp_state *state) 254 mu_common_argp_parser (int key, char *arg, struct argp_state *state)
321 { 255 {
...@@ -394,52 +328,6 @@ mu_common_argp_parser (int key, char *arg, struct argp_state *state) ...@@ -394,52 +328,6 @@ mu_common_argp_parser (int key, char *arg, struct argp_state *state)
394 log_facility = parse_log_facility (arg); 328 log_facility = parse_log_facility (arg);
395 break; 329 break;
396 330
397 /* authentication */
398 #ifdef USE_LIBPAM
399 case ARG_PAM_SERVICE:
400 pam_service = arg;
401 break;
402 #endif
403
404 #ifdef HAVE_MYSQL
405 case ARG_SQL_GETPWNAM:
406 sql_getpwnam_query = arg;
407 break;
408
409 case ARG_SQL_GETPWUID:
410 sql_getpwuid_query = arg;
411 break;
412
413 case ARG_SQL_GETPASS:
414 sql_getpass_query = arg;
415 break;
416
417 case ARG_SQL_HOST:
418 sql_host = arg;
419 break;
420
421 case ARG_SQL_USER:
422 sql_user = arg;
423 break;
424
425 case ARG_SQL_PASSWD:
426 sql_passwd = arg;
427 break;
428
429 case ARG_SQL_DB:
430 sql_db = arg;
431 break;
432
433 case ARG_SQL_PORT:
434 sql_port = strtoul (arg, NULL, 0);
435 if (sql_port == 0)
436 {
437 sql_host = NULL;
438 sql_socket = arg;
439 }
440 break;
441
442 #endif
443 case ARGP_KEY_FINI: 331 case ARGP_KEY_FINI:
444 p = mu_normalize_maildir (mu_path_maildir); 332 p = mu_normalize_maildir (mu_path_maildir);
445 if (!p) 333 if (!p)
...@@ -740,21 +628,38 @@ mu_create_argcv (const char *capa[], ...@@ -740,21 +628,38 @@ mu_create_argcv (const char *capa[],
740 *p_argv = x_argv; 628 *p_argv = x_argv;
741 } 629 }
742 630
631 #define MU_MAX_CAPA 24
632
743 struct argp_capa { 633 struct argp_capa {
744 char *capability; 634 char *capability;
745 struct argp_child *child; 635 struct argp_child *child;
746 } mu_argp_capa[] = { 636 } mu_argp_capa[MU_MAX_CAPA] = {
747 {"common", &mu_common_argp_child}, 637 {"common", &mu_common_argp_child},
748 {"license", &mu_license_argp_child}, 638 {"license", &mu_license_argp_child},
749 {"mailbox", &mu_mailbox_argp_child}, 639 {"mailbox", &mu_mailbox_argp_child},
750 {"address", &mu_address_argp_child}, 640 {"address", &mu_address_argp_child},
751 {"mailer", &mu_mailer_argp_child}, 641 {"mailer", &mu_mailer_argp_child},
752 {"logging", &mu_logging_argp_child}, 642 {"logging", &mu_logging_argp_child},
753 {"auth", &mu_auth_argp_child},
754 {"daemon", &mu_daemon_argp_child}, 643 {"daemon", &mu_daemon_argp_child},
755 {NULL,} 644 {NULL,}
756 }; 645 };
757 646
647 int
648 mu_register_capa (const char *name, struct argp_child *child)
649 {
650 int i;
651
652 for (i = 0; i < MU_MAX_CAPA; i++)
653 if (mu_argp_capa[i].capability == NULL)
654 {
655 mu_argp_capa[i].capability = strdup (name);
656 mu_argp_capa[i].child = child;
657 return 0;
658 }
659 return 1;
660 }
661
662
758 static struct argp_child * 663 static struct argp_child *
759 find_argp_child (const char *capa) 664 find_argp_child (const char *capa)
760 { 665 {
......