diff options
author | Gerald Carter <jerry@samba.org> | 2006-01-13 20:24:50 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:06:07 -0500 |
commit | e7a1a0ead2013464dc8204e5b997ddc3ae46e973 (patch) | |
tree | 62ed9768e9473a8541cf48a9d846971e68413154 /source3/services | |
parent | c5e7ddc63b1bf7d4b4e06baeff222c5859ae4061 (diff) | |
download | samba-e7a1a0ead2013464dc8204e5b997ddc3ae46e973.tar.gz samba-e7a1a0ead2013464dc8204e5b997ddc3ae46e973.tar.bz2 samba-e7a1a0ead2013464dc8204e5b997ddc3ae46e973.zip |
r12914: adding query/set ops for security descriptors on services.
(This used to be commit cefd2d7cb6140b068d66e2383e9acfa4c3c4b4c7)
Diffstat (limited to 'source3/services')
-rw-r--r-- | source3/services/services_db.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/source3/services/services_db.c b/source3/services/services_db.c index b3ba7fcc96..a16657c0ed 100644 --- a/source3/services/services_db.c +++ b/source3/services/services_db.c @@ -520,6 +520,53 @@ SEC_DESC* svcctl_get_secdesc( TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN * } /******************************************************************** + Wrapper to make storing a Service sd easier +********************************************************************/ + +BOOL svcctl_set_secdesc( TALLOC_CTX *ctx, const char *name, SEC_DESC *sec_desc, NT_USER_TOKEN *token ) +{ + REGISTRY_KEY *key; + WERROR wresult; + pstring path; + REGVAL_CTR *values; + prs_struct ps; + BOOL ret = False; + + /* now add the security descriptor */ + + pstr_sprintf( path, "%s\\%s\\%s", KEY_SERVICES, name, "Security" ); + wresult = regkey_open_internal( &key, path, token, REG_KEY_ALL ); + if ( !W_ERROR_IS_OK(wresult) ) { + DEBUG(0,("svcctl_get_secdesc: key lookup failed! [%s] (%s)\n", + path, dos_errstr(wresult))); + return False; + } + + if ( !(values = TALLOC_ZERO_P( key, REGVAL_CTR )) ) { + DEBUG(0,("add_new_svc_name: talloc() failed!\n")); + regkey_close_internal( key ); + return False; + } + + /* stream the printer security descriptor */ + + prs_init( &ps, RPC_MAX_PDU_FRAG_LEN, key, MARSHALL); + + if ( sec_io_desc("sec_desc", &sec_desc, &ps, 0 ) ) { + uint32 offset = prs_offset( &ps ); + regval_ctr_addvalue( values, "Security", REG_BINARY, prs_data_p(&ps), offset ); + ret = store_reg_values( key, values ); + } + + /* cleanup */ + + prs_mem_free( &ps ); + regkey_close_internal( key); + + return ret; +} + +/******************************************************************** ********************************************************************/ char* svcctl_lookup_dispname( const char *name, NT_USER_TOKEN *token ) |