s3:utils: Allow to run smbpasswd as user
[metze/samba/wip.git] / 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();
 int main(int argc, char **argv)
 {      
        TALLOC_CTX *frame = talloc_stackframe();
+       struct messaging_context *msg_ctx = NULL;
        int local_flags = 0;
        int ret;
 
        int local_flags = 0;
        int ret;
 
@@ -603,8 +604,17 @@ int main(int argc, char **argv)
 
        setup_logging("smbpasswd", DEBUG_STDERR);
 
 
        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;
+               }
        }
 
        /*
        }
 
        /*