libsmbconf:registry: Return correct case for get_share
authorChristof Schmitt <cs@samba.org>
Wed, 15 May 2019 23:05:26 +0000 (16:05 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 23 May 2019 23:26:14 +0000 (23:26 +0000)
get_share (called from 'net conf showshare') does a lookup of the share
name case-insensitively. As the registry stores the share name in the
correct case and 'net conf list' prints the correct case, also lookup
the correct case for get_share.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail
source3/lib/smbconf/smbconf_reg.c

index b414e5b1367f775fec276ad1c914d1d6e6d72c93..2c31bf916190c7cc420c9ce145bffb4bcedbe3f5 100644 (file)
 ^samba.tests.ntlmdisabled.python\(ktest\).python2.ntlmdisabled.NtlmDisabledTests.test_samr_change_password\(ktest\)
 ^samba.tests.ntlmdisabled.python\(ad_dc_no_ntlm\).python3.ntlmdisabled.NtlmDisabledTests.test_ntlm_connection\(ad_dc_no_ntlm\)
 ^samba.tests.ntlmdisabled.python\(ad_dc_no_ntlm\).python2.ntlmdisabled.NtlmDisabledTests.test_ntlm_connection\(ad_dc_no_ntlm\)
-^samba3.blackbox.net.rpc.conf.test_conf_showshare_case\(nt4_dc\)
index 781f19436426bbfb17374de255c7748a4219deae..d4a8b8c2989538183f26df42c659564b451acbcb 100644 (file)
@@ -897,10 +897,28 @@ static sbcErr smbconf_reg_get_share(struct smbconf_ctx *ctx,
        }
 
        if (servicename != NULL) {
-               tmp_service->name = talloc_strdup(tmp_service, servicename);
-               if (tmp_service->name == NULL) {
-                       err = SBC_ERR_NOMEM;
-                       goto done;
+               WERROR werr;
+               uint32_t count = 0;
+               char *name = NULL;
+
+               /*
+                * Determine correct upper/lowercase.
+                */
+               for (count = 0;
+                    werr = reg_enumkey(tmp_ctx, rpd(ctx)->base_key, count,
+                                       &name, NULL),
+                            W_ERROR_IS_OK(werr);
+                    count++) {
+                       if (!strequal(name, servicename)) {
+                               continue;
+                       }
+
+                       tmp_service->name = talloc_strdup(tmp_service, name);
+                       if (tmp_service->name == NULL) {
+                               err = SBC_ERR_NOMEM;
+                               goto done;
+                       }
+                       break;
                }
        }