]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
r3761: Fix bug #1932: crash when non-root invokes net getlocalsid
authorJim McDonough <jmcd@samba.org>
Mon, 15 Nov 2004 17:20:58 +0000 (17:20 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:53:16 +0000 (10:53 -0500)
First check to see if we can open secrets.tdb.

source/utils/net.c

index 2fe15c2b8ef6a518a42e872f91fb5a0a451ecbe0..784612fc71b26f1144f3b53985c8c89659d419d2 100644 (file)
@@ -479,11 +479,19 @@ static int net_getlocalsid(int argc, const char **argv)
                          "backend knowlege (such as the sid stored in LDAP)\n"));
        }
 
+       /* first check to see if we can even access secrets, so we don't
+          panic when we can't. */
+
+       if (!secrets_init()) {
+               d_printf("Unable to open secrets.tdb.  Can't fetch domain SID for name: %s\n", name);
+               return 1;
+       }
+
        /* Generate one, if it doesn't exist */
        get_global_sam_sid();
 
        if (!secrets_fetch_domain_sid(name, &sid)) {
-               DEBUG(0, ("Can't fetch domain SID for name: %s\n", name));      
+               DEBUG(0, ("Can't fetch domain SID for name: %s\n", name));
                return 1;
        }
        sid_to_string(sid_str, &sid);