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