mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
Make sure libnet_smbconf_get_share_names() always lists "global" first.
And don't return count-1 but count.
Michael
(This used to be commit b7cb9b7823
)
This commit is contained in:
parent
0e8ca78720
commit
e8cb7cecf2
@ -424,6 +424,7 @@ WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares,
|
|||||||
char ***share_names)
|
char ***share_names)
|
||||||
{
|
{
|
||||||
uint32_t count;
|
uint32_t count;
|
||||||
|
uint32_t added_count = 0;
|
||||||
TALLOC_CTX *tmp_ctx = NULL;
|
TALLOC_CTX *tmp_ctx = NULL;
|
||||||
WERROR werr = WERR_OK;
|
WERROR werr = WERR_OK;
|
||||||
struct registry_key *key = NULL;
|
struct registry_key *key = NULL;
|
||||||
@ -441,6 +442,17 @@ WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* make sure "global" is always listed first */
|
||||||
|
if (libnet_smbconf_key_exists(GLOBAL_NAME)) {
|
||||||
|
werr = libnet_smbconf_add_string_to_array(tmp_ctx,
|
||||||
|
&tmp_share_names,
|
||||||
|
0, GLOBAL_NAME);
|
||||||
|
if (!W_ERROR_IS_OK(werr)) {
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
added_count++;
|
||||||
|
}
|
||||||
|
|
||||||
werr = libnet_smbconf_reg_open_basepath(tmp_ctx,
|
werr = libnet_smbconf_reg_open_basepath(tmp_ctx,
|
||||||
SEC_RIGHTS_ENUM_SUBKEYS,
|
SEC_RIGHTS_ENUM_SUBKEYS,
|
||||||
&key);
|
&key);
|
||||||
@ -453,21 +465,26 @@ WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares,
|
|||||||
&subkey_name, NULL));
|
&subkey_name, NULL));
|
||||||
count++)
|
count++)
|
||||||
{
|
{
|
||||||
|
if (strequal(subkey_name, GLOBAL_NAME)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
werr = libnet_smbconf_add_string_to_array(tmp_ctx,
|
werr = libnet_smbconf_add_string_to_array(tmp_ctx,
|
||||||
&tmp_share_names,
|
&tmp_share_names,
|
||||||
count, subkey_name);
|
added_count,
|
||||||
|
subkey_name);
|
||||||
if (!W_ERROR_IS_OK(werr)) {
|
if (!W_ERROR_IS_OK(werr)) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
added_count++;
|
||||||
}
|
}
|
||||||
if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
|
if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
werr = WERR_OK;
|
werr = WERR_OK;
|
||||||
|
|
||||||
*num_shares = count - 1;
|
*num_shares = added_count;
|
||||||
if (count > 0) {
|
if (added_count > 0) {
|
||||||
*share_names = talloc_move(mem_ctx, &tmp_share_names);
|
*share_names = talloc_move(mem_ctx, &tmp_share_names);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +475,7 @@ static int net_conf_listshares(int argc, const char **argv)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (count = 0; count <= num_shares; count++)
|
for (count = 0; count < num_shares; count++)
|
||||||
{
|
{
|
||||||
d_printf("%s\n", share_names[count]);
|
d_printf("%s\n", share_names[count]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user