uidassume.c (910B)
1 /************************************************************************* 2 * This file is part of Crosroads 1.23, a load balancer and fail over 3 * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. 4 * Visit http://crossroads.e-tunity.com for information. 5 *************************************************************************/ 6 #include "crossroads.h" 7 8 void uid_assume() { 9 uid_set = 0; 10 gid_set = 0; 11 12 if (activeservice->uid) { 13 if (activeservice->gid) { 14 gid_org = getgid(); 15 if (setegid (activeservice->gid)) 16 error ("Service %s: cannot set effective gid to %d: %s", 17 activeservice->name, activeservice->gid, 18 strerror(errno)); 19 gid_set++; 20 } 21 uid_org = getuid(); 22 if (seteuid (activeservice->uid)) 23 error ("Service %s: cannot set effective uid to %d: %s", 24 activeservice->name, activeservice->uid, strerror(errno)); 25 uid_set++; 26 } 27 }