[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Wed Nov 16 03:11:04 UTC 2016
The branch, master has been updated
via 08d1ac0 nss_wins: Fix errno values for HOST_NOT_FOUND
via 233b903 s3:net: Use messaging_init_client()
via 4c6f7b1 s3:rpcclient: Use messaging_init_client()
via acf2e77 s3:messaging: Add messaging_init_client() function
via ad8c717 s3:messaging: Create an messaging_init_internal() returning NTSTATUS
via 9347a2c s3:rpcclient: Print a new line on exit
via 69329cf lib:util: Don't print lstat warning on ERROR debug level
via 39fcdad s3:tests: Set missing directories for test_registry_upgrade.sh
from 31ee1c5 s3-winbind: Directly pass creds with cli_session_setup_creds()
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 08d1ac0e36339e97e4464f6a6724464b0a568347
Author: Andreas Schneider <asn at samba.org>
Date: Sun Nov 13 17:40:21 2016 +0100
nss_wins: Fix errno values for HOST_NOT_FOUND
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12269
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Wed Nov 16 04:10:55 CET 2016 on sn-devel-144
commit 233b903f3ffaae702c4d4e984ddc8a7871b47529
Author: Andreas Schneider <asn at samba.org>
Date: Mon Nov 14 09:54:53 2016 +0100
s3:net: Use messaging_init_client()
Pair-Programmed-With: Jeremy Allison <jra at samba.org>
Signed-off-by: Andreas Schneider <asn at samba.org>
Signed-off-by: Jeremy Allison <jra at samba.org>
commit 4c6f7b18f6bab6b991c678b1b010dc96a0a46f01
Author: Andreas Schneider <asn at samba.org>
Date: Mon Nov 14 09:51:52 2016 +0100
s3:rpcclient: Use messaging_init_client()
Pair-Programmed-With: Jeremy Allison <jra at samba.org>
Signed-off-by: Andreas Schneider <asn at samba.org>
Signed-off-by: Jeremy Allison <jra at samba.org>
commit acf2e77473ba69ee74cf42527cacad06bb588cdf
Author: Andreas Schneider <asn at samba.org>
Date: Mon Nov 14 09:49:20 2016 +0100
s3:messaging: Add messaging_init_client() function
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit ad8c7171ba86e8a47d78b0c7329bb814e5a8871e
Author: Andreas Schneider <asn at samba.org>
Date: Mon Nov 14 09:42:51 2016 +0100
s3:messaging: Create an messaging_init_internal() returning NTSTATUS
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 9347a2c9548df0d134ad105f92e4183ce04d7517
Author: Andreas Schneider <asn at samba.org>
Date: Mon Nov 14 11:36:03 2016 +0100
s3:rpcclient: Print a new line on exit
If you press 'ctrl+d' print a new line for the shell.
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 69329cf22c7a7cc620f14e7a94eb9a4419723f49
Author: Andreas Schneider <asn at samba.org>
Date: Mon Nov 14 11:31:20 2016 +0100
lib:util: Don't print lstat warning on ERROR debug level
If we are a client and can't access the lock directory don't confuse a
user.
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 39fcdadc0f47f243a5e480c3c86a4d69f63e767b
Author: Andreas Schneider <asn at samba.org>
Date: Tue Nov 15 10:58:48 2016 +0100
s3:tests: Set missing directories for test_registry_upgrade.sh
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/util/util.c | 4 +-
nsswitch/wins.c | 3 +-
source3/include/messages.h | 3 +
source3/lib/messages.c | 125 +++++++++++++++++---------
source3/rpcclient/rpcclient.c | 20 ++++-
source3/script/tests/test_registry_upgrade.sh | 2 +
source3/utils/net.c | 22 +++--
7 files changed, 125 insertions(+), 54 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/util/util.c b/lib/util/util.c
index a8bbc15..56056a3 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -202,8 +202,8 @@ _PUBLIC_ bool directory_create_or_exist(const char *dname,
}
if (errno != ENOENT) {
- DEBUG(0, ("lstat failed on directory %s: %s\n",
- dname, strerror(errno)));
+ DBG_WARNING("lstat failed on directory %s: %s\n",
+ dname, strerror(errno));
return false;
}
diff --git a/nsswitch/wins.c b/nsswitch/wins.c
index dccb6dd..19d3c5b 100644
--- a/nsswitch/wins.c
+++ b/nsswitch/wins.c
@@ -260,8 +260,7 @@ _nss_wins_gethostbyname_r(const char *hostname,
ip = lookup_byname_backend(name);
if (ip == NULL) {
- *errnop = EINVAL;
- *h_errnop = NETDB_INTERNAL;
+ *h_errnop = HOST_NOT_FOUND;
nss_status = NSS_STATUS_NOTFOUND;
goto out;
}
diff --git a/source3/include/messages.h b/source3/include/messages.h
index 1b4e2f6..ea89383 100644
--- a/source3/include/messages.h
+++ b/source3/include/messages.h
@@ -75,6 +75,9 @@ struct ctdbd_connection *messaging_ctdbd_connection(void);
struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev);
+NTSTATUS messaging_init_client(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct messaging_context **pmsg_ctx);
struct server_id messaging_server_id(const struct messaging_context *msg_ctx);
struct tevent_context *messaging_tevent_context(
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 08942a6..505eb66 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -234,67 +234,77 @@ static const char *private_path(const char *name)
return talloc_asprintf(talloc_tos(), "%s/%s", lp_private_dir(), name);
}
-struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev)
+static NTSTATUS messaging_init_internal(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct messaging_context **pmsg_ctx)
{
+ TALLOC_CTX *frame;
struct messaging_context *ctx;
+ NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
int ret;
const char *lck_path;
const char *priv_path;
bool ok;
- if (!(ctx = talloc_zero(mem_ctx, struct messaging_context))) {
- return NULL;
- }
-
- ctx->id = (struct server_id) {
- .pid = getpid(), .vnn = NONCLUSTER_VNN
- };
-
- ctx->event_ctx = ev;
-
- sec_init();
-
lck_path = lock_path("msg.lock");
if (lck_path == NULL) {
- TALLOC_FREE(ctx);
- return NULL;
+ return NT_STATUS_NO_MEMORY;
}
- ok = directory_create_or_exist_strict(lck_path, sec_initial_uid(),
+ ok = directory_create_or_exist_strict(lck_path,
+ sec_initial_uid(),
0755);
if (!ok) {
- DEBUG(10, ("%s: Could not create lock directory: %s\n",
- __func__, strerror(errno)));
- TALLOC_FREE(ctx);
- return NULL;
+ DBG_DEBUG("Could not create lock directory: %s\n",
+ strerror(errno));
+ return NT_STATUS_ACCESS_DENIED;
}
priv_path = private_path("msg.sock");
if (priv_path == NULL) {
- TALLOC_FREE(ctx);
- return NULL;
+ return NT_STATUS_NO_MEMORY;
}
ok = directory_create_or_exist_strict(priv_path, sec_initial_uid(),
0700);
if (!ok) {
- DEBUG(10, ("%s: Could not create msg directory: %s\n",
- __func__, strerror(errno)));
- TALLOC_FREE(ctx);
- return NULL;
+ DBG_DEBUG("Could not create msg directory: %s\n",
+ strerror(errno));
+ return NT_STATUS_ACCESS_DENIED;
}
- ctx->msg_dgm_ref = messaging_dgm_ref(
- ctx, ctx->event_ctx, &ctx->id.unique_id,
- priv_path, lck_path, messaging_recv_cb, ctx, &ret);
+ frame = talloc_stackframe();
+ if (frame == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ctx = talloc_zero(frame, struct messaging_context);
+ if (ctx == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+ ctx->id = (struct server_id) {
+ .pid = getpid(), .vnn = NONCLUSTER_VNN
+ };
+
+ ctx->event_ctx = ev;
+
+ sec_init();
+
+ ctx->msg_dgm_ref = messaging_dgm_ref(ctx,
+ ctx->event_ctx,
+ &ctx->id.unique_id,
+ priv_path,
+ lck_path,
+ messaging_recv_cb,
+ ctx,
+ &ret);
if (ctx->msg_dgm_ref == NULL) {
DEBUG(2, ("messaging_dgm_ref failed: %s\n", strerror(ret)));
- TALLOC_FREE(ctx);
- return NULL;
+ status = NT_STATUS_INTERNAL_ERROR;
+ goto done;
}
-
talloc_set_destructor(ctx, messaging_context_destructor);
if (lp_clustering()) {
@@ -303,19 +313,21 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
if (ret != 0) {
DEBUG(2, ("messaging_ctdbd_init failed: %s\n",
strerror(ret)));
- TALLOC_FREE(ctx);
- return NULL;
+ status = NT_STATUS_INTERNAL_ERROR;
+ goto done;
}
}
ctx->id.vnn = get_my_vnn();
- ctx->names_db = server_id_db_init(
- ctx, ctx->id, lp_lock_directory(), 0,
- TDB_INCOMPATIBLE_HASH|TDB_CLEAR_IF_FIRST);
+ ctx->names_db = server_id_db_init(ctx,
+ ctx->id,
+ lp_lock_directory(),
+ 0,
+ TDB_INCOMPATIBLE_HASH|TDB_CLEAR_IF_FIRST);
if (ctx->names_db == NULL) {
- DEBUG(10, ("%s: server_id_db_init failed\n", __func__));
- TALLOC_FREE(ctx);
- return NULL;
+ DBG_DEBUG("server_id_db_init failed\n");
+ status = NT_STATUS_INTERNAL_ERROR;
+ goto done;
}
messaging_register(ctx, NULL, MSG_PING, ping_message);
@@ -331,9 +343,40 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
DBG_DEBUG("my id: %s\n", server_id_str_buf(ctx->id, &tmp));
}
+ *pmsg_ctx = talloc_steal(mem_ctx, ctx);
+
+ status = NT_STATUS_OK;
+done:
+ TALLOC_FREE(frame);
+
+ return status;
+}
+
+struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev)
+{
+ struct messaging_context *ctx = NULL;
+ NTSTATUS status;
+
+ status = messaging_init_internal(mem_ctx,
+ ev,
+ &ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ return NULL;
+ }
+
return ctx;
}
+NTSTATUS messaging_init_client(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct messaging_context **pmsg_ctx)
+{
+ return messaging_init_internal(mem_ctx,
+ ev,
+ pmsg_ctx);
+}
+
struct server_id messaging_server_id(const struct messaging_context *msg_ctx)
{
return msg_ctx->id;
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index a38c141..35f17bb 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -1025,9 +1025,19 @@ out_free:
goto done;
}
- rpcclient_msg_ctx = messaging_init(talloc_autofree_context(),
- samba_tevent_context_init(talloc_autofree_context()));
- if (rpcclient_msg_ctx == NULL) {
+ nt_status = messaging_init_client(talloc_autofree_context(),
+ samba_tevent_context_init(talloc_autofree_context()),
+ &rpcclient_msg_ctx);
+ if (geteuid() != 0 &&
+ NT_STATUS_EQUAL(nt_status, NT_STATUS_ACCESS_DENIED)) {
+ /*
+ * Normal to fail to initialize messaging context
+ * if we're not root as we don't have ability to
+ * read lock directory.
+ */
+ DBG_NOTICE("Unable to initialize messaging context. "
+ "Must be root to do that.\n");
+ } else if (!NT_STATUS_IS_OK(nt_status)) {
fprintf(stderr, "Could not init messaging context\n");
result = 1;
goto done;
@@ -1229,8 +1239,10 @@ out_free:
line = smb_readline("rpcclient $> ", NULL, completion_fn);
- if (line == NULL)
+ if (line == NULL) {
+ printf("\n");
break;
+ }
if (line[0] != '\n')
process_cmd(rpcclient_auth_info, cli, binding, line);
diff --git a/source3/script/tests/test_registry_upgrade.sh b/source3/script/tests/test_registry_upgrade.sh
index f15ac07..cf14141 100755
--- a/source3/script/tests/test_registry_upgrade.sh
+++ b/source3/script/tests/test_registry_upgrade.sh
@@ -89,6 +89,8 @@ registry_upgrade()
# create config file
echo '[global]' > ${CONFIG_FILE}
echo " state directory = ${WORKSPACE}" >> ${CONFIG_FILE}
+ echo " private directory = ${WORKSPACE}" >> ${CONFIG_FILE}
+ echo " lock directory = ${WORKSPACE}" >> ${CONFIG_FILE}
# set database INFO/version to 1
#$DBWRAP_TOOL $REGISTRY store 'INFO/version' uint32 1
diff --git a/source3/utils/net.c b/source3/utils/net.c
index 3d0940d..beb8760 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -786,6 +786,7 @@ static struct functable net_func[] = {
poptContext pc;
TALLOC_CTX *frame = talloc_stackframe();
struct net_context *c = talloc_zero(frame, struct net_context);
+ NTSTATUS status;
struct poptOption long_options[] = {
{"help", 'h', POPT_ARG_NONE, 0, 'h'},
@@ -905,11 +906,22 @@ static struct functable net_func[] = {
exit(1);
}
- /*
- * Failing to init the msg_ctx isn't a fatal error. Only root-level
- * things (joining/leaving domains etc.) will be denied.
- */
- c->msg_ctx = messaging_init(c, samba_tevent_context_init(c));
+ status = messaging_init_client(c,
+ samba_tevent_context_init(c),
+ &c->msg_ctx);
+ if (geteuid() != 0 &&
+ NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
+ /*
+ * Normal to fail to initialize messaging context
+ * if we're not root as we don't have ability to
+ * read lock directory.
+ */
+ DBG_NOTICE("Unable to initialize messaging context. "
+ "Must be root to do that.\n");
+ } else if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, "Failed to init messaging context\n");
+ exit(1);
+ }
if (!lp_load_global(get_dyn_CONFIGFILE())) {
d_fprintf(stderr, "Can't load %s - run testparm to debug it\n",
--
Samba Shared Repository
More information about the samba-cvs
mailing list