[SCM] Samba Shared Repository - branch master updated
Michael Adam
obnox at samba.org
Tue Jan 29 07:38:03 MST 2013
The branch, master has been updated
via bab61a2 s3:utils/net remove aclmapset command
via 3a4ed48 s3:net_idmap_dump support dumping autorid backend
via 580008f s3:net_idmap_dump add missing braces
via e0bd87e s3:net_idmap_dump remove obsolete support for tdb:idmap2.tdb parameter
via 65268f4 s3:net_idmap_dump deal with idmap config * : backend config style
from e104e5a Regression test for bug #9571 - Unlink after open causes smbd to panic
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit bab61a21595070d29fc5822d1ec6747db641d26a
Author: Christian Ambach <ambi at samba.org>
Date: Fri Dec 7 12:33:38 2012 +0100
s3:utils/net remove aclmapset command
this was made for the nfs4:sidmap code that has been removed, so
this subcommand can also go away
Signed-off-by: Christian Ambach <ambi at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
Autobuild-User(master): Michael Adam <obnox at samba.org>
Autobuild-Date(master): Tue Jan 29 15:37:18 CET 2013 on sn-devel-104
commit 3a4ed4803f2b911e58420531548cb5658cb9fb74
Author: Christian Ambach <ambi at samba.org>
Date: Thu Nov 29 21:40:15 2012 +0100
s3:net_idmap_dump support dumping autorid backend
- remember the type of idmapping database (tdb or autorid)
this allows to make rest of the code (e.g. dump) know which database-style it will encounter
- add a seperate dump function for autorid
- default to TDB if db-file is given on the command-line
Pair-Programmed-With: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
Signed-off-by: Christian Ambach <ambi at samba.org>
Signed-off-by: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
Reviewed-by: Michael Adam <obnox at samba.org>
commit 580008f307e0883a11be6b1ece8342642760f41e
Author: Christian Ambach <ambi at samba.org>
Date: Tue Dec 4 15:11:50 2012 +0100
s3:net_idmap_dump add missing braces
see README.Coding
Signed-off-by: Christian Ambach <ambi at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit e0bd87ecc41dc4f61f7f545cd485f371eb75e8b0
Author: Christian Ambach <ambi at samba.org>
Date: Mon Dec 3 14:15:40 2012 +0100
s3:net_idmap_dump remove obsolete support for tdb:idmap2.tdb parameter
this one got removed from idmap_tdb2 a while ago
Signed-off-by: Christian Ambach <ambi at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit 65268f482d9103aff8a6e239c9b8cc53d07f760a
Author: Christian Ambach <ambi at samba.org>
Date: Thu Nov 29 21:39:54 2012 +0100
s3:net_idmap_dump deal with idmap config * : backend config style
this is the new config style since Samba 3.6 and should be detected by net idmap dump
Signed-off-by: Christian Ambach <ambi at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
-----------------------------------------------------------------------
Summary of changes:
source3/utils/net_idmap.c | 213 +++++++++++++++++++++++++-------------------
1 files changed, 121 insertions(+), 92 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c
index ebc14e5..1190627 100644
--- a/source3/utils/net_idmap.c
+++ b/source3/utils/net_idmap.c
@@ -35,11 +35,74 @@
return -1; \
} } while(0)
+enum idmap_dump_backend {
+ TDB,
+ AUTORID
+};
+
+struct idmap_dump_ctx {
+ enum idmap_dump_backend backend;
+};
+
+static int net_idmap_dump_one_autorid_entry(struct db_record *rec,
+ void *unused)
+{
+ TDB_DATA key;
+ TDB_DATA value;
+
+ key = dbwrap_record_get_key(rec);
+ value = dbwrap_record_get_value(rec);
+
+ if (strncmp((char *)key.dptr, "CONFIG", 6) == 0) {
+ char *config = talloc_array(talloc_tos(), char, value.dsize+1);
+ memcpy(config, value.dptr, value.dsize);
+ config[value.dsize] = '\0';
+ printf("CONFIG: %s\n", config);
+ talloc_free(config);
+ return 0;
+ }
+
+ if (strncmp((char *)key.dptr, "NEXT RANGE", 10) == 0) {
+ printf("RANGE HWM: %"PRIu32"\n", IVAL(value.dptr, 0));
+ return 0;
+ }
+
+ if (strncmp((char *)key.dptr, "NEXT ALLOC UID", 14) == 0) {
+ printf("UID HWM: %"PRIu32"\n", IVAL(value.dptr, 0));
+ return 0;
+ }
+
+ if (strncmp((char *)key.dptr, "NEXT ALLOC GID", 14) == 0) {
+ printf("GID HWM: %"PRIu32"\n", IVAL(value.dptr, 0));
+ return 0;
+ }
+
+ if (strncmp((char *)key.dptr, "UID", 3) == 0 ||
+ strncmp((char *)key.dptr, "GID", 3) == 0)
+ {
+ /* mapped entry from allocation pool */
+ printf("%s %s\n", value.dptr, key.dptr);
+ return 0;
+ }
+
+ if ((strncmp((char *)key.dptr, "S-1-5-", 6) == 0 ||
+ strncmp((char *)key.dptr, "ALLOC", 5) == 0) &&
+ value.dsize == sizeof(uint32_t))
+ {
+ /* this is a domain range assignment */
+ uint32_t range = IVAL(value.dptr, 0);
+ printf("RANGE %"PRIu32": %s\n", range, key.dptr);
+ return 0;
+ }
+
+ return 0;
+}
+
/***********************************************************
Helper function for net_idmap_dump. Dump one entry.
**********************************************************/
-static int net_idmap_dump_one_entry(struct db_record *rec,
- void *unused)
+static int net_idmap_dump_one_tdb_entry(struct db_record *rec,
+ void *unused)
{
TDB_DATA key;
TDB_DATA value;
@@ -57,48 +120,61 @@ static int net_idmap_dump_one_entry(struct db_record *rec,
return 0;
}
- if (strncmp((char *)key.dptr, "S-", 2) != 0)
+ if (strncmp((char *)key.dptr, "S-", 2) != 0) {
return 0;
+ }
printf("%s %s\n", value.dptr, key.dptr);
return 0;
}
-static const char* net_idmap_dbfile(struct net_context *c)
+static const char* net_idmap_dbfile(struct net_context *c,
+ struct idmap_dump_ctx *ctx)
{
const char* dbfile = NULL;
+ const char *backend = NULL;
+
+ /* prefer idmap config * : backend over idmap backend parameter */
+ backend = lp_parm_const_string(-1, "idmap config *", "backend", NULL);
+ if (!backend) {
+ backend = lp_idmap_backend();
+ }
if (c->opt_db != NULL) {
dbfile = talloc_strdup(talloc_tos(), c->opt_db);
if (dbfile == NULL) {
d_fprintf(stderr, _("Out of memory!\n"));
}
- } else if (strequal(lp_idmap_backend(), "tdb")) {
+ } else if (strequal(backend, "tdb")) {
dbfile = state_path("winbindd_idmap.tdb");
if (dbfile == NULL) {
d_fprintf(stderr, _("Out of memory!\n"));
}
- } else if (strequal(lp_idmap_backend(), "tdb2")) {
- dbfile = lp_parm_talloc_string(talloc_tos(),
- -1, "tdb", "idmap2.tdb", NULL);
+ ctx->backend = TDB;
+ } else if (strequal(backend, "tdb2")) {
+ dbfile = talloc_asprintf(talloc_tos(), "%s/idmap2.tdb",
+ lp_private_dir());
if (dbfile == NULL) {
- dbfile = talloc_asprintf(talloc_tos(), "%s/idmap2.tdb",
- lp_private_dir());
+ d_fprintf(stderr, _("Out of memory!\n"));
}
+ ctx->backend = TDB;
+ } else if (strequal(backend, "autorid")) {
+ dbfile = state_path("autorid.tdb");
if (dbfile == NULL) {
d_fprintf(stderr, _("Out of memory!\n"));
}
+ ctx->backend = AUTORID;
} else {
- char* backend = talloc_strdup(talloc_tos(), lp_idmap_backend());
- char* args = strchr(backend, ':');
+ char *_backend = talloc_strdup(talloc_tos(), backend);
+ char* args = strchr(_backend, ':');
if (args != NULL) {
*args = '\0';
}
d_printf(_("Sorry, 'idmap backend = %s' is currently not supported\n"),
- backend);
+ _backend);
- talloc_free(backend);
+ talloc_free(_backend);
}
return dbfile;
@@ -114,6 +190,7 @@ static int net_idmap_dump(struct net_context *c, int argc, const char **argv)
const char* dbfile;
NTSTATUS status;
int ret = -1;
+ struct idmap_dump_ctx ctx = { .backend = TDB };
if ( argc > 1 || c->display_usage) {
d_printf("%s\n%s",
@@ -126,7 +203,7 @@ static int net_idmap_dump(struct net_context *c, int argc, const char **argv)
mem_ctx = talloc_stackframe();
- dbfile = (argc > 0) ? argv[0] : net_idmap_dbfile(c);
+ dbfile = (argc > 0) ? argv[0] : net_idmap_dbfile(c, &ctx);
if (dbfile == NULL) {
goto done;
}
@@ -140,7 +217,15 @@ static int net_idmap_dump(struct net_context *c, int argc, const char **argv)
goto done;
}
- status = dbwrap_traverse_read(db, net_idmap_dump_one_entry, NULL, NULL);
+ if (ctx.backend == AUTORID) {
+ status = dbwrap_traverse_read(db,
+ net_idmap_dump_one_autorid_entry,
+ NULL, NULL);
+ } else {
+ status = dbwrap_traverse_read(db,
+ net_idmap_dump_one_tdb_entry,
+ NULL, NULL);
+ }
if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, _("error traversing the database\n"));
ret = -1;
@@ -207,6 +292,7 @@ static int net_idmap_restore(struct net_context *c, int argc, const char **argv)
struct db_context *db;
const char *dbfile = NULL;
int ret = 0;
+ struct idmap_dump_ctx ctx = { .backend = TDB };
if (c->display_usage) {
d_printf("%s\n%s",
@@ -221,13 +307,20 @@ static int net_idmap_restore(struct net_context *c, int argc, const char **argv)
mem_ctx = talloc_stackframe();
- dbfile = net_idmap_dbfile(c);
+ dbfile = net_idmap_dbfile(c, &ctx);
if (dbfile == NULL) {
ret = -1;
goto done;
}
+ if (ctx.backend != TDB) {
+ d_fprintf(stderr, _("Sorry, restoring of non-TDB databases is "
+ "currently not supported\n"));
+ ret = -1;
+ goto done;
+ }
+
d_fprintf(stderr, _("restoring id mapping to %s\n"), dbfile);
if (argc == 1) {
@@ -429,6 +522,7 @@ static int net_idmap_delete(struct net_context *c, int argc, const char **argv)
TDB_DATA key;
NTSTATUS status;
const char* dbfile;
+ struct idmap_dump_ctx ctx = { .backend = TDB };
if ( !delete_args_ok(argc,argv) || c->display_usage) {
d_printf("%s\n%s",
@@ -443,7 +537,7 @@ static int net_idmap_delete(struct net_context *c, int argc, const char **argv)
mem_ctx = talloc_stackframe();
- dbfile = net_idmap_dbfile(c);
+ dbfile = net_idmap_dbfile(c, &ctx);
if (dbfile == NULL) {
goto done;
}
@@ -570,6 +664,7 @@ static int net_idmap_check(struct net_context *c, int argc, const char **argv)
{
const char* dbfile;
struct check_options opts;
+ struct idmap_dump_ctx ctx = { .backend = TDB };
if ( argc > 1 || c->display_usage) {
d_printf("%s\n%s",
@@ -586,10 +681,17 @@ static int net_idmap_check(struct net_context *c, int argc, const char **argv)
return c->display_usage ? 0 : -1;
}
- dbfile = (argc > 0) ? argv[0] : net_idmap_dbfile(c);
+ dbfile = (argc > 0) ? argv[0] : net_idmap_dbfile(c, &ctx);
if (dbfile == NULL) {
return -1;
}
+
+ if (ctx.backend != TDB) {
+ d_fprintf(stderr, _("Sorry, checking of non-TDB databases is "
+ "currently not supported\n"));
+ return -1;
+ }
+
d_fprintf(stderr, _("check database: %s\n"), dbfile);
opts = (struct check_options) {
@@ -604,71 +706,6 @@ static int net_idmap_check(struct net_context *c, int argc, const char **argv)
return net_idmap_check_db(dbfile, &opts);
}
-static int net_idmap_aclmapset(struct net_context *c, int argc, const char **argv)
-{
- TALLOC_CTX *mem_ctx;
- int result = -1;
- struct dom_sid src_sid, dst_sid;
- char *src, *dst;
- struct db_context *db;
- struct db_record *rec;
- NTSTATUS status;
-
- if (argc != 3 || c->display_usage) {
- d_fprintf(stderr, "%s net idmap aclmapset <tdb> "
- "<src-sid> <dst-sid>\n", _("Usage:"));
- 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,
- DBWRAP_LOCK_ORDER_1))) {
- 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 = dbwrap_fetch_locked(
- db, mem_ctx, string_term_tdb_data(src)))) {
- d_fprintf(stderr, _("could not fetch db record\n"));
- goto fail;
- }
-
- status = dbwrap_record_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
**********************************************************/
@@ -716,14 +753,6 @@ int net_idmap(struct net_context *c, int argc, const char **argv)
" Set secret for specified domain")
},
{
- "aclmapset",
- net_idmap_aclmapset,
- NET_TRANSPORT_LOCAL,
- N_("Set acl map"),
- N_("net idmap aclmapset\n"
- " Set acl map")
- },
- {
"check",
net_idmap_check,
NET_TRANSPORT_LOCAL,
--
Samba Shared Repository
More information about the samba-cvs
mailing list