Commit c2149578 c21495784ae7f9551311a09e5d24d40df2354e48 by Sergey Poznyakoff

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.
1 parent ca898e17
......@@ -29,6 +29,10 @@ maidag_SOURCES=\
script.c\
util.c
if MU_COND_DBM
LIBMU_DBM=../libmu_dbm/libmu_dbm.la
endif
maidag_LDADD = \
@LIBMU_SCM@ @GUILE_LIBS@\
@LIBMU_SCM_DEPS@\
......@@ -46,7 +50,7 @@ maidag_LDADD = \
@MU_AUTHLIBS@\
${MU_LIB_MAILUTILS} \
@MU_COMMON_LIBRARIES@\
../libmu_dbm/libmu_dbm.la\
$(LIBMU_DBM)\
@DBMLIBS@\
@TCPWRAP_LIBRARIES@
......
......@@ -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,
......
......@@ -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 "
......
......@@ -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 */
......