Commit e285e2d5 e285e2d5b3e1a53ca29971a1ef7a8dcbc45d2986 by Sergey Poznyakoff

* maidag/maidag.c (main): Fix autodetection of log_to_stderr.

* maidag/deliver.c, maidag/maidag.h, maidag/mailtmp.c: Rename
mailer_err to maidag_error.
* maidag/util.c (mailer_err): Rename to maidag_error. Print to
stderr only if log_to_stderr is set.
1 parent a574e78f
1 2008-03-03 Sergey Poznyakoff <gray@gnu.org.ua> 1 2008-03-03 Sergey Poznyakoff <gray@gnu.org.ua>
2 2
3 * maidag/maidag.c (main): Fix autodetection of log_to_stderr.
4 * maidag/deliver.c, maidag/maidag.h, maidag/mailtmp.c: Rename
5 mailer_err to maidag_error.
6 * maidag/util.c (mailer_err): Rename to maidag_error. Print to
7 stderr only if log_to_stderr is set.
8
3 Fix bootstrapping with gettext 0.17. 9 Fix bootstrapping with gettext 0.17.
4 10
5 * bootstrap.conf (avoided_gnulib_modules): Remove size_max 11 * bootstrap.conf (avoided_gnulib_modules): Remove size_max
......
1 /* GNU Mailutils -- a suite of utilities for electronic mail 1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000, 2001, 2002, 2005, 2 Copyright (C) 1999, 2000, 2001, 2002, 2005,
3 2007 Free Software Foundation, Inc. 3 2007, 2008 Free Software Foundation, Inc.
4 4
5 GNU Mailutils is free software; you can redistribute it and/or modify 5 GNU Mailutils is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
...@@ -159,7 +159,8 @@ deliver_to_user (mu_mailbox_t imbx, mu_mailbox_t mbox, mu_message_t msg, ...@@ -159,7 +159,8 @@ deliver_to_user (mu_mailbox_t imbx, mu_mailbox_t mbox, mu_message_t msg,
159 status = mu_mailbox_open (mbox, MU_STREAM_APPEND|MU_STREAM_CREAT); 159 status = mu_mailbox_open (mbox, MU_STREAM_APPEND|MU_STREAM_CREAT);
160 if (status != 0) 160 if (status != 0)
161 { 161 {
162 mailer_err (_("Cannot open mailbox %s: %s"), path, mu_strerror (status)); 162 maidag_error (_("Cannot open mailbox %s: %s"),
163 path, mu_strerror (status));
163 mu_mailbox_destroy (&mbox); 164 mu_mailbox_destroy (&mbox);
164 return EX_TEMPFAIL; 165 return EX_TEMPFAIL;
165 } 166 }
...@@ -176,8 +177,8 @@ deliver_to_user (mu_mailbox_t imbx, mu_mailbox_t mbox, mu_message_t msg, ...@@ -176,8 +177,8 @@ deliver_to_user (mu_mailbox_t imbx, mu_mailbox_t mbox, mu_message_t msg,
176 177
177 if (status) 178 if (status)
178 { 179 {
179 mailer_err (_("Cannot lock mailbox `%s': %s"), path, 180 maidag_error (_("Cannot lock mailbox `%s': %s"), path,
180 mu_strerror (status)); 181 mu_strerror (status));
181 mu_mailbox_destroy (&mbox); 182 mu_mailbox_destroy (&mbox);
182 exit_code = EX_TEMPFAIL; 183 exit_code = EX_TEMPFAIL;
183 return EX_TEMPFAIL; 184 return EX_TEMPFAIL;
...@@ -192,8 +193,8 @@ deliver_to_user (mu_mailbox_t imbx, mu_mailbox_t mbox, mu_message_t msg, ...@@ -192,8 +193,8 @@ deliver_to_user (mu_mailbox_t imbx, mu_mailbox_t mbox, mu_message_t msg,
192 193
193 if ((status = mu_mailbox_get_size (mbox, &mbsize))) 194 if ((status = mu_mailbox_get_size (mbox, &mbsize)))
194 { 195 {
195 mailer_err (_("Cannot get size of mailbox %s: %s"), 196 maidag_error (_("Cannot get size of mailbox %s: %s"),
196 path, mu_strerror (status)); 197 path, mu_strerror (status));
197 if (status == ENOSYS) 198 if (status == ENOSYS)
198 mbsize = 0; /* Try to continue anyway */ 199 mbsize = 0; /* Try to continue anyway */
199 else 200 else
...@@ -206,7 +207,7 @@ deliver_to_user (mu_mailbox_t imbx, mu_mailbox_t mbox, mu_message_t msg, ...@@ -206,7 +207,7 @@ deliver_to_user (mu_mailbox_t imbx, mu_mailbox_t mbox, mu_message_t msg,
206 switch (check_quota (auth, mbsize, &n)) 207 switch (check_quota (auth, mbsize, &n))
207 { 208 {
208 case MQUOTA_EXCEEDED: 209 case MQUOTA_EXCEEDED:
209 mailer_err (_("%s: mailbox quota exceeded for this recipient"), name); 210 maidag_error (_("%s: mailbox quota exceeded for this recipient"), name);
210 if (errp) 211 if (errp)
211 asprintf (errp, "%s: mailbox quota exceeded for this recipient", 212 asprintf (errp, "%s: mailbox quota exceeded for this recipient",
212 name); 213 name);
...@@ -220,16 +221,16 @@ deliver_to_user (mu_mailbox_t imbx, mu_mailbox_t mbox, mu_message_t msg, ...@@ -220,16 +221,16 @@ deliver_to_user (mu_mailbox_t imbx, mu_mailbox_t mbox, mu_message_t msg,
220 default: 221 default:
221 if ((status = mu_mailbox_get_size (imbx, &msg_size))) 222 if ((status = mu_mailbox_get_size (imbx, &msg_size)))
222 { 223 {
223 mailer_err (_("Cannot get message size (input message %s): %s"), 224 maidag_error (_("Cannot get message size (input message %s): %s"),
224 path, mu_strerror (status)); 225 path, mu_strerror (status));
225 exit_code = EX_UNAVAILABLE; 226 exit_code = EX_UNAVAILABLE;
226 failed++; 227 failed++;
227 } 228 }
228 else if (msg_size > n) 229 else if (msg_size > n)
229 { 230 {
230 mailer_err (_("%s: message would exceed maximum mailbox size for " 231 maidag_error (_("%s: message would exceed maximum mailbox size for "
231 "this recipient"), 232 "this recipient"),
232 name); 233 name);
233 if (errp) 234 if (errp)
234 asprintf (errp, 235 asprintf (errp,
235 "%s: message would exceed maximum mailbox size " 236 "%s: message would exceed maximum mailbox size "
...@@ -248,8 +249,8 @@ deliver_to_user (mu_mailbox_t imbx, mu_mailbox_t mbox, mu_message_t msg, ...@@ -248,8 +249,8 @@ deliver_to_user (mu_mailbox_t imbx, mu_mailbox_t mbox, mu_message_t msg,
248 status = mu_mailbox_append_message (mbox, msg); 249 status = mu_mailbox_append_message (mbox, msg);
249 if (status) 250 if (status)
250 { 251 {
251 mailer_err (_("Error writing to mailbox %s: %s"), 252 maidag_error (_("Error writing to mailbox %s: %s"),
252 path, mu_strerror (status)); 253 path, mu_strerror (status));
253 failed++; 254 failed++;
254 } 255 }
255 else 256 else
...@@ -257,8 +258,8 @@ deliver_to_user (mu_mailbox_t imbx, mu_mailbox_t mbox, mu_message_t msg, ...@@ -257,8 +258,8 @@ deliver_to_user (mu_mailbox_t imbx, mu_mailbox_t mbox, mu_message_t msg,
257 status = mu_mailbox_sync (mbox); 258 status = mu_mailbox_sync (mbox);
258 if (status) 259 if (status)
259 { 260 {
260 mailer_err (_("Error flushing mailbox %s: %s"), 261 maidag_error (_("Error flushing mailbox %s: %s"),
261 path, mu_strerror (status)); 262 path, mu_strerror (status));
262 failed++; 263 failed++;
263 } 264 }
264 } 265 }
...@@ -283,7 +284,7 @@ deliver (mu_mailbox_t imbx, char *name, char **errp) ...@@ -283,7 +284,7 @@ deliver (mu_mailbox_t imbx, char *name, char **errp)
283 auth = mu_get_auth_by_name (name); 284 auth = mu_get_auth_by_name (name);
284 if (!auth) 285 if (!auth)
285 { 286 {
286 mailer_err (_("%s: no such user"), name); 287 maidag_error (_("%s: no such user"), name);
287 if (errp) 288 if (errp)
288 asprintf (errp, "%s: no such user", name); 289 asprintf (errp, "%s: no such user", name);
289 exit_code = EX_UNAVAILABLE; 290 exit_code = EX_UNAVAILABLE;
...@@ -301,16 +302,16 @@ deliver (mu_mailbox_t imbx, char *name, char **errp) ...@@ -301,16 +302,16 @@ deliver (mu_mailbox_t imbx, char *name, char **errp)
301 302
302 if ((status = mu_mailbox_get_message (imbx, 1, &msg)) != 0) 303 if ((status = mu_mailbox_get_message (imbx, 1, &msg)) != 0)
303 { 304 {
304 mailer_err (_("Cannot get message from the temporary mailbox: %s"), 305 maidag_error (_("Cannot get message from the temporary mailbox: %s"),
305 mu_strerror (status)); 306 mu_strerror (status));
306 mu_auth_data_free (auth); 307 mu_auth_data_free (auth);
307 return EX_TEMPFAIL; 308 return EX_TEMPFAIL;
308 } 309 }
309 310
310 if ((status = mu_mailbox_create (&mbox, auth->mailbox)) != 0) 311 if ((status = mu_mailbox_create (&mbox, auth->mailbox)) != 0)
311 { 312 {
312 mailer_err (_("Cannot open mailbox %s: %s"), 313 maidag_error (_("Cannot open mailbox %s: %s"),
313 auth->mailbox, mu_strerror (status)); 314 auth->mailbox, mu_strerror (status));
314 mu_auth_data_free (auth); 315 mu_auth_data_free (auth);
315 return EX_TEMPFAIL; 316 return EX_TEMPFAIL;
316 } 317 }
......
...@@ -490,7 +490,7 @@ main (int argc, char *argv[]) ...@@ -490,7 +490,7 @@ main (int argc, char *argv[])
490 current_uid = getuid (); 490 current_uid = getuid ();
491 491
492 if (log_to_stderr == -1) 492 if (log_to_stderr == -1)
493 log_to_stderr = (getuid () != 0); 493 log_to_stderr = !lmtp_mode && (current_uid != 0);
494 494
495 if (!log_to_stderr) 495 if (!log_to_stderr)
496 { 496 {
...@@ -502,7 +502,7 @@ main (int argc, char *argv[]) ...@@ -502,7 +502,7 @@ main (int argc, char *argv[])
502 502
503 mu_debug_default_printer = mu_debug_syslog_printer; 503 mu_debug_default_printer = mu_debug_syslog_printer;
504 } 504 }
505 505
506 argc -= arg_index; 506 argc -= arg_index;
507 argv += arg_index; 507 argv += arg_index;
508 508
......
...@@ -136,7 +136,7 @@ int maidag_lmtp_server (void); ...@@ -136,7 +136,7 @@ int maidag_lmtp_server (void);
136 int lmtp_connection (int fd, struct sockaddr *sa, int salen, void *data, 136 int lmtp_connection (int fd, struct sockaddr *sa, int salen, void *data,
137 mu_ip_server_t srv, time_t timeout, int transcript); 137 mu_ip_server_t srv, time_t timeout, int transcript);
138 138
139 void mailer_err (const char *fmt, ...) MU_PRINTFLIKE(1, 2); 139 void maidag_error (const char *fmt, ...) MU_PRINTFLIKE(1, 2);
140 void notify_biff (mu_mailbox_t mbox, char *name, size_t size); 140 void notify_biff (mu_mailbox_t mbox, char *name, size_t size);
141 void guess_retval (int ec); 141 void guess_retval (int ec);
142 142
......
...@@ -44,16 +44,16 @@ mail_tmp_begin (struct mail_tmp **pmtmp, const char *from) ...@@ -44,16 +44,16 @@ mail_tmp_begin (struct mail_tmp **pmtmp, const char *from)
44 MU_STREAM_RDWR))) 44 MU_STREAM_RDWR)))
45 { 45 {
46 free (mtmp); 46 free (mtmp);
47 mailer_err (_("Unable to open temporary file: %s"), 47 maidag_error (_("Unable to open temporary file: %s"),
48 mu_strerror (status)); 48 mu_strerror (status));
49 return status; 49 return status;
50 } 50 }
51 51
52 if ((status = mu_stream_open (mtmp->stream))) 52 if ((status = mu_stream_open (mtmp->stream)))
53 { 53 {
54 free (mtmp); 54 free (mtmp);
55 mailer_err (_("unable to open temporary file: %s"), 55 maidag_error (_("unable to open temporary file: %s"),
56 mu_strerror (status)); 56 mu_strerror (status));
57 return status; 57 return status;
58 } 58 }
59 mtmp->from = from; 59 mtmp->from = from;
...@@ -94,7 +94,7 @@ mail_tmp_add_line (struct mail_tmp *mtmp, char *buf, size_t buflen) ...@@ -94,7 +94,7 @@ mail_tmp_add_line (struct mail_tmp *mtmp, char *buf, size_t buflen)
94 } 94 }
95 else 95 else
96 { 96 {
97 mailer_err (_("Cannot determine sender address")); 97 maidag_error (_("Cannot determine sender address"));
98 return EINVAL; 98 return EINVAL;
99 } 99 }
100 if (auth) 100 if (auth)
...@@ -112,7 +112,8 @@ mail_tmp_add_line (struct mail_tmp *mtmp, char *buf, size_t buflen) ...@@ -112,7 +112,8 @@ mail_tmp_add_line (struct mail_tmp *mtmp, char *buf, size_t buflen)
112 112
113 if (status) 113 if (status)
114 { 114 {
115 mailer_err (_("Error writing temporary file: %s"), mu_strerror (status)); 115 maidag_error (_("Error writing temporary file: %s"),
116 mu_strerror (status));
116 mu_stream_destroy (&mtmp->stream, mu_stream_get_owner (mtmp->stream)); 117 mu_stream_destroy (&mtmp->stream, mu_stream_get_owner (mtmp->stream));
117 } 118 }
118 mtmp->had_nl = buf[buflen-1] == '\n'; 119 mtmp->had_nl = buf[buflen-1] == '\n';
...@@ -137,7 +138,8 @@ mail_tmp_finish (struct mail_tmp *mtmp, mu_mailbox_t *mbox) ...@@ -137,7 +138,8 @@ mail_tmp_finish (struct mail_tmp *mtmp, mu_mailbox_t *mbox)
137 if (status) 138 if (status)
138 { 139 {
139 errno = status; 140 errno = status;
140 mailer_err (_("Error writing temporary file: %s"), mu_strerror (status)); 141 maidag_error (_("Error writing temporary file: %s"),
142 mu_strerror (status));
141 mu_stream_destroy (&mtmp->stream, mu_stream_get_owner (mtmp->stream)); 143 mu_stream_destroy (&mtmp->stream, mu_stream_get_owner (mtmp->stream));
142 return status; 144 return status;
143 } 145 }
...@@ -147,7 +149,8 @@ mail_tmp_finish (struct mail_tmp *mtmp, mu_mailbox_t *mbox) ...@@ -147,7 +149,8 @@ mail_tmp_finish (struct mail_tmp *mtmp, mu_mailbox_t *mbox)
147 || (status = mu_mailbox_open (*mbox, MU_STREAM_READ)) 149 || (status = mu_mailbox_open (*mbox, MU_STREAM_READ))
148 || (status = mu_mailbox_set_stream (*mbox, mtmp->stream))) 150 || (status = mu_mailbox_set_stream (*mbox, mtmp->stream)))
149 { 151 {
150 mailer_err (_("Error opening temporary file: %s"), mu_strerror (status)); 152 maidag_error (_("Error opening temporary file: %s"),
153 mu_strerror (status));
151 mu_stream_destroy (&mtmp->stream, mu_stream_get_owner (mtmp->stream)); 154 mu_stream_destroy (&mtmp->stream, mu_stream_get_owner (mtmp->stream));
152 return status; 155 return status;
153 } 156 }
...@@ -156,8 +159,8 @@ mail_tmp_finish (struct mail_tmp *mtmp, mu_mailbox_t *mbox) ...@@ -156,8 +159,8 @@ mail_tmp_finish (struct mail_tmp *mtmp, mu_mailbox_t *mbox)
156 if (status) 159 if (status)
157 { 160 {
158 errno = status; 161 errno = status;
159 mailer_err (_("Error creating temporary message: %s"), 162 maidag_error (_("Error creating temporary message: %s"),
160 mu_strerror (status)); 163 mu_strerror (status));
161 mu_stream_destroy (&mtmp->stream, mu_stream_get_owner (mtmp->stream)); 164 mu_stream_destroy (&mtmp->stream, mu_stream_get_owner (mtmp->stream));
162 return status; 165 return status;
163 } 166 }
......
...@@ -58,19 +58,19 @@ switch_user_id (struct mu_auth_data *auth, int user) ...@@ -58,19 +58,19 @@ switch_user_id (struct mu_auth_data *auth, int user)
58 # error "No way to reset user privileges?" 58 # error "No way to reset user privileges?"
59 #endif 59 #endif
60 if (rc < 0) 60 if (rc < 0)
61 mailer_err ("setreuid(0, %d): %s (r=%d, e=%d)", 61 maidag_error ("setreuid(0, %d): %s (r=%d, e=%d)",
62 uid, strerror (errno), getuid (), geteuid ()); 62 uid, strerror (errno), getuid (), geteuid ());
63 return rc; 63 return rc;
64 } 64 }
65 65
66 void 66 void
67 mailer_err (const char *fmt, ...) 67 maidag_error (const char *fmt, ...)
68 { 68 {
69 va_list ap; 69 va_list ap;
70 70
71 guess_retval (errno); 71 guess_retval (errno);
72 va_start (ap, fmt); 72 va_start (ap, fmt);
73 if (!lmtp_mode && !log_to_stderr) 73 if (log_to_stderr)
74 { 74 {
75 vfprintf (stderr, fmt, ap); 75 vfprintf (stderr, fmt, ap);
76 fputc ('\n', stderr); 76 fputc ('\n', stderr);
......