Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / util / set_eugid.h
blobf81e0c73a177d80ac6aa22b8ec434a8e51fe65fe
1 /* $NetBSD$ */
3 #ifndef _SET_EUGID_H_INCLUDED_
4 #define _SET_EUGID_H_INCLUDED_
6 /*++
7 /* NAME
8 /* set_eugid 3h
9 /* SUMMARY
10 /* set effective user and group attributes
11 /* SYNOPSIS
12 /* #include <set_eugid.h>
13 /* DESCRIPTION
14 /* .nf
16 /* External interface. */
18 extern void set_eugid(uid_t, gid_t);
21 * The following macros open and close a block that runs at a different
22 * privilege level. To make mistakes with stray curly braces less likely, we
23 * shape the macros below as the head and tail of a do-while loop.
25 #define SAVE_AND_SET_EUGID(uid, gid) do { \
26 uid_t __set_eugid_uid = geteuid(); \
27 gid_t __set_eugid_gid = getegid(); \
28 set_eugid((uid), (gid));
30 #define RESTORE_SAVED_EUGID() \
31 set_eugid(__set_eugid_uid, __set_eugid_gid); \
32 } while (0)
34 /* LICENSE
35 /* .ad
36 /* .fi
37 /* The Secure Mailer license must be distributed with this software.
38 /* AUTHOR(S)
39 /* Wietse Venema
40 /* IBM T.J. Watson Research
41 /* P.O. Box 704
42 /* Yorktown Heights, NY 10598, USA
43 /*--*/
45 #endif