mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
parent
64c53e819b
commit
8c53b214da
@ -3,8 +3,9 @@
|
||||
* RPC Pipe client / server routines
|
||||
* Copyright (C) Andrew Tridgell 1992-1997,
|
||||
* Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
|
||||
* Copyright (C) Paul Ashton 1997.
|
||||
* Copyright (C) Jeremy Allison 2001.
|
||||
* Copyright (C) Paul Ashton 1997,
|
||||
* Copyright (C) Jeremy Allison 2001,
|
||||
* Copyright (C) Jim McDonough 2002.
|
||||
*
|
||||
* 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
|
||||
@ -609,6 +610,37 @@ static BOOL api_lsa_query_secobj(pipes_struct *p)
|
||||
return True;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
api_lsa_query_dnsdomainfo
|
||||
***************************************************************************/
|
||||
|
||||
static BOOL api_lsa_query_info2(pipes_struct *p)
|
||||
{
|
||||
LSA_Q_QUERY_INFO2 q_u;
|
||||
LSA_R_QUERY_INFO2 r_u;
|
||||
|
||||
prs_struct *data = &p->in_data.data;
|
||||
prs_struct *rdata = &p->out_data.rdata;
|
||||
|
||||
ZERO_STRUCT(q_u);
|
||||
ZERO_STRUCT(r_u);
|
||||
|
||||
if(!lsa_io_q_query_info2("", &q_u, data, 0)) {
|
||||
DEBUG(0,("api_lsa_query_info2: failed to unmarshall LSA_Q_QUERY_INFO2.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
r_u.status = _lsa_query_info2(p, &q_u, &r_u);
|
||||
|
||||
if (!lsa_io_r_query_info2("", &r_u, rdata, 0)) {
|
||||
DEBUG(0,("api_lsa_query_info2: failed to marshall LSA_R_QUERY_INFO2.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
\PIPE\ntlsa commands
|
||||
***************************************************************************/
|
||||
@ -634,6 +666,7 @@ static struct api_struct api_lsa_cmds[] =
|
||||
{ "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs },
|
||||
{ "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs },
|
||||
{ "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj },
|
||||
{ "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 },
|
||||
{ NULL , 0 , NULL }
|
||||
};
|
||||
|
||||
|
@ -5,7 +5,8 @@
|
||||
* Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
|
||||
* Copyright (C) Paul Ashton 1997,
|
||||
* Copyright (C) Jeremy Allison 2001,
|
||||
* Copyright (C) Rafal Szczesniak 2002.
|
||||
* Copyright (C) Rafal Szczesniak 2002,
|
||||
* Copyright (C) Jim McDonough 2002.
|
||||
*
|
||||
* 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
|
||||
@ -341,6 +342,48 @@ static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *s
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
init_dns_dom_info.
|
||||
***************************************************************************/
|
||||
static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, char *nb_name,
|
||||
char *dns_name, char *forest_name,
|
||||
GUID *dom_guid, DOM_SID *dom_sid)
|
||||
{
|
||||
if (nb_name && *nb_name) {
|
||||
init_uni_hdr(&r_l->hdr_nb_dom_name, strlen(nb_name));
|
||||
init_unistr2(&r_l->uni_nb_dom_name, nb_name,
|
||||
strlen(nb_name));
|
||||
r_l->hdr_nb_dom_name.uni_max_len += 2;
|
||||
r_l->uni_nb_dom_name.uni_max_len += 1;
|
||||
}
|
||||
|
||||
if (dns_name && *dns_name) {
|
||||
init_uni_hdr(&r_l->hdr_dns_dom_name, strlen(dns_name));
|
||||
init_unistr2(&r_l->uni_dns_dom_name, dns_name,
|
||||
strlen(dns_name));
|
||||
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) {
|
||||
init_uni_hdr(&r_l->hdr_forest_name, strlen(forest_name));
|
||||
init_unistr2(&r_l->uni_forest_name, forest_name,
|
||||
strlen(forest_name));
|
||||
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) {
|
||||
memcpy(&r_l->dom_guid, dom_guid, sizeof(GUID));
|
||||
}
|
||||
|
||||
if (dom_sid) {
|
||||
r_l->ptr_dom_sid = 1;
|
||||
init_dom_sid2(&r_l->dom_sid, dom_sid);
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
_lsa_open_policy2.
|
||||
***************************************************************************/
|
||||
@ -1166,3 +1209,55 @@ NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUER
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_INFO2 *r_u)
|
||||
{
|
||||
struct lsa_info *handle;
|
||||
char *nb_name = NULL;
|
||||
char *dns_name = NULL;
|
||||
char *forest_name = NULL;
|
||||
DOM_SID *sid = NULL;
|
||||
GUID guid;
|
||||
|
||||
ZERO_STRUCT(guid);
|
||||
r_u->status = NT_STATUS_OK;
|
||||
|
||||
if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle))
|
||||
return NT_STATUS_INVALID_HANDLE;
|
||||
|
||||
switch (q_u->info_class) {
|
||||
case 0x0c:
|
||||
/* check if the user have enough rights */
|
||||
if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
|
||||
return NT_STATUS_ACCESS_DENIED;
|
||||
|
||||
/* Request PolicyPrimaryDomainInformation. */
|
||||
switch (lp_server_role()) {
|
||||
case ROLE_DOMAIN_PDC:
|
||||
case ROLE_DOMAIN_BDC:
|
||||
nb_name = global_myworkgroup;
|
||||
/* ugly temp hack for these next two */
|
||||
dns_name = lp_realm();
|
||||
forest_name = lp_realm();
|
||||
sid = get_global_sam_sid();
|
||||
secrets_fetch_domain_guid(global_myworkgroup,
|
||||
&guid);
|
||||
break;
|
||||
default:
|
||||
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
|
||||
}
|
||||
init_dns_dom_info(&r_u->info.dns_dom_info, nb_name, dns_name,
|
||||
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;
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u)
|
||||
|
||||
/* from client / server challenges and md4 password, generate sess key */
|
||||
cred_session_key(&p->dc.clnt_chal, &p->dc.srv_chal,
|
||||
(char *)p->dc.md4pw, p->dc.sess_key);
|
||||
p->dc.md4pw, p->dc.sess_key);
|
||||
|
||||
/* check that the client credentials are valid */
|
||||
if (cred_assert(&q_u->clnt_chal, p->dc.sess_key, &p->dc.clnt_cred.challenge, srv_time)) {
|
||||
@ -342,7 +342,7 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u)
|
||||
|
||||
/* from client / server challenges and md4 password, generate sess key */
|
||||
cred_session_key(&p->dc.clnt_chal, &p->dc.srv_chal,
|
||||
(char *)p->dc.md4pw, p->dc.sess_key);
|
||||
p->dc.md4pw, p->dc.sess_key);
|
||||
|
||||
/* check that the client credentials are valid */
|
||||
if (cred_assert(&q_u->clnt_chal, p->dc.sess_key, &p->dc.clnt_cred.challenge, srv_time)) {
|
||||
@ -708,7 +708,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *
|
||||
pdb_get_username(sampw),
|
||||
pdb_get_fullname(sampw),
|
||||
pdb_get_homedir(sampw),
|
||||
pdb_get_dirdrive(sampw),
|
||||
pdb_get_dir_drive(sampw),
|
||||
pdb_get_logon_script(sampw),
|
||||
pdb_get_profile_path(sampw),
|
||||
pdb_get_logon_time(sampw),
|
||||
|
@ -83,7 +83,7 @@ static BOOL api_reg_open_hklm(pipes_struct *p)
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
api_reg_open_khlm
|
||||
api_reg_open_khu
|
||||
********************************************************************/
|
||||
|
||||
static BOOL api_reg_open_hku(pipes_struct *p)
|
||||
@ -108,6 +108,32 @@ static BOOL api_reg_open_hku(pipes_struct *p)
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
api_reg_open_khcr
|
||||
********************************************************************/
|
||||
|
||||
static BOOL api_reg_open_hkcr(pipes_struct *p)
|
||||
{
|
||||
REG_Q_OPEN_HKCR q_u;
|
||||
REG_R_OPEN_HKCR r_u;
|
||||
prs_struct *data = &p->in_data.data;
|
||||
prs_struct *rdata = &p->out_data.rdata;
|
||||
|
||||
ZERO_STRUCT(q_u);
|
||||
ZERO_STRUCT(r_u);
|
||||
|
||||
/* grab the reg open */
|
||||
if(!reg_io_q_open_hkcr("", &q_u, data, 0))
|
||||
return False;
|
||||
|
||||
r_u.status = _reg_open_hkcr(p, &q_u, &r_u);
|
||||
|
||||
if(!reg_io_r_open_hkcr("", &r_u, rdata, 0))
|
||||
return False;
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
api_reg_open_entry
|
||||
@ -290,6 +316,56 @@ static BOOL api_reg_enum_key(pipes_struct *p)
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
api_reg_enum_value
|
||||
********************************************************************/
|
||||
|
||||
static BOOL api_reg_enum_value(pipes_struct *p)
|
||||
{
|
||||
REG_Q_ENUM_VALUE q_u;
|
||||
REG_R_ENUM_VALUE r_u;
|
||||
prs_struct *data = &p->in_data.data;
|
||||
prs_struct *rdata = &p->out_data.rdata;
|
||||
|
||||
ZERO_STRUCT(q_u);
|
||||
ZERO_STRUCT(r_u);
|
||||
|
||||
if(!reg_io_q_enum_val("", &q_u, data, 0))
|
||||
return False;
|
||||
|
||||
r_u.status = _reg_enum_value(p, &q_u, &r_u);
|
||||
|
||||
if(!reg_io_r_enum_val("", &r_u, rdata, 0))
|
||||
return False;
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
api_reg_save_key
|
||||
********************************************************************/
|
||||
|
||||
static BOOL api_reg_save_key(pipes_struct *p)
|
||||
{
|
||||
REG_Q_SAVE_KEY q_u;
|
||||
REG_R_SAVE_KEY r_u;
|
||||
prs_struct *data = &p->in_data.data;
|
||||
prs_struct *rdata = &p->out_data.rdata;
|
||||
|
||||
ZERO_STRUCT(q_u);
|
||||
ZERO_STRUCT(r_u);
|
||||
|
||||
if(!reg_io_q_save_key("", &q_u, data, 0))
|
||||
return False;
|
||||
|
||||
r_u.status = _reg_save_key(p, &q_u, &r_u);
|
||||
|
||||
if(!reg_io_r_save_key("", &r_u, rdata, 0))
|
||||
return False;
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
@ -299,14 +375,17 @@ static struct api_struct api_reg_cmds[] =
|
||||
{
|
||||
{ "REG_CLOSE" , REG_CLOSE , api_reg_close },
|
||||
{ "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry },
|
||||
{ "REG_OPEN_HKCR" , REG_OPEN_HKCR , api_reg_open_hkcr },
|
||||
{ "REG_OPEN_HKLM" , REG_OPEN_HKLM , api_reg_open_hklm },
|
||||
{ "REG_OPEN_HKU" , REG_OPEN_HKU , api_reg_open_hku },
|
||||
{ "REG_ENUM_KEY" , REG_ENUM_KEY , api_reg_enum_key },
|
||||
{ "REG_ENUM_VALUE" , REG_ENUM_VALUE , api_reg_enum_value },
|
||||
{ "REG_QUERY_KEY" , REG_QUERY_KEY , api_reg_query_key },
|
||||
{ "REG_INFO" , REG_INFO , api_reg_info },
|
||||
{ "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown },
|
||||
{ "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown },
|
||||
{ "REG_UNKNOWN_1A" , REG_UNKNOWN_1A , api_reg_unknown_1a },
|
||||
{ "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key },
|
||||
{ NULL , 0 , NULL }
|
||||
};
|
||||
|
||||
|
@ -1,12 +1,11 @@
|
||||
/*
|
||||
* Unix SMB/CIFS implementation.
|
||||
* RPC Pipe client / server routines
|
||||
* Copyright (C) Andrew Tridgell 1992-1997,
|
||||
* Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
|
||||
* Copyright (C) Paul Ashton 1997.
|
||||
* Copyright (C) Hewlett-Packard Company 1999.
|
||||
* Copyright (C) Jeremy Allison 2001.
|
||||
* Copyright (C) Gerald Carter 2002.
|
||||
* Copyright (C) Andrew Tridgell 1992-1997.
|
||||
* Copyright (C) Luke Kenneth Casson Leighton 1996-1997.
|
||||
* Copyright (C) Paul Ashton 1997.
|
||||
* Copyright (C) Jeremy Allison 2001.
|
||||
* Copyright (C) Gerald Carter 2002.
|
||||
*
|
||||
* 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
|
||||
@ -30,332 +29,38 @@
|
||||
#undef DBGC_CLASS
|
||||
#define DBGC_CLASS DBGC_RPC_SRV
|
||||
|
||||
#define KEY_HKLM "HKLM"
|
||||
#define KEY_HKU "HKU"
|
||||
#define REGSTR_PRODUCTTYPE "ProductType"
|
||||
#define REG_PT_WINNT "WinNT"
|
||||
#define REG_PT_LANMANNT "LanmanNT"
|
||||
#define REG_PT_SERVERNT "ServerNT"
|
||||
|
||||
#define OUR_HANDLE(hnd) (((hnd)==NULL)?"NULL":(IVAL((hnd)->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")), \
|
||||
((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid())
|
||||
|
||||
/* structure to store the registry handles */
|
||||
|
||||
typedef struct _RegistryKey {
|
||||
struct _RegistryKey *prev, *next;
|
||||
static REGISTRY_KEY *regkeys_list;
|
||||
|
||||
fstring name; /* name of registry key */
|
||||
POLICY_HND hnd;
|
||||
|
||||
} Registry_Key;
|
||||
|
||||
static Registry_Key *regkeys_list;
|
||||
static TDB_CONTEXT *tdb_reg;
|
||||
|
||||
/***********************************************************************
|
||||
Add subkey strings to the registry tdb under a defined key
|
||||
fmt is the same format as tdb_pack except this function only supports
|
||||
fstrings
|
||||
***********************************************************************/
|
||||
/******************************************************************
|
||||
free() function for REGISTRY_KEY
|
||||
*****************************************************************/
|
||||
|
||||
static BOOL store_reg_keys( TDB_CONTEXT *tdb, char *keyname, char **subkeys, uint32 num_subkeys )
|
||||
static void free_regkey_info(void *ptr)
|
||||
{
|
||||
TDB_DATA kbuf, dbuf;
|
||||
char *buffer, *tmpbuf;
|
||||
int i = 0;
|
||||
uint32 len, buflen;
|
||||
BOOL ret = True;
|
||||
REGISTRY_KEY *info = (REGISTRY_KEY*)ptr;
|
||||
|
||||
if ( !keyname )
|
||||
return False;
|
||||
|
||||
/* allocate some initial memory */
|
||||
|
||||
buffer = malloc(sizeof(pstring));
|
||||
buflen = sizeof(pstring);
|
||||
len = 0;
|
||||
|
||||
/* store the number of subkeys */
|
||||
|
||||
len += tdb_pack(buffer+len, buflen-len, "d", num_subkeys);
|
||||
|
||||
/* pack all the strings */
|
||||
|
||||
for (i=0; i<num_subkeys; i++) {
|
||||
len += tdb_pack(buffer+len, buflen-len, "f", subkeys[i]);
|
||||
if ( len > buflen ) {
|
||||
/* allocate some extra space */
|
||||
if ((tmpbuf = Realloc( buffer, len*2 )) == NULL) {
|
||||
DEBUG(0,("store_reg_keys: Failed to realloc memory of size [%d]\n", len*2));
|
||||
ret = False;
|
||||
goto done;
|
||||
}
|
||||
buffer = tmpbuf;
|
||||
buflen = len*2;
|
||||
|
||||
len = tdb_pack(buffer+len, buflen-len, "f", subkeys[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* finally write out the data */
|
||||
|
||||
kbuf.dptr = keyname;
|
||||
kbuf.dsize = strlen(keyname)+1;
|
||||
dbuf.dptr = buffer;
|
||||
dbuf.dsize = len;
|
||||
if ( tdb_store( tdb, kbuf, dbuf, TDB_REPLACE ) == -1) {
|
||||
ret = False;
|
||||
goto done;
|
||||
}
|
||||
DLIST_REMOVE(regkeys_list, info);
|
||||
|
||||
done:
|
||||
SAFE_FREE( buffer );
|
||||
return ret;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
Retrieve an array of strings containing subkeys. Memory should be
|
||||
released by the caller. The subkeys are stored in a catenated string
|
||||
of null terminated character strings
|
||||
***********************************************************************/
|
||||
|
||||
static int fetch_reg_keys( TDB_CONTEXT *tdb, char* key, char **subkeys )
|
||||
{
|
||||
pstring path;
|
||||
uint32 num_items;
|
||||
TDB_DATA dbuf;
|
||||
char *buf;
|
||||
uint32 buflen, len;
|
||||
int i;
|
||||
char *s;
|
||||
|
||||
|
||||
pstrcpy( path, key );
|
||||
|
||||
/* convert to key format */
|
||||
pstring_sub( path, "\\", "/" );
|
||||
|
||||
dbuf = tdb_fetch_by_string( tdb, path );
|
||||
|
||||
buf = dbuf.dptr;
|
||||
buflen = dbuf.dsize;
|
||||
|
||||
if ( !buf ) {
|
||||
DEBUG(5,("fetch_reg_keys: Failed to fetch any subkeys for [%s]\n", key));
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = tdb_unpack( buf, buflen, "d", &num_items);
|
||||
if (num_items) {
|
||||
if ( (*subkeys = (char*)malloc(sizeof(fstring)*num_items)) == NULL ) {
|
||||
DEBUG(0,("fetch_reg_keys: Failed to malloc memory for subkey array containing [%d] items!\n",
|
||||
num_items));
|
||||
num_items = -1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
s = *subkeys;
|
||||
for (i=0; i<num_items; i++) {
|
||||
len += tdb_unpack( buf+len, buflen-len, "f", s );
|
||||
s += strlen(s) + 1;
|
||||
}
|
||||
|
||||
done:
|
||||
SAFE_FREE(dbuf.dptr);
|
||||
return num_items;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
count the number of subkeys dtored in the registry
|
||||
***********************************************************************/
|
||||
|
||||
static int fetch_reg_keys_count( TDB_CONTEXT *tdb, char* key )
|
||||
{
|
||||
pstring path;
|
||||
uint32 num_items;
|
||||
TDB_DATA dbuf;
|
||||
char *buf;
|
||||
uint32 buflen, len;
|
||||
|
||||
|
||||
pstrcpy( path, key );
|
||||
|
||||
/* convert to key format */
|
||||
pstring_sub( path, "\\", "/" );
|
||||
|
||||
dbuf = tdb_fetch_by_string( tdb, path );
|
||||
|
||||
buf = dbuf.dptr;
|
||||
buflen = dbuf.dsize;
|
||||
|
||||
if ( !buf ) {
|
||||
DEBUG(5,("fetch_reg_keys: Failed to fetch any subkeys for [%s]\n", key));
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = tdb_unpack( buf, buflen, "d", &num_items);
|
||||
|
||||
SAFE_FREE( buf );
|
||||
|
||||
return num_items;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
retreive a specific subkey specified by index. The subkey parameter
|
||||
is assumed to be an fstring.
|
||||
***********************************************************************/
|
||||
|
||||
static BOOL fetch_reg_keys_specific( TDB_CONTEXT *tdb, char* key, char* subkey,
|
||||
uint32 key_index )
|
||||
{
|
||||
int num_subkeys, i;
|
||||
char *subkeys = NULL;
|
||||
char *s;
|
||||
|
||||
num_subkeys = fetch_reg_keys( tdb_reg, key, &subkeys );
|
||||
if ( num_subkeys == -1 )
|
||||
return False;
|
||||
|
||||
s = subkeys;
|
||||
for ( i=0; i<num_subkeys; i++ ) {
|
||||
/* copy the key if the index matches */
|
||||
if ( i == key_index ) {
|
||||
fstrcpy( subkey, s );
|
||||
break;
|
||||
}
|
||||
|
||||
/* go onto the next string */
|
||||
s += strlen(s) + 1;
|
||||
}
|
||||
|
||||
SAFE_FREE(subkeys);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
Open the registry database
|
||||
***********************************************************************/
|
||||
|
||||
static BOOL init_registry_data( TDB_CONTEXT* registry_tdb )
|
||||
{
|
||||
pstring keyname;
|
||||
char *subkeys[3];
|
||||
|
||||
/* HKEY_LOCAL_MACHINE */
|
||||
|
||||
pstrcpy( keyname, KEY_HKLM );
|
||||
subkeys[0] = "SYSTEM";
|
||||
if ( !store_reg_keys( registry_tdb, keyname, subkeys, 1 ))
|
||||
return False;
|
||||
|
||||
pstrcpy( keyname, KEY_HKLM );
|
||||
pstrcat( keyname, "/SYSTEM" );
|
||||
subkeys[0] = "CurrentControlSet";
|
||||
if ( !store_reg_keys( registry_tdb, keyname, subkeys, 1 ))
|
||||
return False;
|
||||
|
||||
pstrcpy( keyname, KEY_HKLM );
|
||||
pstrcat( keyname, "/SYSTEM/CurrentControlSet" );
|
||||
subkeys[0] = "Control";
|
||||
subkeys[1] = "services";
|
||||
if ( !store_reg_keys( registry_tdb, keyname, subkeys, 2 ))
|
||||
return False;
|
||||
|
||||
pstrcpy( keyname, KEY_HKLM );
|
||||
pstrcat( keyname, "/SYSTEM/CurrentControlSet/Control" );
|
||||
subkeys[0] = "Print";
|
||||
subkeys[1] = "ProduceOptions";
|
||||
if ( !store_reg_keys( registry_tdb, keyname, subkeys, 2 ))
|
||||
return False;
|
||||
|
||||
pstrcpy( keyname, KEY_HKLM );
|
||||
pstrcat( keyname, "/SYSTEM/CurrentControlSet/Control/Print" );
|
||||
subkeys[0] = "Environments";
|
||||
subkeys[1] = "Forms";
|
||||
subkeys[2] = "Printers";
|
||||
if ( !store_reg_keys( registry_tdb, keyname, subkeys, 3 ))
|
||||
return False;
|
||||
|
||||
pstrcpy( keyname, KEY_HKLM );
|
||||
pstrcat( keyname, "/SYSTEM/CurrentControlSet/Control/ProductOptions" );
|
||||
if ( !store_reg_keys( registry_tdb, keyname, subkeys, 0 ))
|
||||
return False;
|
||||
|
||||
pstrcpy( keyname, KEY_HKLM );
|
||||
pstrcat( keyname, "/SYSTEM/CurrentControlSet/services" );
|
||||
subkeys[0] = "Netlogon";
|
||||
if ( !store_reg_keys( registry_tdb, keyname, subkeys, 1 ))
|
||||
return False;
|
||||
|
||||
pstrcpy( keyname, KEY_HKLM );
|
||||
pstrcat( keyname, "/SYSTEM/CurrentControlSet/services/Netlogon" );
|
||||
subkeys[0] = "parameters";
|
||||
if ( !store_reg_keys( registry_tdb, keyname, subkeys, 1 ))
|
||||
return False;
|
||||
|
||||
pstrcpy( keyname, KEY_HKLM );
|
||||
pstrcat( keyname, "/SYSTEM/CurrentControlSet/services/Netlogon/parameters" );
|
||||
if ( !store_reg_keys( registry_tdb, keyname, subkeys, 0 ))
|
||||
return False;
|
||||
|
||||
|
||||
/* HKEY_USER */
|
||||
|
||||
pstrcpy( keyname, KEY_HKU );
|
||||
if ( !store_reg_keys( registry_tdb, keyname, subkeys, 0 ) )
|
||||
return False;
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
Open the registry database
|
||||
***********************************************************************/
|
||||
|
||||
BOOL init_registry( void )
|
||||
{
|
||||
static pid_t local_pid;
|
||||
|
||||
|
||||
if (tdb_reg && local_pid == sys_getpid())
|
||||
return True;
|
||||
|
||||
/*
|
||||
* try to open first without creating so we can determine
|
||||
* if we need to init the data in the registry
|
||||
*/
|
||||
|
||||
tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600);
|
||||
if ( !tdb_reg )
|
||||
{
|
||||
tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
|
||||
if ( !tdb_reg ) {
|
||||
DEBUG(0,("init_registry: Failed to open registry %s (%s)\n",
|
||||
lock_path("registry.tdb"), strerror(errno) ));
|
||||
return False;
|
||||
}
|
||||
|
||||
DEBUG(10,("init_registry: Successfully created registry tdb\n"));
|
||||
|
||||
/* create the registry here */
|
||||
if ( !init_registry_data( tdb_reg ) ) {
|
||||
DEBUG(0,("init_registry: Failed to initiailize data in registry!\n"));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
local_pid = sys_getpid();
|
||||
|
||||
return True;
|
||||
SAFE_FREE(info);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
Find a registry key handle and return a Registry_Key
|
||||
Find a registry key handle and return a REGISTRY_KEY
|
||||
*****************************************************************/
|
||||
|
||||
static Registry_Key *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd)
|
||||
static REGISTRY_KEY *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd)
|
||||
{
|
||||
Registry_Key *regkey = NULL;
|
||||
REGISTRY_KEY *regkey = NULL;
|
||||
|
||||
if(!find_policy_by_hnd(p,hnd,(void **)®key)) {
|
||||
DEBUG(2,("find_regkey_index_by_hnd: Registry Key not found: "));
|
||||
@ -366,50 +71,92 @@ static Registry_Key *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd)
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************
|
||||
free() function for Registry_Key
|
||||
*****************************************************************/
|
||||
|
||||
static void free_reg_info(void *ptr)
|
||||
{
|
||||
Registry_Key *info = (Registry_Key*)ptr;
|
||||
|
||||
DLIST_REMOVE(regkeys_list, info);
|
||||
|
||||
SAFE_FREE(info);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Function for open a new registry handle and creating a handle
|
||||
Note that P should be valid & hnd should already have space
|
||||
|
||||
When we open a key, we store the full path to the key as
|
||||
HK[LM|U]\<key>\<key>\...
|
||||
*******************************************************************/
|
||||
|
||||
static BOOL open_registry_key(pipes_struct *p, POLICY_HND *hnd, char *name,
|
||||
uint32 access_granted)
|
||||
static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY *parent,
|
||||
char *subkeyname, uint32 access_granted )
|
||||
{
|
||||
Registry_Key *regkey = NULL;
|
||||
|
||||
DEBUG(7,("open_registry_key: name = [%s]\n", name));
|
||||
|
||||
/* All registry keys **must** have a name of non-zero length */
|
||||
REGISTRY_KEY *regkey = NULL;
|
||||
NTSTATUS result = NT_STATUS_OK;
|
||||
REGSUBKEY_CTR subkeys;
|
||||
|
||||
if (!name || !*name )
|
||||
return False;
|
||||
|
||||
if ((regkey=(Registry_Key*)malloc(sizeof(Registry_Key))) == NULL)
|
||||
return False;
|
||||
DEBUG(7,("open_registry_key: name = [%s][%s]\n",
|
||||
parent ? parent->name : "NULL", subkeyname));
|
||||
|
||||
if ((regkey=(REGISTRY_KEY*)malloc(sizeof(REGISTRY_KEY))) == NULL)
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
|
||||
ZERO_STRUCTP( regkey );
|
||||
|
||||
DLIST_ADD( regkeys_list, regkey );
|
||||
|
||||
/* copy the name and obtain a handle */
|
||||
/*
|
||||
* very crazy, but regedit.exe on Win2k will attempt to call
|
||||
* REG_OPEN_ENTRY with a keyname of "". We should return a new
|
||||
* (second) handle here on the key->name. regedt32.exe does
|
||||
* not do this stupidity. --jerry
|
||||
*/
|
||||
|
||||
fstrcpy( regkey->name, name );
|
||||
if (!subkeyname || !*subkeyname ) {
|
||||
pstrcpy( regkey->name, parent->name );
|
||||
}
|
||||
else {
|
||||
pstrcpy( regkey->name, "" );
|
||||
if ( parent ) {
|
||||
pstrcat( regkey->name, parent->name );
|
||||
pstrcat( regkey->name, "\\" );
|
||||
}
|
||||
pstrcat( regkey->name, subkeyname );
|
||||
}
|
||||
|
||||
/* Look up the table of registry I/O operations */
|
||||
|
||||
if ( !(regkey->hook = reghook_cache_find( regkey->name )) ) {
|
||||
DEBUG(0,("open_registry_key: Failed to assigned a REGISTRY_HOOK to [%s]\n",
|
||||
regkey->name ));
|
||||
return NT_STATUS_OBJECT_PATH_NOT_FOUND;
|
||||
}
|
||||
|
||||
/* check if the path really exists; failed is indicated by -1 */
|
||||
/* if the subkey count failed, bail out */
|
||||
|
||||
ZERO_STRUCTP( &subkeys );
|
||||
|
||||
regsubkey_ctr_init( &subkeys );
|
||||
|
||||
if ( fetch_reg_keys( regkey, &subkeys ) == -1 ) {
|
||||
|
||||
/* don't really know what to return here */
|
||||
|
||||
result = NT_STATUS_NO_SUCH_FILE;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* This would previously return NT_STATUS_TOO_MANY_SECRETS
|
||||
* that doesn't sound quite right to me --jerry
|
||||
*/
|
||||
|
||||
if ( !create_policy_hnd( p, hnd, free_regkey_info, regkey ) )
|
||||
result = NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
/* clean up */
|
||||
|
||||
regsubkey_ctr_destroy( &subkeys );
|
||||
|
||||
if ( ! NT_STATUS_IS_OK(result) )
|
||||
SAFE_FREE( regkey );
|
||||
else
|
||||
DLIST_ADD( regkeys_list, regkey );
|
||||
|
||||
|
||||
DEBUG(7,("open_registry_key: exit\n"));
|
||||
|
||||
return create_policy_hnd( p, hnd, free_reg_info, regkey );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -419,7 +166,7 @@ static BOOL open_registry_key(pipes_struct *p, POLICY_HND *hnd, char *name,
|
||||
|
||||
static BOOL close_registry_key(pipes_struct *p, POLICY_HND *hnd)
|
||||
{
|
||||
Registry_Key *regkey = find_regkey_index_by_hnd(p, hnd);
|
||||
REGISTRY_KEY *regkey = find_regkey_index_by_hnd(p, hnd);
|
||||
|
||||
if ( !regkey ) {
|
||||
DEBUG(2,("close_registry_key: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(hnd)));
|
||||
@ -435,35 +182,37 @@ static BOOL close_registry_key(pipes_struct *p, POLICY_HND *hnd)
|
||||
retrieve information about the subkeys
|
||||
*******************************************************************/
|
||||
|
||||
static BOOL get_subkey_information( Registry_Key *key, uint32 *maxnum, uint32 *maxlen )
|
||||
static BOOL get_subkey_information( REGISTRY_KEY *key, uint32 *maxnum, uint32 *maxlen )
|
||||
{
|
||||
int num_subkeys, i;
|
||||
uint32 max_len;
|
||||
char *subkeys = NULL;
|
||||
uint32 len;
|
||||
char *s;
|
||||
int num_subkeys, i;
|
||||
uint32 max_len;
|
||||
REGSUBKEY_CTR subkeys;
|
||||
uint32 len;
|
||||
|
||||
if ( !key )
|
||||
return False;
|
||||
|
||||
ZERO_STRUCTP( &subkeys );
|
||||
|
||||
num_subkeys = fetch_reg_keys( tdb_reg, key->name, &subkeys );
|
||||
if ( num_subkeys == -1 )
|
||||
regsubkey_ctr_init( &subkeys );
|
||||
|
||||
if ( fetch_reg_keys( key, &subkeys ) == -1 )
|
||||
return False;
|
||||
|
||||
/* find the longest string */
|
||||
|
||||
max_len = 0;
|
||||
s = subkeys;
|
||||
num_subkeys = regsubkey_ctr_numkeys( &subkeys );
|
||||
|
||||
for ( i=0; i<num_subkeys; i++ ) {
|
||||
len = strlen(s);
|
||||
len = strlen( regsubkey_ctr_specific_key(&subkeys, i) );
|
||||
max_len = MAX(max_len, len);
|
||||
s += len + 1;
|
||||
}
|
||||
|
||||
*maxnum = num_subkeys;
|
||||
*maxlen = max_len*2;
|
||||
|
||||
SAFE_FREE(subkeys);
|
||||
regsubkey_ctr_destroy( &subkeys );
|
||||
|
||||
return True;
|
||||
}
|
||||
@ -474,30 +223,48 @@ static BOOL get_subkey_information( Registry_Key *key, uint32 *maxnum, uint32 *m
|
||||
Samba tdb's (such as ntdrivers.tdb).
|
||||
*******************************************************************/
|
||||
|
||||
static BOOL get_value_information( Registry_Key *key, uint32 *maxnum,
|
||||
static BOOL get_value_information( REGISTRY_KEY *key, uint32 *maxnum,
|
||||
uint32 *maxlen, uint32 *maxsize )
|
||||
{
|
||||
REGVAL_CTR values;
|
||||
REGISTRY_VALUE *val;
|
||||
uint32 sizemax, lenmax;
|
||||
int i, num_values;
|
||||
|
||||
if ( !key )
|
||||
return False;
|
||||
|
||||
/* Hard coded key names first */
|
||||
/* nothing has valuies right now */
|
||||
|
||||
ZERO_STRUCTP( &values );
|
||||
|
||||
regval_ctr_init( &values );
|
||||
|
||||
if ( fetch_reg_values( key, &values ) == -1 )
|
||||
return False;
|
||||
|
||||
lenmax = sizemax = 0;
|
||||
num_values = regval_ctr_numvals( &values );
|
||||
|
||||
val = regval_ctr_specific_value( &values, 0 );
|
||||
|
||||
for ( i=0; i<num_values && val; i++ )
|
||||
{
|
||||
lenmax = MAX(lenmax, strlen(val->valuename)+1 );
|
||||
sizemax = MAX(sizemax, val->size );
|
||||
|
||||
*maxnum = 0;
|
||||
*maxlen = 0;
|
||||
*maxsize = 0;
|
||||
val = regval_ctr_specific_value( &values, i );
|
||||
}
|
||||
|
||||
*maxnum = num_values;
|
||||
*maxlen = lenmax;
|
||||
*maxsize = sizemax;
|
||||
|
||||
regval_ctr_destroy( &values );
|
||||
|
||||
return True;
|
||||
|
||||
#if 0 /* JERRY */
|
||||
/*
|
||||
* FIXME!!! Need to add routines to look up values in other
|
||||
* databases --jerry
|
||||
*/
|
||||
|
||||
return False;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
reg_close
|
||||
********************************************************************/
|
||||
@ -515,27 +282,27 @@ NTSTATUS _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u)
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reg_reply_open
|
||||
********************************************************************/
|
||||
|
||||
NTSTATUS _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_u)
|
||||
{
|
||||
if (!open_registry_key(p, &r_u->pol, KEY_HKLM, 0x0))
|
||||
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
|
||||
return NT_STATUS_OK;
|
||||
return open_registry_key( p, &r_u->pol, NULL, KEY_HKLM, 0x0 );
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
********************************************************************/
|
||||
|
||||
NTSTATUS _reg_open_hkcr(pipes_struct *p, REG_Q_OPEN_HKCR *q_u, REG_R_OPEN_HKCR *r_u)
|
||||
{
|
||||
return open_registry_key( p, &r_u->pol, NULL, KEY_HKCR, 0x0 );
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reg_reply_open
|
||||
********************************************************************/
|
||||
|
||||
NTSTATUS _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HKU *q_u, REG_R_OPEN_HKU *r_u)
|
||||
{
|
||||
if (!open_registry_key(p, &r_u->pol, KEY_HKU, 0x0))
|
||||
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
|
||||
return NT_STATUS_OK;
|
||||
return open_registry_key( p, &r_u->pol, NULL, KEY_HKU, 0x0 );
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -546,9 +313,8 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR
|
||||
{
|
||||
POLICY_HND pol;
|
||||
fstring name;
|
||||
pstring path;
|
||||
int num_subkeys;
|
||||
Registry_Key *key = find_regkey_index_by_hnd(p, &q_u->pol);
|
||||
REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->pol);
|
||||
NTSTATUS result;
|
||||
|
||||
DEBUG(5,("reg_open_entry: Enter\n"));
|
||||
|
||||
@ -556,26 +322,14 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR
|
||||
return NT_STATUS_INVALID_HANDLE;
|
||||
|
||||
rpcstr_pull(name,q_u->uni_name.buffer,sizeof(name),q_u->uni_name.uni_str_len*2,0);
|
||||
|
||||
/* store the full path in the regkey_list */
|
||||
|
||||
pstrcpy( path, key->name );
|
||||
pstrcat( path, "\\" );
|
||||
pstrcat( path, name );
|
||||
|
||||
DEBUG(5,("reg_open_entry: %s\n", path));
|
||||
|
||||
/* do a check on the name, here */
|
||||
DEBUG(5,("reg_open_entry: Enter\n"));
|
||||
|
||||
result = open_registry_key( p, &pol, key, name, 0x0 );
|
||||
|
||||
if ( (num_subkeys=fetch_reg_keys_count( tdb_reg, path )) == -1 )
|
||||
return NT_STATUS_ACCESS_DENIED;
|
||||
init_reg_r_open_entry( r_u, &pol, result );
|
||||
|
||||
if (!open_registry_key(p, &pol, path, 0x0))
|
||||
return NT_STATUS_TOO_MANY_SECRETS;
|
||||
|
||||
init_reg_r_open_entry(r_u, &pol, NT_STATUS_OK);
|
||||
|
||||
DEBUG(5,("reg_open_entry: Exitn"));
|
||||
DEBUG(5,("reg_open_entry: Exit\n"));
|
||||
|
||||
return r_u->status;
|
||||
}
|
||||
@ -586,66 +340,85 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR
|
||||
|
||||
NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u)
|
||||
{
|
||||
NTSTATUS status = NT_STATUS_OK;
|
||||
char *value = NULL;
|
||||
uint32 type = 0x1; /* key type: REG_SZ */
|
||||
UNISTR2 *uni_key = NULL;
|
||||
BUFFER2 *buf = NULL;
|
||||
fstring name;
|
||||
Registry_Key *key = find_regkey_index_by_hnd( p, &q_u->pol );
|
||||
NTSTATUS status = NT_STATUS_NO_SUCH_FILE;
|
||||
fstring name;
|
||||
REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol );
|
||||
REGISTRY_VALUE *val = NULL;
|
||||
REGISTRY_VALUE emptyval;
|
||||
REGVAL_CTR regvals;
|
||||
int i;
|
||||
|
||||
DEBUG(5,("_reg_info: Enter\n"));
|
||||
|
||||
if ( !key )
|
||||
if ( !regkey )
|
||||
return NT_STATUS_INVALID_HANDLE;
|
||||
|
||||
DEBUG(7,("_reg_info: policy key name = [%s]\n", key->name));
|
||||
|
||||
DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->name));
|
||||
|
||||
rpcstr_pull(name, q_u->uni_type.buffer, sizeof(name), q_u->uni_type.uni_str_len*2, 0);
|
||||
|
||||
DEBUG(5,("reg_info: checking subkey: %s\n", name));
|
||||
DEBUG(5,("reg_info: looking up value: [%s]\n", name));
|
||||
|
||||
uni_key = (UNISTR2 *)talloc_zero(p->mem_ctx, sizeof(UNISTR2));
|
||||
buf = (BUFFER2 *)talloc_zero(p->mem_ctx, sizeof(BUFFER2));
|
||||
|
||||
if (!uni_key || !buf)
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
ZERO_STRUCTP( ®vals );
|
||||
|
||||
regval_ctr_init( ®vals );
|
||||
|
||||
/* couple of hard coded registry values */
|
||||
|
||||
if ( strequal(name, "RefusePasswordChange") ) {
|
||||
type=0xF770;
|
||||
status = NT_STATUS_NO_SUCH_FILE;
|
||||
init_unistr2(uni_key, "", 0);
|
||||
init_buffer2(buf, (uint8*) uni_key->buffer, uni_key->uni_str_len*2);
|
||||
|
||||
buf->buf_max_len=4;
|
||||
|
||||
ZERO_STRUCTP( &emptyval );
|
||||
val = &emptyval;
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
switch (lp_server_role()) {
|
||||
case ROLE_DOMAIN_PDC:
|
||||
case ROLE_DOMAIN_BDC:
|
||||
value = "LanmanNT";
|
||||
break;
|
||||
case ROLE_STANDALONE:
|
||||
value = "ServerNT";
|
||||
break;
|
||||
case ROLE_DOMAIN_MEMBER:
|
||||
value = "WinNT";
|
||||
break;
|
||||
if ( strequal(name, REGSTR_PRODUCTTYPE) ) {
|
||||
/* This makes the server look like a member server to clients */
|
||||
/* which tells clients that we have our own local user and */
|
||||
/* group databases and helps with ACL support. */
|
||||
|
||||
switch (lp_server_role()) {
|
||||
case ROLE_DOMAIN_PDC:
|
||||
case ROLE_DOMAIN_BDC:
|
||||
regval_ctr_addvalue( ®vals, REGSTR_PRODUCTTYPE, REG_SZ, REG_PT_LANMANNT, strlen(REG_PT_LANMANNT)+1 );
|
||||
break;
|
||||
case ROLE_STANDALONE:
|
||||
regval_ctr_addvalue( ®vals, REGSTR_PRODUCTTYPE, REG_SZ, REG_PT_SERVERNT, strlen(REG_PT_SERVERNT)+1 );
|
||||
break;
|
||||
case ROLE_DOMAIN_MEMBER:
|
||||
regval_ctr_addvalue( ®vals, REGSTR_PRODUCTTYPE, REG_SZ, REG_PT_WINNT, strlen(REG_PT_WINNT)+1 );
|
||||
break;
|
||||
}
|
||||
|
||||
val = dup_registry_value( regval_ctr_specific_value( ®vals, 0 ) );
|
||||
|
||||
status = NT_STATUS_OK;
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* This makes the server look like a member server to clients */
|
||||
/* which tells clients that we have our own local user and */
|
||||
/* group databases and helps with ACL support. */
|
||||
/* else fall back to actually looking up the value */
|
||||
|
||||
for ( i=0; fetch_reg_values_specific(regkey, &val, i); i++ )
|
||||
{
|
||||
DEBUG(10,("_reg_info: Testing value [%s]\n", val->valuename));
|
||||
if ( StrCaseCmp( val->valuename, name ) == 0 ) {
|
||||
DEBUG(10,("_reg_info: Found match for value [%s]\n", name));
|
||||
status = NT_STATUS_OK;
|
||||
break;
|
||||
}
|
||||
|
||||
free_registry_value( val );
|
||||
}
|
||||
|
||||
init_unistr2(uni_key, value, strlen(value)+1);
|
||||
init_buffer2(buf, (uint8*)uni_key->buffer, uni_key->uni_str_len*2);
|
||||
|
||||
out:
|
||||
init_reg_r_info(q_u->ptr_buf, r_u, buf, type, status);
|
||||
out:
|
||||
new_init_reg_r_info(q_u->ptr_buf, r_u, val, status);
|
||||
|
||||
regval_ctr_destroy( ®vals );
|
||||
free_registry_value( val );
|
||||
|
||||
DEBUG(5,("reg_open_entry: Exit\n"));
|
||||
DEBUG(5,("_reg_info: Exit\n"));
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -658,7 +431,7 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u)
|
||||
NTSTATUS _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *r_u)
|
||||
{
|
||||
NTSTATUS status = NT_STATUS_OK;
|
||||
Registry_Key *regkey = find_regkey_index_by_hnd( p, &q_u->pol );
|
||||
REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol );
|
||||
|
||||
DEBUG(5,("_reg_query_key: Enter\n"));
|
||||
|
||||
@ -670,6 +443,7 @@ NTSTATUS _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *
|
||||
|
||||
if ( !get_value_information( regkey, &r_u->num_values, &r_u->max_valnamelen, &r_u->max_valbufsize ) )
|
||||
return NT_STATUS_ACCESS_DENIED;
|
||||
|
||||
|
||||
r_u->sec_desc = 0x00000078; /* size for key's sec_desc */
|
||||
|
||||
@ -691,7 +465,7 @@ NTSTATUS _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *
|
||||
NTSTATUS _reg_unknown_1a(pipes_struct *p, REG_Q_UNKNOWN_1A *q_u, REG_R_UNKNOWN_1A *r_u)
|
||||
{
|
||||
NTSTATUS status = NT_STATUS_OK;
|
||||
Registry_Key *regkey = find_regkey_index_by_hnd( p, &q_u->pol );
|
||||
REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol );
|
||||
|
||||
DEBUG(5,("_reg_unknown_1a: Enter\n"));
|
||||
|
||||
@ -713,8 +487,8 @@ NTSTATUS _reg_unknown_1a(pipes_struct *p, REG_Q_UNKNOWN_1A *q_u, REG_R_UNKNOWN_1
|
||||
NTSTATUS _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u)
|
||||
{
|
||||
NTSTATUS status = NT_STATUS_OK;
|
||||
Registry_Key *regkey = find_regkey_index_by_hnd( p, &q_u->pol );
|
||||
fstring subkey;
|
||||
REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol );
|
||||
char *subkey = NULL;
|
||||
|
||||
|
||||
DEBUG(5,("_reg_enum_key: Enter\n"));
|
||||
@ -724,9 +498,9 @@ NTSTATUS _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u
|
||||
|
||||
DEBUG(8,("_reg_enum_key: enumerating key [%s]\n", regkey->name));
|
||||
|
||||
if ( !fetch_reg_keys_specific( tdb_reg, regkey->name, subkey, q_u->key_index ) )
|
||||
if ( !fetch_reg_keys_specific( regkey, &subkey, q_u->key_index ) )
|
||||
{
|
||||
status = werror_to_ntstatus( WERR_NO_MORE_ITEMS );
|
||||
status = NT_STATUS_NO_MORE_ENTRIES;
|
||||
goto done;
|
||||
}
|
||||
|
||||
@ -739,6 +513,46 @@ NTSTATUS _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u
|
||||
DEBUG(5,("_reg_enum_key: Exit\n"));
|
||||
|
||||
done:
|
||||
SAFE_FREE( subkey );
|
||||
return status;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
Implementation of REG_ENUM_VALUE
|
||||
****************************************************************************/
|
||||
|
||||
NTSTATUS _reg_enum_value(pipes_struct *p, REG_Q_ENUM_VALUE *q_u, REG_R_ENUM_VALUE *r_u)
|
||||
{
|
||||
NTSTATUS status = NT_STATUS_OK;
|
||||
REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol );
|
||||
REGISTRY_VALUE *val;
|
||||
|
||||
|
||||
DEBUG(5,("_reg_enum_value: Enter\n"));
|
||||
|
||||
if ( !regkey )
|
||||
return NT_STATUS_INVALID_HANDLE;
|
||||
|
||||
DEBUG(8,("_reg_enum_key: enumerating values for key [%s]\n", regkey->name));
|
||||
|
||||
if ( !fetch_reg_values_specific( regkey, &val, q_u->val_index ) )
|
||||
{
|
||||
status = NT_STATUS_NO_MORE_ENTRIES;
|
||||
goto done;
|
||||
}
|
||||
|
||||
DEBUG(10,("_reg_enum_value: retrieved value named [%s]\n", val->valuename));
|
||||
|
||||
/* subkey has the string name now */
|
||||
|
||||
init_reg_r_enum_val( r_u, val );
|
||||
|
||||
|
||||
DEBUG(5,("_reg_enum_value: Exit\n"));
|
||||
|
||||
done:
|
||||
free_registry_value( val );
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -808,4 +622,28 @@ NTSTATUS _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_A
|
||||
return status;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
REG_SAVE_KEY (0x14)
|
||||
********************************************************************/
|
||||
|
||||
NTSTATUS _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u)
|
||||
{
|
||||
REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol );
|
||||
|
||||
DEBUG(5,("_reg_save_key: Enter\n"));
|
||||
|
||||
/*
|
||||
* basically this is a no op function which just gverifies
|
||||
* that the client gave us a valid registry key handle
|
||||
*/
|
||||
|
||||
if ( !regkey )
|
||||
return NT_STATUS_INVALID_HANDLE;
|
||||
|
||||
DEBUG(8,("_reg_save_key: berifying backup of key [%s]\n", regkey->name));
|
||||
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,9 +3,11 @@
|
||||
* RPC Pipe client / server routines
|
||||
* Copyright (C) Andrew Tridgell 1992-1997,
|
||||
* Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
|
||||
* Copyright (C) Paul Ashton 1997.
|
||||
* Copyright (C) Marc Jacobsen 1999.
|
||||
* Copyright (C) Jean François Micouleau 1998-2001.
|
||||
* Copyright (C) Paul Ashton 1997,
|
||||
* Copyright (C) Marc Jacobsen 1999,
|
||||
* Copyright (C) Jean François Micouleau 1998-2001,
|
||||
* Copyright (C) Anthony Liguori 2002,
|
||||
* Copyright (C) Jim McDonough 2002.
|
||||
*
|
||||
* Split into interface and implementation modules by,
|
||||
*
|
||||
@ -652,6 +654,37 @@ static BOOL api_samr_connect(pipes_struct *p)
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
api_samr_connect4
|
||||
********************************************************************/
|
||||
|
||||
static BOOL api_samr_connect4(pipes_struct *p)
|
||||
{
|
||||
SAMR_Q_CONNECT4 q_u;
|
||||
SAMR_R_CONNECT4 r_u;
|
||||
prs_struct *data = &p->in_data.data;
|
||||
prs_struct *rdata = &p->out_data.rdata;
|
||||
|
||||
ZERO_STRUCT(q_u);
|
||||
ZERO_STRUCT(r_u);
|
||||
|
||||
/* grab the samr open policy */
|
||||
if(!samr_io_q_connect4("", &q_u, data, 0)) {
|
||||
DEBUG(0,("api_samr_connect4: unable to unmarshall SAMR_Q_CONNECT4.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
r_u.status = _samr_connect4(p, &q_u, &r_u);
|
||||
|
||||
/* store the response in the SMB stream */
|
||||
if(!samr_io_r_connect4("", &r_u, rdata, 0)) {
|
||||
DEBUG(0,("api_samr_connect4: unable to marshall SAMR_R_CONNECT4.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
api_samr_lookup_domain
|
||||
**********************************************************************/
|
||||
@ -1465,6 +1498,7 @@ static struct api_struct api_samr_cmds [] =
|
||||
{"SAMR_GET_USRDOM_PWINFO" , SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo},
|
||||
{"SAMR_UNKNOWN_2E" , SAMR_UNKNOWN_2E , api_samr_unknown_2e },
|
||||
{"SAMR_SET_DOMAIN_INFO" , SAMR_SET_DOMAIN_INFO , api_samr_set_dom_info },
|
||||
{"SAMR_CONNECT4" , SAMR_CONNECT4 , api_samr_connect4 },
|
||||
{NULL , 0 , NULL }
|
||||
};
|
||||
|
||||
|
@ -3,10 +3,12 @@
|
||||
* RPC Pipe client / server routines
|
||||
* Copyright (C) Andrew Tridgell 1992-1997,
|
||||
* Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
|
||||
* Copyright (C) Paul Ashton 1997.
|
||||
* Copyright (C) Marc Jacobsen 1999.
|
||||
* Copyright (C) Jeremy Allison 2001-2002.
|
||||
* Copyright (C) Jean François Micouleau 1998-2001.
|
||||
* Copyright (C) Paul Ashton 1997,
|
||||
* Copyright (C) Marc Jacobsen 1999,
|
||||
* Copyright (C) Jeremy Allison 2001-2002,
|
||||
* Copyright (C) Jean François Micouleau 1998-2001,
|
||||
* Copyright (C) Anthony Liguori 2002,
|
||||
* Copyright (C) Jim McDonough 2002.
|
||||
*
|
||||
* 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
|
||||
@ -727,8 +729,6 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UN
|
||||
}
|
||||
|
||||
for (i = 0; i < num_entries; i++) {
|
||||
int len = uni_temp_name.uni_str_len;
|
||||
|
||||
pwd = disp_user_info[i+start_idx].sam;
|
||||
temp_name = pdb_get_username(pwd);
|
||||
init_unistr2(&uni_temp_name, temp_name, strlen(temp_name)+1);
|
||||
@ -743,7 +743,7 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UN
|
||||
return NT_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
init_sam_entry(&sam[i], len, user_rid);
|
||||
init_sam_entry(&sam[i], uni_temp_name.uni_str_len, user_rid);
|
||||
copy_unistr2(&uni_name[i], &uni_temp_name);
|
||||
}
|
||||
|
||||
@ -1081,7 +1081,9 @@ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAM
|
||||
DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__));
|
||||
|
||||
/* the domain group array is being allocated in the function below */
|
||||
get_group_domain_entries(p->mem_ctx, &grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES);
|
||||
if (!NT_STATUS_IS_OK(r_u->status = get_group_domain_entries(p->mem_ctx, &grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES))) {
|
||||
return r_u->status;
|
||||
}
|
||||
|
||||
make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_entries, grp);
|
||||
|
||||
@ -2081,6 +2083,8 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA
|
||||
time_t u_logout;
|
||||
NTTIME nt_logout;
|
||||
|
||||
uint32 account_policy_temp;
|
||||
|
||||
uint32 num_users=0, num_groups=0, num_aliases=0;
|
||||
|
||||
if ((ctr = (SAM_UNK_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_UNK_CTR))) == NULL)
|
||||
@ -2098,12 +2102,22 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA
|
||||
|
||||
switch (q_u->switch_value) {
|
||||
case 0x01:
|
||||
account_policy_get(AP_MIN_PASSWORD_LEN, &min_pass_len);
|
||||
account_policy_get(AP_PASSWORD_HISTORY, &pass_hist);
|
||||
account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &flag);
|
||||
account_policy_get(AP_MAX_PASSWORD_AGE, (int *)&u_expire);
|
||||
account_policy_get(AP_MIN_PASSWORD_AGE, (int *)&u_min_age);
|
||||
|
||||
account_policy_get(AP_MIN_PASSWORD_LEN, &account_policy_temp);
|
||||
min_pass_len = account_policy_temp;
|
||||
|
||||
account_policy_get(AP_PASSWORD_HISTORY, &account_policy_temp);
|
||||
pass_hist = account_policy_temp;
|
||||
|
||||
account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp);
|
||||
flag = account_policy_temp;
|
||||
|
||||
account_policy_get(AP_MAX_PASSWORD_AGE, &account_policy_temp);
|
||||
u_expire = account_policy_temp;
|
||||
|
||||
account_policy_get(AP_MIN_PASSWORD_AGE, &account_policy_temp);
|
||||
u_min_age = account_policy_temp;
|
||||
|
||||
unix_to_nt_time_abs(&nt_expire, u_expire);
|
||||
unix_to_nt_time_abs(&nt_min_age, u_min_age);
|
||||
|
||||
@ -2149,10 +2163,15 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA
|
||||
init_unk_info7(&ctr->info.inf7);
|
||||
break;
|
||||
case 0x0c:
|
||||
account_policy_get(AP_LOCK_ACCOUNT_DURATION, (int *)&u_lock_duration);
|
||||
account_policy_get(AP_RESET_COUNT_TIME, (int *)&u_reset_time);
|
||||
account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &lockout);
|
||||
|
||||
account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp);
|
||||
u_lock_duration = account_policy_temp;
|
||||
|
||||
account_policy_get(AP_RESET_COUNT_TIME, &account_policy_temp);
|
||||
u_reset_time = account_policy_temp;
|
||||
|
||||
account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp);
|
||||
lockout = account_policy_temp;
|
||||
|
||||
unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration);
|
||||
unix_to_nt_time_abs(&nt_reset_time, u_reset_time);
|
||||
|
||||
@ -2344,7 +2363,8 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_
|
||||
}
|
||||
|
||||
r_u->user_rid=pdb_get_user_rid(sam_pass);
|
||||
r_u->unknown_0 = 0x000703ff;
|
||||
|
||||
r_u->access_granted = acc_granted;
|
||||
|
||||
pdb_free_sam(&sam_pass);
|
||||
|
||||
@ -2434,6 +2454,56 @@ NTSTATUS _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u
|
||||
return r_u->status;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
samr_connect4
|
||||
********************************************************************/
|
||||
|
||||
NTSTATUS _samr_connect4(pipes_struct *p, SAMR_Q_CONNECT4 *q_u, SAMR_R_CONNECT4 *r_u)
|
||||
{
|
||||
struct samr_info *info = NULL;
|
||||
SEC_DESC *psd = NULL;
|
||||
uint32 acc_granted;
|
||||
uint32 des_access = q_u->access_mask;
|
||||
size_t sd_size;
|
||||
NTSTATUS nt_status;
|
||||
|
||||
|
||||
DEBUG(5,("_samr_connect4: %d\n", __LINE__));
|
||||
|
||||
/* Access check */
|
||||
|
||||
if (!pipe_access_check(p)) {
|
||||
DEBUG(3, ("access denied to samr_connect4\n"));
|
||||
r_u->status = NT_STATUS_ACCESS_DENIED;
|
||||
return r_u->status;
|
||||
}
|
||||
|
||||
samr_make_sam_obj_sd(p->mem_ctx, &psd, &sd_size);
|
||||
se_map_generic(&des_access, &sam_generic_mapping);
|
||||
if (!NT_STATUS_IS_OK(nt_status =
|
||||
access_check_samr_object(psd, p->pipe_user.nt_user_token,
|
||||
des_access, &acc_granted, "_samr_connect"))) {
|
||||
return nt_status;
|
||||
}
|
||||
|
||||
r_u->status = NT_STATUS_OK;
|
||||
|
||||
/* associate the user's SID and access granted with the new handle. */
|
||||
if ((info = get_samr_info_by_sid(NULL)) == NULL)
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
|
||||
info->acc_granted = acc_granted;
|
||||
info->status = q_u->access_mask;
|
||||
|
||||
/* get a (unique) handle. open a policy on it. */
|
||||
if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info))
|
||||
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
|
||||
DEBUG(5,("_samr_connect: %d\n", __LINE__));
|
||||
|
||||
return r_u->status;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
api_samr_lookup_domain
|
||||
**********************************************************************/
|
||||
@ -4180,6 +4250,8 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW
|
||||
|
||||
uint32 num_users=0, num_groups=0, num_aliases=0;
|
||||
|
||||
uint32 account_policy_temp;
|
||||
|
||||
if ((ctr = (SAM_UNK_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_UNK_CTR))) == NULL)
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
|
||||
@ -4195,11 +4267,20 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW
|
||||
|
||||
switch (q_u->switch_value) {
|
||||
case 0x01:
|
||||
account_policy_get(AP_MIN_PASSWORD_LEN, &min_pass_len);
|
||||
account_policy_get(AP_PASSWORD_HISTORY, &pass_hist);
|
||||
account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &flag);
|
||||
account_policy_get(AP_MAX_PASSWORD_AGE, (int *)&u_expire);
|
||||
account_policy_get(AP_MIN_PASSWORD_AGE, (int *)&u_min_age);
|
||||
account_policy_get(AP_MIN_PASSWORD_LEN, &account_policy_temp);
|
||||
min_pass_len = account_policy_temp;
|
||||
|
||||
account_policy_get(AP_PASSWORD_HISTORY, &account_policy_temp);
|
||||
pass_hist = account_policy_temp;
|
||||
|
||||
account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp);
|
||||
flag = account_policy_temp;
|
||||
|
||||
account_policy_get(AP_MAX_PASSWORD_AGE, &account_policy_temp);
|
||||
u_expire = account_policy_temp;
|
||||
|
||||
account_policy_get(AP_MIN_PASSWORD_AGE, &account_policy_temp);
|
||||
u_min_age = account_policy_temp;
|
||||
|
||||
unix_to_nt_time_abs(&nt_expire, u_expire);
|
||||
unix_to_nt_time_abs(&nt_min_age, u_min_age);
|
||||
@ -4231,7 +4312,9 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW
|
||||
num_users, num_groups, num_aliases);
|
||||
break;
|
||||
case 0x03:
|
||||
account_policy_get(AP_TIME_TO_LOGOUT, (int *)&u_logout);
|
||||
account_policy_get(AP_TIME_TO_LOGOUT, &account_policy_temp);
|
||||
u_logout = account_policy_temp;
|
||||
|
||||
unix_to_nt_time_abs(&nt_logout, u_logout);
|
||||
|
||||
init_unk_info3(&ctr->info.inf3, nt_logout);
|
||||
@ -4246,9 +4329,14 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW
|
||||
init_unk_info7(&ctr->info.inf7);
|
||||
break;
|
||||
case 0x0c:
|
||||
account_policy_get(AP_LOCK_ACCOUNT_DURATION, (int *)&u_lock_duration);
|
||||
account_policy_get(AP_RESET_COUNT_TIME, (int *)&u_reset_time);
|
||||
account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &lockout);
|
||||
account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp);
|
||||
u_lock_duration = account_policy_temp;
|
||||
|
||||
account_policy_get(AP_RESET_COUNT_TIME, &account_policy_temp);
|
||||
u_reset_time = account_policy_temp;
|
||||
|
||||
account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp);
|
||||
lockout = account_policy_temp;
|
||||
|
||||
unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration);
|
||||
unix_to_nt_time_abs(&nt_reset_time, u_reset_time);
|
||||
|
@ -1515,6 +1515,65 @@ static BOOL api_spoolss_deleteprinterdriverex(pipes_struct *p)
|
||||
return True;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
/****************************************************************************
|
||||
****************************************************************************/
|
||||
|
||||
static BOOL api_spoolss_replyopenprinter(pipes_struct *p)
|
||||
{
|
||||
SPOOL_Q_REPLYOPENPRINTER q_u;
|
||||
SPOOL_R_REPLYOPENPRINTER r_u;
|
||||
prs_struct *data = &p->in_data.data;
|
||||
prs_struct *rdata = &p->out_data.rdata;
|
||||
|
||||
ZERO_STRUCT(q_u);
|
||||
ZERO_STRUCT(r_u);
|
||||
|
||||
if(!spoolss_io_q_replyopenprinter("", &q_u, data, 0)) {
|
||||
DEBUG(0,("spoolss_io_q_replyopenprinter: unable to unmarshall SPOOL_Q_REPLYOPENPRINTER.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
r_u.status = _spoolss_replyopenprinter(p, &q_u, &r_u);
|
||||
|
||||
if(!spoolss_io_r_replyopenprinter("", &r_u, rdata, 0)) {
|
||||
DEBUG(0,("spoolss_io_r_replyopenprinter: unable to marshall SPOOL_R_REPLYOPENPRINTER.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
****************************************************************************/
|
||||
|
||||
static BOOL api_spoolss_replycloseprinter(pipes_struct *p)
|
||||
{
|
||||
SPOOL_Q_REPLYCLOSEPRINTER q_u;
|
||||
SPOOL_R_REPLYCLOSEPRINTER r_u;
|
||||
prs_struct *data = &p->in_data.data;
|
||||
prs_struct *rdata = &p->out_data.rdata;
|
||||
|
||||
ZERO_STRUCT(q_u);
|
||||
ZERO_STRUCT(r_u);
|
||||
|
||||
if(!spoolss_io_q_replycloseprinter("", &q_u, data, 0)) {
|
||||
DEBUG(0,("spoolss_io_q_replycloseprinter: unable to unmarshall SPOOL_Q_REPLYCLOSEPRINTER.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
r_u.status = _spoolss_replycloseprinter(p, &q_u, &r_u);
|
||||
|
||||
if(!spoolss_io_r_replycloseprinter("", &r_u, rdata, 0)) {
|
||||
DEBUG(0,("spoolss_io_r_replycloseprinter: unable to marshall SPOOL_R_REPLYCLOSEPRINTER.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*******************************************************************
|
||||
\pipe\spoolss commands
|
||||
@ -1573,6 +1632,10 @@ struct api_struct api_spoolss_cmds[] =
|
||||
{"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory},
|
||||
{"SPOOLSS_ADDPRINTERDRIVEREX", SPOOLSS_ADDPRINTERDRIVEREX, api_spoolss_addprinterdriverex },
|
||||
{"SPOOLSS_DELETEPRINTERDRIVEREX", SPOOLSS_DELETEPRINTERDRIVEREX, api_spoolss_deleteprinterdriverex },
|
||||
#if 0
|
||||
{"SPOOLSS_REPLYOPENPRINTER", SPOOLSS_REPLYOPENPRINTER, api_spoolss_replyopenprinter },
|
||||
{"SPOOLSS_REPLYCLOSEPRINTER", SPOOLSS_REPLYCLOSEPRINTER, api_spoolss_replycloseprinter },
|
||||
#endif
|
||||
{ NULL, 0, NULL }
|
||||
};
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -344,6 +344,36 @@ static BOOL api_srv_net_share_del(pipes_struct *p)
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
RPC to delete share information.
|
||||
********************************************************************/
|
||||
|
||||
static BOOL api_srv_net_share_del_sticky(pipes_struct *p)
|
||||
{
|
||||
SRV_Q_NET_SHARE_DEL q_u;
|
||||
SRV_R_NET_SHARE_DEL r_u;
|
||||
prs_struct *data = &p->in_data.data;
|
||||
prs_struct *rdata = &p->out_data.rdata;
|
||||
|
||||
ZERO_STRUCT(q_u);
|
||||
ZERO_STRUCT(r_u);
|
||||
|
||||
/* Unmarshall the net server del info. */
|
||||
if(!srv_io_q_net_share_del("", &q_u, data, 0)) {
|
||||
DEBUG(0,("api_srv_net_share_del_sticky: Failed to unmarshall SRV_Q_NET_SHARE_DEL.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
r_u.status = _srv_net_share_del_sticky(p, &q_u, &r_u);
|
||||
|
||||
if(!srv_io_r_net_share_del("", &r_u, rdata, 0)) {
|
||||
DEBUG(0,("api_srv_net_share_del_sticky: Failed to marshall SRV_R_NET_SHARE_DEL.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
api_srv_net_remote_tod
|
||||
********************************************************************/
|
||||
@ -503,6 +533,7 @@ static const struct api_struct api_srv_cmds[] =
|
||||
{ "SRV_NET_SHARE_ENUM" , SRV_NET_SHARE_ENUM , api_srv_net_share_enum },
|
||||
{ "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add },
|
||||
{ "SRV_NET_SHARE_DEL" , SRV_NET_SHARE_DEL , api_srv_net_share_del },
|
||||
{ "SRV_NET_SHARE_DEL_STICKY", SRV_NET_SHARE_DEL_STICKY, api_srv_net_share_del_sticky },
|
||||
{ "SRV_NET_SHARE_GET_INFO", SRV_NET_SHARE_GET_INFO, api_srv_net_share_get_info },
|
||||
{ "SRV_NET_SHARE_SET_INFO", SRV_NET_SHARE_SET_INFO, api_srv_net_share_set_info },
|
||||
{ "SRV_NET_FILE_ENUM" , SRV_NET_FILE_ENUM , api_srv_net_file_enum },
|
||||
|
@ -3,6 +3,7 @@
|
||||
* RPC Pipe client / server routines
|
||||
* Copyright (C) Andrew Tridgell 1992-1997,
|
||||
* Copyright (C) Jeremy Allison 2001.
|
||||
* Copyright (C) Nigel Williams 2001.
|
||||
*
|
||||
* 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
|
||||
@ -28,33 +29,54 @@
|
||||
|
||||
extern pstring global_myname;
|
||||
|
||||
/*******************************************************************
|
||||
Utility function to get the 'type' of a share from an snum.
|
||||
********************************************************************/
|
||||
static uint32 get_share_type(int snum)
|
||||
{
|
||||
char *net_name = lp_servicename(snum);
|
||||
int len_net_name = strlen(net_name);
|
||||
|
||||
/* work out the share type */
|
||||
uint32 type = STYPE_DISKTREE;
|
||||
|
||||
if (lp_print_ok(snum))
|
||||
type = STYPE_PRINTQ;
|
||||
if (strequal(lp_fstype(snum), "IPC"))
|
||||
type = STYPE_IPC;
|
||||
if (net_name[len_net_name] == '$')
|
||||
type |= STYPE_HIDDEN;
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Fill in a share info level 0 structure.
|
||||
********************************************************************/
|
||||
|
||||
static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, int snum)
|
||||
{
|
||||
pstring net_name;
|
||||
|
||||
pstrcpy(net_name, lp_servicename(snum));
|
||||
|
||||
init_srv_share_info0(&sh0->info_0, net_name);
|
||||
init_srv_share_info0_str(&sh0->info_0_str, net_name);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Fill in a share info level 1 structure.
|
||||
********************************************************************/
|
||||
|
||||
static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int snum)
|
||||
{
|
||||
int len_net_name;
|
||||
pstring net_name;
|
||||
pstring remark;
|
||||
uint32 type;
|
||||
|
||||
pstrcpy(net_name, lp_servicename(snum));
|
||||
char *net_name = lp_servicename(snum);
|
||||
pstrcpy(remark, lp_comment(snum));
|
||||
standard_sub_conn(p->conn, remark,sizeof(remark));
|
||||
len_net_name = strlen(net_name);
|
||||
|
||||
/* work out the share type */
|
||||
type = STYPE_DISKTREE;
|
||||
|
||||
if (lp_print_ok(snum))
|
||||
type = STYPE_PRINTQ;
|
||||
if (strequal("IPC$", net_name) || strequal("ADMIN$", net_name))
|
||||
type = STYPE_IPC;
|
||||
if (net_name[len_net_name] == '$')
|
||||
type |= STYPE_HIDDEN;
|
||||
|
||||
init_srv_share_info1(&sh1->info_1, net_name, type, remark);
|
||||
init_srv_share_info1(&sh1->info_1, net_name, get_share_type(snum), remark);
|
||||
init_srv_share_info1_str(&sh1->info_1_str, net_name, remark);
|
||||
}
|
||||
|
||||
@ -64,14 +86,11 @@ static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int sn
|
||||
|
||||
static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int snum)
|
||||
{
|
||||
int len_net_name;
|
||||
pstring net_name;
|
||||
pstring remark;
|
||||
pstring path;
|
||||
pstring passwd;
|
||||
uint32 type;
|
||||
|
||||
pstrcpy(net_name, lp_servicename(snum));
|
||||
char *net_name = lp_servicename(snum);
|
||||
pstrcpy(remark, lp_comment(snum));
|
||||
standard_sub_conn(p->conn, remark,sizeof(remark));
|
||||
pstrcpy(path, "C:");
|
||||
@ -85,19 +104,8 @@ static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int sn
|
||||
string_replace(path, '/', '\\');
|
||||
|
||||
pstrcpy(passwd, "");
|
||||
len_net_name = strlen(net_name);
|
||||
|
||||
/* work out the share type */
|
||||
type = STYPE_DISKTREE;
|
||||
|
||||
if (lp_print_ok(snum))
|
||||
type = STYPE_PRINTQ;
|
||||
if (strequal("IPC$", net_name) || strequal("ADMIN$", net_name))
|
||||
type = STYPE_IPC;
|
||||
if (net_name[len_net_name] == '$')
|
||||
type |= STYPE_HIDDEN;
|
||||
|
||||
init_srv_share_info2(&sh2->info_2, net_name, type, remark, 0, 0xffffffff, 1, path, passwd);
|
||||
init_srv_share_info2(&sh2->info_2, net_name, get_share_type(snum), remark, 0, 0xffffffff, 1, path, passwd);
|
||||
init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd);
|
||||
}
|
||||
|
||||
@ -251,7 +259,7 @@ static BOOL set_share_security(TALLOC_CTX *ctx, const char *share_name, SEC_DESC
|
||||
|
||||
/* Free malloc'ed memory */
|
||||
|
||||
out:
|
||||
out:
|
||||
|
||||
prs_mem_free(&ps);
|
||||
if (mem_ctx)
|
||||
@ -337,7 +345,7 @@ BOOL share_access_check(connection_struct *conn, int snum, user_struct *vuser, u
|
||||
|
||||
ret = se_access_check(psd, token, desired_access, &granted, &status);
|
||||
|
||||
out:
|
||||
out:
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
@ -351,27 +359,15 @@ BOOL share_access_check(connection_struct *conn, int snum, user_struct *vuser, u
|
||||
static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, int snum)
|
||||
{
|
||||
int len_net_name;
|
||||
pstring net_name;
|
||||
pstring remark;
|
||||
uint32 type;
|
||||
|
||||
pstrcpy(net_name, lp_servicename(snum));
|
||||
char *net_name = lp_servicename(snum);
|
||||
pstrcpy(remark, lp_comment(snum));
|
||||
standard_sub_conn(p->conn, remark, sizeof(remark));
|
||||
|
||||
len_net_name = strlen(net_name);
|
||||
|
||||
/* work out the share type */
|
||||
type = STYPE_DISKTREE;
|
||||
|
||||
if (lp_print_ok(snum))
|
||||
type = STYPE_PRINTQ;
|
||||
if (strequal("IPC$", net_name) || strequal("ADMIN$", net_name))
|
||||
type = STYPE_IPC;
|
||||
if (net_name[len_net_name] == '$')
|
||||
type |= STYPE_HIDDEN;
|
||||
|
||||
init_srv_share_info501(&sh501->info_501, net_name, type, remark, (lp_csc_policy(snum) << 4));
|
||||
init_srv_share_info501(&sh501->info_501, net_name, get_share_type(snum), remark, (lp_csc_policy(snum) << 4));
|
||||
init_srv_share_info501_str(&sh501->info_501_str, net_name, remark);
|
||||
}
|
||||
|
||||
@ -386,7 +382,6 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502,
|
||||
pstring remark;
|
||||
pstring path;
|
||||
pstring passwd;
|
||||
uint32 type;
|
||||
SEC_DESC *sd;
|
||||
size_t sd_size;
|
||||
TALLOC_CTX *ctx = p->mem_ctx;
|
||||
@ -410,39 +405,86 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502,
|
||||
pstrcpy(passwd, "");
|
||||
len_net_name = strlen(net_name);
|
||||
|
||||
/* work out the share type */
|
||||
type = STYPE_DISKTREE;
|
||||
|
||||
if (lp_print_ok(snum))
|
||||
type = STYPE_PRINTQ;
|
||||
if (strequal("IPC$", net_name))
|
||||
type = STYPE_IPC;
|
||||
if (net_name[len_net_name] == '$')
|
||||
type |= STYPE_HIDDEN;
|
||||
|
||||
sd = get_share_security(ctx, snum, &sd_size);
|
||||
|
||||
init_srv_share_info502(&sh502->info_502, net_name, type, remark, 0, 0xffffffff, 1, path, passwd, sd, sd_size);
|
||||
init_srv_share_info502_str(&sh502->info_502_str, &sh502->info_502, net_name, remark, path, passwd, sd, sd_size);
|
||||
init_srv_share_info502(&sh502->info_502, net_name, get_share_type(snum), remark, 0, 0xffffffff, 1, path, passwd, sd, sd_size);
|
||||
init_srv_share_info502_str(&sh502->info_502_str, net_name, remark, path, passwd, sd, sd_size);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
Fill in a share info level 1004 structure.
|
||||
***************************************************************************/
|
||||
|
||||
static void init_srv_share_info_1004(pipes_struct *p, SRV_SHARE_INFO_1004* sh1004, int snum)
|
||||
{
|
||||
pstring remark;
|
||||
|
||||
pstrcpy(remark, lp_comment(snum));
|
||||
standard_sub_conn(p->conn, remark, sizeof(remark));
|
||||
|
||||
ZERO_STRUCTP(sh1004);
|
||||
|
||||
init_srv_share_info1004(&sh1004->info_1004, remark);
|
||||
init_srv_share_info1004_str(&sh1004->info_1004_str, remark);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
Fill in a share info level 1005 structure.
|
||||
***************************************************************************/
|
||||
|
||||
static void init_srv_share_info_1005(SRV_SHARE_INFO_1005* sh1005, int snum)
|
||||
static void init_srv_share_info_1005(pipes_struct *p, SRV_SHARE_INFO_1005* sh1005, int snum)
|
||||
{
|
||||
sh1005->dfs_root_flag = 0;
|
||||
|
||||
if(lp_host_msdfs() && lp_msdfs_root(snum))
|
||||
sh1005->dfs_root_flag = 3;
|
||||
}
|
||||
/***************************************************************************
|
||||
Fill in a share info level 1006 structure.
|
||||
***************************************************************************/
|
||||
|
||||
static void init_srv_share_info_1006(pipes_struct *p, SRV_SHARE_INFO_1006* sh1006, int snum)
|
||||
{
|
||||
sh1006->max_uses = -1;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
Fill in a share info level 1007 structure.
|
||||
***************************************************************************/
|
||||
|
||||
static void init_srv_share_info_1007(pipes_struct *p, SRV_SHARE_INFO_1007* sh1007, int snum)
|
||||
{
|
||||
pstring alternate_directory_name = "";
|
||||
uint32 flags = 0;
|
||||
|
||||
ZERO_STRUCTP(sh1007);
|
||||
|
||||
init_srv_share_info1007(&sh1007->info_1007, flags, alternate_directory_name);
|
||||
init_srv_share_info1007_str(&sh1007->info_1007_str, alternate_directory_name);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Fill in a share info level 1501 structure.
|
||||
********************************************************************/
|
||||
|
||||
static void init_srv_share_info_1501(pipes_struct *p, SRV_SHARE_INFO_1501 *sh1501, int snum)
|
||||
{
|
||||
SEC_DESC *sd;
|
||||
size_t sd_size;
|
||||
TALLOC_CTX *ctx = p->mem_ctx;
|
||||
|
||||
ZERO_STRUCTP(sh1501);
|
||||
|
||||
sd = get_share_security(ctx, snum, &sd_size);
|
||||
|
||||
sh1501->sdb = make_sec_desc_buf(p->mem_ctx, sd_size, sd);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
True if it ends in '$'.
|
||||
********************************************************************/
|
||||
|
||||
static BOOL is_admin_share(int snum)
|
||||
static BOOL is_hidden_share(int snum)
|
||||
{
|
||||
pstring net_name;
|
||||
|
||||
@ -471,7 +513,7 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr,
|
||||
|
||||
/* Count the number of entries. */
|
||||
for (snum = 0; snum < num_services; snum++) {
|
||||
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) )
|
||||
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) )
|
||||
num_entries++;
|
||||
}
|
||||
|
||||
@ -483,6 +525,24 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr,
|
||||
return True;
|
||||
|
||||
switch (info_level) {
|
||||
case 0:
|
||||
{
|
||||
SRV_SHARE_INFO_0 *info0;
|
||||
int i = 0;
|
||||
|
||||
info0 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_0));
|
||||
|
||||
for (snum = *resume_hnd; snum < num_services; snum++) {
|
||||
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
|
||||
init_srv_share_info_0(p, &info0[i++], snum);
|
||||
}
|
||||
}
|
||||
|
||||
ctr->share.info0 = info0;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
SRV_SHARE_INFO_1 *info1;
|
||||
@ -491,7 +551,7 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr,
|
||||
info1 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1));
|
||||
|
||||
for (snum = *resume_hnd; snum < num_services; snum++) {
|
||||
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) {
|
||||
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
|
||||
init_srv_share_info_1(p, &info1[i++], snum);
|
||||
}
|
||||
}
|
||||
@ -508,7 +568,7 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr,
|
||||
info2 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_2));
|
||||
|
||||
for (snum = *resume_hnd; snum < num_services; snum++) {
|
||||
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) {
|
||||
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
|
||||
init_srv_share_info_2(p, &info2[i++], snum);
|
||||
}
|
||||
}
|
||||
@ -525,7 +585,7 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr,
|
||||
info501 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_501));
|
||||
|
||||
for (snum = *resume_hnd; snum < num_services; snum++) {
|
||||
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) {
|
||||
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
|
||||
init_srv_share_info_501(p, &info501[i++], snum);
|
||||
}
|
||||
}
|
||||
@ -542,7 +602,7 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr,
|
||||
info502 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_502));
|
||||
|
||||
for (snum = *resume_hnd; snum < num_services; snum++) {
|
||||
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) {
|
||||
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
|
||||
init_srv_share_info_502(p, &info502[i++], snum);
|
||||
}
|
||||
}
|
||||
@ -551,6 +611,92 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr,
|
||||
break;
|
||||
}
|
||||
|
||||
/* here for completeness but not currently used with enum (1004 - 1501)*/
|
||||
|
||||
case 1004:
|
||||
{
|
||||
SRV_SHARE_INFO_1004 *info1004;
|
||||
int i = 0;
|
||||
|
||||
info1004 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1004));
|
||||
|
||||
for (snum = *resume_hnd; snum < num_services; snum++) {
|
||||
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
|
||||
init_srv_share_info_1004(p, &info1004[i++], snum);
|
||||
}
|
||||
}
|
||||
|
||||
ctr->share.info1004 = info1004;
|
||||
break;
|
||||
}
|
||||
|
||||
case 1005:
|
||||
{
|
||||
SRV_SHARE_INFO_1005 *info1005;
|
||||
int i = 0;
|
||||
|
||||
info1005 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1005));
|
||||
|
||||
for (snum = *resume_hnd; snum < num_services; snum++) {
|
||||
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
|
||||
init_srv_share_info_1005(p, &info1005[i++], snum);
|
||||
}
|
||||
}
|
||||
|
||||
ctr->share.info1005 = info1005;
|
||||
break;
|
||||
}
|
||||
|
||||
case 1006:
|
||||
{
|
||||
SRV_SHARE_INFO_1006 *info1006;
|
||||
int i = 0;
|
||||
|
||||
info1006 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1006));
|
||||
|
||||
for (snum = *resume_hnd; snum < num_services; snum++) {
|
||||
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
|
||||
init_srv_share_info_1006(p, &info1006[i++], snum);
|
||||
}
|
||||
}
|
||||
|
||||
ctr->share.info1006 = info1006;
|
||||
break;
|
||||
}
|
||||
|
||||
case 1007:
|
||||
{
|
||||
SRV_SHARE_INFO_1007 *info1007;
|
||||
int i = 0;
|
||||
|
||||
info1007 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1007));
|
||||
|
||||
for (snum = *resume_hnd; snum < num_services; snum++) {
|
||||
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
|
||||
init_srv_share_info_1007(p, &info1007[i++], snum);
|
||||
}
|
||||
}
|
||||
|
||||
ctr->share.info1007 = info1007;
|
||||
break;
|
||||
}
|
||||
|
||||
case 1501:
|
||||
{
|
||||
SRV_SHARE_INFO_1501 *info1501;
|
||||
int i = 0;
|
||||
|
||||
info1501 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1501));
|
||||
|
||||
for (snum = *resume_hnd; snum < num_services; snum++) {
|
||||
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
|
||||
init_srv_share_info_1501(p, &info1501[i++], snum);
|
||||
}
|
||||
}
|
||||
|
||||
ctr->share.info1501 = info1501;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n", info_level));
|
||||
return False;
|
||||
@ -596,6 +742,9 @@ static void init_srv_r_net_share_get_info(pipes_struct *p, SRV_R_NET_SHARE_GET_I
|
||||
|
||||
if (snum >= 0) {
|
||||
switch (info_level) {
|
||||
case 0:
|
||||
init_srv_share_info_0(p, &r_n->info.share.info0, snum);
|
||||
break;
|
||||
case 1:
|
||||
init_srv_share_info_1(p, &r_n->info.share.info1, snum);
|
||||
break;
|
||||
@ -608,8 +757,24 @@ static void init_srv_r_net_share_get_info(pipes_struct *p, SRV_R_NET_SHARE_GET_I
|
||||
case 502:
|
||||
init_srv_share_info_502(p, &r_n->info.share.info502, snum);
|
||||
break;
|
||||
|
||||
/* here for completeness */
|
||||
case 1004:
|
||||
init_srv_share_info_1004(p, &r_n->info.share.info1004, snum);
|
||||
break;
|
||||
case 1005:
|
||||
init_srv_share_info_1005(&r_n->info.share.info1005, snum);
|
||||
init_srv_share_info_1005(p, &r_n->info.share.info1005, snum);
|
||||
break;
|
||||
|
||||
/* here for completeness 1006 - 1501 */
|
||||
case 1006:
|
||||
init_srv_share_info_1006(p, &r_n->info.share.info1006, snum);
|
||||
break;
|
||||
case 1007:
|
||||
init_srv_share_info_1007(p, &r_n->info.share.info1007, snum);
|
||||
break;
|
||||
case 1501:
|
||||
init_srv_share_info_1501(p, &r_n->info.share.info1501, snum);
|
||||
break;
|
||||
default:
|
||||
DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level));
|
||||
@ -955,7 +1120,8 @@ static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n,
|
||||
********************************************************************/
|
||||
|
||||
static WERROR init_srv_file_info_ctr(pipes_struct *p, SRV_FILE_INFO_CTR *ctr,
|
||||
int switch_value, uint32 *resume_hnd, uint32 *total_entries)
|
||||
int switch_value, uint32 *resume_hnd,
|
||||
uint32 *total_entries)
|
||||
{
|
||||
WERROR status = WERR_OK;
|
||||
TALLOC_CTX *ctx = p->mem_ctx;
|
||||
@ -1206,8 +1372,8 @@ WERROR _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET
|
||||
|
||||
/* Create the list of shares for the response. */
|
||||
init_srv_r_net_share_enum(p, r_u,
|
||||
q_u->ctr.info_level,
|
||||
get_enum_hnd(&q_u->enum_hnd), False);
|
||||
q_u->ctr.info_level,
|
||||
get_enum_hnd(&q_u->enum_hnd), False);
|
||||
|
||||
DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__));
|
||||
|
||||
@ -1295,7 +1461,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S
|
||||
|
||||
unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name));
|
||||
|
||||
r_u->switch_value = 0;
|
||||
r_u->parm_error = 0;
|
||||
|
||||
if (strequal(share_name,"IPC$") || strequal(share_name,"ADMIN$") || strequal(share_name,"global"))
|
||||
return WERR_ACCESS_DENIED;
|
||||
@ -1312,28 +1478,47 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S
|
||||
|
||||
get_current_user(&user,p);
|
||||
|
||||
if (user.uid != 0)
|
||||
if (user.uid != sec_initial_uid())
|
||||
return WERR_ACCESS_DENIED;
|
||||
|
||||
switch (q_u->info_level) {
|
||||
case 1:
|
||||
/* Not enough info in a level 1 to do anything. */
|
||||
return WERR_ACCESS_DENIED;
|
||||
case 2:
|
||||
unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(share_name));
|
||||
unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name));
|
||||
fstrcpy(pathname, lp_pathname(snum));
|
||||
unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment));
|
||||
type = q_u->info.share.info2.info_2.type;
|
||||
psd = NULL;
|
||||
break;
|
||||
case 2:
|
||||
unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment));
|
||||
unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(pathname));
|
||||
type = q_u->info.share.info2.info_2.type;
|
||||
psd = NULL;
|
||||
break;
|
||||
#if 0
|
||||
/* not supported on set but here for completeness */
|
||||
case 501:
|
||||
unistr2_to_ascii(comment, &q_u->info.share.info501.info_501_str.uni_remark, sizeof(comment));
|
||||
type = q_u->info.share.info501.info_501.type;
|
||||
psd = NULL;
|
||||
break;
|
||||
#endif
|
||||
case 502:
|
||||
unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name));
|
||||
unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(share_name));
|
||||
unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(comment));
|
||||
unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(pathname));
|
||||
type = q_u->info.share.info502.info_502.type;
|
||||
psd = q_u->info.share.info502.info_502_str.sd;
|
||||
map_generic_share_sd_bits(psd);
|
||||
break;
|
||||
case 1004:
|
||||
fstrcpy(pathname, lp_pathname(snum));
|
||||
unistr2_to_ascii(comment, &q_u->info.share.info1004.info_1004_str.uni_remark, sizeof(comment));
|
||||
type = STYPE_DISKTREE;
|
||||
break;
|
||||
case 1005:
|
||||
case 1006:
|
||||
case 1007:
|
||||
return WERR_ACCESS_DENIED;
|
||||
break;
|
||||
case 1501:
|
||||
fstrcpy(pathname, lp_pathname(snum));
|
||||
fstrcpy(comment, lp_comment(snum));
|
||||
@ -1422,12 +1607,12 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S
|
||||
|
||||
DEBUG(5,("_srv_net_share_add: %d\n", __LINE__));
|
||||
|
||||
r_u->switch_value = 0;
|
||||
r_u->parm_error = 0;
|
||||
|
||||
get_current_user(&user,p);
|
||||
|
||||
if (user.uid != 0) {
|
||||
DEBUG(10,("_srv_net_share_add: uid != 0. Access denied.\n"));
|
||||
if (user.uid != sec_initial_uid()) {
|
||||
DEBUG(10,("_srv_net_share_add: uid != sec_initial_uid(). Access denied.\n"));
|
||||
return WERR_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
@ -1437,6 +1622,9 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S
|
||||
}
|
||||
|
||||
switch (q_u->info_level) {
|
||||
case 0:
|
||||
/* No path. Not enough info in a level 0 to do anything. */
|
||||
return WERR_ACCESS_DENIED;
|
||||
case 1:
|
||||
/* Not enough info in a level 1 to do anything. */
|
||||
return WERR_ACCESS_DENIED;
|
||||
@ -1446,6 +1634,9 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S
|
||||
unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name));
|
||||
type = q_u->info.share.info2.info_2.type;
|
||||
break;
|
||||
case 501:
|
||||
/* No path. Not enough info in a level 501 to do anything. */
|
||||
return WERR_ACCESS_DENIED;
|
||||
case 502:
|
||||
unistr2_to_ascii(share_name, &q_u->info.share.info502.info_502_str.uni_netname, sizeof(share_name));
|
||||
unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name));
|
||||
@ -1454,7 +1645,16 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S
|
||||
psd = q_u->info.share.info502.info_502_str.sd;
|
||||
map_generic_share_sd_bits(psd);
|
||||
break;
|
||||
|
||||
/* none of the following contain share names. NetShareAdd does not have a separate parameter for the share name */
|
||||
|
||||
case 1004:
|
||||
case 1005:
|
||||
case 1006:
|
||||
case 1007:
|
||||
return WERR_ACCESS_DENIED;
|
||||
break;
|
||||
case 1501:
|
||||
/* DFS only level. */
|
||||
return WERR_ACCESS_DENIED;
|
||||
default:
|
||||
@ -1544,7 +1744,7 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S
|
||||
|
||||
get_current_user(&user,p);
|
||||
|
||||
if (user.uid != 0)
|
||||
if (user.uid != sec_initial_uid())
|
||||
return WERR_ACCESS_DENIED;
|
||||
|
||||
if (!lp_delete_share_cmd() || !*lp_delete_share_cmd())
|
||||
@ -1570,6 +1770,13 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S
|
||||
return WERR_OK;
|
||||
}
|
||||
|
||||
WERROR _srv_net_share_del_sticky(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u)
|
||||
{
|
||||
DEBUG(5,("_srv_net_share_del_stick: %d\n", __LINE__));
|
||||
|
||||
return _srv_net_share_del(p, q_u, r_u);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
time of day
|
||||
********************************************************************/
|
||||
@ -1703,7 +1910,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC
|
||||
close_cnum(conn, user.vuid);
|
||||
return r_u->status;
|
||||
|
||||
error_exit:
|
||||
error_exit:
|
||||
|
||||
if(fsp) {
|
||||
close_file(fsp, True);
|
||||
@ -1799,7 +2006,7 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_
|
||||
close_cnum(conn, user.vuid);
|
||||
return r_u->status;
|
||||
|
||||
error_exit:
|
||||
error_exit:
|
||||
|
||||
if(fsp) {
|
||||
close_file(fsp, True);
|
||||
@ -1864,6 +2071,7 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D
|
||||
{
|
||||
uint32 i;
|
||||
const char *disk_name;
|
||||
TALLOC_CTX *ctx = p->mem_ctx;
|
||||
uint32 resume=get_enum_hnd(&q_u->enum_hnd);
|
||||
|
||||
r_u->status=WERR_OK;
|
||||
@ -1872,6 +2080,18 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D
|
||||
|
||||
r_u->disk_enum_ctr.unknown = 0;
|
||||
|
||||
{
|
||||
DISK_INFO *dinfo;
|
||||
|
||||
int dinfo_size = MAX_SERVER_DISK_ENTRIES * sizeof(*dinfo);
|
||||
|
||||
if(!(dinfo = talloc(ctx, dinfo_size))) {
|
||||
return WERR_NOMEM;
|
||||
}
|
||||
|
||||
r_u->disk_enum_ctr.disk_info = dinfo;
|
||||
}
|
||||
|
||||
r_u->disk_enum_ctr.disk_info_ptr = r_u->disk_enum_ctr.disk_info ? 1 : 0;
|
||||
|
||||
/*allow one DISK_INFO for null terminator*/
|
||||
@ -1885,7 +2105,7 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D
|
||||
init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, disk_name);
|
||||
}
|
||||
|
||||
/*add a terminating null string. Is this there if there is more data to come?*/
|
||||
/* add a terminating null string. Is this there if there is more data to come? */
|
||||
|
||||
r_u->disk_enum_ctr.entries_read++;
|
||||
|
||||
|
@ -84,10 +84,10 @@ rid_name domain_group_rids[] =
|
||||
NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, uint32 **prids, DOM_SID *q_sid)
|
||||
{
|
||||
SAM_ACCOUNT *sam_pass=NULL;
|
||||
struct sys_grent *glist;
|
||||
struct sys_grent *grp;
|
||||
int i, num, cur_rid=0;
|
||||
int i, cur_rid=0;
|
||||
gid_t gid;
|
||||
gid_t *groups = NULL;
|
||||
int num_groups;
|
||||
GROUP_MAP map;
|
||||
DOM_SID tmp_sid;
|
||||
fstring user_name;
|
||||
@ -130,16 +130,21 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui
|
||||
fstrcpy(user_name, pdb_get_username(sam_pass));
|
||||
grid=pdb_get_group_rid(sam_pass);
|
||||
gid=pdb_get_gid(sam_pass);
|
||||
|
||||
grp = glist = getgrent_list();
|
||||
if (grp == NULL) {
|
||||
|
||||
become_root();
|
||||
/* on some systems this must run as root */
|
||||
num_groups = getgroups_user(user_name, &groups);
|
||||
unbecome_root();
|
||||
if (num_groups == -1) {
|
||||
/* this should never happen */
|
||||
DEBUG(2,("get_alias_user_groups: getgroups_user failed\n"));
|
||||
pdb_free_sam(&sam_pass);
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
return NT_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
for (; grp != NULL; grp = grp->next) {
|
||||
if(!get_group_from_gid(grp->gr_gid, &map, MAPPING_WITHOUT_PRIV)) {
|
||||
DEBUG(10,("get_alias_user_groups: gid %d. not found\n", (int)grp->gr_gid));
|
||||
|
||||
for (i=0;i<num_groups;i++) {
|
||||
if(!get_group_from_gid(groups[i], &map, MAPPING_WITHOUT_PRIV)) {
|
||||
DEBUG(10,("get_alias_user_groups: gid %d. not found\n", (int)groups[i]));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -159,7 +164,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui
|
||||
}
|
||||
|
||||
/* Don't return winbind groups as they are not local! */
|
||||
if (winbind_groups_exist && (grp->gr_gid >= winbind_gid_low) && (grp->gr_gid <= winbind_gid_high)) {
|
||||
if (winbind_groups_exist && (groups[i] >= winbind_gid_low) && (groups[i] <= winbind_gid_high)) {
|
||||
DEBUG(10,("get_alias_user_groups: not returing %s, not local.\n", map.nt_name));
|
||||
continue;
|
||||
}
|
||||
@ -170,30 +175,21 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui
|
||||
continue;
|
||||
}
|
||||
|
||||
/* the group is fine, we can check if there is the user we're looking for */
|
||||
DEBUG(10,("get_alias_user_groups: checking if the user is a member of %s.\n", map.nt_name));
|
||||
|
||||
for(num=0; grp->gr_mem[num]!=NULL; num++) {
|
||||
if(strcmp(grp->gr_mem[num], user_name)==0) {
|
||||
/* we found the user, add the group to the list */
|
||||
|
||||
new_rids=(uint32 *)Realloc(rids, sizeof(uint32)*(cur_rid+1));
|
||||
if (new_rids==NULL) {
|
||||
DEBUG(10,("get_alias_user_groups: could not realloc memory\n"));
|
||||
pdb_free_sam(&sam_pass);
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
rids=new_rids;
|
||||
|
||||
sid_peek_rid(&map.sid, &(rids[cur_rid]));
|
||||
DEBUG(10,("get_alias_user_groups: user found in group %s\n", map.nt_name));
|
||||
cur_rid++;
|
||||
break;
|
||||
}
|
||||
new_rids=(uint32 *)Realloc(rids, sizeof(uint32)*(cur_rid+1));
|
||||
if (new_rids==NULL) {
|
||||
DEBUG(10,("get_alias_user_groups: could not realloc memory\n"));
|
||||
pdb_free_sam(&sam_pass);
|
||||
free(groups);
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
rids=new_rids;
|
||||
|
||||
sid_peek_rid(&map.sid, &(rids[cur_rid]));
|
||||
cur_rid++;
|
||||
break;
|
||||
}
|
||||
|
||||
grent_free(glist);
|
||||
free(groups);
|
||||
|
||||
/* now check for the user's gid (the primary group rid) */
|
||||
for (i=0; i<cur_rid && grid!=rids[i]; i++)
|
||||
|
Loading…
Reference in New Issue
Block a user