2000-05-10 10:41:59 +00:00
# define OLD_NTDOMAIN 1
1998-03-11 21:11:04 +00:00
/*
* Unix SMB / Netbios implementation .
* Version 1.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.
2001-02-26 08:10:51 +00:00
* Copyright ( C ) Jeremy Allison 2001.
1998-05-14 01:30:40 +00:00
*
1998-03-11 21:11:04 +00: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
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* 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 .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
2001-02-26 19:45:00 +00:00
/* This is the interface to the lsa server code. */
1998-03-11 21:11:04 +00:00
# include "includes.h"
extern int DEBUGLEVEL ;
1998-10-15 05:47:29 +00:00
/***************************************************************************
1999-12-13 13:27:58 +00:00
api_lsa_open_policy2
1998-10-15 05:47:29 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1999-12-13 13:27:58 +00:00
2000-06-16 08:11:32 +00:00
static BOOL api_lsa_open_policy2 ( pipes_struct * p )
1998-10-15 05:47:29 +00:00
{
2001-02-26 19:45:00 +00:00
LSA_Q_OPEN_POL2 q_u ;
LSA_R_OPEN_POL2 r_u ;
2000-06-16 08:11:32 +00:00
prs_struct * data = & p - > in_data . data ;
prs_struct * rdata = & p - > out_data . rdata ;
2001-02-26 19:45:00 +00:00
ZERO_STRUCT ( q_u ) ;
ZERO_STRUCT ( r_u ) ;
1998-10-15 05:47:29 +00:00
/* grab the server, object attributes and desired access flag...*/
2001-02-26 19:45:00 +00:00
if ( ! lsa_io_q_open_pol2 ( " " , & q_u , data , 0 ) ) {
1999-12-13 13:27:58 +00:00
DEBUG ( 0 , ( " api_lsa_open_policy2: unable to unmarshall LSA_Q_OPEN_POL2. \n " ) ) ;
return False ;
}
1998-10-15 05:47:29 +00:00
2001-02-26 19:45:00 +00:00
r_u . status = _lsa_open_policy2 ( p , & q_u , & r_u ) ;
1998-10-15 05:47:29 +00:00
2001-02-26 19:45:00 +00:00
/* store the response in the SMB stream */
if ( ! lsa_io_r_open_pol2 ( " " , & r_u , rdata , 0 ) ) {
DEBUG ( 0 , ( " api_lsa_open_policy2: unable to marshall LSA_R_OPEN_POL2. \n " ) ) ;
1999-12-13 13:27:58 +00:00
return False ;
2001-02-26 19:45:00 +00:00
}
1999-12-13 13:27:58 +00:00
return True ;
1998-10-15 05:47:29 +00:00
}
1998-03-11 21:11:04 +00:00
/***************************************************************************
api_lsa_open_policy
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-02-26 19:45:00 +00:00
2000-06-16 08:11:32 +00:00
static BOOL api_lsa_open_policy ( pipes_struct * p )
1998-03-11 21:11:04 +00:00
{
2001-02-26 19:45:00 +00:00
LSA_Q_OPEN_POL q_u ;
LSA_R_OPEN_POL r_u ;
2000-06-16 08:11:32 +00:00
prs_struct * data = & p - > in_data . data ;
prs_struct * rdata = & p - > out_data . rdata ;
2001-02-26 19:45:00 +00:00
ZERO_STRUCT ( q_u ) ;
ZERO_STRUCT ( r_u ) ;
1998-08-21 09:44:30 +00:00
1998-03-11 21:11:04 +00:00
/* grab the server, object attributes and desired access flag...*/
2001-02-26 19:45:00 +00:00
if ( ! lsa_io_q_open_pol ( " " , & q_u , data , 0 ) ) {
1999-12-13 13:27:58 +00:00
DEBUG ( 0 , ( " api_lsa_open_policy: unable to unmarshall LSA_Q_OPEN_POL. \n " ) ) ;
return False ;
}
1998-03-11 21:11:04 +00:00
2001-02-26 19:45:00 +00:00
r_u . status = _lsa_open_policy ( p , & q_u , & r_u ) ;
1998-03-11 21:11:04 +00:00
2001-02-26 19:45:00 +00:00
/* store the response in the SMB stream */
if ( ! lsa_io_r_open_pol ( " " , & r_u , rdata , 0 ) ) {
DEBUG ( 0 , ( " api_lsa_open_policy: unable to marshall LSA_R_OPEN_POL. \n " ) ) ;
1999-12-13 13:27:58 +00:00
return False ;
2001-02-26 19:45:00 +00:00
}
1999-12-13 13:27:58 +00:00
return True ;
1998-03-11 21:11:04 +00:00
}
/***************************************************************************
2001-02-26 19:45:00 +00:00
api_lsa_enum_trust_dom
1998-03-11 21:11:04 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-02-26 19:45:00 +00:00
2000-06-16 08:11:32 +00:00
static BOOL api_lsa_enum_trust_dom ( pipes_struct * p )
1998-03-11 21:11:04 +00:00
{
2001-02-26 19:45:00 +00:00
LSA_Q_ENUM_TRUST_DOM q_u ;
LSA_R_ENUM_TRUST_DOM r_u ;
2000-06-16 08:11:32 +00:00
prs_struct * data = & p - > in_data . data ;
prs_struct * rdata = & p - > out_data . rdata ;
1998-03-11 21:11:04 +00:00
2001-02-26 19:45:00 +00:00
ZERO_STRUCT ( q_u ) ;
ZERO_STRUCT ( r_u ) ;
1998-08-21 09:44:30 +00:00
1998-03-11 21:11:04 +00:00
/* grab the enum trust domain context etc. */
2001-02-26 19:45:00 +00:00
if ( ! lsa_io_q_enum_trust_dom ( " " , & q_u , data , 0 ) )
2000-05-04 21:57:28 +00:00
return False ;
1998-03-11 21:11:04 +00:00
2001-02-26 19:45:00 +00:00
r_u . status = _lsa_enum_trust_dom ( p , & q_u , & r_u ) ;
if ( ! lsa_io_r_enum_trust_dom ( " " , & r_u , rdata , 0 ) )
return False ;
1999-12-13 13:27:58 +00:00
return True ;
1998-03-11 21:11:04 +00:00
}
/***************************************************************************
2001-02-26 19:45:00 +00:00
api_lsa_query_info
1998-03-11 21:11:04 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-02-26 19:45:00 +00:00
2000-06-16 08:11:32 +00:00
static BOOL api_lsa_query_info ( pipes_struct * p )
1998-03-11 21:11:04 +00:00
{
2001-02-26 19:45:00 +00:00
LSA_Q_QUERY_INFO q_u ;
LSA_R_QUERY_INFO r_u ;
2000-06-16 08:11:32 +00:00
prs_struct * data = & p - > in_data . data ;
prs_struct * rdata = & p - > out_data . rdata ;
2000-05-04 21:57:28 +00:00
2001-02-26 19:45:00 +00:00
ZERO_STRUCT ( q_u ) ;
ZERO_STRUCT ( r_u ) ;
1998-08-21 09:44:30 +00:00
1998-03-11 21:11:04 +00:00
/* grab the info class and policy handle */
2001-02-26 19:45:00 +00:00
if ( ! lsa_io_q_query ( " " , & q_u , data , 0 ) ) {
1999-12-13 13:27:58 +00:00
DEBUG ( 0 , ( " api_lsa_query_info: failed to unmarshall LSA_Q_QUERY_INFO. \n " ) ) ;
return False ;
}
2001-02-26 19:45:00 +00:00
r_u . status = _lsa_query_info ( p , & q_u , & r_u ) ;
1998-03-11 21:11:04 +00:00
2001-02-26 19:45:00 +00:00
/* store the response in the SMB stream */
if ( ! lsa_io_r_query ( " " , & r_u , rdata , 0 ) ) {
DEBUG ( 0 , ( " api_lsa_query_info: failed to marshall LSA_R_QUERY_INFO. \n " ) ) ;
1999-12-13 13:27:58 +00:00
return False ;
2001-02-26 19:45:00 +00:00
}
1999-12-13 13:27:58 +00:00
return True ;
1998-03-11 21:11:04 +00:00
}
/***************************************************************************
1999-12-13 13:27:58 +00:00
api_lsa_lookup_sids
1998-03-11 21:11:04 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1999-12-13 13:27:58 +00:00
2000-06-16 08:11:32 +00:00
static BOOL api_lsa_lookup_sids ( pipes_struct * p )
1998-03-11 21:11:04 +00:00
{
2001-02-26 19:45:00 +00:00
LSA_Q_LOOKUP_SIDS q_u ;
LSA_R_LOOKUP_SIDS r_u ;
2000-06-16 08:11:32 +00:00
prs_struct * data = & p - > in_data . data ;
prs_struct * rdata = & p - > out_data . rdata ;
2001-02-26 19:45:00 +00:00
ZERO_STRUCT ( q_u ) ;
ZERO_STRUCT ( r_u ) ;
1998-08-21 09:44:30 +00:00
1998-03-11 21:11:04 +00:00
/* grab the info class and policy handle */
2001-02-26 19:45:00 +00:00
if ( ! lsa_io_q_lookup_sids ( " " , & q_u , data , 0 ) ) {
1999-12-13 13:27:58 +00:00
DEBUG ( 0 , ( " api_lsa_lookup_sids: failed to unmarshall LSA_Q_LOOKUP_SIDS. \n " ) ) ;
2001-02-26 19:45:00 +00:00
return False ;
2000-12-12 02:45:11 +00:00
}
1999-12-13 13:27:58 +00:00
2001-02-26 19:45:00 +00:00
r_u . status = _lsa_lookup_sids ( p , & q_u , & r_u ) ;
2001-02-26 08:10:51 +00:00
2001-02-26 19:45:00 +00:00
if ( ! lsa_io_r_lookup_sids ( " " , & r_u , rdata , 0 ) ) {
DEBUG ( 0 , ( " api_lsa_lookup_sids: Failed to marshall LSA_R_LOOKUP_SIDS. \n " ) ) ;
return False ;
}
2001-02-26 08:10:51 +00:00
2001-02-26 19:45:00 +00:00
return True ;
2001-02-26 08:10:51 +00:00
}
1998-03-11 21:11:04 +00:00
/***************************************************************************
1999-12-13 13:27:58 +00:00
api_lsa_lookup_names
1998-03-11 21:11:04 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1999-12-13 13:27:58 +00:00
2000-06-16 08:11:32 +00:00
static BOOL api_lsa_lookup_names ( pipes_struct * p )
1998-03-11 21:11:04 +00:00
{
2001-02-26 08:10:51 +00:00
LSA_Q_LOOKUP_NAMES q_u ;
LSA_R_LOOKUP_NAMES r_u ;
2000-06-16 08:11:32 +00:00
prs_struct * data = & p - > in_data . data ;
prs_struct * rdata = & p - > out_data . rdata ;
2001-02-26 08:10:51 +00:00
ZERO_STRUCT ( q_u ) ;
ZERO_STRUCT ( r_u ) ;
1998-08-21 09:44:30 +00:00
1998-03-11 21:11:04 +00:00
/* grab the info class and policy handle */
2001-02-26 08:10:51 +00:00
if ( ! lsa_io_q_lookup_names ( " " , & q_u , data , 0 ) ) {
1999-12-13 13:27:58 +00:00
DEBUG ( 0 , ( " api_lsa_lookup_names: failed to unmarshall LSA_Q_LOOKUP_NAMES. \n " ) ) ;
return False ;
}
1998-03-11 21:11:04 +00:00
2001-02-26 08:10:51 +00:00
r_u . status = _lsa_lookup_names ( p , & q_u , & r_u ) ;
/* store the response in the SMB stream */
if ( ! lsa_io_r_lookup_names ( " " , & r_u , rdata , 0 ) ) {
DEBUG ( 0 , ( " api_lsa_lookup_names: Failed to marshall LSA_R_LOOKUP_NAMES. \n " ) ) ;
return False ;
}
return True ;
1998-03-11 21:11:04 +00:00
}
2001-02-26 08:10:51 +00:00
/***************************************************************************
api_lsa_close .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2000-06-16 08:11:32 +00:00
static BOOL api_lsa_close ( pipes_struct * p )
1998-03-11 21:11:04 +00:00
{
2001-02-26 08:10:51 +00:00
LSA_Q_CLOSE q_u ;
LSA_R_CLOSE r_u ;
prs_struct * data = & p - > in_data . data ;
2000-06-23 06:43:08 +00:00
prs_struct * rdata = & p - > out_data . rdata ;
1998-03-11 21:11:04 +00:00
2001-02-26 08:10:51 +00:00
ZERO_STRUCT ( q_u ) ;
ZERO_STRUCT ( r_u ) ;
if ( ! lsa_io_q_close ( " " , & q_u , data , 0 ) ) {
DEBUG ( 0 , ( " api_lsa_close: lsa_io_q_close failed. \n " ) ) ;
return False ;
}
r_u . status = _lsa_close ( p , & q_u , & r_u ) ;
1998-03-11 21:11:04 +00:00
1999-12-13 13:27:58 +00:00
/* store the response in the SMB stream */
2001-02-26 08:10:51 +00:00
if ( ! lsa_io_r_close ( " " , & r_u , rdata , 0 ) ) {
1999-12-13 13:27:58 +00:00
DEBUG ( 0 , ( " api_lsa_close: lsa_io_r_close failed. \n " ) ) ;
return False ;
1999-11-18 00:26:11 +00:00
}
1999-12-13 13:27:58 +00:00
return True ;
1998-03-11 21:11:04 +00:00
}
2001-02-26 08:10:51 +00:00
/***************************************************************************
api_lsa_open_secret .
1998-03-11 21:11:04 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-02-26 08:10:51 +00:00
2000-06-16 08:11:32 +00:00
static BOOL api_lsa_open_secret ( pipes_struct * p )
1998-03-11 21:11:04 +00:00
{
2001-02-26 08:10:51 +00:00
LSA_Q_OPEN_SECRET q_u ;
LSA_R_OPEN_SECRET r_u ;
prs_struct * data = & p - > in_data . data ;
2000-06-16 08:11:32 +00:00
prs_struct * rdata = & p - > out_data . rdata ;
1999-12-13 13:27:58 +00:00
2001-02-26 08:10:51 +00:00
ZERO_STRUCT ( q_u ) ;
ZERO_STRUCT ( r_u ) ;
if ( ! lsa_io_q_open_secret ( " " , & q_u , data , 0 ) ) {
DEBUG ( 0 , ( " api_lsa_open_secret: failed to unmarshall LSA_Q_OPEN_SECRET. \n " ) ) ;
return False ;
1999-12-13 13:27:58 +00:00
}
2001-02-26 08:10:51 +00:00
r_u . status = _lsa_open_secret ( p , & q_u , & r_u ) ;
/* store the response in the SMB stream */
if ( ! lsa_io_r_open_secret ( " " , & r_u , rdata , 0 ) ) {
DEBUG ( 0 , ( " api_lsa_open_secret: Failed to marshall LSA_R_OPEN_SECRET. \n " ) ) ;
1999-12-13 13:27:58 +00:00
return False ;
}
return True ;
1998-03-11 21:11:04 +00:00
}
/***************************************************************************
\ PIPE \ ntlsa commands
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-02-26 08:10:51 +00:00
1998-03-11 21:11:04 +00:00
static struct api_struct api_lsa_cmds [ ] =
{
1998-10-15 05:47:29 +00:00
{ " LSA_OPENPOLICY2 " , LSA_OPENPOLICY2 , api_lsa_open_policy2 } ,
1998-03-11 21:11:04 +00:00
{ " LSA_OPENPOLICY " , LSA_OPENPOLICY , api_lsa_open_policy } ,
{ " LSA_QUERYINFOPOLICY " , LSA_QUERYINFOPOLICY , api_lsa_query_info } ,
{ " LSA_ENUMTRUSTDOM " , LSA_ENUMTRUSTDOM , api_lsa_enum_trust_dom } ,
{ " LSA_CLOSE " , LSA_CLOSE , api_lsa_close } ,
{ " LSA_OPENSECRET " , LSA_OPENSECRET , api_lsa_open_secret } ,
{ " LSA_LOOKUPSIDS " , LSA_LOOKUPSIDS , api_lsa_lookup_sids } ,
{ " LSA_LOOKUPNAMES " , LSA_LOOKUPNAMES , api_lsa_lookup_names } ,
{ NULL , 0 , NULL }
} ;
/***************************************************************************
api_ntLsarpcTNP
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2000-06-16 08:11:32 +00:00
BOOL api_ntlsa_rpc ( pipes_struct * p )
1998-03-11 21:11:04 +00:00
{
2000-06-16 08:11:32 +00:00
return api_rpcTNP ( p , " api_ntlsa_rpc " , api_lsa_cmds ) ;
1998-03-11 21:11:04 +00:00
}
2000-05-10 10:41:59 +00:00
# undef OLD_NTDOMAIN