summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-04-11 12:00:29 +0200
committerStefan Metzmacher <metze@samba.org>2008-04-11 15:59:33 +0200
commit08591d0095b80080d42b7292073ad59c58586155 (patch)
treeeb9761e3cd74a113afc99a527cb9183e97284476 /source3/utils
parentdc9569e45fe39a6376dcb9a39295ac296e449ee7 (diff)
downloadsamba-08591d0095b80080d42b7292073ad59c58586155.tar.gz
samba-08591d0095b80080d42b7292073ad59c58586155.tar.bz2
samba-08591d0095b80080d42b7292073ad59c58586155.zip
net_idmap: use wbcSet[U|G]idMapping() and wbcSet[U|G]idHwm() functions
metze (This used to be commit dc9a3f8db0af03b4e8223068857092fcaff404f2)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_idmap.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c
index f0c3e56ef3..b0024895f7 100644
--- a/source3/utils/net_idmap.c
+++ b/source3/utils/net_idmap.c
@@ -101,9 +101,10 @@ static int net_idmap_restore(int argc, const char **argv)
while (!feof(input)) {
char line[128], sid_string[128];
int len;
- DOM_SID sid;
- struct id_map map;
+ struct wbcDomainSid sid;
+ enum id_type type = ID_TYPE_NOT_SPECIFIED;
unsigned long idval;
+ wbcErr wbc_status;
if (fgets(line, 127, input) == NULL)
break;
@@ -114,21 +115,23 @@ static int net_idmap_restore(int argc, const char **argv)
line[len-1] = '\0';
if (sscanf(line, "GID %lu %128s", &idval, sid_string) == 2) {
- map.xid.type = ID_TYPE_GID;
- map.xid.id = idval;
+ type = ID_TYPE_GID;
} else if (sscanf(line, "UID %lu %128s", &idval, sid_string) == 2) {
- map.xid.type = ID_TYPE_UID;
- map.xid.id = idval;
+ type = ID_TYPE_UID;
} else if (sscanf(line, "USER HWM %lu", &idval) == 1) {
/* set uid hwm */
- if (! winbind_set_uid_hwm(idval)) {
- d_fprintf(stderr, "Could not set USER HWM\n");
+ wbc_status = wbcSetUidHwm(idval);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_fprintf(stderr, "Could not set USER HWM: %s\n",
+ wbcErrorString(wbc_status));
}
continue;
} else if (sscanf(line, "GROUP HWM %lu", &idval) == 1) {
/* set gid hwm */
- if (! winbind_set_gid_hwm(idval)) {
- d_fprintf(stderr, "Could not set GROUP HWM\n");
+ wbc_status = wbcSetGidHwm(idval);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_fprintf(stderr, "Could not set GROUP HWM: %s\n",
+ wbcErrorString(wbc_status));
}
continue;
} else {
@@ -136,20 +139,25 @@ static int net_idmap_restore(int argc, const char **argv)
continue;
}
- if (!string_to_sid(&sid, sid_string)) {
- d_fprintf(stderr, "ignoring invalid sid [%s]\n", sid_string);
+ wbc_status = wbcStringToSid(sid_string, &sid);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_fprintf(stderr, "ignoring invalid sid [%s]: %s\n",
+ sid_string, wbcErrorString(wbc_status));
continue;
}
- map.sid = &sid;
- if (!winbind_set_mapping(&map)) {
- d_fprintf(stderr, "Could not set mapping of %s %lu to sid %s\n",
- (map.xid.type == ID_TYPE_GID) ? "GID" : "UID",
- (unsigned long)map.xid.id,
- sid_string_tos(map.sid));
+ if (type == ID_TYPE_UID) {
+ wbc_status = wbcSetUidMapping(idval, &sid);
+ } else {
+ wbc_status = wbcSetGidMapping(idval, &sid);
+ }
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_fprintf(stderr, "Could not set mapping of %s %lu to sid %s: %s\n",
+ (type == ID_TYPE_GID) ? "GID" : "UID",
+ idval, sid_string,
+ wbcErrorString(wbc_status));
continue;
}
-
}
if (input != stdin) {