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