2010-03-23 16:04:30 +01:00
/*
2007-08-19 21:09:15 +00:00
Unix SMB / CIFS implementation .
Test suite for libnet calls .
Copyright ( C ) Rafal Szczesniak 2007
2010-03-23 16:04:30 +01:00
2007-08-19 21:09:15 +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 3 of the License , or
( at your option ) any later version .
2010-03-23 16:04:30 +01:00
2007-08-19 21:09:15 +00:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2010-03-23 16:04:30 +01:00
2007-08-19 21:09:15 +00:00
You should have received a copy of the GNU General Public License
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
# include "includes.h"
2010-04-13 22:06:51 +02:00
# include "torture/rpc/torture_rpc.h"
2007-08-19 21:09:15 +00:00
# include "libnet/libnet.h"
# include "libcli/security/security.h"
# include "librpc/gen_ndr/ndr_samr_c.h"
2007-09-08 12:42:09 +00:00
# include "param/param.h"
2010-05-28 05:14:47 +03:00
# include "torture/libnet/proto.h"
2007-08-19 21:09:15 +00:00
# define TEST_GROUPNAME "libnetgroupinfotest"
2010-03-23 15:31:27 +01:00
static bool test_groupinfo ( struct torture_context * tctx ,
struct dcerpc_pipe * p , TALLOC_CTX * mem_ctx ,
2007-08-19 21:09:15 +00:00
struct policy_handle * domain_handle ,
struct dom_sid2 * domain_sid , const char * group_name ,
uint32_t * rid )
{
const uint16_t level = 5 ;
NTSTATUS status ;
struct libnet_rpc_groupinfo group ;
struct dom_sid * group_sid ;
2010-03-23 16:04:30 +01:00
2007-08-19 21:09:15 +00:00
group_sid = dom_sid_add_rid ( mem_ctx , domain_sid , * rid ) ;
2010-03-23 16:04:30 +01:00
2007-08-19 21:09:15 +00:00
group . in . domain_handle = * domain_handle ;
group . in . sid = dom_sid_string ( mem_ctx , group_sid ) ;
group . in . level = level ; /* this should be extended */
2010-03-23 15:31:27 +01:00
torture_comment ( tctx , " Testing sync libnet_rpc_groupinfo (SID argument) \n " ) ;
2007-08-19 21:09:15 +00:00
status = libnet_rpc_groupinfo ( p , mem_ctx , & group ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
2010-03-23 15:31:27 +01:00
torture_comment ( tctx , " Failed to call sync libnet_rpc_userinfo - %s \n " , nt_errstr ( status ) ) ;
2007-10-06 22:28:14 +00:00
return false ;
2007-08-19 21:09:15 +00:00
}
ZERO_STRUCT ( group ) ;
group . in . domain_handle = * domain_handle ;
group . in . sid = NULL ;
group . in . groupname = TEST_GROUPNAME ;
group . in . level = level ;
printf ( " Testing sync libnet_rpc_groupinfo (groupname argument) \n " ) ;
status = libnet_rpc_groupinfo ( p , mem_ctx , & group ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
2010-03-23 15:31:27 +01:00
torture_comment ( tctx , " Failed to call sync libnet_rpc_groupinfo - %s \n " , nt_errstr ( status ) ) ;
2007-10-06 22:28:14 +00:00
return false ;
2007-08-19 21:09:15 +00:00
}
2007-10-06 22:28:14 +00:00
return true ;
2007-08-19 21:09:15 +00:00
}
2007-10-06 22:28:14 +00:00
bool torture_groupinfo ( struct torture_context * torture )
2007-08-19 21:09:15 +00:00
{
NTSTATUS status ;
struct dcerpc_pipe * p ;
TALLOC_CTX * mem_ctx ;
2007-10-06 22:28:14 +00:00
bool ret = true ;
2007-08-19 21:09:15 +00:00
struct policy_handle h ;
struct lsa_String name ;
struct dom_sid2 sid ;
uint32_t rid ;
2010-03-15 09:37:42 +01:00
struct dcerpc_binding_handle * b ;
2007-08-19 21:09:15 +00:00
mem_ctx = talloc_init ( " test_userinfo " ) ;
2010-03-23 16:04:30 +01:00
status = torture_rpc_connection ( torture ,
2007-08-19 21:09:15 +00:00
& p ,
2007-08-20 01:03:51 +00:00
& ndr_table_samr ) ;
2010-03-23 16:04:30 +01:00
2007-08-19 21:09:15 +00:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2007-10-06 22:28:14 +00:00
return false ;
2007-08-19 21:09:15 +00:00
}
2010-03-15 09:37:42 +01:00
b = p - > binding_handle ;
2007-08-19 21:09:15 +00:00
2010-07-16 14:32:42 +10:00
name . string = lpcfg_workgroup ( torture - > lp_ctx ) ;
2007-08-19 21:09:15 +00:00
/*
* Testing synchronous version
*/
2010-05-28 05:06:55 +03:00
if ( ! test_domain_open ( torture , b , & name , mem_ctx , & h , & sid ) ) {
2007-10-06 22:28:14 +00:00
ret = false ;
2007-08-19 21:09:15 +00:00
goto done ;
}
2010-03-23 15:31:27 +01:00
if ( ! test_group_create ( torture , b , mem_ctx , & h , TEST_GROUPNAME , & rid ) ) {
2007-10-06 22:28:14 +00:00
ret = false ;
2007-08-19 21:09:15 +00:00
goto done ;
}
2010-03-23 15:31:27 +01:00
if ( ! test_groupinfo ( torture , p , mem_ctx , & h , & sid , TEST_GROUPNAME , & rid ) ) {
2007-10-06 22:28:14 +00:00
ret = false ;
2007-08-19 21:09:15 +00:00
goto done ;
}
2010-03-23 15:31:27 +01:00
if ( ! test_group_cleanup ( torture , b , mem_ctx , & h , TEST_GROUPNAME ) ) {
2007-10-06 22:28:14 +00:00
ret = false ;
2007-08-19 21:09:15 +00:00
goto done ;
}
done :
talloc_free ( mem_ctx ) ;
return ret ;
}