114 #include <sys/stat.h>
177 #define REMOVE_MESSAGE_FILE 1
178 #define KEEP_MESSAGE_FILE 2
188 static int file_read_error(
PICKUP_INFO *info,
int type)
190 msg_warn(
"uid=%ld: unexpected or malformed record type %d",
191 (
long) info->
st.st_uid, type);
197 static int cleanup_service_error_reason(
PICKUP_INFO *info,
int status,
209 if (reason == 0 || *reason == 0)
210 msg_warn(
"%s: error writing %s: %s",
216 #define cleanup_service_error(info, status) \
217 cleanup_service_error_reason((info), (status), (char *) 0)
243 || strchr(expected, type) == 0)
244 return (file_read_error(info, type));
247 if (type == *expected)
255 (
long) info->
st.st_mtime);
284 &attr_name, &attr_value) == 0
315 time_t now = time((time_t *) 0);
325 #define DAY_SECONDS 86400
326 #define HOUR_SECONDS 3600
329 msg_warn(
"%s: message dated %ld seconds into the future",
330 info->
id, (
long) (info->
st.st_mtime - now));
331 info->
st.st_mtime = now;
333 msg_warn(
"%s: message has been queued for %d days",
351 msg_warn(
"%s: uid=%ld: no envelope sender",
352 info->
id, (
long) info->
st.st_uid);
360 #define MAIL_IS_REQUEUED(info) \
361 ((info)->st.st_uid == var_owner_uid && ((info)->st.st_mode & S_IROTH) == 0)
364 msg_info(
"%s: uid=%d from=<%s> orig_id=%s", info->
id,
365 (
int) info->
st.st_uid, info->
sender,
366 ((name = strrchr(info->
path,
'/')) != 0 ?
367 name + 1 : info->
path));
370 (
int) info->
st.st_uid, info->
sender);
388 if ((status = copy_segment(qfile, cleanup, info, buf,
REC_TYPE_CONTENT)) != 0)
398 if ((status = copy_segment(qfile, cleanup, info, buf,
REC_TYPE_EXTRACT)) != 0)
420 return (cleanup_service_error_reason(info, status,
vstring_str(buf)));
444 (
struct stat *) 0, -1, -1, buf);
450 msg_warn(
"if this file was created by Postfix < 1.1, then you may have to chmod a+r %s/%s",
491 status = pickup_copy(qfile, cleanup, info, buf);
512 #define SAFE_FREE(x) { if (x) myfree(x); }
521 static void pickup_service(
char *unused_buf, ssize_t unused_len,
522 char *unused_service,
char **argv)
535 msg_fatal(
"unexpected command-line argument: %s", argv[0]);
566 }
while (file_count);
571 static void post_jail_init(
char *unused_name,
char **unused_argv)
592 int main(
int argc,
char **argv)
#define MAIL_SRC_MASK_SENDMAIL
#define CA_MAIL_SERVER_WATCHDOG(v)
VSTREAM * mail_connect_wait(const char *class, const char *name)
char * mystrdup(const char *str)
char * var_cleanup_service
int smtputf8_autodetect(int class)
const char * mail_date(time_t when)
#define CA_MAIL_SERVER_STR_TABLE(v)
#define cleanup_service_error(info, status)
#define ATTR_FLAG_MISSING
int REMOVE(const char *path)
#define CLEANUP_FLAG_BOUNCE
int pickup_input_transp_mask
#define CLEANUP_FLAG_MILTER
#define RECV_ATTR_INT(name, val)
NORETURN trigger_server_main(int, char **, TRIGGER_SERVER_FN,...)
const char * split_nameval(char *buf, char **name, char **value)
MAIL_VERSION_STAMP_DECLARE
SCAN_DIR * scan_dir_open(const char *path)
#define MAIL_CLASS_PUBLIC
#define CA_MAIL_SERVER_POST_INIT(v)
#define REC_PUT_BUF(v, t, b)
int main(int argc, char **argv)
int vstream_fclose(VSTREAM *stream)
SCAN_DIR * scan_dir_close(SCAN_DIR *scan)
int rec_fputs(VSTREAM *stream, int type, const char *str)
int mail_open_ok(const char *queue_name, const char *queue_id, struct stat *statp, const char **path)
void msg_warn(const char *fmt,...)
VSTRING * vstring_alloc(ssize_t len)
#define MAIL_VERSION_STAMP_ALLOCATE
#define SEND_ATTR_INT(name, val)
int rec_attr_map(const char *attr_name)
#define MAIL_QUEUE_MAILDROP
int rec_put(VSTREAM *stream, int type, const char *data, ssize_t len)
NORETURN msg_fatal(const char *fmt,...)
#define CLEANUP_FLAG_MASK_EXTERNAL
#define REMOVE_MESSAGE_FILE
#define KEEP_MESSAGE_FILE
void set_ugid(uid_t uid, gid_t gid)
#define CLEANUP_STAT_RCPT
VSTREAM * safe_open(const char *path, int flags, mode_t mode, struct stat *st, uid_t user, gid_t group, VSTRING *why)
VSTRING * vstring_free(VSTRING *vp)
#define CA_MAIL_SERVER_SOLITARY
#define CLEANUP_STAT_WRITE
const char * cleanup_strerror(unsigned status)
#define MAIL_ATTR_QUEUEID
#define rec_get(fp, buf, limit)
int rec_fprintf(VSTREAM *stream, int type, const char *format,...)
#define MAIL_IS_REQUEUED(info)
char * scan_dir_next(SCAN_DIR *scan)
#define RECV_ATTR_STR(name, val)
void msg_info(const char *fmt,...)
#define REC_TYPE_ENVELOPE