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