The branch, master has been updated via 08cf13a s3:registry: remove now (finally) obsolete reg_util_registry.{c,h} via 7f1efa6 s3:services_db: does not need legacy registry code any more. via 8df2ab9 s3:services_db: rewrite svcctl_init_keys() to use reg_api calls instead of legacy via a6f0f91 s3:services_db: extract core of svcctl_set_secdesc to _internal version via f2a4d55 s3:services_db: create the "Security" subkey if it does not exist in svcctl_set_secdesc() via 8be007d s3:services_db: remove bogus comments via 5fe2abb s3:services_db: remove unused legacy function svcctl_fetch_regvalues(). via e869af9 s3:rpc_server:ntsvcs: registry is not directly used an more. via d760e54 s3:rpc_server:ntsvcs: use svcctl_lookup_dispname instead of legacy svcctl in _PNP_GetDeviceRegProp via 4cee4bb s3:rpc_server: registry is not direclty used in the svcctl server any more via 3cab109 s3:srv_ntsvcs_nt: make fill_svc_config() use svcctl_get_string_value() via 3c85a9f s3:services_db: publish svcctl_get_string_value() via e28bc8d s3:services_db: factor out common code of lookup_dispname and lookup_description via 53dcbc2 s3:services_db: change svcctl_lookup_description() to use reg_api functions via 9fee033 s3:services_db: rewrite svcctl_lookup_description() to use a tmp talloc ctx via 464515c s3:services_db: change svcctl_lookup_dispname() to use reg_api functions via e464ca9 s3:services_db: make svcctl_lookup_dispname() use a temp talloc ctx via a4b1042 s3:services_db: change svcctl_get_secdesc() to use reg_api functions via 4fc2b5c s3:services_db: use temp talloc ctx in svcctl_get_secdesc() via 9bfd587 s3:services_db: remove the TALLOC_CTX argument from svcctl_set_secdesc via 91d5446 s3:services_db: fix a debug message via d2794b0 s3:services_db: rewrite svcctl_set_secdesc to use tmp talloc ctx via 7cefb89 s3:services_db: rewrite svcctl_set_secdesc() using reg_api calls instead of legacy via f53c17b s3:services_db: untanlge assignments from check in read_init_file(). via a67a553 s3:services_db: untangle assignments from check in construct_service_sd(). from 7ffcf90 s4-drepl: use the partition UDV and hwm for extended getncchanges ops
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 08cf13a3df212bd421275f61e2db146752490c7d Author: Michael Adam <ob...@samba.org> Date: Tue Sep 21 06:51:38 2010 +0200 s3:registry: remove now (finally) obsolete reg_util_registry.{c,h} commit 7f1efa6ea25eba0c0829131758746ac0c2ab9e42 Author: Michael Adam <ob...@samba.org> Date: Tue Sep 21 06:49:40 2010 +0200 s3:services_db: does not need legacy registry code any more. commit 8df2ab974689c585f19b5a0de40a80245d12639d Author: Michael Adam <ob...@samba.org> Date: Tue Sep 21 06:48:19 2010 +0200 s3:services_db: rewrite svcctl_init_keys() to use reg_api calls instead of legacy commit a6f0f912cc461dcca2b34242327c6fc82d6ff849 Author: Michael Adam <ob...@samba.org> Date: Tue Sep 21 03:11:43 2010 +0200 s3:services_db: extract core of svcctl_set_secdesc to _internal version The internal version operates on an already opened key. commit f2a4d5536b68f344edab717c4e6dfbef15523499 Author: Michael Adam <ob...@samba.org> Date: Tue Sep 21 03:00:29 2010 +0200 s3:services_db: create the "Security" subkey if it does not exist in svcctl_set_secdesc() Windows behaves like this. - Tests will follow. commit 8be007dbb0c10a0755a87639eccabd7f5cdd05b3 Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 11:24:36 2010 +0200 s3:services_db: remove bogus comments (from copy and paste probably...) commit 5fe2abb2f85afe2e8655257446c7dd03a08b2d57 Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 11:20:37 2010 +0200 s3:services_db: remove unused legacy function svcctl_fetch_regvalues(). commit e869af9e0e6e460d8ae225310f58f458e094e86f Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 11:18:33 2010 +0200 s3:rpc_server:ntsvcs: registry is not directly used an more. commit d760e543a1340a2166a43f83b27b5a4a6a39dfcf Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 11:17:38 2010 +0200 s3:rpc_server:ntsvcs: use svcctl_lookup_dispname instead of legacy svcctl in _PNP_GetDeviceRegProp commit 4cee4bbd02cdd0e4bc458378016621948e58d47c Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 10:57:53 2010 +0200 s3:rpc_server: registry is not direclty used in the svcctl server any more commit 3cab10975464a6f67c1728301ffc0264fb1763e0 Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 10:30:30 2010 +0200 s3:srv_ntsvcs_nt: make fill_svc_config() use svcctl_get_string_value() instead of using legacy svcctl_fetch_regvalues() commit 3c85a9fcbe56aadc6a50706d253d7d010cf91c63 Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 10:27:56 2010 +0200 s3:services_db: publish svcctl_get_string_value() commit e28bc8d763978762480367d031a4a62ebd411f8a Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 08:06:30 2010 +0200 s3:services_db: factor out common code of lookup_dispname and lookup_description into a new function svcctl_get_string_value() commit 53dcbc2dd2705c5273163c757e2587e3596c6971 Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 06:19:57 2010 +0200 s3:services_db: change svcctl_lookup_description() to use reg_api functions commit 9fee03365621cca011da4521d98f1e1aa2882278 Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 06:03:58 2010 +0200 s3:services_db: rewrite svcctl_lookup_description() to use a tmp talloc ctx Also remove a possible memory by tallocing the result string also in a default case, where a string constant was returned before. commit 464515cd610b5ee3862d8bc8558cd698d4f7258e Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 08:11:07 2010 +0200 s3:services_db: change svcctl_lookup_dispname() to use reg_api functions commit e464ca9f311e3becd5f88f41fa7a95520fe6fbc3 Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 04:58:27 2010 +0200 s3:services_db: make svcctl_lookup_dispname() use a temp talloc ctx commit a4b1042f33b505dcb51ac25bf84a597d98fa9d4b Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 04:41:59 2010 +0200 s3:services_db: change svcctl_get_secdesc() to use reg_api functions commit 4fc2b5c40e63579c2fe4e95bdbaa31108f2b3475 Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 04:12:42 2010 +0200 s3:services_db: use temp talloc ctx in svcctl_get_secdesc() commit 9bfd587358fb58b98dd0fbdd72069430a89cefc7 Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 03:38:45 2010 +0200 s3:services_db: remove the TALLOC_CTX argument from svcctl_set_secdesc commit 91d5446390dc41b43fe18785a765bbd71ff709c2 Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 03:36:23 2010 +0200 s3:services_db: fix a debug message commit d2794b05a6b8be40ebde4a47b9c03008242b1c46 Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 03:34:49 2010 +0200 s3:services_db: rewrite svcctl_set_secdesc to use tmp talloc ctx and add a common exit point commit 7cefb898729bc46e1ba9fd1c8b48e7aef0486339 Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 02:43:33 2010 +0200 s3:services_db: rewrite svcctl_set_secdesc() using reg_api calls instead of legacy commit f53c17b4ff27c39fbeccce4d369f4bb8f1b13ce7 Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 00:46:59 2010 +0200 s3:services_db: untanlge assignments from check in read_init_file(). commit a67a553f40833a182b89a058d59015bcf19640f0 Author: Michael Adam <ob...@samba.org> Date: Mon Sep 20 00:40:44 2010 +0200 s3:services_db: untangle assignments from check in construct_service_sd(). ----------------------------------------------------------------------- Summary of changes: source3/Makefile.in | 3 +- source3/include/proto.h | 7 +- source3/registry/reg_util_legacy.c | 52 ---- source3/registry/reg_util_legacy.h | 45 --- source3/rpc_server/srv_ntsvcs_nt.c | 32 +- source3/rpc_server/srv_svcctl_nt.c | 31 +-- source3/services/services_db.c | 571 ++++++++++++++++-------------------- 7 files changed, 294 insertions(+), 447 deletions(-) delete mode 100644 source3/registry/reg_util_legacy.c delete mode 100644 source3/registry/reg_util_legacy.h Changeset truncated at 500 lines: diff --git a/source3/Makefile.in b/source3/Makefile.in index b7dfc6e..c72a6c3 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -657,8 +657,7 @@ REG_FULL_OBJ = $(REG_SMBCONF_OBJ) \ $(REG_INIT_FULL_OBJ) \ registry/reg_eventlog.o \ registry/reg_perfcount.o \ - librpc/gen_ndr/ndr_perfcount.o \ - registry/reg_util_legacy.o + librpc/gen_ndr/ndr_perfcount.o LIB_EVENTLOG_OBJ = lib/eventlog/eventlog.o diff --git a/source3/include/proto.h b/source3/include/proto.h index d7b9cb0..3349e02 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -4397,10 +4397,13 @@ bool init_service_op_table( void ); void svcctl_init_keys( void ); struct security_descriptor *svcctl_get_secdesc( TALLOC_CTX *ctx, const char *name, struct security_token *token ); -bool svcctl_set_secdesc( TALLOC_CTX *ctx, const char *name, struct security_descriptor *sec_desc, struct security_token *token ); +bool svcctl_set_secdesc(const char *name, struct security_descriptor *sec_desc, + struct security_token *token); +const char *svcctl_get_string_value(TALLOC_CTX *ctx, const char *key_name, + const char *value_name, + struct security_token *token); const char *svcctl_lookup_dispname(TALLOC_CTX *ctx, const char *name, struct security_token *token ); const char *svcctl_lookup_description(TALLOC_CTX *ctx, const char *name, struct security_token *token ); -struct regval_ctr *svcctl_fetch_regvalues( const char *name, struct security_token *token ); /* The following definitions come from services/svc_netlogon.c */ diff --git a/source3/registry/reg_util_legacy.c b/source3/registry/reg_util_legacy.c deleted file mode 100644 index 29b0889..0000000 --- a/source3/registry/reg_util_legacy.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * Virtual Windows Registry Layer - * Copyright (C) Gerald Carter 2002-2005 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. - */ - -/* Implementation of registry frontend view functions. */ - -#include "includes.h" -#include "registry.h" -#include "reg_util_legacy.h" -#include "reg_api_util.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_REGISTRY - -/** - * legacy open key function that should be replaced by uses of - * reg_open_path - */ -WERROR regkey_open_internal(TALLOC_CTX *ctx, - struct registry_key_handle **regkey, - const char *path, - const struct security_token *token, - uint32 access_desired ) -{ - struct registry_key *key; - WERROR err; - TALLOC_CTX *tmp_ctx = talloc_stackframe(); - - err = reg_open_path(tmp_ctx, path, access_desired, token, &key); - if (!W_ERROR_IS_OK(err)) { - return err; - } - - *regkey = talloc_move(ctx, &key->key); - TALLOC_FREE(tmp_ctx); - return WERR_OK; -} diff --git a/source3/registry/reg_util_legacy.h b/source3/registry/reg_util_legacy.h deleted file mode 100644 index d0cb626..0000000 --- a/source3/registry/reg_util_legacy.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * Virtual Windows Registry Layer - * Copyright (C) Gerald Carter 2002-2005 - * Copyright (C) Michael Adam 2009 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef _REG_UTIL_LEGACY_H -#define _REG_UTIL_LEGACY_H - -/* - * This module contains legacy code code from the old regkey - * interface that is now mostly hidden behind the reg_api interface. - * This code should be removed once the last users of the old code - * have been converted. - */ - -#include "includes.h" -#include "registry.h" - -/** - * legacy open key function that should be replaced by uses of - * reg_open_path - */ - -WERROR regkey_open_internal(TALLOC_CTX *ctx, - struct registry_key_handle **regkey, - const char *path, - const struct security_token *token, - uint32 access_desired ); - -#endif /* _REG_UTIL_LEGACY_H */ diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index aed9a53..a948b86 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -21,8 +21,6 @@ #include "includes.h" #include "../librpc/gen_ndr/srv_ntsvcs.h" -#include "registry.h" -#include "registry/reg_objects.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV @@ -125,8 +123,9 @@ WERROR _PNP_GetDeviceRegProp(struct pipes_struct *p, struct PNP_GetDeviceRegProp *r) { char *ptr; - struct regval_ctr *values; - struct regval_blob *val; + const char *result; + DATA_BLOB blob; + TALLOC_CTX *mem_ctx = NULL; switch( r->in.property ) { case DEV_REGPROP_DESC: @@ -141,31 +140,34 @@ WERROR _PNP_GetDeviceRegProp(struct pipes_struct *p, return WERR_GENERAL_FAILURE; ptr++; - if ( !(values = svcctl_fetch_regvalues( - ptr, p->server_info->ptok))) + mem_ctx = talloc_stackframe(); + + result = svcctl_lookup_dispname(mem_ctx, ptr, p->server_info->ptok); + if (result == NULL) { return WERR_GENERAL_FAILURE; + } - if ( !(val = regval_ctr_getvalue( values, "DisplayName" )) ) { - TALLOC_FREE( values ); + if (!push_reg_sz(mem_ctx, &blob, result)) { + talloc_free(mem_ctx); return WERR_GENERAL_FAILURE; } - if (*r->in.buffer_size < regval_size(val)) { - *r->out.needed = regval_size(val); + if (*r->in.buffer_size < blob.length) { + *r->out.needed = blob.length; *r->out.buffer_size = 0; - TALLOC_FREE( values ); + talloc_free(mem_ctx); return WERR_CM_BUFFER_SMALL; } - r->out.buffer = (uint8_t *)talloc_memdup(p->mem_ctx, regval_data_p(val), regval_size(val)); - TALLOC_FREE(values); + r->out.buffer = (uint8_t *)talloc_memdup(p->mem_ctx, blob.data, blob.length); + talloc_free(mem_ctx); if (!r->out.buffer) { return WERR_NOMEM; } *r->out.reg_data_type = REG_SZ; /* always 1...tested using a remove device manager connection */ - *r->out.buffer_size = regval_size(val); - *r->out.needed = regval_size(val); + *r->out.buffer_size = blob.length; + *r->out.needed = blob.length; break; diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index e55978c..6c74ade 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -25,8 +25,6 @@ #include "includes.h" #include "../librpc/gen_ndr/srv_svcctl.h" #include "services/services.h" -#include "registry.h" -#include "registry/reg_objects.h" #include "../librpc/gen_ndr/ndr_security.h" #undef DBGC_CLASS @@ -644,27 +642,21 @@ static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, struct QUERY_SERVICE_CONFIG *config, struct security_token *token ) { - struct regval_ctr *values; - struct regval_blob *val; - - /* retrieve the registry values for this service */ - - if ( !(values = svcctl_fetch_regvalues( name, token )) ) - return WERR_REG_CORRUPT; + TALLOC_CTX *mem_ctx = talloc_stackframe(); + const char *result = NULL; /* now fill in the individual values */ - if ( (val = regval_ctr_getvalue( values, "DisplayName" )) != NULL ) - config->displayname = regval_sz(val); - else - config->displayname = name; + config->displayname = svcctl_lookup_dispname(mem_ctx, name, token); - if ( (val = regval_ctr_getvalue( values, "ObjectName" )) != NULL ) { - config->startname = regval_sz(val); + result = svcctl_get_string_value(mem_ctx, name, "ObjectName", token); + if (result != NULL) { + config->startname = result; } - if ( (val = regval_ctr_getvalue( values, "ImagePath" )) != NULL ) { - config->executablepath = regval_sz(val); + result = svcctl_get_string_value(mem_ctx, name, "ImagePath", token); + if (result != NULL) { + config->executablepath = result; } /* a few hard coded values */ @@ -686,7 +678,7 @@ static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, config->start_type = SVCCTL_DEMAND_START; - TALLOC_FREE( values ); + talloc_free(mem_ctx); return WERR_OK; } @@ -956,8 +948,7 @@ WERROR _svcctl_SetServiceObjectSecurity(struct pipes_struct *p, /* store the new SD */ - if ( !svcctl_set_secdesc( p->mem_ctx, info->name, sec_desc, - p->server_info->ptok) ) + if (!svcctl_set_secdesc(info->name, sec_desc, p->server_info->ptok)) return WERR_ACCESS_DENIED; return WERR_OK; diff --git a/source3/services/services_db.c b/source3/services/services_db.c index 0afc6c1..6d361c7 100644 --- a/source3/services/services_db.c +++ b/source3/services/services_db.c @@ -23,9 +23,7 @@ #include "includes.h" #include "services/services.h" #include "registry.h" -#include "registry/reg_util_legacy.h" -#include "registry/reg_dispatcher.h" -#include "registry/reg_objects.h" +#include "registry/reg_api_util.h" struct rcinit_file_information { char *description; @@ -87,6 +85,8 @@ struct service_display_info common_unix_svcs[] = { { NULL, NULL, NULL, NULL } }; +static WERROR svcctl_set_secdesc_internal(struct registry_key *key, + struct security_descriptor *sec_desc); /******************************************************************** ********************************************************************/ @@ -114,13 +114,17 @@ static struct security_descriptor* construct_service_sd( TALLOC_CTX *ctx ) /* create the security descriptor */ - if ( !(theacl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) ) + theacl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace); + if (theacl == NULL) { return NULL; + } - if ( !(sd = make_sec_desc(ctx, SECURITY_DESCRIPTOR_REVISION_1, - SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, - theacl, &sd_size)) ) + sd = make_sec_desc(ctx, SECURITY_DESCRIPTOR_REVISION_1, + SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, + theacl, &sd_size); + if (sd == NULL) { return NULL; + } return sd; } @@ -199,8 +203,10 @@ static bool read_init_file( const char *servicename, struct rcinit_file_informat XFILE *f = NULL; char *p = NULL; - if ( !(info = TALLOC_ZERO_P( NULL, struct rcinit_file_information ) ) ) + info = TALLOC_ZERO_P( NULL, struct rcinit_file_information ); + if (info == NULL) { return False; + } /* attempt the file open */ @@ -210,7 +216,8 @@ static bool read_init_file( const char *servicename, struct rcinit_file_informat TALLOC_FREE(info); return false; } - if (!(f = x_fopen( filepath, O_RDONLY, 0 ))) { + f = x_fopen( filepath, O_RDONLY, 0 ); + if (f == NULL) { DEBUG(0,("read_init_file: failed to open [%s]\n", filepath)); TALLOC_FREE(info); return false; @@ -225,14 +232,16 @@ static bool read_init_file( const char *servicename, struct rcinit_file_informat /* Look for a line like '^#.*Description:' */ - if ( (p = strstr( str, "Description:" )) != NULL ) { + p = strstr( str, "Description:" ); + if (p != NULL) { char *desc; p += strlen( "Description:" ) + 1; if ( !p ) break; - if ( (desc = cleanup_string(p)) != NULL ) + desc = cleanup_string(p); + if (desc != NULL) info->description = talloc_strdup( info, desc ); } } @@ -253,37 +262,105 @@ static bool read_init_file( const char *servicename, struct rcinit_file_informat Display name, Description, etc... ********************************************************************/ -static void fill_service_values(const char *name, struct regval_ctr *values) +static WERROR svcctl_setvalue(struct registry_key *key, + const char *name, + struct registry_value *value) +{ + WERROR wresult; + + wresult = reg_setvalue(key, name, value); + if (!W_ERROR_IS_OK(wresult)) { + DEBUG(0, ("reg_setvalue failed for %s in key %s: %s\n", + name, key->key->name, win_errstr(wresult))); + } + + return wresult; +} + +static WERROR svcctl_setvalue_dword(struct registry_key *key, + const char *name, + uint32_t dword) +{ + struct registry_value value; + + value.type = REG_DWORD; + value.data.length = sizeof(uint32_t); + value.data.data = (uint8_t *)&dword; + + return svcctl_setvalue(key, name, &value); +} + +static WERROR svcctl_setvalue_sz(struct registry_key *key, + const char *name, + const char *sz) +{ + struct registry_value value; + WERROR wresult; + TALLOC_CTX *mem_ctx = talloc_stackframe(); + + if (!push_reg_sz(mem_ctx, &value.data, sz)) { + DEBUG(0, ("push_reg_sz failed\n")); + wresult = WERR_NOMEM; + goto done; + } + value.type = REG_SZ; + + wresult = svcctl_setvalue(key, name, &value); +done: + talloc_free(mem_ctx); + return wresult; +} + +static void fill_service_values(struct registry_key *key) { char *dname, *ipath, *description; - uint32 dword; int i; + WERROR wresult; + TALLOC_CTX *mem_ctx = talloc_stackframe(); + char *name = NULL; + + name = strrchr(key->key->name, '\\'); + if (name == NULL) { + name = key->key->name; + } else { + name++; + } /* These values are hardcoded in all QueryServiceConfig() replies. I'm just storing them here for cosmetic purposes */ - dword = SVCCTL_AUTO_START; - regval_ctr_addvalue( values, "Start", REG_DWORD, (uint8 *)&dword, sizeof(uint32)); + wresult = svcctl_setvalue_dword(key, "Start", SVCCTL_AUTO_START); + if (!W_ERROR_IS_OK(wresult)) { + goto done; + } - dword = SERVICE_TYPE_WIN32_OWN_PROCESS; - regval_ctr_addvalue( values, "Type", REG_DWORD, (uint8 *)&dword, sizeof(uint32)); + wresult = svcctl_setvalue_dword(key, "Type", SERVICE_TYPE_WIN32_OWN_PROCESS); + if (!W_ERROR_IS_OK(wresult)) { + goto done; + } - dword = SVCCTL_SVC_ERROR_NORMAL; - regval_ctr_addvalue( values, "ErrorControl", REG_DWORD, (uint8 *)&dword, sizeof(uint32)); + wresult = svcctl_setvalue_dword(key, "ErrorControl", SVCCTL_SVC_ERROR_NORMAL); + if (!W_ERROR_IS_OK(wresult)) { + goto done; + } /* everything runs as LocalSystem */ - regval_ctr_addvalue_sz(values, "ObjectName", "LocalSystem"); + wresult = svcctl_setvalue_sz(key, "ObjectName", "LocalSystem"); + if (!W_ERROR_IS_OK(wresult)) { + goto done; + } /* special considerations for internal services and the DisplayName value */ for ( i=0; builtin_svcs[i].servicename; i++ ) { if ( strequal( name, builtin_svcs[i].servicename ) ) { - ipath = talloc_asprintf(talloc_tos(), "%s/%s/%s", - get_dyn_MODULESDIR(), SVCCTL_SCRIPT_DIR, - builtin_svcs[i].daemon); - description = talloc_strdup(talloc_tos(), builtin_svcs[i].description); - dname = talloc_strdup(talloc_tos(), builtin_svcs[i].dispname); + ipath = talloc_asprintf(mem_ctx, "%s/%s/%s", + get_dyn_MODULESDIR(), + SVCCTL_SCRIPT_DIR, + builtin_svcs[i].daemon); + description = talloc_strdup(mem_ctx, builtin_svcs[i].description); + dname = talloc_strdup(mem_ctx, builtin_svcs[i].dispname); break; } } @@ -294,147 +371,83 @@ static void fill_service_values(const char *name, struct regval_ctr *values) char *dispname = NULL; struct rcinit_file_information *init_info = NULL; - ipath = talloc_asprintf(talloc_tos(), "%s/%s/%s", + ipath = talloc_asprintf(mem_ctx, "%s/%s/%s", get_dyn_MODULESDIR(), SVCCTL_SCRIPT_DIR, name); /* lookup common unix display names */ -- Samba Shared Repository