2004-10-31 18:40:08 +00:00
/*
Unix SMB / CIFS implementation .
test suite for remoteactivation operations
Copyright ( C ) Jelmer Vernooij 2004
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-10 02:07:03 +00:00
the Free Software Foundation ; either version 3 of the License , or
2004-10-31 18:40:08 +00: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 02:07:03 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2004-10-31 18:40:08 +00:00
*/
# include "includes.h"
2006-01-03 13:41:17 +00:00
# include "torture/torture.h"
2006-03-14 23:35:30 +00:00
# include "librpc/gen_ndr/ndr_remact_c.h"
# include "librpc/gen_ndr/ndr_epmapper_c.h"
2006-03-14 15:02:05 +00:00
# include "torture/rpc/rpc.h"
2004-10-31 18:40:08 +00:00
2005-07-18 23:58:59 +00:00
# define CLSID_IMAGEDOC "02B01C80-E03D-101A-B294-00DD010F2BF9"
2007-02-18 18:44:56 +00:00
# define DCERPC_IUNKNOWN_UUID "00000000-0000-0000-c000-000000000046"
# define DCERPC_ICLASSFACTORY_UUID "00000001-0000-0000-c000-000000000046"
2005-07-18 23:58:59 +00:00
2004-10-31 18:40:08 +00:00
static int test_RemoteActivation ( struct dcerpc_pipe * p , TALLOC_CTX * mem_ctx )
{
struct RemoteActivation r ;
NTSTATUS status ;
2005-07-18 23:58:59 +00:00
struct GUID iids [ 1 ] ;
2005-02-10 05:09:35 +00:00
uint16_t protseq [ 3 ] = { EPM_PROTOCOL_TCP , EPM_PROTOCOL_NCALRPC , EPM_PROTOCOL_UUID } ;
2004-10-31 18:40:08 +00:00
ZERO_STRUCT ( r . in ) ;
r . in . this . version . MajorVersion = 5 ;
r . in . this . version . MinorVersion = 1 ;
2004-11-25 20:03:46 +00:00
r . in . this . cid = GUID_random ( ) ;
2005-07-18 23:58:59 +00:00
GUID_from_string ( CLSID_IMAGEDOC , & r . in . Clsid ) ;
2004-10-31 18:40:08 +00:00
r . in . ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY ;
2004-11-02 15:32:58 +00:00
r . in . num_protseqs = 3 ;
2004-10-31 18:40:08 +00:00
r . in . protseq = protseq ;
2005-07-18 23:58:59 +00:00
r . in . Interfaces = 1 ;
2004-10-31 18:40:08 +00:00
GUID_from_string ( DCERPC_IUNKNOWN_UUID , & iids [ 0 ] ) ;
r . in . pIIDs = iids ;
status = dcerpc_RemoteActivation ( p , mem_ctx , & r ) ;
if ( NT_STATUS_IS_ERR ( status ) ) {
2005-03-06 15:57:08 +00:00
printf ( " RemoteActivation: %s \n " , nt_errstr ( status ) ) ;
2004-10-31 18:40:08 +00:00
return 0 ;
}
if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
2005-03-06 15:57:08 +00:00
printf ( " RemoteActivation: %s \n " , win_errstr ( r . out . result ) ) ;
2004-10-31 18:40:08 +00:00
return 0 ;
}
2006-09-19 01:34:53 +00:00
if ( ! W_ERROR_IS_OK ( * r . out . hr ) ) {
printf ( " RemoteActivation: %s \n " , win_errstr ( * r . out . hr ) ) ;
2004-10-31 18:40:08 +00:00
return 0 ;
}
2004-11-02 17:38:11 +00:00
if ( ! W_ERROR_IS_OK ( r . out . results [ 0 ] ) ) {
2005-03-06 15:57:08 +00:00
printf ( " RemoteActivation: %s \n " , win_errstr ( r . out . results [ 0 ] ) ) ;
2004-11-02 17:38:11 +00:00
return 0 ;
}
2004-11-03 20:32:28 +00:00
GUID_from_string ( DCERPC_ICLASSFACTORY_UUID , & iids [ 0 ] ) ;
2004-11-07 16:47:46 +00:00
r . in . Interfaces = 1 ;
2004-11-02 17:38:11 +00:00
r . in . Mode = MODE_GET_CLASS_OBJECT ;
status = dcerpc_RemoteActivation ( p , mem_ctx , & r ) ;
if ( NT_STATUS_IS_ERR ( status ) ) {
2005-03-06 15:57:08 +00:00
printf ( " RemoteActivation(GetClassObject): %s \n " , nt_errstr ( status ) ) ;
2004-11-02 17:38:11 +00:00
return 0 ;
}
if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
2005-03-06 15:57:08 +00:00
printf ( " RemoteActivation(GetClassObject): %s \n " , win_errstr ( r . out . result ) ) ;
2004-11-02 17:38:11 +00:00
return 0 ;
}
2006-09-19 01:34:53 +00:00
if ( ! W_ERROR_IS_OK ( * r . out . hr ) ) {
printf ( " RemoteActivation(GetClassObject): %s \n " , win_errstr ( * r . out . hr ) ) ;
2004-11-02 17:38:11 +00:00
return 0 ;
}
if ( ! W_ERROR_IS_OK ( r . out . results [ 0 ] ) ) {
2005-03-12 17:12:52 +00:00
printf ( " RemoteActivation(GetClassObject): %s \n " , win_errstr ( r . out . results [ 0 ] ) ) ;
2004-11-02 17:38:11 +00:00
return 0 ;
}
2004-10-31 18:40:08 +00:00
return 1 ;
}
2006-03-25 16:01:28 +00:00
BOOL torture_rpc_remact ( struct torture_context * torture )
2004-10-31 18:40:08 +00:00
{
2005-03-22 08:00:45 +00:00
NTSTATUS status ;
struct dcerpc_pipe * p ;
2004-10-31 18:40:08 +00:00
TALLOC_CTX * mem_ctx ;
BOOL ret = True ;
mem_ctx = talloc_init ( " torture_rpc_remact " ) ;
2007-08-28 12:54:27 +00:00
status = torture_rpc_connection ( torture ,
2005-03-22 08:00:45 +00:00
& p ,
2007-08-19 21:23:03 +00:00
& ndr_table_IRemoteActivation ) ;
2004-10-31 18:40:08 +00:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2005-03-22 08:00:45 +00:00
talloc_free ( mem_ctx ) ;
2004-10-31 18:40:08 +00:00
return False ;
}
if ( ! test_RemoteActivation ( p , mem_ctx ) )
ret = False ;
2005-01-27 07:08:20 +00:00
talloc_free ( mem_ctx ) ;
2004-10-31 18:40:08 +00:00
return ret ;
}