diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-03-09 13:19:18 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-03-09 13:23:24 +0200 |
commit | c21495784ae7f9551311a09e5d24d40df2354e48 (patch) | |
tree | 111a992506888782fb3cf7876f237cb6b448c551 /pop3d | |
parent | ca898e17e779eed5ca95f603767d91f298c33159 (diff) | |
download | mailutils-c21495784ae7f9551311a09e5d24d40df2354e48.tar.gz mailutils-c21495784ae7f9551311a09e5d24d40df2354e48.tar.bz2 |
Fix compilation of pop3d and maidag without DBM.
* maidag/Makefile.am: Load libmu_dbm.la if MU_COND_DBM is true.
* pop3d/apop.c (pop3d_apopuser): Set owner, if specified in the
config.
* pop3d/pop3d.c (apop_database_owner)
(apop_database_owner_set): New globals.
(pop3d_cfg_param) <apop-database-owner>: New keyword.
* pop3d/pop3d.h (apop_database_owner)
(apop_database_owner_set): New declarations.
Diffstat (limited to 'pop3d')
-rw-r--r-- | pop3d/apop.c | 5 | ||||
-rw-r--r-- | pop3d/pop3d.c | 31 | ||||
-rw-r--r-- | pop3d/pop3d.h | 2 |
3 files changed, 37 insertions, 1 deletions
diff --git a/pop3d/apop.c b/pop3d/apop.c index 7f06a7c27..a4f4e122e 100644 --- a/pop3d/apop.c +++ b/pop3d/apop.c @@ -57,6 +57,9 @@ pop3d_apopuser (const char *user) return NULL; } + if (apop_database_owner_set) + mu_dbm_safety_set_owner (db, apop_database_owner); + rc = mu_dbm_safety_check (db); if (rc) { @@ -116,7 +119,7 @@ pop3d_apopuser (const char *user) FILE *apop_file; rc = mu_file_safety_check (apop_database_name, apop_database_safety, - apop_database_uid, NULL); + apop_database_owner, NULL); if (rc) { mu_diag_output (MU_DIAG_ERROR, diff --git a/pop3d/pop3d.c b/pop3d/pop3d.c index 17b59e1fb..3fe6c4ed7 100644 --- a/pop3d/pop3d.c +++ b/pop3d/pop3d.c @@ -33,6 +33,8 @@ int tls_required; int pop3d_xlines; char *apop_database_name = APOP_PASSFILE; int apop_database_safety = MU_FILE_SAFETY_ALL; +uid_t apop_database_owner; +int apop_database_owner_set; #ifdef WITH_TLS int tls_available; @@ -94,6 +96,33 @@ cb_apop_safety_checks (void *data, mu_config_value_t *arg) &apop_database_safety); } +static int +cb_apop_database_owner (void *data, mu_config_value_t *val) +{ + struct passwd *pw; + + if (mu_cfg_assert_value_type (val, MU_CFG_STRING)) + return 1; + pw = getpwnam (val->v.string); + if (!pw) + { + char *p; + unsigned long n; + + n = strtoul (val->v.string, &p, 10); + if (*p) + { + mu_error (_("no such user: %s"), val->v.string); + return 1; + } + apop_database_owner = n; + } + else + apop_database_owner = pw->pw_uid; + apop_database_owner_set = 1; + return 0; +} + #ifdef ENABLE_DBM static int cb_bulletin_db (void *data, mu_config_value_t *val) @@ -130,6 +159,8 @@ static struct mu_cfg_param pop3d_cfg_param[] = { N_("Output the number of lines in the message in its scan listing.") }, { "apop-database-file", mu_cfg_string, &apop_database_name, 0, NULL, N_("set APOP database file name or URL") }, + { "apop-database-owner", mu_cfg_callback, NULL, 0, cb_apop_database_owner, + N_("Name or UID of the APOP database owner") }, { "apop-database-safety", mu_cfg_callback, NULL, 0, cb_apop_safety_checks, N_("Configure safety checks for APOP database files. Argument is a list or " "sequence of check names optionally prefixed with '+' to enable or " diff --git a/pop3d/pop3d.h b/pop3d/pop3d.h index d9d4206bd..aa99ea4de 100644 --- a/pop3d/pop3d.h +++ b/pop3d/pop3d.h @@ -198,6 +198,8 @@ extern size_t pop3d_output_bufsize; extern int pop3d_xlines; extern char *apop_database_name; extern int apop_database_safety; +extern uid_t apop_database_owner; +extern int apop_database_owner_set; /* Safety checks for group-rw database files, such as stat and bulletin databases */ |