summaryrefslogtreecommitdiff
path: root/source3/services
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-12-17 18:00:43 -0800
committerJeremy Allison <jra@samba.org>2007-12-17 18:00:43 -0800
commite3efe7cd7e11be5a78ddce9a49316b516ab81ba3 (patch)
tree08e16e20e0f3146b71a6271479c9f375422e4ba9 /source3/services
parent192aae0564c641fa06f90a064c033fa52d8cf549 (diff)
downloadsamba-e3efe7cd7e11be5a78ddce9a49316b516ab81ba3.tar.gz
samba-e3efe7cd7e11be5a78ddce9a49316b516ab81ba3.tar.bz2
samba-e3efe7cd7e11be5a78ddce9a49316b516ab81ba3.zip
More static fstring elimination.
Jeremy. (This used to be commit b4dfec09e89428cac9b21a94ce4d24e60d4a54f4)
Diffstat (limited to 'source3/services')
-rw-r--r--source3/services/services_db.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/source3/services/services_db.c b/source3/services/services_db.c
index 430c58f50d..c57b29cc80 100644
--- a/source3/services/services_db.c
+++ b/source3/services/services_db.c
@@ -125,22 +125,22 @@ static SEC_DESC* construct_service_sd( TALLOC_CTX *ctx )
static char *get_common_service_dispname( const char *servicename )
{
- static fstring dispname;
int i;
for ( i=0; common_unix_svcs[i].servicename; i++ ) {
if (strequal(servicename, common_unix_svcs[i].servicename)) {
- fstr_sprintf( dispname, "%s (%s)",
+ char *dispname;
+ if (asprintf(&dispname,
+ "%s (%s)",
common_unix_svcs[i].dispname,
- common_unix_svcs[i].servicename );
-
+ common_unix_svcs[i].servicename) < 0) {
+ return NULL;
+ }
return dispname;
}
}
- fstrcpy( dispname, servicename );
-
- return dispname;
+ return SMB_STRDUP(servicename );
}
/********************************************************************
@@ -292,6 +292,7 @@ static void fill_service_values( const char *name, REGVAL_CTR *values )
if ( builtin_svcs[i].servicename == NULL ) {
char *pstr = NULL;
+ char *dispname = NULL;
struct rcinit_file_information *init_info = NULL;
if (asprintf(&pstr, "%s/%s/%s",get_dyn_LIBDIR(),
@@ -303,7 +304,9 @@ static void fill_service_values( const char *name, REGVAL_CTR *values )
}
/* lookup common unix display names */
- init_unistr2( &dname, get_common_service_dispname( name ), UNI_STR_TERMINATE );
+ dispname = get_common_service_dispname(name);
+ init_unistr2( &dname, dispname ? dispname : "", UNI_STR_TERMINATE );
+ SAFE_FREE(dispname);
/* get info from init file itself */
if ( read_init_file( name, &init_info ) ) {
@@ -602,9 +605,9 @@ bool svcctl_set_secdesc( TALLOC_CTX *ctx, const char *name, SEC_DESC *sec_desc,
/********************************************************************
********************************************************************/
-char *svcctl_lookup_dispname( const char *name, NT_USER_TOKEN *token )
+const char *svcctl_lookup_dispname(TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN *token )
{
- static fstring display_name;
+ char *display_name = NULL;
REGISTRY_KEY *key = NULL;
REGVAL_CTR *values;
REGISTRY_VALUE *val;
@@ -637,7 +640,7 @@ char *svcctl_lookup_dispname( const char *name, NT_USER_TOKEN *token )
if ( !(val = regval_ctr_getvalue( values, "DisplayName" )) )
goto fail;
- rpcstr_pull( display_name, regval_data_p(val), sizeof(display_name), regval_size(val), 0 );
+ rpcstr_pull_talloc(ctx, &display_name, regval_data_p(val), regval_size(val), 0 );
TALLOC_FREE( key );
@@ -646,16 +649,15 @@ char *svcctl_lookup_dispname( const char *name, NT_USER_TOKEN *token )
fail:
/* default to returning the service name */
TALLOC_FREE( key );
- fstrcpy( display_name, name );
- return display_name;
+ return talloc_strdup(ctx, name);
}
/********************************************************************
********************************************************************/
-char *svcctl_lookup_description( const char *name, NT_USER_TOKEN *token )
+const char *svcctl_lookup_description(TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN *token )
{
- static fstring description;
+ char *description = NULL;
REGISTRY_KEY *key = NULL;
REGVAL_CTR *values;
REGISTRY_VALUE *val;
@@ -670,7 +672,7 @@ char *svcctl_lookup_description( const char *name, NT_USER_TOKEN *token )
wresult = regkey_open_internal( NULL, &key, path, token,
REG_KEY_READ );
if ( !W_ERROR_IS_OK(wresult) ) {
- DEBUG(0,("svcctl_lookup_dispname: key lookup failed! [%s] (%s)\n",
+ DEBUG(0,("svcctl_lookup_description: key lookup failed! [%s] (%s)\n",
path, dos_errstr(wresult)));
SAFE_FREE(path);
return NULL;
@@ -678,19 +680,19 @@ char *svcctl_lookup_description( const char *name, NT_USER_TOKEN *token )
SAFE_FREE(path);
if ( !(values = TALLOC_ZERO_P( key, REGVAL_CTR )) ) {
- DEBUG(0,("svcctl_lookup_dispname: talloc() failed!\n"));
+ DEBUG(0,("svcctl_lookup_description: talloc() failed!\n"));
TALLOC_FREE( key );
return NULL;
}
fetch_reg_values( key, values );
- if ( !(val = regval_ctr_getvalue( values, "Description" )) )
- fstrcpy( description, "Unix Service");
- else
- rpcstr_pull( description, regval_data_p(val), sizeof(description), regval_size(val), 0 );
-
- TALLOC_FREE( key );
+ if ( !(val = regval_ctr_getvalue( values, "Description" )) ) {
+ TALLOC_FREE( key );
+ return "Unix Service";
+ }
+ rpcstr_pull_talloc(ctx, &description, regval_data_p(val), regval_size(val), 0 );
+ TALLOC_FREE(key);
return description;
}