1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
5 /* Copyright (c) University of Cambridge 1995 - 2009 */
6 /* See the file NOTICE for conditions of use and distribution. */
9 #include "rf_functions.h"
12 /*************************************************
13 * Get uid/gid for a router *
14 *************************************************/
16 /* This function is called by routers to sort out the uid/gid values which are
17 passed with an address for use by local transports.
20 rblock the router block
21 addr the address being worked on
22 ugid pointer to a ugid block to fill in
24 Returns: TRUE if all goes well, else FALSE
28 rf_get_ugid(router_instance
*rblock
, address_item
*addr
, ugid_block
*ugid
)
30 struct passwd
*upw
= NULL
;
32 /* Initialize from fixed values */
34 ugid
->uid
= rblock
->uid
;
35 ugid
->gid
= rblock
->gid
;
36 ugid
->uid_set
= rblock
->uid_set
;
37 ugid
->gid_set
= rblock
->gid_set
;
38 ugid
->initgroups
= rblock
->initgroups
;
40 /* If there is no fixed uid set, see if there's a dynamic one that can
41 be expanded and possibly looked up. */
43 if (!ugid
->uid_set
&& rblock
->expand_uid
!= NULL
)
45 if (route_find_expanded_user(rblock
->expand_uid
, rblock
->name
, US
"router",
46 &upw
, &(ugid
->uid
), &(addr
->message
))) ugid
->uid_set
= TRUE
;
50 /* Likewise for the gid */
52 if (!ugid
->gid_set
&& rblock
->expand_gid
!= NULL
)
54 if (route_find_expanded_group(rblock
->expand_gid
, rblock
->name
, US
"router",
55 &(ugid
->gid
), &(addr
->message
))) ugid
->gid_set
= TRUE
;
59 /* If a uid is set, then a gid must also be available; use one from the passwd
60 lookup if it happened. */
62 if (ugid
->uid_set
&& !ugid
->gid_set
)
66 ugid
->gid
= upw
->pw_gid
;
71 addr
->message
= string_sprintf("user set without group for %s router",
80 /* End of rf_get_ugid.c */