1998-11-12 19:07:00 +03:00
/*
2002-01-30 09:08:46 +03:00
* Unix SMB / CIFS implementation .
1998-11-12 19:07:00 +03:00
* RPC Pipe client / server routines
2010-02-19 03:12:04 +03:00
* Almost completely rewritten by ( C ) Jeremy Allison 2005 - 2010
1998-11-12 19:07:00 +03:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2007-07-09 23:25:36 +04:00
* the Free Software Foundation ; either version 3 of the License , or
1998-11-12 19:07:00 +03:00
* ( 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
2007-07-10 09:23:25 +04:00
* along with this program ; if not , see < http : //www.gnu.org/licenses/>.
1998-11-12 19:07:00 +03:00
*/
/* this module apparently provides an implementation of DCE/RPC over a
* named pipe ( IPC $ connection using SMBtrans ) . details of DCE / RPC
* documentation are available ( in on - line form ) from the X - Open group .
*
* this module should provide a level of abstraction between SMB
* and DCE / RPC , while minimising the amount of mallocs , unnecessary
* data copies , and network traffic .
*
*/
# include "includes.h"
2010-07-17 23:22:26 +04:00
# include "rpc_server.h"
2011-05-02 15:27:45 +04:00
# include "rpc_server/srv_pipe.h"
1998-11-12 19:07:00 +03:00
2002-07-15 14:35:28 +04:00
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_RPC_SRV
2008-07-19 22:27:56 +04:00
/**
* Is a named pipe known ?
2019-02-27 23:36:22 +03:00
* @ param [ in ] dce_ctx The rpc server context
2012-05-28 18:49:23 +04:00
* @ param [ in ] pipename Just the filename
2019-02-27 23:36:22 +03:00
* @ param [ out ] endpoint The DCERPC endpoint serving the pipe name
2019-02-18 23:06:02 +03:00
* @ result NT error code
2008-07-19 22:27:56 +04:00
*/
2019-02-27 23:36:22 +03:00
NTSTATUS is_known_pipename ( struct dcesrv_context * dce_ctx ,
const char * pipename ,
struct dcesrv_endpoint * * ep )
2008-07-19 22:27:56 +04:00
{
2009-10-03 17:33:12 +04:00
NTSTATUS status ;
2008-07-19 22:27:56 +04:00
2017-05-08 22:40:40 +03:00
if ( strchr ( pipename , ' / ' ) ) {
2019-02-18 23:06:02 +03:00
DBG_WARNING ( " Refusing open on pipe %s \n " , pipename ) ;
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
2017-05-08 22:40:40 +03:00
}
2008-07-19 22:27:56 +04:00
if ( lp_disable_spoolss ( ) & & strequal ( pipename , " spoolss " ) ) {
2019-02-18 23:06:02 +03:00
DBG_DEBUG ( " refusing spoolss access \n " ) ;
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
2008-07-19 22:27:56 +04:00
}
2019-02-27 23:36:22 +03:00
status = dcesrv_endpoint_by_ncacn_np_name ( dce_ctx , pipename , ep ) ;
if ( NT_STATUS_IS_OK ( status ) ) {
2019-02-18 23:06:02 +03:00
return NT_STATUS_OK ;
2008-07-19 22:27:56 +04:00
}
2009-10-03 17:33:12 +04:00
status = smb_probe_module ( " rpc " , pipename ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
2019-02-18 23:06:02 +03:00
DBG_DEBUG ( " Unknown pipe '%s' \n " , pipename ) ;
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
2009-10-03 17:33:12 +04:00
}
2019-02-18 23:06:02 +03:00
DBG_DEBUG ( " '%s' loaded dynamically \n " , pipename ) ;
2009-10-03 17:33:12 +04:00
/*
* Scan the list again for the interface id
*/
2019-02-27 23:36:22 +03:00
status = dcesrv_endpoint_by_ncacn_np_name ( dce_ctx , pipename , ep ) ;
if ( NT_STATUS_IS_OK ( status ) ) {
2019-02-18 23:06:02 +03:00
return NT_STATUS_OK ;
2009-10-03 17:33:12 +04:00
}
2019-02-18 23:06:02 +03:00
DBG_DEBUG ( " pipe %s did not register itself! \n " , pipename ) ;
2009-10-03 17:33:12 +04:00
2019-02-18 23:06:02 +03:00
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
2008-07-19 22:27:56 +04:00
}