Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / global / mark_corrupt.c
blob74337733e5f2b8df4ed6f64712a9fbf44c49a8e6
1 /* $NetBSD$ */
3 /*++
4 /* NAME
5 /* mark_corrupt 3
6 /* SUMMARY
7 /* mark queue file as corrupt
8 /* SYNOPSIS
9 /* #include <mark_corrupt.h>
11 /* char *mark_corrupt(src)
12 /* VSTREAM *src;
13 /* DESCRIPTION
14 /* The \fBmark_corrupt\fR() routine marks the specified open
15 /* queue file as corrupt, and returns a suitable delivery status
16 /* so that the queue manager will do the right thing.
17 /* LICENSE
18 /* .ad
19 /* .fi
20 /* The Secure Mailer license must be distributed with this software.
21 /* AUTHOR(S)
22 /* Wietse Venema
23 /* IBM T.J. Watson Research
24 /* P.O. Box 704
25 /* Yorktown Heights, NY 10598, USA
26 /*--*/
28 /* System library. */
30 #include <sys_defs.h>
31 #include <sys/stat.h>
32 #include <unistd.h>
34 /* Utility library. */
36 #include <msg.h>
37 #include <vstream.h>
38 #include <set_eugid.h>
40 /* Global library. */
42 #include <mail_queue.h>
43 #include <mail_params.h>
44 #include <deliver_request.h>
45 #include <mark_corrupt.h>
47 /* mark_corrupt - mark queue file as corrupt */
49 int mark_corrupt(VSTREAM *src)
51 const char *myname = "mark_corrupt";
52 uid_t saved_uid;
53 gid_t saved_gid;
56 * If not running as the mail system, change privileges first.
58 if ((saved_uid = geteuid()) != var_owner_uid) {
59 saved_gid = getegid();
60 set_eugid(var_owner_uid, var_owner_gid);
64 * For now, the result value is -1; this may become a bit mask, or
65 * something even more advanced than that, when the delivery status
66 * becomes more than just done/deferred.
68 msg_warn("corrupted queue file: %s", VSTREAM_PATH(src));
69 if (fchmod(vstream_fileno(src), MAIL_QUEUE_STAT_CORRUPT))
70 msg_fatal("%s: fchmod %s: %m", myname, VSTREAM_PATH(src));
73 * Restore privileges.
75 if (saved_uid != var_owner_uid)
76 set_eugid(saved_uid, saved_gid);
78 return (DEL_STAT_DEFER);