diff options
author | Volker Lendecke <vl@samba.org> | 2008-03-17 13:51:50 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2008-03-17 14:56:45 +0100 |
commit | c82e84862896b9753e63ca5a887639ee6c0137f3 (patch) | |
tree | aa72ffe20f88b05192b1270156e0b804a1914a04 /source3 | |
parent | 6a2a76bc9294b7bc8085ff5284a05a40adfa8f30 (diff) | |
download | samba-c82e84862896b9753e63ca5a887639ee6c0137f3.tar.gz samba-c82e84862896b9753e63ca5a887639ee6c0137f3.tar.bz2 samba-c82e84862896b9753e63ca5a887639ee6c0137f3.zip |
Add "net idmap aclmapset"
This is a merge from 3-0-ctdb that goes along with 1daad835, the option
nfs4:sidmap option
(This used to be commit f5e26d28be6581149bed0b599c38b82d1a44444e)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/utils/net_idmap.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c index 2a060d2f49..7ac2a82f6e 100644 --- a/source3/utils/net_idmap.c +++ b/source3/utils/net_idmap.c @@ -284,6 +284,70 @@ int net_help_idmap(int argc, const char **argv) return -1; } +static int net_idmap_aclmapset(int argc, const char **argv) +{ + TALLOC_CTX *mem_ctx; + int result = -1; + DOM_SID src_sid, dst_sid; + char *src, *dst; + struct db_context *db; + struct db_record *rec; + NTSTATUS status; + + if (argc != 3) { + d_fprintf(stderr, "usage: net idmap aclmapset <tdb> " + "<src-sid> <dst-sid>\n"); + return -1; + } + + if (!(mem_ctx = talloc_init("net idmap aclmapset"))) { + d_fprintf(stderr, "talloc_init failed\n"); + return -1; + } + + if (!(db = db_open(mem_ctx, argv[0], 0, TDB_DEFAULT, + O_RDWR|O_CREAT, 0600))) { + d_fprintf(stderr, "db_open failed: %s\n", strerror(errno)); + goto fail; + } + + if (!string_to_sid(&src_sid, argv[1])) { + d_fprintf(stderr, "%s is not a valid sid\n", argv[1]); + goto fail; + } + + if (!string_to_sid(&dst_sid, argv[2])) { + d_fprintf(stderr, "%s is not a valid sid\n", argv[2]); + goto fail; + } + + if (!(src = sid_string_talloc(mem_ctx, &src_sid)) + || !(dst = sid_string_talloc(mem_ctx, &dst_sid))) { + d_fprintf(stderr, "talloc_strdup failed\n"); + goto fail; + } + + if (!(rec = db->fetch_locked( + db, mem_ctx, string_term_tdb_data(src)))) { + d_fprintf(stderr, "could not fetch db record\n"); + goto fail; + } + + status = rec->store(rec, string_term_tdb_data(dst), 0); + TALLOC_FREE(rec); + + if (!NT_STATUS_IS_OK(status)) { + d_fprintf(stderr, "could not store record: %s\n", + nt_errstr(status)); + goto fail; + } + + result = 0; +fail: + TALLOC_FREE(mem_ctx); + return result; +} + /*********************************************************** Look at the current idmap **********************************************************/ @@ -295,6 +359,7 @@ int net_idmap(int argc, const char **argv) {"setmap", net_idmap_set }, {"delete", net_idmap_delete}, {"secret", net_idmap_secret}, + {"aclmapset", net_idmap_aclmapset}, {"help", net_help_idmap}, {NULL, NULL} }; |