2005-01-13 21:20:37 +03:00
/*
2002-01-30 09:08:46 +03:00
* Unix SMB / CIFS implementation .
2001-02-26 22:31:07 +03:00
* RPC Pipe client / server routines
* Copyright ( C ) Andrew Tridgell 1992 - 1997 ,
* Copyright ( C ) Luke Kenneth Casson Leighton 1996 - 1997 ,
2002-07-15 14:35:28 +04:00
* Copyright ( C ) Paul Ashton 1997 ,
2006-02-16 04:06:21 +03:00
* Copyright ( C ) Jeremy Allison 2001 , 2006.
2002-08-17 19:34:15 +04:00
* Copyright ( C ) Rafal Szczesniak 2002 ,
2004-04-13 18:39:48 +04:00
* Copyright ( C ) Jim McDonough < jmcd @ us . ibm . com > 2002 ,
2005-01-13 21:20:37 +03:00
* Copyright ( C ) Simo Sorce 2003.
2005-03-10 21:50:47 +03:00
* Copyright ( C ) Gerald ( Jerry ) Carter 2005.
2006-02-04 01:19:41 +03:00
* Copyright ( C ) Volker Lendecke 2005.
2008-02-27 21:38:48 +03:00
* Copyright ( C ) Guenther Deschner 2008.
2001-02-26 22:31:07 +03:00
*
* 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
2007-07-09 23:25:36 +04:00
* the Free Software Foundation ; either version 3 of the License , or
2001-02-26 22:31:07 +03:00
* ( at your option ) any later version .
2008-02-14 15:12:28 +03:00
*
2001-02-26 22:31:07 +03:00
* 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 .
2008-02-14 15:12:28 +03:00
*
2001-02-26 22:31:07 +03:00
* You should have received a copy of the GNU General Public License
2007-07-10 09:23:25 +04:00
* along with this program ; if not , see < http : //www.gnu.org/licenses/>.
2001-02-26 22:31:07 +03:00
*/
/* This is the implementation of the lsa server code. */
# include "includes.h"
2002-07-15 14:35:28 +04:00
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_RPC_SRV
2001-07-09 22:32:54 +04:00
extern PRIVS privs [ ] ;
struct lsa_info {
2002-11-13 02:20:50 +03:00
DOM_SID sid ;
uint32 access ;
2001-07-09 22:32:54 +04:00
} ;
2007-10-06 01:41:17 +04:00
const struct generic_mapping lsa_generic_mapping = {
2008-02-27 17:49:31 +03:00
LSA_POLICY_READ ,
LSA_POLICY_WRITE ,
LSA_POLICY_EXECUTE ,
LSA_POLICY_ALL_ACCESS
2001-12-18 02:03:23 +03:00
} ;
2008-02-18 16:40:34 +03:00
/***************************************************************************
init_lsa_ref_domain_list - adds a domain if it ' s not already in , returns the index .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static int init_lsa_ref_domain_list ( TALLOC_CTX * mem_ctx ,
struct lsa_RefDomainList * ref ,
const char * dom_name ,
DOM_SID * dom_sid )
{
int num = 0 ;
if ( dom_name ! = NULL ) {
for ( num = 0 ; num < ref - > count ; num + + ) {
if ( sid_equal ( dom_sid , ref - > domains [ num ] . sid ) ) {
return num ;
}
}
} else {
num = ref - > count ;
}
if ( num > = MAX_REF_DOMAINS ) {
/* index not found, already at maximum domain limit */
return - 1 ;
}
ref - > count = num + 1 ;
ref - > max_size = MAX_REF_DOMAINS ;
ref - > domains = TALLOC_REALLOC_ARRAY ( mem_ctx , ref - > domains ,
struct lsa_DomainInfo , ref - > count ) ;
if ( ! ref - > domains ) {
return - 1 ;
}
2008-03-04 13:06:02 +03:00
ZERO_STRUCT ( ref - > domains [ num ] ) ;
2008-02-18 16:40:34 +03:00
init_lsa_StringLarge ( & ref - > domains [ num ] . name , dom_name ) ;
ref - > domains [ num ] . sid = sid_dup_talloc ( mem_ctx , dom_sid ) ;
if ( ! ref - > domains [ num ] . sid ) {
return - 1 ;
}
return num ;
}
2001-07-09 22:32:54 +04:00
/*******************************************************************
Function to free the per handle data .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void free_lsa_info ( void * ptr )
{
struct lsa_info * lsa = ( struct lsa_info * ) ptr ;
2003-04-22 12:50:20 +04:00
SAFE_FREE ( lsa ) ;
2001-07-09 22:32:54 +04:00
}
2001-02-26 22:31:07 +03:00
/***************************************************************************
2008-02-08 03:13:50 +03:00
initialize a lsa_DomainInfo structure .
2001-02-26 22:31:07 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-08 03:13:50 +03:00
static void init_dom_query_3 ( struct lsa_DomainInfo * r ,
const char * name ,
DOM_SID * sid )
2001-02-26 22:31:07 +03:00
{
2008-02-08 03:13:50 +03:00
init_lsa_StringLarge ( & r - > name , name ) ;
r - > sid = sid ;
2001-02-26 22:31:07 +03:00
}
2006-04-11 19:47:24 +04:00
/***************************************************************************
2008-02-08 03:13:50 +03:00
initialize a lsa_DomainInfo structure .
2006-04-11 19:47:24 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-08 03:13:50 +03:00
static void init_dom_query_5 ( struct lsa_DomainInfo * r ,
const char * name ,
DOM_SID * sid )
2006-04-11 19:47:24 +04:00
{
2008-02-08 03:13:50 +03:00
init_lsa_StringLarge ( & r - > name , name ) ;
r - > sid = sid ;
2006-04-11 19:47:24 +04:00
}
2001-02-26 22:31:07 +03:00
/***************************************************************************
2006-02-16 04:06:21 +03:00
lookup_lsa_rids . Must be called as root for lookup_name to work .
2001-02-26 22:31:07 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-02-16 04:06:21 +03:00
static NTSTATUS lookup_lsa_rids ( TALLOC_CTX * mem_ctx ,
2008-02-18 16:40:34 +03:00
struct lsa_RefDomainList * ref ,
struct lsa_TranslatedSid * prid ,
uint32_t num_entries ,
struct lsa_String * name ,
int flags ,
uint32_t * pmapped_count )
2001-02-26 22:31:07 +03:00
{
2006-02-18 03:27:31 +03:00
uint32 mapped_count , i ;
2001-02-26 22:31:07 +03:00
SMB_ASSERT ( num_entries < = MAX_LOOKUP_SIDS ) ;
2005-12-03 21:34:13 +03:00
mapped_count = 0 ;
2006-02-16 04:06:21 +03:00
* pmapped_count = 0 ;
2002-01-26 13:02:23 +03:00
2001-02-26 22:31:07 +03:00
for ( i = 0 ; i < num_entries ; i + + ) {
DOM_SID sid ;
2005-12-03 21:34:13 +03:00
uint32 rid ;
int dom_idx ;
2008-02-18 16:40:34 +03:00
const char * full_name ;
2005-12-10 14:22:01 +03:00
const char * domain ;
2006-09-08 18:28:06 +04:00
enum lsa_SidType type = SID_NAME_UNKNOWN ;
2001-02-26 22:31:07 +03:00
/* Split name into domain and user component */
2008-02-18 16:40:34 +03:00
full_name = name [ i ] . string ;
2006-02-04 01:19:41 +03:00
if ( full_name = = NULL ) {
2006-02-16 04:06:21 +03:00
return NT_STATUS_NO_MEMORY ;
2005-12-03 21:34:13 +03:00
}
2001-02-26 22:31:07 +03:00
2006-02-16 04:06:21 +03:00
DEBUG ( 5 , ( " lookup_lsa_rids: looking up name %s \n " , full_name ) ) ;
2001-02-26 22:31:07 +03:00
2005-12-03 21:34:13 +03:00
/* We can ignore the result of lookup_name, it will not touch
" type " if it ' s not successful */
2004-04-07 02:02:47 +04:00
2005-12-03 21:34:13 +03:00
lookup_name ( mem_ctx , full_name , flags , & domain , NULL ,
& sid , & type ) ;
2004-04-07 16:43:44 +04:00
2005-12-03 21:34:13 +03:00
switch ( type ) {
case SID_NAME_USER :
case SID_NAME_DOM_GRP :
case SID_NAME_DOMAIN :
case SID_NAME_ALIAS :
case SID_NAME_WKN_GRP :
2006-02-11 05:46:41 +03:00
DEBUG ( 5 , ( " init_lsa_rids: %s found \n " , full_name ) ) ;
2005-12-03 21:34:13 +03:00
/* Leave these unchanged */
break ;
default :
/* Don't hand out anything but the list above */
2006-02-11 05:46:41 +03:00
DEBUG ( 5 , ( " init_lsa_rids: %s not found \n " , full_name ) ) ;
2005-12-03 21:34:13 +03:00
type = SID_NAME_UNKNOWN ;
break ;
}
rid = 0 ;
dom_idx = - 1 ;
if ( type ! = SID_NAME_UNKNOWN ) {
2001-02-26 22:31:07 +03:00
sid_split_rid ( & sid , & rid ) ;
2008-02-18 16:40:34 +03:00
dom_idx = init_lsa_ref_domain_list ( mem_ctx , ref , domain , & sid ) ;
2005-12-03 21:34:13 +03:00
mapped_count + + ;
2001-02-26 22:31:07 +03:00
}
2008-02-18 16:40:34 +03:00
init_lsa_translated_sid ( & prid [ i ] , type , rid , dom_idx ) ;
2001-02-26 22:31:07 +03:00
}
2002-01-26 13:02:23 +03:00
2006-02-16 04:06:21 +03:00
* pmapped_count = mapped_count ;
return NT_STATUS_OK ;
}
/***************************************************************************
lookup_lsa_sids . Must be called as root for lookup_name to work .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static NTSTATUS lookup_lsa_sids ( TALLOC_CTX * mem_ctx ,
2008-02-18 18:57:02 +03:00
struct lsa_RefDomainList * ref ,
struct lsa_TranslatedSid3 * trans_sids ,
uint32_t num_entries ,
struct lsa_String * name ,
int flags ,
uint32 * pmapped_count )
2006-02-16 04:06:21 +03:00
{
2006-02-18 03:27:31 +03:00
uint32 mapped_count , i ;
2006-02-16 04:06:21 +03:00
SMB_ASSERT ( num_entries < = MAX_LOOKUP_SIDS ) ;
mapped_count = 0 ;
* pmapped_count = 0 ;
for ( i = 0 ; i < num_entries ; i + + ) {
DOM_SID sid ;
uint32 rid ;
int dom_idx ;
2008-02-18 18:57:02 +03:00
const char * full_name ;
2006-02-16 04:06:21 +03:00
const char * domain ;
2006-09-08 18:28:06 +04:00
enum lsa_SidType type = SID_NAME_UNKNOWN ;
2006-02-16 04:06:21 +03:00
2008-03-04 13:06:02 +03:00
ZERO_STRUCT ( sid ) ;
2006-02-16 04:06:21 +03:00
/* Split name into domain and user component */
2008-02-18 18:57:02 +03:00
full_name = name [ i ] . string ;
2006-02-16 04:06:21 +03:00
if ( full_name = = NULL ) {
return NT_STATUS_NO_MEMORY ;
}
DEBUG ( 5 , ( " init_lsa_sids: looking up name %s \n " , full_name ) ) ;
/* We can ignore the result of lookup_name, it will not touch
" type " if it ' s not successful */
lookup_name ( mem_ctx , full_name , flags , & domain , NULL ,
& sid , & type ) ;
switch ( type ) {
case SID_NAME_USER :
case SID_NAME_DOM_GRP :
case SID_NAME_DOMAIN :
case SID_NAME_ALIAS :
case SID_NAME_WKN_GRP :
DEBUG ( 5 , ( " init_lsa_sids: %s found \n " , full_name ) ) ;
/* Leave these unchanged */
break ;
default :
/* Don't hand out anything but the list above */
DEBUG ( 5 , ( " init_lsa_sids: %s not found \n " , full_name ) ) ;
type = SID_NAME_UNKNOWN ;
break ;
}
rid = 0 ;
dom_idx = - 1 ;
if ( type ! = SID_NAME_UNKNOWN ) {
DOM_SID domain_sid ;
sid_copy ( & domain_sid , & sid ) ;
sid_split_rid ( & domain_sid , & rid ) ;
2008-02-18 18:57:02 +03:00
dom_idx = init_lsa_ref_domain_list ( mem_ctx , ref , domain , & domain_sid ) ;
2006-02-16 04:06:21 +03:00
mapped_count + + ;
}
2008-02-18 18:57:02 +03:00
/* Initialize the lsa_TranslatedSid3 return. */
2006-02-16 04:06:21 +03:00
trans_sids [ i ] . sid_type = type ;
2008-02-18 18:57:02 +03:00
trans_sids [ i ] . sid = sid_dup_talloc ( mem_ctx , & sid ) ;
trans_sids [ i ] . sid_index = dom_idx ;
2006-02-16 04:06:21 +03:00
}
2005-12-03 21:34:13 +03:00
2006-02-16 04:06:21 +03:00
* pmapped_count = mapped_count ;
return NT_STATUS_OK ;
2001-02-26 22:31:07 +03:00
}
2001-12-18 02:03:23 +03:00
static NTSTATUS lsa_get_generic_sd ( TALLOC_CTX * mem_ctx , SEC_DESC * * sd , size_t * sd_size )
{
DOM_SID local_adm_sid ;
DOM_SID adm_sid ;
SEC_ACE ace [ 3 ] ;
SEC_ACL * psa = NULL ;
2008-10-09 20:49:03 +04:00
init_sec_ace ( & ace [ 0 ] , & global_sid_World , SEC_ACE_TYPE_ACCESS_ALLOWED , LSA_POLICY_EXECUTE , 0 ) ;
2001-12-18 02:03:23 +03:00
2002-07-15 14:35:28 +04:00
sid_copy ( & adm_sid , get_global_sam_sid ( ) ) ;
2001-12-18 02:03:23 +03:00
sid_append_rid ( & adm_sid , DOMAIN_GROUP_RID_ADMINS ) ;
2008-10-09 20:49:03 +04:00
init_sec_ace ( & ace [ 1 ] , & adm_sid , SEC_ACE_TYPE_ACCESS_ALLOWED , LSA_POLICY_ALL_ACCESS , 0 ) ;
2001-12-18 02:03:23 +03:00
sid_copy ( & local_adm_sid , & global_sid_Builtin ) ;
sid_append_rid ( & local_adm_sid , BUILTIN_ALIAS_RID_ADMINS ) ;
2008-10-09 20:49:03 +04:00
init_sec_ace ( & ace [ 2 ] , & local_adm_sid , SEC_ACE_TYPE_ACCESS_ALLOWED , LSA_POLICY_ALL_ACCESS , 0 ) ;
2001-12-18 02:03:23 +03:00
if ( ( psa = make_sec_acl ( mem_ctx , NT4_ACL_REVISION , 3 , ace ) ) = = NULL )
return NT_STATUS_NO_MEMORY ;
2007-12-21 00:27:01 +03:00
if ( ( * sd = make_sec_desc ( mem_ctx , SECURITY_DESCRIPTOR_REVISION_1 ,
SEC_DESC_SELF_RELATIVE , & adm_sid , NULL , NULL ,
psa , sd_size ) ) = = NULL )
2001-12-18 02:03:23 +03:00
return NT_STATUS_NO_MEMORY ;
return NT_STATUS_OK ;
}
2005-03-10 21:50:47 +03:00
#if 0 /* AD DC work in ongoing in Samba 4 */
2002-08-17 19:34:15 +04:00
/***************************************************************************
2002-11-13 02:20:50 +03:00
Init_dns_dom_info .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void init_dns_dom_info ( LSA_DNS_DOM_INFO * r_l , const char * nb_name ,
const char * dns_name , const char * forest_name ,
2006-09-19 21:29:31 +04:00
struct GUID * dom_guid , DOM_SID * dom_sid )
2002-08-17 19:34:15 +04:00
{
if ( nb_name & & * nb_name ) {
2003-09-26 01:26:16 +04:00
init_unistr2 ( & r_l - > uni_nb_dom_name , nb_name , UNI_FLAGS_NONE ) ;
init_uni_hdr ( & r_l - > hdr_nb_dom_name , & r_l - > uni_nb_dom_name ) ;
2002-08-17 19:34:15 +04:00
r_l - > hdr_nb_dom_name . uni_max_len + = 2 ;
r_l - > uni_nb_dom_name . uni_max_len + = 1 ;
}
2008-02-14 15:12:28 +03:00
2002-08-17 19:34:15 +04:00
if ( dns_name & & * dns_name ) {
2003-09-26 01:26:16 +04:00
init_unistr2 ( & r_l - > uni_dns_dom_name , dns_name , UNI_FLAGS_NONE ) ;
init_uni_hdr ( & r_l - > hdr_dns_dom_name , & r_l - > uni_dns_dom_name ) ;
2002-08-17 19:34:15 +04:00
r_l - > hdr_dns_dom_name . uni_max_len + = 2 ;
r_l - > uni_dns_dom_name . uni_max_len + = 1 ;
}
if ( forest_name & & * forest_name ) {
2003-09-26 01:26:16 +04:00
init_unistr2 ( & r_l - > uni_forest_name , forest_name , UNI_FLAGS_NONE ) ;
init_uni_hdr ( & r_l - > hdr_forest_name , & r_l - > uni_forest_name ) ;
2002-08-17 19:34:15 +04:00
r_l - > hdr_forest_name . uni_max_len + = 2 ;
r_l - > uni_forest_name . uni_max_len + = 1 ;
}
/* how do we init the guid ? probably should write an init fn */
if ( dom_guid ) {
2006-09-19 21:29:31 +04:00
memcpy ( & r_l - > dom_guid , dom_guid , sizeof ( struct GUID ) ) ;
2002-08-17 19:34:15 +04:00
}
2008-02-14 15:12:28 +03:00
2002-08-17 19:34:15 +04:00
if ( dom_sid ) {
r_l - > ptr_dom_sid = 1 ;
init_dom_sid2 ( & r_l - > dom_sid , dom_sid ) ;
}
}
2005-03-10 21:50:47 +03:00
# endif /* AD DC work in ongoing in Samba 4 */
2002-08-17 19:34:15 +04:00
2001-02-26 22:31:07 +03:00
/***************************************************************************
2008-02-04 23:00:38 +03:00
_lsa_OpenPolicy2
2001-02-26 22:31:07 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-04 23:00:38 +03:00
NTSTATUS _lsa_OpenPolicy2 ( pipes_struct * p ,
struct lsa_OpenPolicy2 * r )
2001-02-26 22:31:07 +03:00
{
2001-12-18 02:03:23 +03:00
struct lsa_info * info ;
SEC_DESC * psd = NULL ;
size_t sd_size ;
2008-02-04 23:00:38 +03:00
uint32 des_access = r - > in . access_mask ;
2001-12-18 02:03:23 +03:00
uint32 acc_granted ;
NTSTATUS status ;
/* map the generic bits to the lsa policy ones */
se_map_generic ( & des_access , & lsa_generic_mapping ) ;
/* get the generic lsa policy SD until we store it */
lsa_get_generic_sd ( p - > mem_ctx , & psd , & sd_size ) ;
2003-06-18 19:24:10 +04:00
if ( ! se_access_check ( psd , p - > pipe_user . nt_user_token , des_access , & acc_granted , & status ) ) {
2006-07-23 00:46:02 +04:00
if ( p - > pipe_user . ut . uid ! = sec_initial_uid ( ) ) {
2003-06-18 19:24:10 +04:00
return status ;
}
DEBUG ( 4 , ( " ACCESS should be DENIED (granted: %#010x; required: %#010x) \n " ,
acc_granted , des_access ) ) ;
DEBUGADD ( 4 , ( " but overwritten by euid == 0 \n " ) ) ;
}
2005-01-13 21:20:37 +03:00
/* This is needed for lsa_open_account and rpcclient .... :-) */
2006-07-23 00:46:02 +04:00
if ( p - > pipe_user . ut . uid = = sec_initial_uid ( ) )
2008-02-27 17:49:31 +03:00
acc_granted = LSA_POLICY_ALL_ACCESS ;
2001-12-18 02:03:23 +03:00
/* associate the domain SID with the (unique) handle. */
2004-12-07 21:25:53 +03:00
if ( ( info = SMB_MALLOC_P ( struct lsa_info ) ) = = NULL )
2001-12-18 02:03:23 +03:00
return NT_STATUS_NO_MEMORY ;
ZERO_STRUCTP ( info ) ;
2002-07-15 14:35:28 +04:00
sid_copy ( & info - > sid , get_global_sam_sid ( ) ) ;
2001-12-18 02:03:23 +03:00
info - > access = acc_granted ;
2001-02-26 22:31:07 +03:00
/* set up the LSA QUERY INFO response */
2008-02-04 23:00:38 +03:00
if ( ! create_policy_hnd ( p , r - > out . handle , free_lsa_info , ( void * ) info ) )
2001-03-11 03:32:10 +03:00
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
2001-02-26 22:31:07 +03:00
2001-08-27 23:46:22 +04:00
return NT_STATUS_OK ;
2001-02-26 22:31:07 +03:00
}
/***************************************************************************
2008-02-04 23:00:16 +03:00
_lsa_OpenPolicy
2001-02-26 22:31:07 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-04 23:00:16 +03:00
NTSTATUS _lsa_OpenPolicy ( pipes_struct * p ,
struct lsa_OpenPolicy * r )
2001-02-26 22:31:07 +03:00
{
2001-12-18 02:03:23 +03:00
struct lsa_info * info ;
SEC_DESC * psd = NULL ;
size_t sd_size ;
2008-02-04 23:00:16 +03:00
uint32 des_access = r - > in . access_mask ;
2001-12-18 02:03:23 +03:00
uint32 acc_granted ;
NTSTATUS status ;
/* map the generic bits to the lsa policy ones */
se_map_generic ( & des_access , & lsa_generic_mapping ) ;
/* get the generic lsa policy SD until we store it */
lsa_get_generic_sd ( p - > mem_ctx , & psd , & sd_size ) ;
2003-06-18 19:24:10 +04:00
if ( ! se_access_check ( psd , p - > pipe_user . nt_user_token , des_access , & acc_granted , & status ) ) {
2008-10-18 02:24:15 +04:00
if ( p - > pipe_user . ut . uid ! = sec_initial_uid ( ) ) {
2003-06-18 19:24:10 +04:00
return status ;
}
DEBUG ( 4 , ( " ACCESS should be DENIED (granted: %#010x; required: %#010x) \n " ,
acc_granted , des_access ) ) ;
DEBUGADD ( 4 , ( " but overwritten by euid == 0 \n " ) ) ;
acc_granted = des_access ;
}
2001-12-18 02:03:23 +03:00
/* associate the domain SID with the (unique) handle. */
2004-12-07 21:25:53 +03:00
if ( ( info = SMB_MALLOC_P ( struct lsa_info ) ) = = NULL )
2001-12-18 02:03:23 +03:00
return NT_STATUS_NO_MEMORY ;
ZERO_STRUCTP ( info ) ;
2002-07-15 14:35:28 +04:00
sid_copy ( & info - > sid , get_global_sam_sid ( ) ) ;
2001-12-18 02:03:23 +03:00
info - > access = acc_granted ;
2001-02-26 22:31:07 +03:00
/* set up the LSA QUERY INFO response */
2008-02-04 23:00:16 +03:00
if ( ! create_policy_hnd ( p , r - > out . handle , free_lsa_info , ( void * ) info ) )
2001-03-11 03:32:10 +03:00
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
2001-02-26 22:31:07 +03:00
2001-08-27 23:46:22 +04:00
return NT_STATUS_OK ;
2001-02-26 22:31:07 +03:00
}
/***************************************************************************
2008-02-13 02:02:21 +03:00
_lsa_EnumTrustDom - this needs fixing to do more than return NULL ! JRA .
2002-07-15 14:35:28 +04:00
ufff , done : ) mimir
2001-02-26 22:31:07 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-13 02:02:21 +03:00
NTSTATUS _lsa_EnumTrustDom ( pipes_struct * p ,
struct lsa_EnumTrustDom * r )
2001-02-26 22:31:07 +03:00
{
2001-12-18 02:03:23 +03:00
struct lsa_info * info ;
2006-02-04 01:19:41 +03:00
uint32 next_idx ;
struct trustdom_info * * domains ;
2008-02-13 02:02:21 +03:00
struct lsa_DomainInfo * lsa_domains = NULL ;
int i ;
2002-07-15 14:35:28 +04:00
/*
* preferred length is set to 5 as a " our " preferred length
* nt sets this parameter to 2
2002-09-25 19:19:00 +04:00
* update ( 20.08 .2002 ) : it ' s not preferred length , but preferred size !
* it needs further investigation how to optimally choose this value
2002-07-15 14:35:28 +04:00
*/
2006-02-04 01:19:41 +03:00
uint32 max_num_domains =
2008-02-13 02:02:21 +03:00
r - > in . max_size < 5 ? r - > in . max_size : 10 ;
2002-07-15 14:35:28 +04:00
uint32 num_domains ;
NTSTATUS nt_status ;
2006-02-04 01:19:41 +03:00
uint32 num_thistime ;
2001-02-26 22:31:07 +03:00
2008-02-13 02:02:21 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2001-03-11 03:32:10 +03:00
return NT_STATUS_INVALID_HANDLE ;
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( info - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2008-06-16 15:27:16 +04:00
become_root ( ) ;
2007-01-16 11:17:26 +03:00
nt_status = pdb_enum_trusteddoms ( p - > mem_ctx , & num_domains , & domains ) ;
2008-06-16 15:27:16 +04:00
unbecome_root ( ) ;
2002-07-15 14:35:28 +04:00
2006-02-04 01:19:41 +03:00
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
2002-07-15 14:35:28 +04:00
return nt_status ;
}
2008-02-13 02:02:21 +03:00
if ( * r - > in . resume_handle < num_domains ) {
2006-02-04 01:19:41 +03:00
num_thistime = MIN ( num_domains , max_num_domains ) ;
2008-02-13 02:02:21 +03:00
nt_status = STATUS_MORE_ENTRIES ;
2006-02-04 01:19:41 +03:00
2008-02-13 02:02:21 +03:00
if ( * r - > in . resume_handle + num_thistime > num_domains ) {
num_thistime = num_domains - * r - > in . resume_handle ;
nt_status = NT_STATUS_OK ;
2006-02-04 01:19:41 +03:00
}
2008-02-13 02:02:21 +03:00
next_idx = * r - > in . resume_handle + num_thistime ;
2006-02-04 01:19:41 +03:00
} else {
num_thistime = 0 ;
next_idx = 0xffffffff ;
2008-02-13 02:02:21 +03:00
nt_status = NT_STATUS_NO_MORE_ENTRIES ;
2006-02-04 01:19:41 +03:00
}
2008-02-13 02:02:21 +03:00
2002-07-15 14:35:28 +04:00
/* set up the lsa_enum_trust_dom response */
2005-04-07 02:27:55 +04:00
2008-02-13 02:02:21 +03:00
lsa_domains = TALLOC_ZERO_ARRAY ( p - > mem_ctx , struct lsa_DomainInfo ,
num_thistime ) ;
if ( ! lsa_domains ) {
return NT_STATUS_NO_MEMORY ;
}
2001-02-26 22:31:07 +03:00
2008-02-13 02:02:21 +03:00
for ( i = 0 ; i < num_thistime ; i + + ) {
init_lsa_StringLarge ( & lsa_domains [ i ] . name , domains [ i ] - > name ) ;
lsa_domains [ i ] . sid = & domains [ i ] - > sid ;
}
* r - > out . resume_handle = next_idx ;
r - > out . domains - > count = num_thistime ;
r - > out . domains - > domains = lsa_domains ;
return nt_status ;
2001-02-26 22:31:07 +03:00
}
2008-02-27 18:14:27 +03:00
# define LSA_AUDIT_NUM_CATEGORIES_NT4 7
# define LSA_AUDIT_NUM_CATEGORIES_WIN2K 9
# define LSA_AUDIT_NUM_CATEGORIES LSA_AUDIT_NUM_CATEGORIES_NT4
2001-02-26 22:31:07 +03:00
/***************************************************************************
2008-02-08 03:13:50 +03:00
_lsa_QueryInfoPolicy
2001-02-26 22:31:07 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-08 03:13:50 +03:00
NTSTATUS _lsa_QueryInfoPolicy ( pipes_struct * p ,
struct lsa_QueryInfoPolicy * r )
2001-02-26 22:31:07 +03:00
{
2008-02-08 03:13:50 +03:00
NTSTATUS status = NT_STATUS_OK ;
2001-12-18 02:03:23 +03:00
struct lsa_info * handle ;
2001-02-26 22:31:07 +03:00
DOM_SID domain_sid ;
2002-11-13 02:20:50 +03:00
const char * name ;
2001-02-26 22:31:07 +03:00
DOM_SID * sid = NULL ;
2008-02-08 03:13:50 +03:00
union lsa_PolicyInformation * info = NULL ;
2001-02-26 22:31:07 +03:00
2008-02-08 03:13:50 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) )
2001-03-11 03:32:10 +03:00
return NT_STATUS_INVALID_HANDLE ;
2008-02-08 03:13:50 +03:00
info = TALLOC_ZERO_P ( p - > mem_ctx , union lsa_PolicyInformation ) ;
if ( ! info ) {
return NT_STATUS_NO_MEMORY ;
}
switch ( r - > in . level ) {
2001-02-26 22:31:07 +03:00
case 0x02 :
{
2006-04-11 19:47:24 +04:00
uint32 policy_def = LSA_AUDIT_POLICY_ALL ;
2008-02-08 03:13:50 +03:00
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_VIEW_AUDIT_INFORMATION ) ) {
2008-02-08 03:13:50 +03:00
DEBUG ( 10 , ( " _lsa_QueryInfoPolicy: insufficient access rights \n " ) ) ;
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2006-04-11 19:47:24 +04:00
}
2001-12-18 02:03:23 +03:00
/* fake info: We audit everything. ;) */
2006-04-11 19:47:24 +04:00
2008-02-08 03:13:50 +03:00
info - > audit_events . auditing_mode = true ;
info - > audit_events . count = LSA_AUDIT_NUM_CATEGORIES ;
info - > audit_events . settings = TALLOC_ZERO_ARRAY ( p - > mem_ctx ,
enum lsa_PolicyAuditPolicy ,
info - > audit_events . count ) ;
if ( ! info - > audit_events . settings ) {
2001-12-18 02:03:23 +03:00
return NT_STATUS_NO_MEMORY ;
2008-02-08 03:13:50 +03:00
}
2006-04-11 19:47:24 +04:00
2008-02-08 03:13:50 +03:00
info - > audit_events . settings [ LSA_AUDIT_CATEGORY_ACCOUNT_MANAGEMENT ] = policy_def ;
info - > audit_events . settings [ LSA_AUDIT_CATEGORY_FILE_AND_OBJECT_ACCESS ] = policy_def ;
info - > audit_events . settings [ LSA_AUDIT_CATEGORY_LOGON ] = policy_def ;
info - > audit_events . settings [ LSA_AUDIT_CATEGORY_PROCCESS_TRACKING ] = policy_def ;
info - > audit_events . settings [ LSA_AUDIT_CATEGORY_SECURITY_POLICY_CHANGES ] = policy_def ;
info - > audit_events . settings [ LSA_AUDIT_CATEGORY_SYSTEM ] = policy_def ;
info - > audit_events . settings [ LSA_AUDIT_CATEGORY_USE_OF_USER_RIGHTS ] = policy_def ;
2006-04-11 19:47:24 +04:00
2001-12-18 02:03:23 +03:00
break ;
2001-02-26 22:31:07 +03:00
}
case 0x03 :
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2001-04-22 03:06:59 +04:00
/* Request PolicyPrimaryDomainInformation. */
switch ( lp_server_role ( ) ) {
2001-02-26 22:31:07 +03:00
case ROLE_DOMAIN_PDC :
case ROLE_DOMAIN_BDC :
2003-05-07 12:21:06 +04:00
name = get_global_sam_name ( ) ;
2008-03-04 14:46:15 +03:00
sid = sid_dup_talloc ( p - > mem_ctx , get_global_sam_sid ( ) ) ;
if ( ! sid ) {
return NT_STATUS_NO_MEMORY ;
}
2001-02-26 22:31:07 +03:00
break ;
case ROLE_DOMAIN_MEMBER :
2002-11-13 02:20:50 +03:00
name = lp_workgroup ( ) ;
2001-04-22 03:06:59 +04:00
/* We need to return the Domain SID here. */
2008-03-04 14:46:15 +03:00
if ( secrets_fetch_domain_sid ( lp_workgroup ( ) , & domain_sid ) ) {
sid = sid_dup_talloc ( p - > mem_ctx , & domain_sid ) ;
if ( ! sid ) {
return NT_STATUS_NO_MEMORY ;
}
} else {
2001-04-22 03:06:59 +04:00
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO ;
2008-03-04 14:46:15 +03:00
}
2001-02-26 22:31:07 +03:00
break ;
2001-03-15 06:08:22 +03:00
case ROLE_STANDALONE :
2002-11-13 02:20:50 +03:00
name = lp_workgroup ( ) ;
2002-01-31 12:37:26 +03:00
sid = NULL ;
2001-03-15 06:08:22 +03:00
break ;
2001-03-15 05:49:06 +03:00
default :
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO ;
2001-02-26 22:31:07 +03:00
}
2008-02-08 03:13:50 +03:00
init_dom_query_3 ( & info - > domain , name , sid ) ;
2001-02-26 22:31:07 +03:00
break ;
case 0x05 :
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2001-04-22 03:06:59 +04:00
/* Request PolicyAccountDomainInformation. */
2003-05-07 12:21:06 +04:00
name = get_global_sam_name ( ) ;
sid = get_global_sam_sid ( ) ;
2008-02-08 03:13:50 +03:00
init_dom_query_5 ( & info - > account_domain , name , sid ) ;
2001-02-26 22:31:07 +03:00
break ;
case 0x06 :
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2001-04-22 03:06:59 +04:00
switch ( lp_server_role ( ) ) {
2001-02-26 22:31:07 +03:00
case ROLE_DOMAIN_BDC :
/*
* only a BDC is a backup controller
* of the domain , it controls .
*/
2008-02-08 03:13:50 +03:00
info - > role . role = 2 ;
2001-02-26 22:31:07 +03:00
break ;
default :
/*
* any other role is a primary
* of the domain , it controls .
*/
2008-02-08 03:13:50 +03:00
info - > role . role = 3 ;
break ;
2001-02-26 22:31:07 +03:00
}
break ;
default :
2008-02-08 03:13:50 +03:00
DEBUG ( 0 , ( " _lsa_QueryInfoPolicy: unknown info level in Lsa Query: %d \n " ,
r - > in . level ) ) ;
status = NT_STATUS_INVALID_INFO_CLASS ;
2001-02-26 22:31:07 +03:00
break ;
}
2008-02-08 03:13:50 +03:00
* r - > out . info = info ;
2001-02-26 22:31:07 +03:00
2008-02-08 03:13:50 +03:00
return status ;
2001-02-26 22:31:07 +03:00
}
/***************************************************************************
2006-02-11 02:52:53 +03:00
_lsa_lookup_sids_internal
2001-02-26 22:31:07 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-02-11 02:52:53 +03:00
static NTSTATUS _lsa_lookup_sids_internal ( pipes_struct * p ,
2008-02-19 03:01:15 +03:00
TALLOC_CTX * mem_ctx ,
uint16_t level , /* input */
int num_sids , /* input */
struct lsa_SidPtr * sid , /* input */
struct lsa_RefDomainList * * pp_ref , /* input/output */
struct lsa_TranslatedName2 * * pp_names , /* input/output */
uint32_t * pp_mapped_count ) /* input/output */
2001-02-26 22:31:07 +03:00
{
2006-02-11 02:52:53 +03:00
NTSTATUS status ;
int i ;
const DOM_SID * * sids = NULL ;
2008-02-19 03:01:15 +03:00
struct lsa_RefDomainList * ref = NULL ;
2006-02-11 02:52:53 +03:00
uint32 mapped_count = 0 ;
struct lsa_dom_info * dom_infos = NULL ;
struct lsa_name_info * name_infos = NULL ;
2008-02-19 03:01:15 +03:00
struct lsa_TranslatedName2 * names = NULL ;
2002-03-30 00:50:21 +03:00
2006-02-11 02:52:53 +03:00
* pp_mapped_count = 0 ;
2008-02-19 03:01:15 +03:00
* pp_names = NULL ;
2006-02-11 02:52:53 +03:00
* pp_ref = NULL ;
2007-05-05 02:01:26 +04:00
if ( num_sids = = 0 ) {
return NT_STATUS_OK ;
}
2006-02-11 02:52:53 +03:00
sids = TALLOC_ARRAY ( p - > mem_ctx , const DOM_SID * , num_sids ) ;
2008-02-19 03:01:15 +03:00
ref = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_RefDomainList ) ;
2006-02-04 01:19:41 +03:00
2007-06-09 04:13:07 +04:00
if ( sids = = NULL | | ref = = NULL ) {
2006-02-11 02:52:53 +03:00
return NT_STATUS_NO_MEMORY ;
2006-02-04 01:19:41 +03:00
}
for ( i = 0 ; i < num_sids ; i + + ) {
2008-02-19 03:01:15 +03:00
sids [ i ] = sid [ i ] . sid ;
2006-02-04 01:19:41 +03:00
}
2006-02-11 02:52:53 +03:00
status = lookup_sids ( p - > mem_ctx , num_sids , sids , level ,
2006-02-04 01:19:41 +03:00
& dom_infos , & name_infos ) ;
2006-02-11 02:52:53 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
2006-02-04 01:19:41 +03:00
}
2008-02-19 03:01:15 +03:00
names = TALLOC_ARRAY ( p - > mem_ctx , struct lsa_TranslatedName2 , num_sids ) ;
if ( names = = NULL ) {
2007-05-05 02:01:26 +04:00
return NT_STATUS_NO_MEMORY ;
2004-05-21 22:06:27 +04:00
}
2006-02-04 01:19:41 +03:00
for ( i = 0 ; i < MAX_REF_DOMAINS ; i + + ) {
if ( ! dom_infos [ i ] . valid ) {
break ;
}
2008-02-19 03:01:15 +03:00
if ( init_lsa_ref_domain_list ( mem_ctx , ref ,
dom_infos [ i ] . name ,
& dom_infos [ i ] . sid ) ! = i ) {
2006-02-04 01:19:41 +03:00
DEBUG ( 0 , ( " Domain %s mentioned twice?? \n " ,
dom_infos [ i ] . name ) ) ;
2006-02-11 02:52:53 +03:00
return NT_STATUS_INTERNAL_ERROR ;
2006-02-04 01:19:41 +03:00
}
}
for ( i = 0 ; i < num_sids ; i + + ) {
struct lsa_name_info * name = & name_infos [ i ] ;
if ( name - > type = = SID_NAME_UNKNOWN ) {
2007-12-16 00:00:39 +03:00
fstring tmp ;
2006-02-04 01:19:41 +03:00
name - > dom_idx = - 1 ;
2006-07-23 12:18:31 +04:00
/* Unknown sids should return the string
* representation of the SID . Windows 2003 behaves
* rather erratic here , in many cases it returns the
* RID as 8 bytes hex , in others it returns the full
* SID . We ( Jerry / VL ) could not figure out which the
* hard cases are , so leave it with the SID . */
2008-02-14 15:12:28 +03:00
name - > name = talloc_asprintf ( p - > mem_ctx , " %s " ,
2007-12-16 00:47:30 +03:00
sid_to_fstring ( tmp ,
sids [ i ] ) ) ;
2006-02-04 01:19:41 +03:00
if ( name - > name = = NULL ) {
2006-02-11 02:52:53 +03:00
return NT_STATUS_NO_MEMORY ;
2006-02-04 01:19:41 +03:00
}
} else {
mapped_count + = 1 ;
}
2008-02-19 03:01:15 +03:00
init_lsa_translated_name2 ( & names [ i ] , name - > type ,
name - > name , name - > dom_idx , 0 ) ;
}
2006-02-04 01:19:41 +03:00
2006-02-11 02:52:53 +03:00
status = NT_STATUS_NONE_MAPPED ;
2006-02-04 01:19:41 +03:00
if ( mapped_count > 0 ) {
2006-02-11 02:52:53 +03:00
status = ( mapped_count < num_sids ) ?
2006-02-04 01:19:41 +03:00
STATUS_SOME_UNMAPPED : NT_STATUS_OK ;
}
DEBUG ( 10 , ( " num_sids %d, mapped_count %d, status %s \n " ,
2006-02-11 02:52:53 +03:00
num_sids , mapped_count , nt_errstr ( status ) ) ) ;
* pp_mapped_count = mapped_count ;
2008-02-19 03:01:15 +03:00
* pp_names = names ;
2006-02-11 02:52:53 +03:00
* pp_ref = ref ;
return status ;
}
/***************************************************************************
2008-02-19 03:01:15 +03:00
_lsa_LookupSids
2006-02-11 02:52:53 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-19 03:01:15 +03:00
NTSTATUS _lsa_LookupSids ( pipes_struct * p ,
struct lsa_LookupSids * r )
2006-02-11 02:52:53 +03:00
{
2008-02-19 03:01:15 +03:00
NTSTATUS status ;
2006-02-11 02:52:53 +03:00
struct lsa_info * handle ;
2008-02-19 03:01:15 +03:00
int num_sids = r - > in . sids - > num_sids ;
2006-02-11 02:52:53 +03:00
uint32 mapped_count = 0 ;
2008-02-19 03:01:15 +03:00
struct lsa_RefDomainList * domains = NULL ;
struct lsa_TranslatedName * names_out = NULL ;
struct lsa_TranslatedName2 * names = NULL ;
int i ;
2006-02-11 02:52:53 +03:00
2008-02-19 03:01:15 +03:00
if ( ( r - > in . level < 1 ) | | ( r - > in . level > 6 ) ) {
2006-02-11 02:52:53 +03:00
return NT_STATUS_INVALID_PARAMETER ;
}
2008-02-19 03:01:15 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) ) {
2006-02-11 02:52:53 +03:00
return NT_STATUS_INVALID_HANDLE ;
}
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_LOOKUP_NAMES ) ) {
2006-02-11 02:52:53 +03:00
return NT_STATUS_ACCESS_DENIED ;
}
if ( num_sids > MAX_LOOKUP_SIDS ) {
2008-02-19 03:01:15 +03:00
DEBUG ( 5 , ( " _lsa_LookupSids: limit of %d exceeded, requested %d \n " ,
2006-02-11 02:52:53 +03:00
MAX_LOOKUP_SIDS , num_sids ) ) ;
return NT_STATUS_NONE_MAPPED ;
}
2008-02-19 03:01:15 +03:00
status = _lsa_lookup_sids_internal ( p ,
p - > mem_ctx ,
r - > in . level ,
num_sids ,
r - > in . sids - > sids ,
& domains ,
& names ,
& mapped_count ) ;
2006-02-11 02:52:53 +03:00
2008-02-19 03:01:15 +03:00
/* Convert from lsa_TranslatedName2 to lsa_TranslatedName */
names_out = TALLOC_ARRAY ( p - > mem_ctx , struct lsa_TranslatedName ,
num_sids ) ;
if ( ! names_out ) {
return NT_STATUS_NO_MEMORY ;
}
2006-02-11 02:52:53 +03:00
2008-02-19 03:01:15 +03:00
for ( i = 0 ; i < num_sids ; i + + ) {
names_out [ i ] . sid_type = names [ i ] . sid_type ;
names_out [ i ] . name = names [ i ] . name ;
names_out [ i ] . sid_index = names [ i ] . sid_index ;
2006-02-11 02:52:53 +03:00
}
2008-02-19 03:01:15 +03:00
* r - > out . domains = domains ;
r - > out . names - > count = num_sids ;
r - > out . names - > names = names_out ;
* r - > out . count = mapped_count ;
return status ;
2006-02-11 02:52:53 +03:00
}
/***************************************************************************
2008-02-19 03:01:15 +03:00
_lsa_LookupSids2
2006-02-11 02:52:53 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-19 03:01:15 +03:00
NTSTATUS _lsa_LookupSids2 ( pipes_struct * p ,
struct lsa_LookupSids2 * r )
2006-02-11 02:52:53 +03:00
{
2008-02-19 03:01:15 +03:00
NTSTATUS status ;
2006-02-11 02:52:53 +03:00
struct lsa_info * handle ;
2008-02-19 03:01:15 +03:00
int num_sids = r - > in . sids - > num_sids ;
2006-02-11 02:52:53 +03:00
uint32 mapped_count = 0 ;
2008-02-19 03:01:15 +03:00
struct lsa_RefDomainList * domains = NULL ;
struct lsa_TranslatedName2 * names = NULL ;
bool check_policy = true ;
2006-02-11 02:52:53 +03:00
2008-02-19 03:01:15 +03:00
switch ( p - > hdr_req . opnum ) {
case NDR_LSA_LOOKUPSIDS3 :
check_policy = false ;
break ;
case NDR_LSA_LOOKUPSIDS2 :
default :
check_policy = true ;
2006-02-11 02:52:53 +03:00
}
2008-02-19 03:01:15 +03:00
if ( ( r - > in . level < 1 ) | | ( r - > in . level > 6 ) ) {
return NT_STATUS_INVALID_PARAMETER ;
2006-02-11 02:52:53 +03:00
}
2008-02-19 03:01:15 +03:00
if ( check_policy ) {
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) ) {
return NT_STATUS_INVALID_HANDLE ;
}
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_LOOKUP_NAMES ) ) {
2008-02-19 03:01:15 +03:00
return NT_STATUS_ACCESS_DENIED ;
}
2006-02-11 02:52:53 +03:00
}
if ( num_sids > MAX_LOOKUP_SIDS ) {
2008-02-19 03:01:15 +03:00
DEBUG ( 5 , ( " _lsa_LookupSids2: limit of %d exceeded, requested %d \n " ,
2006-02-11 02:52:53 +03:00
MAX_LOOKUP_SIDS , num_sids ) ) ;
return NT_STATUS_NONE_MAPPED ;
}
2008-02-19 03:01:15 +03:00
status = _lsa_lookup_sids_internal ( p ,
p - > mem_ctx ,
r - > in . level ,
num_sids ,
r - > in . sids - > sids ,
& domains ,
& names ,
& mapped_count ) ;
2006-02-11 02:52:53 +03:00
2008-02-19 03:01:15 +03:00
* r - > out . domains = domains ;
r - > out . names - > count = num_sids ;
r - > out . names - > names = names ;
* r - > out . count = mapped_count ;
return status ;
2006-02-11 02:52:53 +03:00
}
/***************************************************************************
2008-02-19 03:01:15 +03:00
_lsa_LookupSids3
2006-02-11 02:52:53 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-19 03:01:15 +03:00
NTSTATUS _lsa_LookupSids3 ( pipes_struct * p ,
struct lsa_LookupSids3 * r )
2006-02-11 02:52:53 +03:00
{
2008-02-19 03:01:15 +03:00
struct lsa_LookupSids2 q ;
2006-02-11 02:52:53 +03:00
2007-10-11 00:34:30 +04:00
/* No policy handle on this call. Restrict to crypto connections. */
if ( p - > auth . auth_type ! = PIPE_AUTH_TYPE_SCHANNEL ) {
2008-02-19 03:01:15 +03:00
DEBUG ( 0 , ( " _lsa_LookupSids3: client %s not using schannel for netlogon \n " ,
2007-10-11 00:34:30 +04:00
get_remote_machine_name ( ) ) ) ;
return NT_STATUS_INVALID_PARAMETER ;
}
2006-07-22 23:44:17 +04:00
2008-02-19 03:01:15 +03:00
q . in . handle = NULL ;
q . in . sids = r - > in . sids ;
q . in . level = r - > in . level ;
q . in . unknown1 = r - > in . unknown1 ;
q . in . unknown2 = r - > in . unknown2 ;
q . in . names = r - > in . names ;
q . in . count = r - > in . count ;
2006-07-22 23:44:17 +04:00
2008-02-19 03:01:15 +03:00
q . out . domains = r - > out . domains ;
q . out . names = r - > out . names ;
q . out . count = r - > out . count ;
2007-10-11 00:34:30 +04:00
2008-02-19 03:01:15 +03:00
return _lsa_LookupSids2 ( p , & q ) ;
2001-02-26 22:31:07 +03:00
}
2008-02-19 03:01:15 +03:00
/***************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-12-12 20:03:20 +03:00
static int lsa_lookup_level_to_flags ( uint16 level )
{
int flags ;
switch ( level ) {
case 1 :
flags = LOOKUP_NAME_ALL ;
break ;
case 2 :
flags = LOOKUP_NAME_DOMAIN | LOOKUP_NAME_REMOTE | LOOKUP_NAME_ISOLATED ;
break ;
case 3 :
flags = LOOKUP_NAME_DOMAIN | LOOKUP_NAME_ISOLATED ;
break ;
case 4 :
case 5 :
case 6 :
default :
flags = LOOKUP_NAME_NONE ;
break ;
}
return flags ;
}
2001-02-26 22:31:07 +03:00
/***************************************************************************
2008-02-18 16:40:34 +03:00
_lsa_LookupNames
2001-02-26 22:31:07 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-18 16:40:34 +03:00
NTSTATUS _lsa_LookupNames ( pipes_struct * p ,
struct lsa_LookupNames * r )
2001-02-26 22:31:07 +03:00
{
2008-02-18 16:40:34 +03:00
NTSTATUS status = NT_STATUS_NONE_MAPPED ;
2001-12-18 02:03:23 +03:00
struct lsa_info * handle ;
2008-02-18 16:40:34 +03:00
struct lsa_String * names = r - > in . names ;
uint32 num_entries = r - > in . num_names ;
struct lsa_RefDomainList * domains = NULL ;
struct lsa_TranslatedSid * rids = NULL ;
2001-02-26 22:31:07 +03:00
uint32 mapped_count = 0 ;
2005-12-03 21:34:13 +03:00
int flags = 0 ;
2001-02-26 22:31:07 +03:00
2002-01-26 13:02:23 +03:00
if ( num_entries > MAX_LOOKUP_SIDS ) {
num_entries = MAX_LOOKUP_SIDS ;
2008-02-18 16:40:34 +03:00
DEBUG ( 5 , ( " _lsa_LookupNames: truncating name lookup list to %d \n " ,
num_entries ) ) ;
2002-01-26 13:02:23 +03:00
}
2008-02-14 15:12:28 +03:00
2008-02-18 16:40:34 +03:00
flags = lsa_lookup_level_to_flags ( r - > in . level ) ;
2005-12-03 21:34:13 +03:00
2008-02-18 16:40:34 +03:00
domains = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_RefDomainList ) ;
if ( ! domains ) {
2007-04-30 05:17:34 +04:00
return NT_STATUS_NO_MEMORY ;
}
if ( num_entries ) {
2008-02-18 16:40:34 +03:00
rids = TALLOC_ZERO_ARRAY ( p - > mem_ctx , struct lsa_TranslatedSid ,
num_entries ) ;
2007-04-30 05:17:34 +04:00
if ( ! rids ) {
return NT_STATUS_NO_MEMORY ;
}
} else {
rids = NULL ;
}
2001-03-01 07:01:23 +03:00
2008-02-18 16:40:34 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) ) {
status = NT_STATUS_INVALID_HANDLE ;
2002-03-30 00:50:21 +03:00
goto done ;
}
2002-03-29 23:37:56 +03:00
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_LOOKUP_NAMES ) ) {
2008-02-18 16:40:34 +03:00
status = NT_STATUS_ACCESS_DENIED ;
2002-03-30 00:50:21 +03:00
goto done ;
}
2002-03-29 23:37:56 +03:00
2005-12-03 21:34:13 +03:00
/* set up the LSA Lookup RIDs response */
2006-02-16 04:06:21 +03:00
become_root ( ) ; /* lookup_name can require root privs */
2008-02-18 16:40:34 +03:00
status = lookup_lsa_rids ( p - > mem_ctx , domains , rids , num_entries ,
names , flags , & mapped_count ) ;
2006-02-16 04:06:21 +03:00
unbecome_root ( ) ;
2002-03-30 00:50:21 +03:00
done :
2008-02-18 16:40:34 +03:00
if ( NT_STATUS_IS_OK ( status ) & & ( num_entries ! = 0 ) ) {
if ( mapped_count = = 0 ) {
status = NT_STATUS_NONE_MAPPED ;
} else if ( mapped_count ! = num_entries ) {
status = STATUS_SOME_UNMAPPED ;
}
2004-05-26 22:27:16 +04:00
}
2001-02-26 22:31:07 +03:00
2008-03-04 15:16:02 +03:00
* r - > out . count = mapped_count ;
2008-02-18 16:40:34 +03:00
* r - > out . domains = domains ;
r - > out . sids - > sids = rids ;
2008-03-04 15:16:02 +03:00
r - > out . sids - > count = num_entries ;
2008-02-18 16:40:34 +03:00
return status ;
2001-02-26 22:31:07 +03:00
}
2006-02-11 07:25:06 +03:00
/***************************************************************************
2008-02-18 16:40:34 +03:00
_lsa_LookupNames2
2006-02-11 07:25:06 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-18 16:40:34 +03:00
NTSTATUS _lsa_LookupNames2 ( pipes_struct * p ,
struct lsa_LookupNames2 * r )
2006-02-11 07:25:06 +03:00
{
2008-02-18 16:40:34 +03:00
NTSTATUS status ;
struct lsa_LookupNames q ;
struct lsa_TransSidArray2 * sid_array2 = r - > in . sids ;
struct lsa_TransSidArray * sid_array = NULL ;
uint32_t i ;
2006-02-11 07:25:06 +03:00
2008-02-18 16:40:34 +03:00
sid_array = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_TransSidArray ) ;
if ( ! sid_array ) {
2006-06-21 04:17:14 +04:00
return NT_STATUS_NO_MEMORY ;
2006-06-20 13:16:53 +04:00
}
2008-02-18 16:40:34 +03:00
q . in . handle = r - > in . handle ;
q . in . num_names = r - > in . num_names ;
q . in . names = r - > in . names ;
q . in . level = r - > in . level ;
q . in . sids = sid_array ;
q . in . count = r - > in . count ;
/* we do not know what this is for */
/* = r->in.unknown1; */
/* = r->in.unknown2; */
2007-04-30 05:17:34 +04:00
2008-02-18 16:40:34 +03:00
q . out . domains = r - > out . domains ;
q . out . sids = sid_array ;
q . out . count = r - > out . count ;
2006-02-11 07:25:06 +03:00
2008-02-18 16:40:34 +03:00
status = _lsa_LookupNames ( p , & q ) ;
2006-02-11 07:25:06 +03:00
2008-02-18 16:40:34 +03:00
sid_array2 - > sids = TALLOC_ARRAY ( p - > mem_ctx , struct lsa_TranslatedSid2 , sid_array - > count ) ;
if ( ! sid_array2 - > sids ) {
return NT_STATUS_NO_MEMORY ;
2006-02-11 07:25:06 +03:00
}
2008-02-18 16:40:34 +03:00
for ( i = 0 ; i < sid_array - > count ; i + + ) {
sid_array2 - > sids [ i ] . sid_type = sid_array - > sids [ i ] . sid_type ;
sid_array2 - > sids [ i ] . rid = sid_array - > sids [ i ] . rid ;
sid_array2 - > sids [ i ] . sid_index = sid_array - > sids [ i ] . sid_index ;
sid_array2 - > sids [ i ] . unknown = 0 ;
2006-02-11 07:25:06 +03:00
}
2008-02-18 16:40:34 +03:00
r - > out . sids = sid_array2 ;
return status ;
2006-02-11 07:25:06 +03:00
}
2006-02-11 08:36:27 +03:00
/***************************************************************************
2008-02-18 18:57:02 +03:00
_lsa_LookupNames3
2006-02-11 08:36:27 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-18 18:57:02 +03:00
NTSTATUS _lsa_LookupNames3 ( pipes_struct * p ,
struct lsa_LookupNames3 * r )
2006-02-11 08:36:27 +03:00
{
2008-02-18 18:57:02 +03:00
NTSTATUS status ;
2006-02-16 04:06:21 +03:00
struct lsa_info * handle ;
2008-02-18 18:57:02 +03:00
struct lsa_String * names = r - > in . names ;
uint32 num_entries = r - > in . num_names ;
struct lsa_RefDomainList * domains = NULL ;
struct lsa_TranslatedSid3 * trans_sids = NULL ;
2006-02-16 04:06:21 +03:00
uint32 mapped_count = 0 ;
int flags = 0 ;
2008-02-18 18:57:02 +03:00
bool check_policy = true ;
switch ( p - > hdr_req . opnum ) {
case NDR_LSA_LOOKUPNAMES4 :
check_policy = false ;
break ;
case NDR_LSA_LOOKUPNAMES3 :
default :
check_policy = true ;
}
2006-02-16 04:06:21 +03:00
if ( num_entries > MAX_LOOKUP_SIDS ) {
num_entries = MAX_LOOKUP_SIDS ;
2008-02-18 18:57:02 +03:00
DEBUG ( 5 , ( " _lsa_LookupNames3: truncating name lookup list to %d \n " , num_entries ) ) ;
2006-02-16 04:06:21 +03:00
}
2008-02-14 15:12:28 +03:00
2006-02-16 04:06:21 +03:00
/* Probably the lookup_level is some sort of bitmask. */
2008-02-18 18:57:02 +03:00
if ( r - > in . level = = 1 ) {
2006-02-16 04:06:21 +03:00
flags = LOOKUP_NAME_ALL ;
}
2008-02-18 18:57:02 +03:00
domains = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_RefDomainList ) ;
if ( ! domains ) {
2007-04-30 05:17:34 +04:00
return NT_STATUS_NO_MEMORY ;
}
2008-02-18 18:57:02 +03:00
2007-04-30 05:17:34 +04:00
if ( num_entries ) {
2008-02-18 18:57:02 +03:00
trans_sids = TALLOC_ZERO_ARRAY ( p - > mem_ctx , struct lsa_TranslatedSid3 ,
num_entries ) ;
2007-04-30 05:17:34 +04:00
if ( ! trans_sids ) {
return NT_STATUS_NO_MEMORY ;
}
} else {
trans_sids = NULL ;
}
2006-02-16 04:06:21 +03:00
2008-02-18 18:57:02 +03:00
if ( check_policy ) {
2006-02-16 04:06:21 +03:00
2008-02-18 18:57:02 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) ) {
status = NT_STATUS_INVALID_HANDLE ;
goto done ;
}
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_LOOKUP_NAMES ) ) {
2008-02-18 18:57:02 +03:00
status = NT_STATUS_ACCESS_DENIED ;
goto done ;
}
2006-02-16 04:06:21 +03:00
}
/* set up the LSA Lookup SIDs response */
become_root ( ) ; /* lookup_name can require root privs */
2008-02-18 18:57:02 +03:00
status = lookup_lsa_sids ( p - > mem_ctx , domains , trans_sids , num_entries ,
names , flags , & mapped_count ) ;
2006-02-16 04:06:21 +03:00
unbecome_root ( ) ;
done :
2008-02-18 18:57:02 +03:00
if ( NT_STATUS_IS_OK ( status ) ) {
2006-02-16 04:06:21 +03:00
if ( mapped_count = = 0 ) {
2008-02-18 18:57:02 +03:00
status = NT_STATUS_NONE_MAPPED ;
2006-02-16 04:06:21 +03:00
} else if ( mapped_count ! = num_entries ) {
2008-02-18 18:57:02 +03:00
status = STATUS_SOME_UNMAPPED ;
2006-02-16 04:06:21 +03:00
}
}
2008-03-04 15:19:38 +03:00
* r - > out . count = mapped_count ;
2008-02-18 18:57:02 +03:00
* r - > out . domains = domains ;
r - > out . sids - > sids = trans_sids ;
2008-03-04 15:19:38 +03:00
r - > out . sids - > count = num_entries ;
2008-02-18 18:57:02 +03:00
return status ;
2006-02-11 08:36:27 +03:00
}
/***************************************************************************
2008-02-18 18:57:02 +03:00
_lsa_LookupNames4
2006-02-11 08:36:27 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-18 18:57:02 +03:00
NTSTATUS _lsa_LookupNames4 ( pipes_struct * p ,
struct lsa_LookupNames4 * r )
2006-02-11 08:36:27 +03:00
{
2008-02-18 18:57:02 +03:00
struct lsa_LookupNames3 q ;
2006-02-16 04:06:21 +03:00
/* No policy handle on this call. Restrict to crypto connections. */
if ( p - > auth . auth_type ! = PIPE_AUTH_TYPE_SCHANNEL ) {
DEBUG ( 0 , ( " _lsa_lookup_names4: client %s not using schannel for netlogon \n " ,
get_remote_machine_name ( ) ) ) ;
return NT_STATUS_INVALID_PARAMETER ;
}
2008-02-18 18:57:02 +03:00
q . in . handle = NULL ;
q . in . num_names = r - > in . num_names ;
q . in . names = r - > in . names ;
q . in . level = r - > in . level ;
2008-10-15 21:33:16 +04:00
q . in . lookup_options = r - > in . lookup_options ;
q . in . client_revision = r - > in . client_revision ;
2008-02-18 18:57:02 +03:00
q . in . sids = r - > in . sids ;
q . in . count = r - > in . count ;
2006-02-16 04:06:21 +03:00
2008-02-18 18:57:02 +03:00
q . out . domains = r - > out . domains ;
q . out . sids = r - > out . sids ;
q . out . count = r - > out . count ;
2006-02-16 04:06:21 +03:00
2008-02-18 18:57:02 +03:00
return _lsa_LookupNames3 ( p , & q ) ;
2006-02-11 08:36:27 +03:00
}
2006-02-11 07:25:06 +03:00
2001-02-26 22:31:07 +03:00
/***************************************************************************
_lsa_close . Also weird - needs to check if lsa handle is correct . JRA .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_Close ( pipes_struct * p , struct lsa_Close * r )
2001-02-26 22:31:07 +03:00
{
2007-01-18 13:18:59 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , NULL ) ) {
2001-03-11 03:32:10 +03:00
return NT_STATUS_INVALID_HANDLE ;
2006-02-16 04:06:21 +03:00
}
2001-03-11 03:32:10 +03:00
2007-01-18 13:18:59 +03:00
close_policy_hnd ( p , r - > in . handle ) ;
2008-03-03 20:12:26 +03:00
ZERO_STRUCTP ( r - > out . handle ) ;
2001-08-27 23:46:22 +04:00
return NT_STATUS_OK ;
2001-02-26 22:31:07 +03:00
}
/***************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_OpenSecret ( pipes_struct * p , struct lsa_OpenSecret * r )
2001-02-26 22:31:07 +03:00
{
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
}
2001-06-30 03:12:55 +04:00
2005-05-31 17:46:45 +04:00
/***************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_OpenTrustedDomain ( pipes_struct * p , struct lsa_OpenTrustedDomain * r )
2005-05-31 17:46:45 +04:00
{
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
}
/***************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CreateTrustedDomain ( pipes_struct * p , struct lsa_CreateTrustedDomain * r )
2005-05-31 17:46:45 +04:00
{
return NT_STATUS_ACCESS_DENIED ;
}
/***************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CreateSecret ( pipes_struct * p , struct lsa_CreateSecret * r )
2005-05-31 17:46:45 +04:00
{
return NT_STATUS_ACCESS_DENIED ;
}
/***************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetSecret ( pipes_struct * p , struct lsa_SetSecret * r )
2005-05-31 17:46:45 +04:00
{
return NT_STATUS_ACCESS_DENIED ;
}
/***************************************************************************
2008-02-05 00:05:48 +03:00
_lsa_DeleteObject
2005-05-31 17:46:45 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-05 00:05:48 +03:00
NTSTATUS _lsa_DeleteObject ( pipes_struct * p ,
struct lsa_DeleteObject * r )
2005-05-31 17:46:45 +04:00
{
return NT_STATUS_ACCESS_DENIED ;
}
2001-07-09 22:32:54 +04:00
/***************************************************************************
2008-02-11 12:19:54 +03:00
_lsa_EnumPrivs
2001-07-09 22:32:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-11 12:19:54 +03:00
NTSTATUS _lsa_EnumPrivs ( pipes_struct * p ,
struct lsa_EnumPrivs * r )
2001-07-09 22:32:54 +04:00
{
2001-12-18 02:03:23 +03:00
struct lsa_info * handle ;
2001-07-09 22:32:54 +04:00
uint32 i ;
2008-02-11 12:19:54 +03:00
uint32 enum_context = * r - > in . resume_handle ;
2005-09-30 21:13:37 +04:00
int num_privs = count_all_privileges ( ) ;
2008-02-11 12:19:54 +03:00
struct lsa_PrivEntry * entries = NULL ;
2005-01-17 18:23:11 +03:00
LUID_ATTR luid ;
2001-07-09 22:32:54 +04:00
2005-01-13 21:20:37 +03:00
/* remember that the enum_context starts at 0 and not 1 */
2001-07-09 22:32:54 +04:00
2005-01-13 21:20:37 +03:00
if ( enum_context > = num_privs )
2002-03-29 23:37:56 +03:00
return NT_STATUS_NO_MORE_ENTRIES ;
2008-02-14 03:53:42 +03:00
DEBUG ( 10 , ( " _lsa_EnumPrivs: enum_context:%d total entries:%d \n " ,
2005-01-13 21:20:37 +03:00
enum_context , num_privs ) ) ;
2008-02-14 03:53:42 +03:00
2008-02-11 12:19:54 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) )
2001-07-09 22:32:54 +04:00
return NT_STATUS_INVALID_HANDLE ;
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights
2005-01-13 21:20:37 +03:00
I don ' t know if it ' s the right one . not documented . */
2001-12-18 02:03:23 +03:00
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2007-04-30 05:17:34 +04:00
if ( num_privs ) {
2008-02-11 12:19:54 +03:00
entries = TALLOC_ZERO_ARRAY ( p - > mem_ctx , struct lsa_PrivEntry , num_privs ) ;
if ( ! entries ) {
2007-04-30 05:17:34 +04:00
return NT_STATUS_NO_MEMORY ;
2008-02-11 12:19:54 +03:00
}
2007-04-30 05:17:34 +04:00
} else {
entries = NULL ;
}
2005-01-13 21:20:37 +03:00
for ( i = 0 ; i < num_privs ; i + + ) {
if ( i < enum_context ) {
2008-02-11 12:19:54 +03:00
init_lsa_StringLarge ( & entries [ i ] . name , NULL ) ;
entries [ i ] . luid . low = 0 ;
entries [ i ] . luid . high = 0 ;
2001-11-23 02:50:16 +03:00
} else {
2008-02-11 12:19:54 +03:00
init_lsa_StringLarge ( & entries [ i ] . name , privs [ i ] . name ) ;
2005-01-17 18:23:11 +03:00
luid = get_privilege_luid ( & privs [ i ] . se_priv ) ;
2008-02-11 12:19:54 +03:00
entries [ i ] . luid . low = luid . luid . low ;
entries [ i ] . luid . high = luid . luid . high ;
2001-11-23 02:50:16 +03:00
}
2001-07-09 22:32:54 +04:00
}
2005-01-13 21:20:37 +03:00
enum_context = num_privs ;
2008-02-11 12:19:54 +03:00
* r - > out . resume_handle = enum_context ;
r - > out . privs - > count = num_privs ;
r - > out . privs - > privs = entries ;
2001-07-09 22:32:54 +04:00
2001-08-27 23:46:22 +04:00
return NT_STATUS_OK ;
2001-07-09 22:32:54 +04:00
}
/***************************************************************************
2008-02-11 13:57:29 +03:00
_lsa_LookupPrivDisplayName
2001-07-09 22:32:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-11 13:57:29 +03:00
NTSTATUS _lsa_LookupPrivDisplayName ( pipes_struct * p ,
struct lsa_LookupPrivDisplayName * r )
2001-07-09 22:32:54 +04:00
{
2001-12-18 02:03:23 +03:00
struct lsa_info * handle ;
2005-01-17 18:23:11 +03:00
const char * description ;
2008-02-11 13:57:29 +03:00
struct lsa_StringLarge * lsa_name ;
2001-07-09 22:32:54 +04:00
2008-02-11 13:57:29 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) )
2001-07-09 22:32:54 +04:00
return NT_STATUS_INVALID_HANDLE ;
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2001-12-18 02:03:23 +03:00
/*
* I don ' t know if it ' s the right one . not documented .
*/
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2008-02-11 13:57:29 +03:00
DEBUG ( 10 , ( " _lsa_LookupPrivDisplayName: name = %s \n " , r - > in . name - > string ) ) ;
2001-07-09 22:32:54 +04:00
2008-02-11 13:57:29 +03:00
description = get_privilege_dispname ( r - > in . name - > string ) ;
if ( ! description ) {
DEBUG ( 10 , ( " _lsa_LookupPrivDisplayName: doesn't exist \n " ) ) ;
return NT_STATUS_NO_SUCH_PRIVILEGE ;
}
2001-07-09 22:32:54 +04:00
2008-02-11 13:57:29 +03:00
DEBUG ( 10 , ( " _lsa_LookupPrivDisplayName: display name = %s \n " , description ) ) ;
2001-07-09 22:32:54 +04:00
2008-02-11 13:57:29 +03:00
lsa_name = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_StringLarge ) ;
if ( ! lsa_name ) {
return NT_STATUS_NO_MEMORY ;
2001-11-22 20:19:59 +03:00
}
2008-02-11 13:57:29 +03:00
init_lsa_StringLarge ( lsa_name , description ) ;
* r - > out . returned_language_id = r - > in . language_id ;
* r - > out . disp_name = lsa_name ;
return NT_STATUS_OK ;
2001-07-09 22:32:54 +04:00
}
/***************************************************************************
2008-02-14 03:16:03 +03:00
_lsa_EnumAccounts
2001-07-09 22:32:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-14 03:16:03 +03:00
NTSTATUS _lsa_EnumAccounts ( pipes_struct * p ,
struct lsa_EnumAccounts * r )
2001-07-09 22:32:54 +04:00
{
2001-12-18 02:03:23 +03:00
struct lsa_info * handle ;
2005-01-13 21:20:37 +03:00
DOM_SID * sid_list ;
int i , j , num_entries ;
2008-02-14 03:16:03 +03:00
NTSTATUS status ;
struct lsa_SidPtr * sids = NULL ;
2001-07-09 22:32:54 +04:00
2008-02-14 03:16:03 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) )
2001-07-09 22:32:54 +04:00
return NT_STATUS_INVALID_HANDLE ;
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2005-01-13 21:20:37 +03:00
sid_list = NULL ;
num_entries = 0 ;
/* The only way we can currently find out all the SIDs that have been
privileged is to scan all privileges */
2008-02-14 03:16:03 +03:00
status = privilege_enumerate_accounts ( & sid_list , & num_entries ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
2003-11-24 20:31:38 +03:00
}
2001-07-09 22:32:54 +04:00
2008-02-14 03:16:03 +03:00
if ( * r - > in . resume_handle > = num_entries ) {
2001-11-23 18:11:22 +03:00
return NT_STATUS_NO_MORE_ENTRIES ;
2008-02-14 03:16:03 +03:00
}
2001-11-23 18:11:22 +03:00
2008-02-14 03:16:03 +03:00
if ( num_entries - * r - > in . resume_handle ) {
sids = TALLOC_ZERO_ARRAY ( p - > mem_ctx , struct lsa_SidPtr ,
num_entries - * r - > in . resume_handle ) ;
if ( ! sids ) {
2007-04-30 05:17:34 +04:00
SAFE_FREE ( sid_list ) ;
return NT_STATUS_NO_MEMORY ;
}
2007-08-04 14:18:33 +04:00
2008-02-14 03:16:03 +03:00
for ( i = * r - > in . resume_handle , j = 0 ; i < num_entries ; i + + , j + + ) {
sids [ j ] . sid = sid_dup_talloc ( p - > mem_ctx , & sid_list [ i ] ) ;
if ( ! sids [ j ] . sid ) {
SAFE_FREE ( sid_list ) ;
return NT_STATUS_NO_MEMORY ;
}
2007-08-04 14:18:33 +04:00
}
2001-07-09 22:32:54 +04:00
}
2007-04-29 23:20:48 +04:00
talloc_free ( sid_list ) ;
2001-07-09 22:32:54 +04:00
2008-02-14 03:16:03 +03:00
* r - > out . resume_handle = num_entries ;
r - > out . sids - > num_sids = num_entries ;
r - > out . sids - > sids = sids ;
2001-07-09 22:32:54 +04:00
2001-08-27 23:46:22 +04:00
return NT_STATUS_OK ;
2001-07-09 22:32:54 +04:00
}
2008-02-11 22:29:31 +03:00
/***************************************************************************
_lsa_GetUserName
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-07-09 22:32:54 +04:00
2008-02-11 22:29:31 +03:00
NTSTATUS _lsa_GetUserName ( pipes_struct * p ,
struct lsa_GetUserName * r )
2001-06-30 03:12:55 +04:00
{
2006-07-15 21:55:01 +04:00
const char * username , * domname ;
2008-02-11 22:29:31 +03:00
struct lsa_String * account_name = NULL ;
struct lsa_String * authority_name = NULL ;
2008-06-24 17:24:08 +04:00
if ( p - > server_info - > guest ) {
2006-07-15 21:55:01 +04:00
/*
* I ' m 99 % sure this is not the right place to do this ,
* global_sid_Anonymous should probably be put into the token
* instead of the guest id - - vl
*/
if ( ! lookup_sid ( p - > mem_ctx , & global_sid_Anonymous ,
& domname , & username , NULL ) ) {
return NT_STATUS_NO_MEMORY ;
}
} else {
2008-06-24 17:24:08 +04:00
username = p - > server_info - > sanitized_username ;
domname = pdb_get_domain ( p - > server_info - > sam_account ) ;
2006-07-15 21:55:01 +04:00
}
2001-06-30 03:12:55 +04:00
2008-02-11 22:29:31 +03:00
account_name = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_String ) ;
if ( ! account_name ) {
return NT_STATUS_NO_MEMORY ;
}
2001-06-30 03:12:55 +04:00
2008-02-11 22:29:31 +03:00
authority_name = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_String ) ;
if ( ! authority_name ) {
return NT_STATUS_NO_MEMORY ;
}
init_lsa_String ( account_name , username ) ;
init_lsa_String ( authority_name , domname ) ;
* r - > out . account_name = account_name ;
* r - > out . authority_name = authority_name ;
return NT_STATUS_OK ;
2001-06-30 03:12:55 +04:00
}
2001-07-09 22:32:54 +04:00
/***************************************************************************
2008-02-06 20:58:11 +03:00
_lsa_CreateAccount
2001-07-09 22:32:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-06 20:58:11 +03:00
NTSTATUS _lsa_CreateAccount ( pipes_struct * p ,
struct lsa_CreateAccount * r )
2001-07-09 22:32:54 +04:00
{
2001-12-18 02:03:23 +03:00
struct lsa_info * handle ;
2001-07-09 22:32:54 +04:00
struct lsa_info * info ;
2005-01-13 21:20:37 +03:00
/* find the connection policy handle. */
2008-02-06 20:58:11 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) )
2005-01-13 21:20:37 +03:00
return NT_STATUS_INVALID_HANDLE ;
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2005-01-13 21:20:37 +03:00
/*
* I don ' t know if it ' s the right one . not documented .
* but guessed with rpcclient .
*/
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_GET_PRIVATE_INFORMATION ) )
2005-01-13 21:20:37 +03:00
return NT_STATUS_ACCESS_DENIED ;
2008-02-14 15:12:28 +03:00
/* check to see if the pipe_user is a Domain Admin since
2005-01-15 00:05:54 +03:00
account_pol . tdb was already opened as root , this is all we have */
2008-02-14 15:12:28 +03:00
2008-10-18 02:24:15 +04:00
if ( p - > pipe_user . ut . uid ! = sec_initial_uid ( )
& & ! nt_token_check_domain_rid ( p - > pipe_user . nt_user_token , DOMAIN_GROUP_RID_ADMINS ) )
2005-01-15 00:05:54 +03:00
return NT_STATUS_ACCESS_DENIED ;
2008-02-14 15:12:28 +03:00
2008-02-06 20:58:11 +03:00
if ( is_privileged_sid ( r - > in . sid ) )
2005-01-18 21:29:28 +03:00
return NT_STATUS_OBJECT_NAME_COLLISION ;
2005-01-15 00:05:54 +03:00
2005-01-13 21:20:37 +03:00
/* associate the user/group SID with the (unique) handle. */
2008-02-14 15:12:28 +03:00
2005-01-13 21:20:37 +03:00
if ( ( info = SMB_MALLOC_P ( struct lsa_info ) ) = = NULL )
return NT_STATUS_NO_MEMORY ;
ZERO_STRUCTP ( info ) ;
2008-02-06 20:58:11 +03:00
info - > sid = * r - > in . sid ;
info - > access = r - > in . access_mask ;
2005-01-13 21:20:37 +03:00
/* get a (unique) handle. open a policy on it. */
2008-02-09 03:33:47 +03:00
if ( ! create_policy_hnd ( p , r - > out . acct_handle , free_lsa_info , ( void * ) info ) )
2005-01-13 21:20:37 +03:00
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
return privilege_create_account ( & info - > sid ) ;
}
/***************************************************************************
2008-02-06 21:19:29 +03:00
_lsa_OpenAccount
2005-01-13 21:20:37 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-06 21:19:29 +03:00
NTSTATUS _lsa_OpenAccount ( pipes_struct * p ,
struct lsa_OpenAccount * r )
2005-01-13 21:20:37 +03:00
{
struct lsa_info * handle ;
struct lsa_info * info ;
2001-07-09 22:32:54 +04:00
/* find the connection policy handle. */
2008-02-06 21:19:29 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) )
2001-07-09 22:32:54 +04:00
return NT_STATUS_INVALID_HANDLE ;
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2001-12-18 02:03:23 +03:00
/*
* I don ' t know if it ' s the right one . not documented .
* but guessed with rpcclient .
*/
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_GET_PRIVATE_INFORMATION ) )
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2005-01-13 21:20:37 +03:00
/* TODO: Fis the parsing routine before reenabling this check! */
#if 0
if ( ! lookup_sid ( & handle - > sid , dom_name , name , & type ) )
return NT_STATUS_ACCESS_DENIED ;
# endif
2001-07-09 22:32:54 +04:00
/* associate the user/group SID with the (unique) handle. */
2004-12-07 21:25:53 +03:00
if ( ( info = SMB_MALLOC_P ( struct lsa_info ) ) = = NULL )
2001-07-09 22:32:54 +04:00
return NT_STATUS_NO_MEMORY ;
ZERO_STRUCTP ( info ) ;
2008-02-06 21:19:29 +03:00
info - > sid = * r - > in . sid ;
info - > access = r - > in . access_mask ;
2001-07-09 22:32:54 +04:00
/* get a (unique) handle. open a policy on it. */
2008-02-09 03:33:47 +03:00
if ( ! create_policy_hnd ( p , r - > out . acct_handle , free_lsa_info , ( void * ) info ) )
2001-07-09 22:32:54 +04:00
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
2005-01-13 21:20:37 +03:00
return NT_STATUS_OK ;
2001-07-09 22:32:54 +04:00
}
/***************************************************************************
2008-02-14 03:53:00 +03:00
_lsa_EnumPrivsAccount
2001-11-23 18:11:22 +03:00
For a given SID , enumerate all the privilege this account has .
2001-07-09 22:32:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-14 03:53:00 +03:00
NTSTATUS _lsa_EnumPrivsAccount ( pipes_struct * p ,
struct lsa_EnumPrivsAccount * r )
2001-07-09 22:32:54 +04:00
{
2008-02-14 03:53:00 +03:00
NTSTATUS status = NT_STATUS_OK ;
2001-07-09 22:32:54 +04:00
struct lsa_info * info = NULL ;
2005-01-17 18:23:11 +03:00
SE_PRIV mask ;
PRIVILEGE_SET privileges ;
2008-02-14 03:53:00 +03:00
struct lsa_PrivilegeSet * priv_set = NULL ;
struct lsa_LUIDAttribute * luid_attrs = NULL ;
int i ;
2001-07-09 22:32:54 +04:00
/* find the connection policy handle. */
2008-02-14 03:53:00 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2001-07-09 22:32:54 +04:00
return NT_STATUS_INVALID_HANDLE ;
2008-10-18 02:24:15 +04:00
if ( ! ( info - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
return NT_STATUS_ACCESS_DENIED ;
2008-02-14 03:53:00 +03:00
if ( ! get_privileges_for_sids ( & mask , & info - > sid , 1 ) )
2005-01-17 18:23:11 +03:00
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
2001-07-09 22:32:54 +04:00
2005-01-17 18:23:11 +03:00
privilege_set_init ( & privileges ) ;
2001-11-29 19:05:05 +03:00
2005-01-17 18:23:11 +03:00
if ( se_priv_to_privilege_set ( & privileges , & mask ) ) {
2001-07-09 22:32:54 +04:00
2008-02-14 03:53:00 +03:00
DEBUG ( 10 , ( " _lsa_EnumPrivsAccount: %s has %d privileges \n " ,
2007-12-15 23:11:36 +03:00
sid_string_dbg ( & info - > sid ) ,
privileges . count ) ) ;
2003-06-18 19:24:10 +04:00
2008-02-14 03:53:00 +03:00
priv_set = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_PrivilegeSet ) ;
if ( ! priv_set ) {
status = NT_STATUS_NO_MEMORY ;
goto done ;
}
luid_attrs = TALLOC_ZERO_ARRAY ( p - > mem_ctx ,
struct lsa_LUIDAttribute ,
privileges . count ) ;
if ( ! luid_attrs ) {
status = NT_STATUS_NO_MEMORY ;
goto done ;
}
for ( i = 0 ; i < privileges . count ; i + + ) {
luid_attrs [ i ] . luid . low = privileges . set [ i ] . luid . low ;
luid_attrs [ i ] . luid . high = privileges . set [ i ] . luid . high ;
luid_attrs [ i ] . attribute = privileges . set [ i ] . attr ;
}
priv_set - > count = privileges . count ;
priv_set - > unknown = 0 ;
priv_set - > set = luid_attrs ;
* r - > out . privs = priv_set ;
} else {
status = NT_STATUS_NO_SUCH_PRIVILEGE ;
2005-01-17 18:23:11 +03:00
}
2001-07-09 22:32:54 +04:00
2008-02-14 03:53:00 +03:00
done :
2005-01-17 18:23:11 +03:00
privilege_set_free ( & privileges ) ;
2008-02-14 03:53:00 +03:00
return status ;
2001-07-09 22:32:54 +04:00
}
/***************************************************************************
2008-02-08 20:54:02 +03:00
_lsa_GetSystemAccessAccount
2001-07-09 22:32:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-08 20:54:02 +03:00
NTSTATUS _lsa_GetSystemAccessAccount ( pipes_struct * p ,
struct lsa_GetSystemAccessAccount * r )
2001-07-09 22:32:54 +04:00
{
2001-11-29 19:05:05 +03:00
struct lsa_info * info = NULL ;
2001-07-09 22:32:54 +04:00
/* find the connection policy handle. */
2005-01-13 21:20:37 +03:00
2008-02-08 20:54:02 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2001-07-09 22:32:54 +04:00
return NT_STATUS_INVALID_HANDLE ;
2008-10-18 02:24:15 +04:00
if ( ! ( info - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
return NT_STATUS_ACCESS_DENIED ;
2005-12-03 21:34:13 +03:00
if ( ! lookup_sid ( p - > mem_ctx , & info - > sid , NULL , NULL , NULL ) )
2007-10-11 00:34:30 +04:00
return NT_STATUS_ACCESS_DENIED ;
2001-11-29 19:05:05 +03:00
/*
0x01 - > Log on locally
0x02 - > Access this computer from network
0x04 - > Log on as a batch job
0x10 - > Log on as a service
2008-02-14 15:12:28 +03:00
2001-11-29 19:05:05 +03:00
they can be ORed together
*/
2008-02-08 20:54:02 +03:00
* r - > out . access_mask = PR_LOG_ON_LOCALLY | PR_ACCESS_FROM_NETWORK ;
2001-07-09 22:32:54 +04:00
2005-01-13 21:20:37 +03:00
return NT_STATUS_OK ;
2001-07-09 22:32:54 +04:00
}
2001-11-29 19:05:05 +03:00
/***************************************************************************
update the systemaccount information
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-08 20:32:05 +03:00
NTSTATUS _lsa_SetSystemAccessAccount ( pipes_struct * p ,
struct lsa_SetSystemAccessAccount * r )
2001-11-29 19:05:05 +03:00
{
struct lsa_info * info = NULL ;
GROUP_MAP map ;
/* find the connection policy handle. */
2008-02-08 20:32:05 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2001-11-29 19:05:05 +03:00
return NT_STATUS_INVALID_HANDLE ;
2008-02-14 15:12:28 +03:00
/* check to see if the pipe_user is a Domain Admin since
2005-01-15 00:05:54 +03:00
account_pol . tdb was already opened as root , this is all we have */
2008-02-14 15:12:28 +03:00
2008-10-18 02:24:15 +04:00
if ( p - > pipe_user . ut . uid ! = sec_initial_uid ( )
& & ! nt_token_check_domain_rid ( p - > pipe_user . nt_user_token , DOMAIN_GROUP_RID_ADMINS ) )
2005-01-15 00:05:54 +03:00
return NT_STATUS_ACCESS_DENIED ;
2006-08-15 18:07:15 +04:00
if ( ! pdb_getgrsid ( & map , info - > sid ) )
2001-11-29 19:05:05 +03:00
return NT_STATUS_NO_SUCH_GROUP ;
2006-02-04 01:19:41 +03:00
return pdb_update_group_mapping_entry ( & map ) ;
2001-11-29 19:05:05 +03:00
}
/***************************************************************************
2008-02-14 15:50:32 +03:00
_lsa_AddPrivilegesToAccount
2001-11-29 19:05:05 +03:00
For a given SID , add some privileges .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-14 15:50:32 +03:00
NTSTATUS _lsa_AddPrivilegesToAccount ( pipes_struct * p ,
struct lsa_AddPrivilegesToAccount * r )
2001-11-29 19:05:05 +03:00
{
2003-10-06 05:38:46 +04:00
struct lsa_info * info = NULL ;
2005-01-17 18:23:11 +03:00
SE_PRIV mask ;
2008-02-14 15:50:32 +03:00
struct lsa_PrivilegeSet * set = NULL ;
2001-11-29 19:05:05 +03:00
/* find the connection policy handle. */
2008-02-14 15:50:32 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2001-11-29 19:05:05 +03:00
return NT_STATUS_INVALID_HANDLE ;
2008-02-14 15:12:28 +03:00
/* check to see if the pipe_user is root or a Domain Admin since
2005-01-15 00:05:54 +03:00
account_pol . tdb was already opened as root , this is all we have */
2008-02-14 15:12:28 +03:00
if ( p - > pipe_user . ut . uid ! = sec_initial_uid ( )
2005-01-28 19:55:09 +03:00
& & ! nt_token_check_domain_rid ( p - > pipe_user . nt_user_token , DOMAIN_GROUP_RID_ADMINS ) )
{
2005-01-15 00:05:54 +03:00
return NT_STATUS_ACCESS_DENIED ;
2005-01-28 19:55:09 +03:00
}
2001-11-29 19:05:05 +03:00
2008-02-14 15:50:32 +03:00
set = r - > in . privs ;
2005-01-17 18:23:11 +03:00
if ( ! privilege_set_to_se_priv ( & mask , set ) )
return NT_STATUS_NO_SUCH_PRIVILEGE ;
2005-01-13 21:20:37 +03:00
2005-01-17 18:23:11 +03:00
if ( ! grant_privilege ( & info - > sid , & mask ) ) {
2008-02-14 15:50:32 +03:00
DEBUG ( 3 , ( " _lsa_AddPrivilegesToAccount: grant_privilege(%s) failed! \n " ,
2007-12-15 23:11:36 +03:00
sid_string_dbg ( & info - > sid ) ) ) ;
2005-01-17 18:23:11 +03:00
DEBUG ( 3 , ( " Privilege mask: \n " ) ) ;
dump_se_priv ( DBGC_ALL , 3 , & mask ) ;
return NT_STATUS_NO_SUCH_PRIVILEGE ;
2001-11-29 19:05:05 +03:00
}
2005-01-13 21:20:37 +03:00
return NT_STATUS_OK ;
2001-11-29 19:05:05 +03:00
}
/***************************************************************************
2008-02-14 15:50:32 +03:00
_lsa_RemovePrivilegesFromAccount
2001-11-29 19:05:05 +03:00
For a given SID , remove some privileges .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-14 15:50:32 +03:00
NTSTATUS _lsa_RemovePrivilegesFromAccount ( pipes_struct * p ,
struct lsa_RemovePrivilegesFromAccount * r )
2001-11-29 19:05:05 +03:00
{
2003-10-06 05:38:46 +04:00
struct lsa_info * info = NULL ;
2005-01-17 18:23:11 +03:00
SE_PRIV mask ;
2008-02-14 15:50:32 +03:00
struct lsa_PrivilegeSet * set = NULL ;
2001-11-29 19:05:05 +03:00
/* find the connection policy handle. */
2008-02-14 15:50:32 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2001-11-29 19:05:05 +03:00
return NT_STATUS_INVALID_HANDLE ;
2008-02-14 15:12:28 +03:00
/* check to see if the pipe_user is root or a Domain Admin since
2005-01-15 00:05:54 +03:00
account_pol . tdb was already opened as root , this is all we have */
2008-02-14 15:12:28 +03:00
2006-07-11 22:01:26 +04:00
if ( p - > pipe_user . ut . uid ! = sec_initial_uid ( )
2008-02-14 15:12:28 +03:00
& & ! nt_token_check_domain_rid ( p - > pipe_user . nt_user_token , DOMAIN_GROUP_RID_ADMINS ) )
2005-01-28 19:55:09 +03:00
{
2005-01-15 00:05:54 +03:00
return NT_STATUS_ACCESS_DENIED ;
2005-01-28 19:55:09 +03:00
}
2005-01-15 00:05:54 +03:00
2008-02-14 15:50:32 +03:00
set = r - > in . privs ;
2001-11-29 19:05:05 +03:00
2005-01-17 18:23:11 +03:00
if ( ! privilege_set_to_se_priv ( & mask , set ) )
return NT_STATUS_NO_SUCH_PRIVILEGE ;
2005-01-13 21:20:37 +03:00
2005-01-17 18:23:11 +03:00
if ( ! revoke_privilege ( & info - > sid , & mask ) ) {
2008-02-14 15:50:32 +03:00
DEBUG ( 3 , ( " _lsa_RemovePrivilegesFromAccount: revoke_privilege(%s) failed! \n " ,
2007-12-15 23:11:36 +03:00
sid_string_dbg ( & info - > sid ) ) ) ;
2005-01-17 18:23:11 +03:00
DEBUG ( 3 , ( " Privilege mask: \n " ) ) ;
dump_se_priv ( DBGC_ALL , 3 , & mask ) ;
return NT_STATUS_NO_SUCH_PRIVILEGE ;
2001-11-29 19:05:05 +03:00
}
2005-01-13 21:20:37 +03:00
return NT_STATUS_OK ;
2001-11-29 19:05:05 +03:00
}
2001-12-14 20:31:48 +03:00
/***************************************************************************
2008-02-04 23:13:19 +03:00
_lsa_QuerySecurity
2001-12-14 20:31:48 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-04 23:13:19 +03:00
NTSTATUS _lsa_QuerySecurity ( pipes_struct * p ,
struct lsa_QuerySecurity * r )
2001-12-14 20:31:48 +03:00
{
2001-12-18 02:03:23 +03:00
struct lsa_info * handle = NULL ;
2001-12-14 20:31:48 +03:00
SEC_DESC * psd = NULL ;
size_t sd_size ;
2001-12-18 02:03:23 +03:00
NTSTATUS status ;
2001-12-14 20:31:48 +03:00
/* find the connection policy handle. */
2008-02-04 23:13:19 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) )
2001-12-14 20:31:48 +03:00
return NT_STATUS_INVALID_HANDLE ;
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2008-02-04 23:13:19 +03:00
switch ( r - > in . sec_info ) {
2001-12-14 20:31:48 +03:00
case 1 :
/* SD contains only the owner */
2001-12-18 02:03:23 +03:00
status = lsa_get_generic_sd ( p - > mem_ctx , & psd , & sd_size ) ;
if ( ! NT_STATUS_IS_OK ( status ) )
2001-12-14 20:31:48 +03:00
return NT_STATUS_NO_MEMORY ;
2001-12-18 02:03:23 +03:00
2008-02-04 23:13:19 +03:00
if ( ( * r - > out . sdbuf = make_sec_desc_buf ( p - > mem_ctx , sd_size , psd ) ) = = NULL )
2001-12-14 20:31:48 +03:00
return NT_STATUS_NO_MEMORY ;
break ;
case 4 :
/* SD contains only the ACL */
2001-12-18 02:03:23 +03:00
status = lsa_get_generic_sd ( p - > mem_ctx , & psd , & sd_size ) ;
if ( ! NT_STATUS_IS_OK ( status ) )
2001-12-14 20:31:48 +03:00
return NT_STATUS_NO_MEMORY ;
2008-02-04 23:13:19 +03:00
if ( ( * r - > out . sdbuf = make_sec_desc_buf ( p - > mem_ctx , sd_size , psd ) ) = = NULL )
2001-12-14 20:31:48 +03:00
return NT_STATUS_NO_MEMORY ;
break ;
default :
return NT_STATUS_INVALID_LEVEL ;
}
2008-02-04 23:13:19 +03:00
return status ;
2001-12-14 20:31:48 +03:00
}
2005-03-10 21:50:47 +03:00
#if 0 /* AD DC work in ongoing in Samba 4 */
2005-01-15 05:20:30 +03:00
/***************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-12-14 20:31:48 +03:00
2008-02-08 03:56:09 +03:00
NTSTATUS _lsa_query_info2 ( pipes_struct * p , LSA_Q_QUERY_INFO2 * q_u , LSA_R_QUERY_INFO2 * r_u )
2002-08-17 19:34:15 +04:00
{
struct lsa_info * handle ;
2002-11-13 02:20:50 +03:00
const char * nb_name ;
2002-08-17 19:34:15 +04:00
char * dns_name = NULL ;
char * forest_name = NULL ;
DOM_SID * sid = NULL ;
2006-09-19 21:29:31 +04:00
struct GUID guid ;
2003-04-22 11:28:41 +04:00
fstring dnsdomname ;
2002-08-17 19:34:15 +04:00
ZERO_STRUCT ( guid ) ;
r_u - > status = NT_STATUS_OK ;
2005-12-03 09:46:46 +03:00
if ( ! find_policy_by_hnd ( p , & q_u - > pol , ( void * * ) ( void * ) & handle ) )
2002-08-17 19:34:15 +04:00
return NT_STATUS_INVALID_HANDLE ;
switch ( q_u - > info_class ) {
case 0x0c :
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
2002-08-17 19:34:15 +04:00
return NT_STATUS_ACCESS_DENIED ;
/* Request PolicyPrimaryDomainInformation. */
switch ( lp_server_role ( ) ) {
case ROLE_DOMAIN_PDC :
case ROLE_DOMAIN_BDC :
2003-05-07 12:21:06 +04:00
nb_name = get_global_sam_name ( ) ;
2002-08-17 19:34:15 +04:00
/* ugly temp hack for these next two */
2003-04-22 11:28:41 +04:00
/* This should be a 'netbios domain -> DNS domain' mapping */
2007-11-09 04:25:45 +03:00
dnsdomname = get_mydnsdomname ( p - > mem_ctx ) ;
2007-11-09 04:58:55 +03:00
if ( ! dnsdomname | | ! * dnsdomname ) {
2007-11-09 04:25:45 +03:00
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO ;
}
2003-07-03 23:11:31 +04:00
strlower_m ( dnsdomname ) ;
2007-11-09 04:25:45 +03:00
2003-04-22 11:28:41 +04:00
dns_name = dnsdomname ;
forest_name = dnsdomname ;
2002-08-17 19:34:15 +04:00
sid = get_global_sam_sid ( ) ;
2002-11-13 02:20:50 +03:00
secrets_fetch_domain_guid ( lp_workgroup ( ) , & guid ) ;
2002-08-17 19:34:15 +04:00
break ;
default :
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO ;
}
2008-02-14 15:12:28 +03:00
init_dns_dom_info ( & r_u - > info . dns_dom_info , nb_name , dns_name ,
2002-08-17 19:34:15 +04:00
forest_name , & guid , sid ) ;
break ;
default :
DEBUG ( 0 , ( " _lsa_query_info2: unknown info level in Lsa Query: %d \n " , q_u - > info_class ) ) ;
r_u - > status = NT_STATUS_INVALID_INFO_CLASS ;
break ;
}
if ( NT_STATUS_IS_OK ( r_u - > status ) ) {
r_u - > ptr = 0x1 ;
r_u - > info_class = q_u - > info_class ;
}
return r_u - > status ;
}
2005-03-10 21:50:47 +03:00
# endif /* AD DC work in ongoing in Samba 4 */
2005-01-15 05:20:30 +03:00
/***************************************************************************
2008-02-14 16:21:49 +03:00
_lsa_AddAccountRights
2005-01-15 05:20:30 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-14 16:21:49 +03:00
NTSTATUS _lsa_AddAccountRights ( pipes_struct * p ,
struct lsa_AddAccountRights * r )
2005-01-15 05:20:30 +03:00
{
struct lsa_info * info = NULL ;
int i = 0 ;
DOM_SID sid ;
/* find the connection policy handle. */
2008-02-14 16:21:49 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2005-01-15 05:20:30 +03:00
return NT_STATUS_INVALID_HANDLE ;
2008-02-14 15:12:28 +03:00
/* check to see if the pipe_user is a Domain Admin since
2005-01-15 05:20:30 +03:00
account_pol . tdb was already opened as root , this is all we have */
2008-02-14 15:12:28 +03:00
2006-07-11 22:01:26 +04:00
if ( p - > pipe_user . ut . uid ! = sec_initial_uid ( )
2008-02-14 15:12:28 +03:00
& & ! nt_token_check_domain_rid ( p - > pipe_user . nt_user_token , DOMAIN_GROUP_RID_ADMINS ) )
2005-02-14 04:13:14 +03:00
{
2005-01-15 05:20:30 +03:00
return NT_STATUS_ACCESS_DENIED ;
2005-02-14 04:13:14 +03:00
}
2005-01-15 05:20:30 +03:00
/* according to an NT4 PDC, you can add privileges to SIDs even without
call_lsa_create_account ( ) first . And you can use any arbitrary SID . */
2008-02-14 15:12:28 +03:00
2008-02-14 16:21:49 +03:00
sid_copy ( & sid , r - > in . sid ) ;
2008-02-14 15:12:28 +03:00
2008-02-14 16:21:49 +03:00
for ( i = 0 ; i < r - > in . rights - > count ; i + + ) {
2008-02-14 15:12:28 +03:00
2008-02-14 16:21:49 +03:00
const char * privname = r - > in . rights - > names [ i ] . string ;
2005-03-26 09:52:56 +03:00
2005-01-15 05:20:30 +03:00
/* only try to add non-null strings */
2005-03-26 09:52:56 +03:00
2008-02-14 16:21:49 +03:00
if ( ! privname )
2005-03-26 09:52:56 +03:00
continue ;
if ( ! grant_privilege_by_name ( & sid , privname ) ) {
2008-02-14 16:21:49 +03:00
DEBUG ( 2 , ( " _lsa_AddAccountRights: Failed to add privilege [%s] \n " ,
privname ) ) ;
2005-01-15 05:20:30 +03:00
return NT_STATUS_NO_SUCH_PRIVILEGE ;
}
}
return NT_STATUS_OK ;
}
/***************************************************************************
2008-02-14 17:20:18 +03:00
_lsa_RemoveAccountRights
2005-01-15 05:20:30 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-14 17:20:18 +03:00
NTSTATUS _lsa_RemoveAccountRights ( pipes_struct * p ,
struct lsa_RemoveAccountRights * r )
2005-01-15 05:20:30 +03:00
{
struct lsa_info * info = NULL ;
int i = 0 ;
DOM_SID sid ;
2008-02-14 17:20:18 +03:00
const char * privname = NULL ;
2005-01-15 05:20:30 +03:00
/* find the connection policy handle. */
2008-02-14 17:20:18 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2005-01-15 05:20:30 +03:00
return NT_STATUS_INVALID_HANDLE ;
2008-02-14 15:12:28 +03:00
/* check to see if the pipe_user is a Domain Admin since
2005-01-15 05:20:30 +03:00
account_pol . tdb was already opened as root , this is all we have */
2008-02-14 15:12:28 +03:00
2006-07-11 22:01:26 +04:00
if ( p - > pipe_user . ut . uid ! = sec_initial_uid ( )
2005-02-14 04:13:14 +03:00
& & ! nt_token_check_domain_rid ( p - > pipe_user . nt_user_token , DOMAIN_GROUP_RID_ADMINS ) )
{
2005-01-15 05:20:30 +03:00
return NT_STATUS_ACCESS_DENIED ;
2005-02-14 04:13:14 +03:00
}
2005-01-15 05:20:30 +03:00
2008-02-14 17:20:18 +03:00
sid_copy ( & sid , r - > in . sid ) ;
2005-01-15 05:20:30 +03:00
2008-02-14 17:20:18 +03:00
if ( r - > in . remove_all ) {
2008-02-14 15:12:28 +03:00
if ( ! revoke_all_privileges ( & sid ) )
2005-01-15 05:20:30 +03:00
return NT_STATUS_ACCESS_DENIED ;
2008-02-14 15:12:28 +03:00
2005-01-15 05:20:30 +03:00
return NT_STATUS_OK ;
}
2008-02-14 15:12:28 +03:00
2008-02-14 17:20:18 +03:00
for ( i = 0 ; i < r - > in . rights - > count ; i + + ) {
2008-02-14 15:12:28 +03:00
2008-02-14 17:20:18 +03:00
privname = r - > in . rights - > names [ i ] . string ;
2005-03-26 09:52:56 +03:00
2005-01-15 05:20:30 +03:00
/* only try to add non-null strings */
2005-03-26 09:52:56 +03:00
2008-02-14 17:20:18 +03:00
if ( ! privname )
2005-03-26 09:52:56 +03:00
continue ;
if ( ! revoke_privilege_by_name ( & sid , privname ) ) {
2008-02-14 17:20:18 +03:00
DEBUG ( 2 , ( " _lsa_RemoveAccountRights: Failed to revoke privilege [%s] \n " ,
privname ) ) ;
2005-01-15 05:20:30 +03:00
return NT_STATUS_NO_SUCH_PRIVILEGE ;
}
}
return NT_STATUS_OK ;
}
2008-02-14 17:02:31 +03:00
/*******************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static NTSTATUS init_lsa_right_set ( TALLOC_CTX * mem_ctx ,
struct lsa_RightSet * r ,
PRIVILEGE_SET * privileges )
{
uint32 i ;
const char * privname ;
const char * * privname_array = NULL ;
int num_priv = 0 ;
for ( i = 0 ; i < privileges - > count ; i + + ) {
privname = luid_to_privilege_name ( & privileges - > set [ i ] . luid ) ;
if ( privname ) {
if ( ! add_string_to_array ( mem_ctx , privname ,
& privname_array , & num_priv ) ) {
return NT_STATUS_NO_MEMORY ;
}
}
}
if ( num_priv ) {
r - > names = TALLOC_ZERO_ARRAY ( mem_ctx , struct lsa_StringLarge ,
num_priv ) ;
if ( ! r - > names ) {
return NT_STATUS_NO_MEMORY ;
}
for ( i = 0 ; i < num_priv ; i + + ) {
init_lsa_StringLarge ( & r - > names [ i ] , privname_array [ i ] ) ;
}
r - > count = num_priv ;
}
return NT_STATUS_OK ;
}
2005-01-15 05:20:30 +03:00
2005-03-26 09:52:56 +03:00
/***************************************************************************
2008-02-14 17:02:31 +03:00
_lsa_EnumAccountRights
2005-03-26 09:52:56 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-14 17:02:31 +03:00
NTSTATUS _lsa_EnumAccountRights ( pipes_struct * p ,
struct lsa_EnumAccountRights * r )
2005-01-15 06:54:03 +03:00
{
2008-02-14 17:02:31 +03:00
NTSTATUS status ;
2005-01-15 06:54:03 +03:00
struct lsa_info * info = NULL ;
DOM_SID sid ;
PRIVILEGE_SET privileges ;
2005-01-17 18:23:11 +03:00
SE_PRIV mask ;
2008-02-14 15:12:28 +03:00
2005-01-15 06:54:03 +03:00
/* find the connection policy handle. */
2008-02-14 15:12:28 +03:00
2008-02-14 17:02:31 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2005-01-15 06:54:03 +03:00
return NT_STATUS_INVALID_HANDLE ;
2008-02-14 15:12:28 +03:00
2008-10-18 02:24:15 +04:00
if ( ! ( info - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
return NT_STATUS_ACCESS_DENIED ;
2005-01-15 06:54:03 +03:00
/* according to an NT4 PDC, you can add privileges to SIDs even without
call_lsa_create_account ( ) first . And you can use any arbitrary SID . */
2008-02-14 15:12:28 +03:00
2008-02-14 17:02:31 +03:00
sid_copy ( & sid , r - > in . sid ) ;
2008-02-14 15:12:28 +03:00
2005-01-17 18:23:11 +03:00
if ( ! get_privileges_for_sids ( & mask , & sid , 1 ) )
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
2005-01-15 06:54:03 +03:00
privilege_set_init ( & privileges ) ;
2005-01-17 18:23:11 +03:00
if ( se_priv_to_privilege_set ( & privileges , & mask ) ) {
2008-02-14 17:02:31 +03:00
DEBUG ( 10 , ( " _lsa_EnumAccountRights: %s has %d privileges \n " ,
2007-12-15 23:11:36 +03:00
sid_string_dbg ( & sid ) , privileges . count ) ) ;
2005-01-15 06:54:03 +03:00
2008-02-14 17:02:31 +03:00
status = init_lsa_right_set ( p - > mem_ctx , r - > out . rights , & privileges ) ;
} else {
status = NT_STATUS_NO_SUCH_PRIVILEGE ;
2005-01-17 18:23:11 +03:00
}
2005-01-15 06:54:03 +03:00
privilege_set_free ( & privileges ) ;
2008-02-14 17:02:31 +03:00
return status ;
2005-01-15 06:54:03 +03:00
}
2005-03-26 09:52:56 +03:00
/***************************************************************************
2008-02-14 15:25:42 +03:00
_lsa_LookupPrivValue
2005-03-26 09:52:56 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-14 15:25:42 +03:00
NTSTATUS _lsa_LookupPrivValue ( pipes_struct * p ,
struct lsa_LookupPrivValue * r )
2005-03-10 21:50:47 +03:00
{
struct lsa_info * info = NULL ;
2008-02-14 15:25:42 +03:00
const char * name = NULL ;
2005-03-10 21:50:47 +03:00
LUID_ATTR priv_luid ;
SE_PRIV mask ;
2008-02-14 15:12:28 +03:00
2005-03-10 21:50:47 +03:00
/* find the connection policy handle. */
2008-02-14 15:12:28 +03:00
2008-02-14 15:25:42 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2005-03-10 21:50:47 +03:00
return NT_STATUS_INVALID_HANDLE ;
2008-02-14 15:12:28 +03:00
2008-10-18 02:24:15 +04:00
if ( ! ( info - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
return NT_STATUS_ACCESS_DENIED ;
2008-02-14 15:25:42 +03:00
name = r - > in . name - > string ;
2008-02-14 15:12:28 +03:00
2005-06-29 20:35:32 +04:00
DEBUG ( 10 , ( " _lsa_lookup_priv_value: name = %s \n " , name ) ) ;
2005-03-10 21:50:47 +03:00
if ( ! se_priv_from_name ( name , & mask ) )
return NT_STATUS_NO_SUCH_PRIVILEGE ;
priv_luid = get_privilege_luid ( & mask ) ;
2008-02-14 15:25:42 +03:00
r - > out . luid - > low = priv_luid . luid . low ;
r - > out . luid - > high = priv_luid . luid . high ;
2005-03-10 21:50:47 +03:00
return NT_STATUS_OK ;
}
2006-10-10 12:39:11 +04:00
/*
* From here on the server routines are just dummy ones to make smbd link with
* librpc / gen_ndr / srv_lsa . c . These routines are actually never called , we are
* pulling the server stubs across one by one .
2008-02-14 15:12:28 +03:00
*/
2006-10-10 12:39:11 +04:00
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_Delete ( pipes_struct * p , struct lsa_Delete * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetSecObj ( pipes_struct * p , struct lsa_SetSecObj * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_ChangePassword ( pipes_struct * p , struct lsa_ChangePassword * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetInfoPolicy ( pipes_struct * p , struct lsa_SetInfoPolicy * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_ClearAuditLog ( pipes_struct * p , struct lsa_ClearAuditLog * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_GetQuotasForAccount ( pipes_struct * p , struct lsa_GetQuotasForAccount * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetQuotasForAccount ( pipes_struct * p , struct lsa_SetQuotasForAccount * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_QueryTrustedDomainInfo ( pipes_struct * p , struct lsa_QueryTrustedDomainInfo * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetInformationTrustedDomain ( pipes_struct * p , struct lsa_SetInformationTrustedDomain * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_QuerySecret ( pipes_struct * p , struct lsa_QuerySecret * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_LookupPrivName ( pipes_struct * p , struct lsa_LookupPrivName * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_EnumAccountsWithUserRight ( pipes_struct * p , struct lsa_EnumAccountsWithUserRight * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_QueryTrustedDomainInfoBySid ( pipes_struct * p , struct lsa_QueryTrustedDomainInfoBySid * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetTrustedDomainInfo ( pipes_struct * p , struct lsa_SetTrustedDomainInfo * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_DeleteTrustedDomain ( pipes_struct * p , struct lsa_DeleteTrustedDomain * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_StorePrivateData ( pipes_struct * p , struct lsa_StorePrivateData * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_RetrievePrivateData ( pipes_struct * p , struct lsa_RetrievePrivateData * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_QueryInfoPolicy2 ( pipes_struct * p , struct lsa_QueryInfoPolicy2 * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetInfoPolicy2 ( pipes_struct * p , struct lsa_SetInfoPolicy2 * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_QueryTrustedDomainInfoByName ( pipes_struct * p , struct lsa_QueryTrustedDomainInfoByName * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetTrustedDomainInfoByName ( pipes_struct * p , struct lsa_SetTrustedDomainInfoByName * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_EnumTrustedDomainsEx ( pipes_struct * p , struct lsa_EnumTrustedDomainsEx * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CreateTrustedDomainEx ( pipes_struct * p , struct lsa_CreateTrustedDomainEx * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CloseTrustedDomainEx ( pipes_struct * p , struct lsa_CloseTrustedDomainEx * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_QueryDomainInformationPolicy ( pipes_struct * p , struct lsa_QueryDomainInformationPolicy * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetDomainInformationPolicy ( pipes_struct * p , struct lsa_SetDomainInformationPolicy * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_OpenTrustedDomainByName ( pipes_struct * p , struct lsa_OpenTrustedDomainByName * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_TestCall ( pipes_struct * p , struct lsa_TestCall * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CreateTrustedDomainEx2 ( pipes_struct * p , struct lsa_CreateTrustedDomainEx2 * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRWRITE ( pipes_struct * p , struct lsa_CREDRWRITE * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRREAD ( pipes_struct * p , struct lsa_CREDRREAD * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRENUMERATE ( pipes_struct * p , struct lsa_CREDRENUMERATE * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRWRITEDOMAINCREDENTIALS ( pipes_struct * p , struct lsa_CREDRWRITEDOMAINCREDENTIALS * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRREADDOMAINCREDENTIALS ( pipes_struct * p , struct lsa_CREDRREADDOMAINCREDENTIALS * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRDELETE ( pipes_struct * p , struct lsa_CREDRDELETE * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRGETTARGETINFO ( pipes_struct * p , struct lsa_CREDRGETTARGETINFO * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRPROFILELOADED ( pipes_struct * p , struct lsa_CREDRPROFILELOADED * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRGETSESSIONTYPES ( pipes_struct * p , struct lsa_CREDRGETSESSIONTYPES * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_LSARREGISTERAUDITEVENT ( pipes_struct * p , struct lsa_LSARREGISTERAUDITEVENT * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_LSARGENAUDITEVENT ( pipes_struct * p , struct lsa_LSARGENAUDITEVENT * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_LSARUNREGISTERAUDITEVENT ( pipes_struct * p , struct lsa_LSARUNREGISTERAUDITEVENT * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2008-01-16 18:31:49 +03:00
NTSTATUS _lsa_lsaRQueryForestTrustInformation ( pipes_struct * p , struct lsa_lsaRQueryForestTrustInformation * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_LSARSETFORESTTRUSTINFORMATION ( pipes_struct * p , struct lsa_LSARSETFORESTTRUSTINFORMATION * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRRENAME ( pipes_struct * p , struct lsa_CREDRRENAME * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_LSAROPENPOLICYSCE ( pipes_struct * p , struct lsa_LSAROPENPOLICYSCE * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_LSARADTREGISTERSECURITYEVENTSOURCE ( pipes_struct * p , struct lsa_LSARADTREGISTERSECURITYEVENTSOURCE * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE ( pipes_struct * p , struct lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_LSARADTREPORTSECURITYEVENT ( pipes_struct * p , struct lsa_LSARADTREPORTSECURITYEVENT * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}