1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

More static fstring elimination.

Jeremy.
This commit is contained in:
Jeremy Allison 2007-12-17 18:00:43 -08:00
parent 97cfdae405
commit b4dfec09e8
2 changed files with 39 additions and 37 deletions

View File

@ -346,8 +346,8 @@ WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u,
rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0);
display_name = svcctl_lookup_dispname( service, p->pipe_user.nt_user_token );
init_svcctl_r_get_display_name( r_u, display_name );
display_name = svcctl_lookup_dispname(p->mem_ctx, service, p->pipe_user.nt_user_token );
init_svcctl_r_get_display_name( r_u, display_name ? display_name : "");
return WERR_OK;
}
@ -394,8 +394,8 @@ static int enumerate_status( TALLOC_CTX *ctx, ENUM_SERVICES_STATUS **status, NT_
for ( i=0; i<num_services; i++ ) {
init_unistr( &st[i].servicename, svcctl_ops[i].name );
display_name = svcctl_lookup_dispname( svcctl_ops[i].name, token );
init_unistr( &st[i].displayname, display_name );
display_name = svcctl_lookup_dispname(ctx, svcctl_ops[i].name, token );
init_unistr( &st[i].displayname, display_name ? display_name : "");
svcctl_ops[i].ops->service_status( svcctl_ops[i].name, &st[i].status );
}
@ -688,16 +688,16 @@ WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CO
{
SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle );
uint32 buffer_size;
/* perform access checks */
if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) )
return WERR_BADFID;
return WERR_BADFID;
if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_CONFIG) )
return WERR_ACCESS_DENIED;
/* we have to set the outgoing buffer size to the same as the
/* we have to set the outgoing buffer size to the same as the
incoming buffer size (even in the case of failure */
rpcbuf_init( &r_u->buffer, q_u->buffer_size, p->mem_ctx );
@ -708,12 +708,12 @@ WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CO
{
SERVICE_DESCRIPTION desc_buf;
const char *description;
description = svcctl_lookup_description( info->name, p->pipe_user.nt_user_token );
description = svcctl_lookup_description(p->mem_ctx, info->name, p->pipe_user.nt_user_token );
ZERO_STRUCTP( &desc_buf );
init_service_description_buffer( &desc_buf, description );
init_service_description_buffer( &desc_buf, description ? description : "");
svcctl_io_service_description( "", &desc_buf, &r_u->buffer, 0 );
buffer_size = svcctl_sizeof_service_description( &desc_buf );
@ -737,7 +737,7 @@ WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CO
default:
return WERR_UNKNOWN_LEVEL;
}
buffer_size += buffer_size % 4;
r_u->needed = (buffer_size > q_u->buffer_size) ? buffer_size : q_u->buffer_size;

View File

@ -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;
}