1 /* $NetBSD: set_eugid.h,v 1.1.1.1 2009/06/23 10:09:00 tron Exp $ */ 2 3 #ifndef _SET_EUGID_H_INCLUDED_ 4 #define _SET_EUGID_H_INCLUDED_ 5 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 15 16 /* External interface. */ 17 18 extern void set_eugid(uid_t, gid_t); 19 20 /* 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. 24 */ 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)); 29 30 #define RESTORE_SAVED_EUGID() \ 31 set_eugid(__set_eugid_uid, __set_eugid_gid); \ 32 } while (0) 33 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 /*--*/ 44 45 #endif 46