s3:rpcclient: Use messaging_init_client()
authorAndreas Schneider <asn@samba.org>
Mon, 14 Nov 2016 08:51:52 +0000 (09:51 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 15 Nov 2016 23:20:06 +0000 (00:20 +0100)
Pair-Programmed-With: Jeremy Allison <jra@samba.org>

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Jeremy Allison <jra@samba.org>
source3/rpcclient/rpcclient.c

index 6cc17d15f6f0459a8587d07cae777457d7a06f25..35f17bb7bd6c006d498957881f2bb765e28d1e23 100644 (file)
@@ -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;