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=\ ...@@ -29,6 +29,10 @@ maidag_SOURCES=\
29 script.c\ 29 script.c\
30 util.c 30 util.c
31 31
32 if MU_COND_DBM
33 LIBMU_DBM=../libmu_dbm/libmu_dbm.la
34 endif
35
32 maidag_LDADD = \ 36 maidag_LDADD = \
33 @LIBMU_SCM@ @GUILE_LIBS@\ 37 @LIBMU_SCM@ @GUILE_LIBS@\
34 @LIBMU_SCM_DEPS@\ 38 @LIBMU_SCM_DEPS@\
...@@ -46,7 +50,7 @@ maidag_LDADD = \ ...@@ -46,7 +50,7 @@ maidag_LDADD = \
46 @MU_AUTHLIBS@\ 50 @MU_AUTHLIBS@\
47 ${MU_LIB_MAILUTILS} \ 51 ${MU_LIB_MAILUTILS} \
48 @MU_COMMON_LIBRARIES@\ 52 @MU_COMMON_LIBRARIES@\
49 ../libmu_dbm/libmu_dbm.la\ 53 $(LIBMU_DBM)\
50 @DBMLIBS@\ 54 @DBMLIBS@\
51 @TCPWRAP_LIBRARIES@ 55 @TCPWRAP_LIBRARIES@
52 56
......
...@@ -57,6 +57,9 @@ pop3d_apopuser (const char *user) ...@@ -57,6 +57,9 @@ pop3d_apopuser (const char *user)
57 return NULL; 57 return NULL;
58 } 58 }
59 59
60 if (apop_database_owner_set)
61 mu_dbm_safety_set_owner (db, apop_database_owner);
62
60 rc = mu_dbm_safety_check (db); 63 rc = mu_dbm_safety_check (db);
61 if (rc) 64 if (rc)
62 { 65 {
...@@ -116,7 +119,7 @@ pop3d_apopuser (const char *user) ...@@ -116,7 +119,7 @@ pop3d_apopuser (const char *user)
116 FILE *apop_file; 119 FILE *apop_file;
117 120
118 rc = mu_file_safety_check (apop_database_name, apop_database_safety, 121 rc = mu_file_safety_check (apop_database_name, apop_database_safety,
119 apop_database_uid, NULL); 122 apop_database_owner, NULL);
120 if (rc) 123 if (rc)
121 { 124 {
122 mu_diag_output (MU_DIAG_ERROR, 125 mu_diag_output (MU_DIAG_ERROR,
......
...@@ -33,6 +33,8 @@ int tls_required; ...@@ -33,6 +33,8 @@ int tls_required;
33 int pop3d_xlines; 33 int pop3d_xlines;
34 char *apop_database_name = APOP_PASSFILE; 34 char *apop_database_name = APOP_PASSFILE;
35 int apop_database_safety = MU_FILE_SAFETY_ALL; 35 int apop_database_safety = MU_FILE_SAFETY_ALL;
36 uid_t apop_database_owner;
37 int apop_database_owner_set;
36 38
37 #ifdef WITH_TLS 39 #ifdef WITH_TLS
38 int tls_available; 40 int tls_available;
...@@ -94,6 +96,33 @@ cb_apop_safety_checks (void *data, mu_config_value_t *arg) ...@@ -94,6 +96,33 @@ cb_apop_safety_checks (void *data, mu_config_value_t *arg)
94 &apop_database_safety); 96 &apop_database_safety);
95 } 97 }
96 98
99 static int
100 cb_apop_database_owner (void *data, mu_config_value_t *val)
101 {
102 struct passwd *pw;
103
104 if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
105 return 1;
106 pw = getpwnam (val->v.string);
107 if (!pw)
108 {
109 char *p;
110 unsigned long n;
111
112 n = strtoul (val->v.string, &p, 10);
113 if (*p)
114 {
115 mu_error (_("no such user: %s"), val->v.string);
116 return 1;
117 }
118 apop_database_owner = n;
119 }
120 else
121 apop_database_owner = pw->pw_uid;
122 apop_database_owner_set = 1;
123 return 0;
124 }
125
97 #ifdef ENABLE_DBM 126 #ifdef ENABLE_DBM
98 static int 127 static int
99 cb_bulletin_db (void *data, mu_config_value_t *val) 128 cb_bulletin_db (void *data, mu_config_value_t *val)
...@@ -130,6 +159,8 @@ static struct mu_cfg_param pop3d_cfg_param[] = { ...@@ -130,6 +159,8 @@ static struct mu_cfg_param pop3d_cfg_param[] = {
130 N_("Output the number of lines in the message in its scan listing.") }, 159 N_("Output the number of lines in the message in its scan listing.") },
131 { "apop-database-file", mu_cfg_string, &apop_database_name, 0, NULL, 160 { "apop-database-file", mu_cfg_string, &apop_database_name, 0, NULL,
132 N_("set APOP database file name or URL") }, 161 N_("set APOP database file name or URL") },
162 { "apop-database-owner", mu_cfg_callback, NULL, 0, cb_apop_database_owner,
163 N_("Name or UID of the APOP database owner") },
133 { "apop-database-safety", mu_cfg_callback, NULL, 0, cb_apop_safety_checks, 164 { "apop-database-safety", mu_cfg_callback, NULL, 0, cb_apop_safety_checks,
134 N_("Configure safety checks for APOP database files. Argument is a list or " 165 N_("Configure safety checks for APOP database files. Argument is a list or "
135 "sequence of check names optionally prefixed with '+' to enable or " 166 "sequence of check names optionally prefixed with '+' to enable or "
......
...@@ -198,6 +198,8 @@ extern size_t pop3d_output_bufsize; ...@@ -198,6 +198,8 @@ extern size_t pop3d_output_bufsize;
198 extern int pop3d_xlines; 198 extern int pop3d_xlines;
199 extern char *apop_database_name; 199 extern char *apop_database_name;
200 extern int apop_database_safety; 200 extern int apop_database_safety;
201 extern uid_t apop_database_owner;
202 extern int apop_database_owner_set;
201 203
202 /* Safety checks for group-rw database files, such as stat and bulletin 204 /* Safety checks for group-rw database files, such as stat and bulletin
203 databases */ 205 databases */
......