s3:utils: Allow to run smbpasswd as user
authorAndreas Schneider <asn@samba.org>
Fri, 18 Aug 2017 07:41:36 +0000 (09:41 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 18 Aug 2017 12:01:27 +0000 (14:01 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12974

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Aug 18 14:01:27 CEST 2017 on sn-devel-144

source3/utils/smbpasswd.c

index aa6b857a2581f00c08323ab227e8eb74214a28ce..ae9862606f1884e747a89e1d4c5ba45440c32872 100644 (file)
@@ -586,6 +586,7 @@ static int process_nonroot(int local_flags)
 int main(int argc, char **argv)
 {      
        TALLOC_CTX *frame = talloc_stackframe();
+       struct messaging_context *msg_ctx = NULL;
        int local_flags = 0;
        int ret;
 
@@ -603,8 +604,17 @@ int main(int argc, char **argv)
 
        setup_logging("smbpasswd", DEBUG_STDERR);
 
-       if (server_messaging_context() == NULL) {
-               return 1;
+       msg_ctx = server_messaging_context();
+       if (msg_ctx == NULL) {
+               if (geteuid() != 0) {
+                       DBG_NOTICE("Unable to initialize messaging context. "
+                                  "Must be root to do that.\n");
+               } else {
+                       fprintf(stderr,
+                               "smbpasswd is not able to initialize the "
+                               "messaging context!\n");
+                       return 1;
+               }
        }
 
        /*