1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-12 20:58:37 +03:00

Merge branch 'v3-2-test' of ssh://git.samba.org/data/git/samba into 3-2-nopipeindex

(This used to be commit 9028f9e065536594df901ae4aac900102f2d85f6)
This commit is contained in:
Jelmer Vernooij 2008-04-15 20:52:17 +02:00
commit d0b946e328
6 changed files with 146 additions and 35 deletions

View File

@ -105,6 +105,8 @@ NT_USER_TOKEN *get_root_nt_token( void )
token = create_local_nt_token(NULL, &u_sid, False,
1, &global_sid_Builtin_Administrators);
token->privileges = se_disk_operators;
memcache_add_talloc(
NULL, SINGLETON_CACHE_TALLOC,
data_blob_string_const("root_nt_token"), token);

View File

@ -183,9 +183,6 @@ WERROR smbconf_get_share_names(struct smbconf_ctx *ctx,
bool smbconf_share_exists(struct smbconf_ctx *ctx,
const char *servicename)
{
if (servicename == NULL) {
return false;
}
return ctx->ops->share_exists(ctx, servicename);
}
@ -195,7 +192,7 @@ bool smbconf_share_exists(struct smbconf_ctx *ctx,
WERROR smbconf_create_share(struct smbconf_ctx *ctx,
const char *servicename)
{
if (smbconf_share_exists(ctx, servicename)) {
if ((servicename != NULL) && smbconf_share_exists(ctx, servicename)) {
return WERR_ALREADY_EXISTS;
}

View File

@ -131,12 +131,11 @@ static WERROR smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx,
char *path = NULL;
if (servicename == NULL) {
DEBUG(3, ("Error: NULL servicename given.\n"));
werr = WERR_INVALID_PARAM;
goto done;
path = talloc_strdup(mem_ctx, ctx->path);
} else {
path = talloc_asprintf(mem_ctx, "%s\\%s", ctx->path,
servicename);
}
path = talloc_asprintf(mem_ctx, "%s\\%s", ctx->path, servicename);
if (path == NULL) {
werr = WERR_NOMEM;
goto done;
@ -544,6 +543,65 @@ done:
return werr;
}
static bool smbconf_reg_key_has_values(struct registry_key *key)
{
WERROR werr;
uint32_t num_subkeys;
uint32_t max_subkeylen;
uint32_t max_subkeysize;
uint32_t num_values;
uint32_t max_valnamelen;
uint32_t max_valbufsize;
uint32_t secdescsize;
NTTIME last_changed_time;
werr = reg_queryinfokey(key, &num_subkeys, &max_subkeylen,
&max_subkeysize, &num_values, &max_valnamelen,
&max_valbufsize, &secdescsize,
&last_changed_time);
if (!W_ERROR_IS_OK(werr)) {
return false;
}
return (num_values != 0);
}
/**
* delete all values from a key
*/
static WERROR smbconf_reg_delete_values(struct registry_key *key)
{
WERROR werr;
char *valname;
struct registry_value *valvalue;
uint32_t count;
TALLOC_CTX *mem_ctx = talloc_stackframe();
for (count = 0;
werr = reg_enumvalue(mem_ctx, key, count, &valname, &valvalue),
W_ERROR_IS_OK(werr);
count++)
{
werr = reg_deletevalue(key, valname);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
}
if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
DEBUG(1, ("smbconf_reg_delete_values: "
"Error enumerating values of %s: %s\n",
key->key->name,
dos_errstr(werr)));
goto done;
}
werr = WERR_OK;
done:
TALLOC_FREE(mem_ctx);
return werr;
}
/**********************************************************************
*
* smbconf operations: registry implementations
@ -707,20 +765,30 @@ static WERROR smbconf_reg_get_share_names(struct smbconf_ctx *ctx,
goto done;
}
/* make sure "global" is always listed first */
if (smbconf_share_exists(ctx, GLOBAL_NAME)) {
/* if there are values in the base key, return NULL as share name */
werr = smbconf_reg_open_base_key(tmp_ctx, ctx,
SEC_RIGHTS_ENUM_SUBKEYS, &key);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
if (smbconf_reg_key_has_values(key)) {
werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
0, GLOBAL_NAME);
0, NULL);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
added_count++;
}
werr = smbconf_reg_open_base_key(tmp_ctx, ctx,
SEC_RIGHTS_ENUM_SUBKEYS, &key);
if (!W_ERROR_IS_OK(werr)) {
goto done;
/* make sure "global" is always listed first */
if (smbconf_share_exists(ctx, GLOBAL_NAME)) {
werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
1, GLOBAL_NAME);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
added_count++;
}
for (count = 0;
@ -789,7 +857,13 @@ static WERROR smbconf_reg_create_share(struct smbconf_ctx *ctx,
TALLOC_CTX *mem_ctx = talloc_stackframe();
struct registry_key *key = NULL;
werr = smbconf_reg_create_service_key(mem_ctx, ctx, servicename, &key);
if (servicename == NULL) {
werr = smbconf_reg_open_base_key(mem_ctx, ctx, REG_KEY_WRITE,
&key);
} else {
werr = smbconf_reg_create_service_key(mem_ctx, ctx,
servicename, &key);
}
TALLOC_FREE(mem_ctx);
return werr;
@ -836,7 +910,11 @@ static WERROR smbconf_reg_delete_share(struct smbconf_ctx *ctx,
goto done;
}
werr = reg_deletekey_recursive(key, key, servicename);
if (servicename != NULL) {
werr = reg_deletekey_recursive(key, key, servicename);
} else {
werr = smbconf_reg_delete_values(key);
}
done:
TALLOC_FREE(mem_ctx);

View File

@ -121,8 +121,14 @@ static bool smbconf_txt_do_parameter(const char *param_name,
struct txt_cache *cache = tpd->cache;
if (cache->num_shares == 0) {
/* not in any share ... */
return false;
/*
* not in any share yet,
* initialize the "empty" section (NULL):
* parameters without a previous [section] are stored here.
*/
if (!smbconf_txt_do_section(NULL, private_data)) {
return false;
}
}
param_names = cache->param_names[cache->current_share];
@ -301,10 +307,21 @@ static WERROR smbconf_txt_get_share_names(struct smbconf_ctx *ctx,
goto done;
}
/* make sure "global" is always listed first */
/* make sure "global" is always listed first,
* possibly after NULL section */
if (smbconf_share_exists(ctx, NULL)) {
werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
0, NULL);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
added_count++;
}
if (smbconf_share_exists(ctx, GLOBAL_NAME)) {
werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
0, GLOBAL_NAME);
added_count, GLOBAL_NAME);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@ -312,7 +329,9 @@ static WERROR smbconf_txt_get_share_names(struct smbconf_ctx *ctx,
}
for (count = 0; count < pd(ctx)->cache->num_shares; count++) {
if (strequal(pd(ctx)->cache->share_names[count], GLOBAL_NAME)) {
if (strequal(pd(ctx)->cache->share_names[count], GLOBAL_NAME) ||
(pd(ctx)->cache->share_names[count] == NULL))
{
continue;
}

View File

@ -82,7 +82,7 @@ WERROR smbconf_add_string_to_array(TALLOC_CTX *mem_ctx,
{
char **new_array = NULL;
if ((array == NULL) || (string == NULL)) {
if (array == NULL) {
return WERR_INVALID_PARAM;
}
@ -91,10 +91,14 @@ WERROR smbconf_add_string_to_array(TALLOC_CTX *mem_ctx,
return WERR_NOMEM;
}
new_array[count] = talloc_strdup(new_array, string);
if (new_array[count] == NULL) {
TALLOC_FREE(new_array);
return WERR_NOMEM;
if (string == NULL) {
new_array[count] = NULL;
} else {
new_array[count] = talloc_strdup(new_array, string);
if (new_array[count] == NULL) {
TALLOC_FREE(new_array);
return WERR_NOMEM;
}
}
*array = new_array;
@ -107,12 +111,14 @@ bool smbconf_find_in_array(const char *string, char **list,
{
uint32_t i;
if ((string == NULL) || (list == NULL)) {
if (list == NULL) {
return false;
}
for (i = 0; i < num_entries; i++) {
if (strequal(string, list[i])) {
if (((string == NULL) && (list[i] == NULL)) ||
strequal(string, list[i]))
{
if (entry != NULL) {
*entry = i;
}

View File

@ -150,9 +150,13 @@ static WERROR import_process_service(struct smbconf_ctx *conf_ctx,
TALLOC_CTX *mem_ctx = talloc_stackframe();
if (opt_testmode) {
d_printf("[%s]\n", servicename);
for (idx = 0; idx < num_params; idx ++) {
d_printf("\t%s = %s\n", param_names[idx],
const char *indent = "";
if (servicename != NULL) {
d_printf("[%s]\n", servicename);
indent = "\t";
}
for (idx = 0; idx < num_params; idx++) {
d_printf("%s%s = %s\n", indent, param_names[idx],
param_values[idx]);
}
d_printf("\n");
@ -242,11 +246,16 @@ static int net_conf_list(struct smbconf_ctx *conf_ctx,
}
for (share_count = 0; share_count < num_shares; share_count++) {
d_printf("[%s]\n", share_names[share_count]);
const char *indent = "";
if (share_names[share_count] != NULL) {
d_printf("[%s]\n", share_names[share_count]);
indent = "\t";
}
for (param_count = 0; param_count < num_params[share_count];
param_count++)
{
d_printf("\t%s = %s\n",
d_printf("%s%s = %s\n",
indent,
param_names[share_count][param_count],
param_values[share_count][param_count]);
}