diff options
author | Jeremy Allison <jra@samba.org> | 2006-07-11 18:01:26 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:19:14 -0500 |
commit | fbdcf2663b56007a438ac4f0d8d82436b1bfe688 (patch) | |
tree | 4e42c1f061391cea3d640152fd240682cbf4fd9a /source3/utils/net_idmap.c | |
parent | 5bf62a0c3cc95abe918f3e772bb10e0a90fdce22 (diff) | |
download | samba-fbdcf2663b56007a438ac4f0d8d82436b1bfe688.tar.gz samba-fbdcf2663b56007a438ac4f0d8d82436b1bfe688.tar.bz2 samba-fbdcf2663b56007a438ac4f0d8d82436b1bfe688.zip |
r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need
to do the upper layer directories but this is what
everyone is waiting for....
Jeremy.
(This used to be commit 9dafb7f48ca3e7af956b0a7d1720c2546fc4cfb8)
Diffstat (limited to 'source3/utils/net_idmap.c')
-rw-r--r-- | source3/utils/net_idmap.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c index 47e1f93b69..87da952247 100644 --- a/source3/utils/net_idmap.c +++ b/source3/utils/net_idmap.c @@ -185,6 +185,7 @@ static NTSTATUS net_idmap_fixup_hwm(void) /*********************************************************** Write entries from stdin to current local idmap **********************************************************/ + static int net_idmap_restore(int argc, const char **argv) { if (!idmap_init(lp_idmap_backend())) { @@ -193,10 +194,11 @@ static int net_idmap_restore(int argc, const char **argv) } while (!feof(stdin)) { - fstring line, sid_string, fmt_string; + fstring line, sid_string, fmt_string1, fmt_string2; int len; unid_t id; - int type = ID_EMPTY; + enum idmap_type type; + unsigned long idval; DOM_SID sid; if (fgets(line, sizeof(line)-1, stdin) == NULL) @@ -207,20 +209,16 @@ static int net_idmap_restore(int argc, const char **argv) if ( (len > 0) && (line[len-1] == '\n') ) line[len-1] = '\0'; - /* Yuck - this is broken for sizeof(gid_t) != sizeof(int) */ - snprintf(fmt_string, sizeof(fmt_string), "GID %%d %%%us", FSTRING_LEN); - if (sscanf(line, fmt_string, &id.gid, sid_string) == 2) { - type = ID_GROUPID; - } - - /* Yuck - this is broken for sizeof(uid_t) != sizeof(int) */ + snprintf(fmt_string1, sizeof(fmt_string1), "GID %%ul %%%us", FSTRING_LEN); + snprintf(fmt_string2, sizeof(fmt_string2), "UID %%ul %%%us", FSTRING_LEN); - snprintf(fmt_string, sizeof(fmt_string), "UID %%d %%%us", FSTRING_LEN); - if (sscanf(line, fmt_string, &id.uid, sid_string) == 2) { + if (sscanf(line, fmt_string1, &idval, sid_string) == 2) { + type = ID_GROUPID; + id.gid = (gid_t)idval; + } else if (sscanf(line, fmt_string2, &idval, sid_string) == 2) { type = ID_USERID; - } - - if (type == ID_EMPTY) { + id.uid = (uid_t)idval; + } else { d_printf("ignoring invalid line [%s]\n", line); continue; } |