|
Lines 16-21
RCSID("$OpenBSD: uidswap.c,v 1.24 2003/0
Link Here
|
| 16 |
|
16 |
|
| 17 |
#include "log.h" |
17 |
#include "log.h" |
| 18 |
#include "uidswap.h" |
18 |
#include "uidswap.h" |
|
|
19 |
#include "xmalloc.h" |
| 19 |
|
20 |
|
| 20 |
/* |
21 |
/* |
| 21 |
* Note: all these functions must work in all of the following cases: |
22 |
* Note: all these functions must work in all of the following cases: |
|
Lines 38-46
static gid_t saved_egid = 0;
Link Here
|
| 38 |
/* Saved effective uid. */ |
39 |
/* Saved effective uid. */ |
| 39 |
static int privileged = 0; |
40 |
static int privileged = 0; |
| 40 |
static int temporarily_use_uid_effective = 0; |
41 |
static int temporarily_use_uid_effective = 0; |
| 41 |
static gid_t saved_egroups[NGROUPS_MAX], user_groups[NGROUPS_MAX]; |
42 |
static gid_t *saved_egroups = NULL, *user_groups = NULL; |
| 42 |
static int saved_egroupslen = -1, user_groupslen = -1; |
43 |
static int saved_egroupslen = -1, user_groupslen = -1; |
| 43 |
|
44 |
|
|
|
45 |
static void |
| 46 |
init_saved_groups(void) |
| 47 |
{ |
| 48 |
if (saved_egroups == NULL) |
| 49 |
saved_egroups = xmalloc(NGROUPS_MAX * sizeof(*saved_egroups)); |
| 50 |
if (user_groups == NULL) |
| 51 |
user_groups = xmalloc(NGROUPS_MAX * sizeof(*user_groups)); |
| 52 |
} |
| 53 |
|
| 44 |
/* |
54 |
/* |
| 45 |
* Temporarily changes to the given uid. If the effective user |
55 |
* Temporarily changes to the given uid. If the effective user |
| 46 |
* id is not root, this does nothing. This call cannot be nested. |
56 |
* id is not root, this does nothing. This call cannot be nested. |
|
Lines 48-53
static int saved_egroupslen = -1, user_g
Link Here
|
| 48 |
void |
58 |
void |
| 49 |
temporarily_use_uid(struct passwd *pw) |
59 |
temporarily_use_uid(struct passwd *pw) |
| 50 |
{ |
60 |
{ |
|
|
61 |
init_saved_groups(); |
| 51 |
/* Save the current euid, and egroups. */ |
62 |
/* Save the current euid, and egroups. */ |
| 52 |
#ifdef SAVED_IDS_WORK_WITH_SETEUID |
63 |
#ifdef SAVED_IDS_WORK_WITH_SETEUID |
| 53 |
saved_euid = geteuid(); |
64 |
saved_euid = geteuid(); |