[SCM] Samba Shared Repository - branch v3-2-test updated -
initial-v3-2-unstable-954-gbfe3d14
Michael Adam
obnox at samba.org
Sat Dec 29 16:07:28 GMT 2007
The branch, v3-2-test has been updated
via bfe3d1462f52d2849611fc58ad70fa08b4917077 (commit)
via ded60dec7d75db7df485a159fb6bf628d8e24805 (commit)
via b7cb9b78231512dc4a88c307048d7fb5334fa319 (commit)
via f4a4c1b26a03cd0f334e00912d32f15c73474ff1 (commit)
from 2322fe718728178990fdc3696b84f5de7ae7701b (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit bfe3d1462f52d2849611fc58ad70fa08b4917077
Author: Michael Adam <obnox at samba.org>
Date: Sat Dec 29 17:06:49 2007 +0100
Return NULL (instead of unchanged) for no shares/parameters defined.
Michael
commit ded60dec7d75db7df485a159fb6bf628d8e24805
Author: Michael Adam <obnox at samba.org>
Date: Sat Dec 29 17:02:27 2007 +0100
Dont return count - 1 but count from libnet_smbconf_reg_get_values().
Michael
commit b7cb9b78231512dc4a88c307048d7fb5334fa319
Author: Michael Adam <obnox at samba.org>
Date: Sat Dec 29 14:38:42 2007 +0100
Make sure libnet_smbconf_get_share_names() always lists "global" first.
And don't return count-1 but count.
Michael
commit f4a4c1b26a03cd0f334e00912d32f15c73474ff1
Author: Michael Adam <obnox at samba.org>
Date: Sat Dec 29 14:32:13 2007 +0100
Move talloc-appending a string to an array to its own helper function
libnet_smbconf_add_string_to_array().
Michael
-----------------------------------------------------------------------
Summary of changes:
source/libnet/libnet_conf.c | 92 +++++++++++++++++++++++++++++++++++--------
source/utils/net_conf.c | 4 +-
2 files changed, 77 insertions(+), 19 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/libnet/libnet_conf.c b/source/libnet/libnet_conf.c
index 23b9131..3f5265a 100644
--- a/source/libnet/libnet_conf.c
+++ b/source/libnet/libnet_conf.c
@@ -27,6 +27,33 @@
**********************************************************************/
+/**
+ * add a string to a talloced array of strings.
+ */
+static WERROR libnet_smbconf_add_string_to_array(TALLOC_CTX *mem_ctx,
+ char ***array,
+ uint32_t count,
+ const char *string)
+{
+ WERROR werr = WERR_OK;
+ char **new_array = NULL;
+
+ if ((array == NULL) || (string == NULL)) {
+ return WERR_INVALID_PARAM;
+ }
+
+ new_array = TALLOC_REALLOC_ARRAY(mem_ctx, *array, char *, count + 1);
+ if (new_array == NULL) {
+ return WERR_NOMEM;
+ }
+
+ new_array[count] = talloc_strdup(new_array, string);
+
+ *array = new_array;
+
+ return WERR_OK;
+}
+
/*
* Open a subkey of KEY_SMBCONF (i.e a service)
*/
@@ -302,18 +329,24 @@ static WERROR libnet_smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
&valvalue));
count++)
{
- tmp_valnames = TALLOC_REALLOC_ARRAY(tmp_ctx, tmp_valnames,
- char *, count + 1);
- tmp_valstrings = TALLOC_REALLOC_ARRAY(tmp_ctx, tmp_valstrings,
- char *, count + 1);
- if ((tmp_valstrings == NULL) || (tmp_valnames == NULL)) {
- werr = WERR_NOMEM;
+ char *valstring;
+
+ werr = libnet_smbconf_add_string_to_array(tmp_ctx,
+ &tmp_valnames,
+ count, valname);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+
+ valstring = libnet_smbconf_format_registry_value(tmp_ctx,
+ valvalue);
+ werr = libnet_smbconf_add_string_to_array(tmp_ctx,
+ &tmp_valstrings,
+ count,
+ valstring);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
- tmp_valnames[count] = talloc_strdup(tmp_valnames, valname);
- tmp_valstrings[count] =
- libnet_smbconf_format_registry_value(tmp_valstrings,
- valvalue);
}
if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
goto done;
@@ -321,10 +354,13 @@ static WERROR libnet_smbconf_reg_get_values(TALLOC_CTX *mem_ctx,
werr = WERR_OK;
- *num_values = count - 1;
+ *num_values = count;
if (count > 0) {
*value_names = talloc_move(mem_ctx, &tmp_valnames);
*value_strings = talloc_move(mem_ctx, &tmp_valstrings);
+ } else {
+ *value_names = NULL;
+ *value_strings = NULL;
}
done:
@@ -391,6 +427,7 @@ WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares,
char ***share_names)
{
uint32_t count;
+ uint32_t added_count = 0;
TALLOC_CTX *tmp_ctx = NULL;
WERROR werr = WERR_OK;
struct registry_key *key = NULL;
@@ -408,6 +445,17 @@ WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares,
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,
SEC_RIGHTS_ENUM_SUBKEYS,
&key);
@@ -420,19 +468,29 @@ WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares,
&subkey_name, NULL));
count++)
{
- tmp_share_names = TALLOC_REALLOC_ARRAY(tmp_ctx, tmp_share_names,
- char *, count + 1);
- tmp_share_names[count] = talloc_strdup(tmp_ctx, subkey_name);
+ if (strequal(subkey_name, GLOBAL_NAME)) {
+ continue;
+ }
+
+ werr = libnet_smbconf_add_string_to_array(tmp_ctx,
+ &tmp_share_names,
+ added_count,
+ subkey_name);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+ added_count++;
}
if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
goto done;
}
-
werr = WERR_OK;
- *num_shares = count - 1;
- if (count > 0) {
+ *num_shares = added_count;
+ if (added_count > 0) {
*share_names = talloc_move(mem_ctx, &tmp_share_names);
+ } else {
+ *share_names = NULL;
}
done:
diff --git a/source/utils/net_conf.c b/source/utils/net_conf.c
index 651948c..8957408 100644
--- a/source/utils/net_conf.c
+++ b/source/utils/net_conf.c
@@ -475,7 +475,7 @@ static int net_conf_listshares(int argc, const char **argv)
goto done;
}
- for (count = 0; count <= num_shares; count++)
+ for (count = 0; count < num_shares; count++)
{
d_printf("%s\n", share_names[count]);
}
@@ -541,7 +541,7 @@ static int net_conf_showshare(int argc, const char **argv)
d_printf("[%s]\n", sharename);
- for (count = 0; count <= num_params; count++) {
+ for (count = 0; count < num_params; count++) {
d_printf("\t%s = %s\n", param_names[count],
param_values[count]);
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list