2007-11-27 11:35:10 +03:00
/*
2003-11-17 15:43:18 +03:00
Unix SMB / CIFS implementation .
test suite for wkssvc rpc operations
Copyright ( C ) Andrew Tridgell 2003
2007-11-27 14:59:35 +03:00
Copyright ( C ) Günther Deschner 2007
2007-11-27 11:35:10 +03:00
2003-11-17 15:43:18 +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-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2003-11-17 15:43:18 +03:00
( at your option ) any later version .
2007-11-27 11:35:10 +03:00
2003-11-17 15:43:18 +03: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 .
2007-11-27 11:35:10 +03:00
2003-11-17 15:43:18 +03:00
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2003-11-17 15:43:18 +03:00
*/
# include "includes.h"
2006-01-03 16:41:17 +03:00
# include "torture/torture.h"
2006-03-15 02:35:30 +03:00
# include "librpc/gen_ndr/ndr_wkssvc_c.h"
2010-04-14 00:06:51 +04:00
# include "torture/rpc/torture_rpc.h"
2020-12-02 19:24:22 +03:00
# include "lib/cmdline/cmdline.h"
2007-11-27 11:41:50 +03:00
# include "param/param.h"
2007-11-30 00:22:19 +03:00
# include "libcli/auth/libcli_auth.h"
2003-11-17 15:43:18 +03:00
2007-11-27 14:04:03 +03:00
# define SMBTORTURE_MACHINE_NAME "smbtrt_name"
2007-11-27 13:04:51 +03:00
# define SMBTORTURE_ALTERNATE_NAME "smbtrt_altname"
2007-11-27 11:49:19 +03:00
# define SMBTORTURE_TRANSPORT_NAME "\\Device\\smbtrt_transport_name"
2007-11-27 12:18:00 +03:00
# define SMBTORTURE_USE_NAME "S:"
2007-11-27 13:21:26 +03:00
# define SMBTORTURE_MESSAGE "You are currently tortured by Samba"
2007-11-27 11:49:19 +03:00
2007-11-27 11:35:10 +03:00
static bool test_NetWkstaGetInfo ( struct torture_context * tctx ,
2007-04-12 15:35:00 +04:00
struct dcerpc_pipe * p )
2003-11-17 15:43:18 +03:00
{
NTSTATUS status ;
2003-12-21 10:53:57 +03:00
struct wkssvc_NetWkstaGetInfo r ;
2006-07-26 16:25:16 +04:00
union wkssvc_NetWkstaInfo info ;
2004-05-25 21:24:24 +04:00
uint16_t levels [ ] = { 100 , 101 , 102 , 502 } ;
2003-11-18 04:18:24 +03:00
int i ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2003-11-17 15:43:18 +03:00
r . in . server_name = dcerpc_server_name ( p ) ;
2006-07-26 16:25:16 +04:00
r . out . info = & info ;
2003-11-17 15:43:18 +03:00
2003-11-18 04:18:24 +03:00
for ( i = 0 ; i < ARRAY_SIZE ( levels ) ; i + + ) {
r . in . level = levels [ i ] ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetWkstaGetInfo level %u \n " ,
2007-11-27 14:56:10 +03:00
r . in . level ) ;
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetWkstaGetInfo_r ( b , tctx , & r ) ;
2007-11-27 11:35:10 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
2007-11-27 14:56:10 +03:00
talloc_asprintf ( tctx , " NetWkstaGetInfo level %u failed " ,
r . in . level ) ) ;
2007-11-27 11:35:10 +03:00
torture_assert_werr_ok ( tctx , r . out . result ,
2007-11-27 14:56:10 +03:00
talloc_asprintf ( tctx , " NetWkstaGetInfo level %u failed " ,
r . in . level ) ) ;
2003-11-17 15:43:18 +03:00
}
2006-10-16 17:06:41 +04:00
return true ;
2003-11-17 15:43:18 +03:00
}
2006-10-16 17:06:41 +04:00
static bool test_NetWkstaTransportEnum ( struct torture_context * tctx ,
2007-04-12 15:35:00 +04:00
struct dcerpc_pipe * p )
2003-11-18 06:28:01 +03:00
{
NTSTATUS status ;
2003-12-21 10:53:57 +03:00
struct wkssvc_NetWkstaTransportEnum r ;
2004-05-25 20:24:13 +04:00
uint32_t resume_handle = 0 ;
2007-11-27 11:49:19 +03:00
struct wkssvc_NetWkstaTransportInfo info ;
2005-12-06 06:53:51 +03:00
union wkssvc_NetWkstaTransportCtr ctr ;
2003-12-21 10:53:57 +03:00
struct wkssvc_NetWkstaTransportCtr0 ctr0 ;
2007-11-27 11:49:19 +03:00
uint32_t total_entries = 0 ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2003-11-18 06:28:01 +03:00
2003-12-21 10:53:57 +03:00
ZERO_STRUCT ( ctr0 ) ;
2005-12-06 06:53:51 +03:00
ctr . ctr0 = & ctr0 ;
2003-11-18 06:28:01 +03:00
2007-11-27 11:49:19 +03:00
info . level = 0 ;
info . ctr = ctr ;
2003-11-18 06:28:01 +03:00
r . in . server_name = dcerpc_server_name ( p ) ;
2007-11-27 11:49:19 +03:00
r . in . info = & info ;
2004-05-25 20:24:13 +04:00
r . in . max_buffer = ( uint32_t ) - 1 ;
2003-11-18 06:28:01 +03:00
r . in . resume_handle = & resume_handle ;
2007-11-27 11:49:19 +03:00
r . out . total_entries = & total_entries ;
r . out . info = & info ;
2003-11-18 06:28:01 +03:00
r . out . resume_handle = & resume_handle ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetWkstaTransportEnum level 0 \n " ) ;
2007-11-27 11:49:19 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetWkstaTransportEnum_r ( b , tctx , & r ) ;
2007-11-27 11:49:19 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetWkstaTransportEnum failed " ) ;
2007-11-27 11:35:10 +03:00
torture_assert_werr_ok ( tctx , r . out . result , talloc_asprintf ( tctx ,
2007-11-27 11:49:19 +03:00
" NetWkstaTransportEnum level %u failed " ,
info . level ) ) ;
return true ;
}
static bool test_NetrWkstaTransportAdd ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrWkstaTransportAdd r ;
struct wkssvc_NetWkstaTransportInfo0 info0 ;
uint32_t parm_err = 0 ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 11:49:19 +03:00
ZERO_STRUCT ( info0 ) ;
info0 . quality_of_service = 0xffff ;
info0 . vc_count = 0 ;
info0 . name = SMBTORTURE_TRANSPORT_NAME ;
info0 . address = " 000000000000 " ;
info0 . wan_link = 0x400 ;
r . in . server_name = dcerpc_server_name ( p ) ;
r . in . level = 0 ;
r . in . info0 = & info0 ;
r . in . parm_err = r . out . parm_err = & parm_err ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrWkstaTransportAdd level 0 \n " ) ;
2007-11-27 11:49:19 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrWkstaTransportAdd_r ( b , tctx , & r ) ;
2007-11-27 11:49:19 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrWkstaTransportAdd failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result ,
2015-12-03 17:24:27 +03:00
WERR_INVALID_PARAMETER ,
2007-11-27 11:49:19 +03:00
" NetrWkstaTransportAdd level 0 failed " ) ;
return true ;
}
static bool test_NetrWkstaTransportDel ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrWkstaTransportDel r ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 11:49:19 +03:00
r . in . server_name = dcerpc_server_name ( p ) ;
r . in . transport_name = SMBTORTURE_TRANSPORT_NAME ;
r . in . unknown3 = 0 ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrWkstaTransportDel \n " ) ;
2007-11-27 11:49:19 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrWkstaTransportDel_r ( b , tctx , & r ) ;
2007-11-27 11:49:19 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrWkstaTransportDel failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetrWkstaTransportDel " ) ;
2003-11-18 06:28:01 +03:00
2006-10-16 17:06:41 +04:00
return true ;
2003-11-18 06:28:01 +03:00
}
2007-11-27 11:35:10 +03:00
static bool test_NetWkstaEnumUsers ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetWkstaEnumUsers r ;
uint32_t handle = 0 ;
uint32_t entries_read = 0 ;
struct wkssvc_NetWkstaEnumUsersInfo info ;
struct wkssvc_NetWkstaEnumUsersCtr0 * user0 ;
struct wkssvc_NetWkstaEnumUsersCtr1 * user1 ;
uint32_t levels [ ] = { 0 , 1 } ;
int i ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 11:35:10 +03:00
for ( i = 0 ; i < ARRAY_SIZE ( levels ) ; i + + ) {
ZERO_STRUCT ( info ) ;
info . level = levels [ i ] ;
switch ( info . level ) {
case 0 :
user0 = talloc_zero ( tctx ,
struct wkssvc_NetWkstaEnumUsersCtr0 ) ;
info . ctr . user0 = user0 ;
break ;
case 1 :
user1 = talloc_zero ( tctx ,
struct wkssvc_NetWkstaEnumUsersCtr1 ) ;
info . ctr . user1 = user1 ;
break ;
default :
break ;
}
r . in . server_name = dcerpc_server_name ( p ) ;
r . in . prefmaxlen = ( uint32_t ) - 1 ;
r . in . info = r . out . info = & info ;
r . in . resume_handle = r . out . resume_handle = & handle ;
r . out . entries_read = & entries_read ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetWkstaEnumUsers level %u \n " ,
2007-11-27 11:35:10 +03:00
levels [ i ] ) ;
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetWkstaEnumUsers_r ( b , tctx , & r ) ;
2007-11-27 11:35:10 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetWkstaEnumUsers failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetWkstaEnumUsers failed " ) ;
}
return true ;
}
2007-11-27 11:41:50 +03:00
static bool test_NetrWkstaUserGetInfo ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrWkstaUserGetInfo r ;
union wkssvc_NetrWkstaUserInfo info ;
2010-07-16 08:32:42 +04:00
const char * dom = lpcfg_workgroup ( tctx - > lp_ctx ) ;
2020-12-02 19:24:22 +03:00
struct cli_credentials * creds = samba_cmdline_get_creds ( ) ;
2007-11-27 11:41:50 +03:00
const char * user = cli_credentials_get_username ( creds ) ;
int i ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 11:41:50 +03:00
const struct {
const char * unknown ;
uint32_t level ;
WERROR result ;
} tests [ ] = {
{ NULL , 0 , WERR_NO_SUCH_LOGON_SESSION } ,
{ NULL , 1 , WERR_NO_SUCH_LOGON_SESSION } ,
{ NULL , 1101 , WERR_OK } ,
2015-12-03 17:24:27 +03:00
{ dom , 0 , WERR_INVALID_PARAMETER } ,
{ dom , 1 , WERR_INVALID_PARAMETER } ,
{ dom , 1101 , WERR_INVALID_PARAMETER } ,
{ user , 0 , WERR_INVALID_PARAMETER } ,
{ user , 1 , WERR_INVALID_PARAMETER } ,
{ user , 1101 , WERR_INVALID_PARAMETER } ,
2007-11-27 11:41:50 +03:00
} ;
for ( i = 0 ; i < ARRAY_SIZE ( tests ) ; i + + ) {
r . in . unknown = tests [ i ] . unknown ;
r . in . level = tests [ i ] . level ;
r . out . info = & info ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrWkstaUserGetInfo level %u \n " ,
2007-11-27 11:41:50 +03:00
r . in . level ) ;
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrWkstaUserGetInfo_r ( b , tctx , & r ) ;
2007-11-27 11:41:50 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrWkstaUserGetInfo failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result ,
tests [ i ] . result ,
" NetrWkstaUserGetInfo failed " ) ;
}
return true ;
}
2007-11-27 12:07:00 +03:00
static bool test_NetrUseEnum ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrUseEnum r ;
uint32_t handle = 0 ;
uint32_t entries_read = 0 ;
struct wkssvc_NetrUseEnumInfo info ;
struct wkssvc_NetrUseEnumCtr0 * use0 ;
struct wkssvc_NetrUseEnumCtr1 * use1 ;
struct wkssvc_NetrUseEnumCtr2 * use2 ;
uint32_t levels [ ] = { 0 , 1 , 2 } ;
int i ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 12:07:00 +03:00
for ( i = 0 ; i < ARRAY_SIZE ( levels ) ; i + + ) {
ZERO_STRUCT ( info ) ;
info . level = levels [ i ] ;
switch ( info . level ) {
case 0 :
use0 = talloc_zero ( tctx , struct wkssvc_NetrUseEnumCtr0 ) ;
info . ctr . ctr0 = use0 ;
break ;
case 1 :
use1 = talloc_zero ( tctx , struct wkssvc_NetrUseEnumCtr1 ) ;
info . ctr . ctr1 = use1 ;
break ;
case 2 :
use2 = talloc_zero ( tctx , struct wkssvc_NetrUseEnumCtr2 ) ;
info . ctr . ctr2 = use2 ;
break ;
default :
break ;
}
r . in . server_name = talloc_asprintf ( tctx , " \\ \\ %s " , dcerpc_server_name ( p ) ) ;
r . in . prefmaxlen = ( uint32_t ) - 1 ;
r . in . info = r . out . info = & info ;
r . in . resume_handle = r . out . resume_handle = & handle ;
r . out . entries_read = & entries_read ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrUseEnum level %u \n " ,
2007-11-27 12:07:00 +03:00
levels [ i ] ) ;
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrUseEnum_r ( b , tctx , & r ) ;
2007-11-27 12:07:00 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrUseEnum failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetrUseEnum failed " ) ;
}
return true ;
}
2007-11-27 12:18:00 +03:00
static bool test_NetrUseAdd ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrUseAdd r ;
struct wkssvc_NetrUseInfo0 info0 ;
struct wkssvc_NetrUseInfo1 info1 ;
union wkssvc_NetrUseGetInfoCtr * ctr ;
uint32_t parm_err = 0 ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 12:18:00 +03:00
ctr = talloc ( tctx , union wkssvc_NetrUseGetInfoCtr ) ;
ZERO_STRUCT ( info0 ) ;
info0 . local = SMBTORTURE_USE_NAME ;
info0 . remote = " \\ \\ localhost \\ c$ " ;
ctr - > info0 = & info0 ;
r . in . server_name = talloc_asprintf ( tctx , " \\ \\ %s " , dcerpc_server_name ( p ) ) ;
r . in . level = 0 ;
r . in . ctr = ctr ;
r . in . parm_err = r . out . parm_err = & parm_err ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrUseAdd level %u \n " ,
2007-11-27 12:18:00 +03:00
r . in . level ) ;
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrUseAdd_r ( b , tctx , & r ) ;
2007-11-27 12:18:00 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrUseAdd failed " ) ;
2015-12-03 17:24:43 +03:00
torture_assert_werr_equal ( tctx , r . out . result , WERR_INVALID_LEVEL ,
2007-11-27 12:18:00 +03:00
" NetrUseAdd failed " ) ;
ZERO_STRUCT ( r ) ;
ZERO_STRUCT ( info1 ) ;
info1 . local = SMBTORTURE_USE_NAME ;
info1 . remote = " \\ \\ localhost \\ sysvol " ;
info1 . password = NULL ;
ctr - > info1 = & info1 ;
r . in . server_name = talloc_asprintf ( tctx , " \\ \\ %s " , dcerpc_server_name ( p ) ) ;
r . in . level = 1 ;
r . in . ctr = ctr ;
r . in . parm_err = r . out . parm_err = & parm_err ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrUseAdd level %u \n " ,
2007-11-27 12:18:00 +03:00
r . in . level ) ;
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrUseAdd_r ( b , tctx , & r ) ;
2007-11-27 12:18:00 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrUseAdd failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetrUseAdd failed " ) ;
return true ;
}
static bool test_NetrUseDel ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrUseDel r ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 12:18:00 +03:00
r . in . server_name = talloc_asprintf ( tctx , " \\ \\ %s " , dcerpc_server_name ( p ) ) ;
r . in . use_name = SMBTORTURE_USE_NAME ;
r . in . force_cond = 0 ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrUseDel \n " ) ;
2007-11-27 12:18:00 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrUseDel_r ( b , tctx , & r ) ;
2007-11-27 12:18:00 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrUseDel failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetrUseDel failed " ) ;
return true ;
}
2007-11-27 12:23:24 +03:00
static bool test_NetrUseGetInfo_level ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
const char * use_name ,
uint32_t level ,
WERROR werr )
{
NTSTATUS status ;
struct wkssvc_NetrUseGetInfo r ;
union wkssvc_NetrUseGetInfoCtr ctr ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 12:23:24 +03:00
ZERO_STRUCT ( ctr ) ;
r . in . server_name = talloc_asprintf ( tctx , " \\ \\ %s " , dcerpc_server_name ( p ) ) ;
r . in . use_name = use_name ;
r . in . level = level ;
r . out . ctr = & ctr ;
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrUseGetInfo_r ( b , tctx , & r ) ;
2007-11-27 12:23:24 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrUseGetInfo failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result , werr ,
" NetrUseGetInfo failed " ) ;
return true ;
}
static bool test_NetrUseGetInfo ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrUseEnum r ;
uint32_t handle = 0 ;
uint32_t entries_read = 0 ;
struct wkssvc_NetrUseEnumInfo info ;
struct wkssvc_NetrUseEnumCtr0 * use0 ;
uint32_t levels [ ] = { 0 , 1 , 2 } ;
const char * use_name = NULL ;
int i , k ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 12:23:24 +03:00
ZERO_STRUCT ( info ) ;
info . level = 0 ;
use0 = talloc_zero ( tctx , struct wkssvc_NetrUseEnumCtr0 ) ;
info . ctr . ctr0 = use0 ;
r . in . server_name = talloc_asprintf ( tctx , " \\ \\ %s " , dcerpc_server_name ( p ) ) ;
r . in . prefmaxlen = ( uint32_t ) - 1 ;
r . in . info = r . out . info = & info ;
r . in . resume_handle = r . out . resume_handle = & handle ;
r . out . entries_read = & entries_read ;
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrUseEnum_r ( b , tctx , & r ) ;
2007-11-27 12:23:24 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrUseEnum failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetrUseEnum failed " ) ;
for ( k = 0 ; k < r . out . info - > ctr . ctr0 - > count ; k + + ) {
use_name = r . out . info - > ctr . ctr0 - > array [ k ] . local ;
for ( i = 0 ; i < ARRAY_SIZE ( levels ) ; i + + ) {
if ( ! test_NetrUseGetInfo_level ( tctx , p , use_name ,
levels [ i ] ,
WERR_OK ) )
{
if ( levels [ i ] ! = 0 ) {
return false ;
}
}
}
use_name = r . out . info - > ctr . ctr0 - > array [ k ] . remote ;
for ( i = 0 ; i < ARRAY_SIZE ( levels ) ; i + + ) {
if ( ! test_NetrUseGetInfo_level ( tctx , p , use_name ,
levels [ i ] ,
2015-12-03 17:24:34 +03:00
WERR_NERR_USENOTFOUND ) )
2007-11-27 12:23:24 +03:00
{
if ( levels [ i ] ! = 0 ) {
return false ;
}
}
}
}
return true ;
}
2007-11-27 12:29:19 +03:00
static bool test_NetrLogonDomainNameAdd ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrLogonDomainNameAdd r ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 12:29:19 +03:00
2010-07-16 08:32:42 +04:00
r . in . domain_name = lpcfg_workgroup ( tctx - > lp_ctx ) ;
2007-11-27 12:29:19 +03:00
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrLogonDomainNameAdd \n " ) ;
2007-11-27 12:29:19 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrLogonDomainNameAdd_r ( b , tctx , & r ) ;
2007-11-27 12:29:19 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrLogonDomainNameAdd failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result , WERR_NOT_SUPPORTED ,
" NetrLogonDomainNameAdd failed " ) ;
return true ;
}
static bool test_NetrLogonDomainNameDel ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrLogonDomainNameDel r ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 12:29:19 +03:00
2010-07-16 08:32:42 +04:00
r . in . domain_name = lpcfg_workgroup ( tctx - > lp_ctx ) ;
2007-11-27 12:29:19 +03:00
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrLogonDomainNameDel \n " ) ;
2007-11-27 12:29:19 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrLogonDomainNameDel_r ( b , tctx , & r ) ;
2007-11-27 12:29:19 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrLogonDomainNameDel failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result , WERR_NOT_SUPPORTED ,
" NetrLogonDomainNameDel failed " ) ;
return true ;
}
2007-11-27 12:42:50 +03:00
static bool test_NetrEnumerateComputerNames_level ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
2007-11-27 13:04:51 +03:00
uint16_t level ,
const char * * * names ,
2014-11-14 16:12:26 +03:00
size_t * num_names )
2007-11-27 12:42:50 +03:00
{
NTSTATUS status ;
struct wkssvc_NetrEnumerateComputerNames r ;
struct wkssvc_ComputerNamesCtr * ctr ;
2007-11-27 13:04:51 +03:00
int i ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 12:42:50 +03:00
ctr = talloc_zero ( tctx , struct wkssvc_ComputerNamesCtr ) ;
r . in . server_name = dcerpc_server_name ( p ) ;
r . in . name_type = level ;
r . in . Reserved = 0 ;
r . out . ctr = & ctr ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrEnumerateComputerNames level %u \n " ,
2007-11-27 12:42:50 +03:00
r . in . name_type ) ;
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrEnumerateComputerNames_r ( b , tctx , & r ) ;
2007-11-27 12:42:50 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrEnumerateComputerNames failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetrEnumerateComputerNames failed " ) ;
if ( ( level = = NetPrimaryComputerName ) & & ctr - > count ! = 1 ) {
torture_comment ( tctx ,
" NetrEnumerateComputerNames did not return one "
" name but %u \n " , ctr - > count ) ;
return false ;
}
2007-11-27 13:04:51 +03:00
if ( names & & num_names ) {
* num_names = 0 ;
* names = NULL ;
for ( i = 0 ; i < ctr - > count ; i + + ) {
if ( ! add_string_to_array ( tctx ,
ctr - > computer_name [ i ] . string ,
names ,
num_names ) )
{
return false ;
}
}
}
2007-11-27 12:42:50 +03:00
return true ;
}
static bool test_NetrEnumerateComputerNames ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
uint16_t levels [ ] = { 0 , 1 , 2 } ;
int i ;
for ( i = 0 ; i < ARRAY_SIZE ( levels ) ; i + + ) {
if ( ! test_NetrEnumerateComputerNames_level ( tctx ,
p ,
2007-11-27 13:04:51 +03:00
levels [ i ] ,
NULL , NULL ) )
2007-11-27 12:42:50 +03:00
{
return false ;
}
}
return true ;
}
2007-11-27 12:34:53 +03:00
static bool test_NetrValidateName ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrValidateName r ;
uint16_t levels [ ] = { 0 , 1 , 2 , 3 , 4 , 5 } ;
int i ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 12:34:53 +03:00
for ( i = 0 ; i < ARRAY_SIZE ( levels ) ; i + + ) {
r . in . server_name = talloc_asprintf ( tctx , " \\ \\ %s " , dcerpc_server_name ( p ) ) ;
2010-07-16 08:32:42 +04:00
r . in . name = lpcfg_workgroup ( tctx - > lp_ctx ) ;
2007-11-27 12:34:53 +03:00
r . in . Account = NULL ;
r . in . Password = NULL ;
r . in . name_type = levels [ i ] ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrValidateName level %u \n " ,
2007-11-27 12:34:53 +03:00
r . in . name_type ) ;
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrValidateName_r ( b , tctx , & r ) ;
2007-11-27 12:34:53 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrValidateName failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result ,
WERR_NOT_SUPPORTED ,
" NetrValidateName failed " ) ;
}
return true ;
}
static bool test_NetrValidateName2 ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrValidateName2 r ;
uint16_t levels [ ] = { 0 , 1 , 2 , 3 , 4 , 5 } ;
int i ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 12:34:53 +03:00
for ( i = 0 ; i < ARRAY_SIZE ( levels ) ; i + + ) {
r . in . server_name = talloc_asprintf ( tctx , " \\ \\ %s " , dcerpc_server_name ( p ) ) ;
2010-07-16 08:32:42 +04:00
r . in . name = lpcfg_workgroup ( tctx - > lp_ctx ) ;
2007-11-27 12:34:53 +03:00
r . in . Account = NULL ;
r . in . EncryptedPassword = NULL ;
r . in . name_type = levels [ i ] ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrValidateName2 level %u \n " ,
2007-11-27 12:34:53 +03:00
r . in . name_type ) ;
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrValidateName2_r ( b , tctx , & r ) ;
2007-11-27 12:34:53 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrValidateName2 failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result ,
2015-12-12 02:15:45 +03:00
W_ERROR ( HRES_ERROR_V ( HRES_RPC_E_REMOTE_DISABLED ) ) ,
2007-11-27 12:34:53 +03:00
" NetrValidateName2 failed " ) ;
}
return true ;
}
2007-11-27 13:04:51 +03:00
static bool test_NetrAddAlternateComputerName ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrAddAlternateComputerName r ;
const char * * names = NULL ;
2014-11-14 16:12:26 +03:00
size_t num_names = 0 ;
2007-11-27 13:04:51 +03:00
int i ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 13:04:51 +03:00
r . in . server_name = dcerpc_server_name ( p ) ;
r . in . NewAlternateMachineName = SMBTORTURE_ALTERNATE_NAME ;
r . in . Account = NULL ;
r . in . EncryptedPassword = NULL ;
r . in . Reserved = 0 ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrAddAlternateComputerName \n " ) ;
2007-11-27 13:04:51 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrAddAlternateComputerName_r ( b , tctx , & r ) ;
2007-11-27 13:04:51 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrAddAlternateComputerName failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetrAddAlternateComputerName failed " ) ;
if ( ! test_NetrEnumerateComputerNames_level ( tctx , p ,
NetAlternateComputerNames ,
& names , & num_names ) )
{
return false ;
}
for ( i = 0 ; i < num_names ; i + + ) {
if ( strequal ( names [ i ] , SMBTORTURE_ALTERNATE_NAME ) ) {
return true ;
}
}
torture_comment ( tctx , " new alternate name not set \n " ) ;
return false ;
}
static bool test_NetrRemoveAlternateComputerName ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrRemoveAlternateComputerName r ;
const char * * names = NULL ;
2014-11-14 16:12:26 +03:00
size_t num_names = 0 ;
2007-11-27 13:04:51 +03:00
int i ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 13:04:51 +03:00
r . in . server_name = dcerpc_server_name ( p ) ;
r . in . AlternateMachineNameToRemove = SMBTORTURE_ALTERNATE_NAME ;
r . in . Account = NULL ;
r . in . EncryptedPassword = NULL ;
r . in . Reserved = 0 ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrRemoveAlternateComputerName \n " ) ;
2007-11-27 13:04:51 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrRemoveAlternateComputerName_r ( b , tctx , & r ) ;
2007-11-27 13:04:51 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrRemoveAlternateComputerName failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetrRemoveAlternateComputerName failed " ) ;
if ( ! test_NetrEnumerateComputerNames_level ( tctx , p ,
NetAlternateComputerNames ,
& names , & num_names ) )
{
return false ;
}
for ( i = 0 ; i < num_names ; i + + ) {
if ( strequal ( names [ i ] , SMBTORTURE_ALTERNATE_NAME ) ) {
return false ;
}
}
return true ;
}
2007-11-27 13:31:09 +03:00
static bool test_NetrSetPrimaryComputername_name ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
const char * name )
{
NTSTATUS status ;
struct wkssvc_NetrSetPrimaryComputername r ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 13:31:09 +03:00
r . in . server_name = dcerpc_server_name ( p ) ;
r . in . primary_name = name ;
r . in . Account = NULL ;
r . in . EncryptedPassword = NULL ;
r . in . Reserved = 0 ;
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrSetPrimaryComputername_r ( b , tctx , & r ) ;
2007-11-27 13:31:09 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrSetPrimaryComputername failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetrSetPrimaryComputername failed " ) ;
return true ;
}
static bool test_NetrSetPrimaryComputername ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
/*
add alternate ,
check if there
store old primary
set new primary ( alternate )
check if there
later : check if del is possible
set primary back to origin
check if there
del alternate
*/
const char * * names_o = NULL , * * names = NULL ;
2014-11-14 16:12:26 +03:00
size_t num_names_o = 0 , num_names = 0 ;
2007-11-27 13:31:09 +03:00
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrSetPrimaryComputername \n " ) ;
2007-11-27 13:31:09 +03:00
if ( ! test_NetrAddAlternateComputerName ( tctx , p ) ) {
return false ;
}
if ( ! test_NetrEnumerateComputerNames_level ( tctx , p ,
NetPrimaryComputerName ,
& names_o , & num_names_o ) )
{
return false ;
}
if ( num_names_o ! = 1 ) {
return false ;
}
if ( ! test_NetrSetPrimaryComputername_name ( tctx , p ,
SMBTORTURE_ALTERNATE_NAME ) )
{
return false ;
}
if ( ! test_NetrEnumerateComputerNames_level ( tctx , p ,
NetPrimaryComputerName ,
& names , & num_names ) )
{
return false ;
}
if ( num_names ! = 1 ) {
return false ;
}
if ( ! strequal ( names [ 0 ] , SMBTORTURE_ALTERNATE_NAME ) ) {
torture_comment ( tctx ,
" name mismatch (%s != %s) after NetrSetPrimaryComputername! \n " ,
names [ 0 ] , SMBTORTURE_ALTERNATE_NAME ) ;
/*return false */ ;
}
if ( ! test_NetrSetPrimaryComputername_name ( tctx , p ,
names_o [ 0 ] ) )
{
return false ;
}
if ( ! test_NetrRemoveAlternateComputerName ( tctx , p ) ) {
return false ;
}
return true ;
}
2007-11-27 14:04:03 +03:00
static bool test_NetrRenameMachineInDomain ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrRenameMachineInDomain r ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 14:04:03 +03:00
r . in . server_name = dcerpc_server_name ( p ) ;
r . in . NewMachineName = SMBTORTURE_MACHINE_NAME ;
r . in . Account = NULL ;
r . in . password = NULL ;
r . in . RenameOptions = 0 ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrRenameMachineInDomain \n " ) ;
2007-11-27 14:04:03 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrRenameMachineInDomain_r ( b , tctx , & r ) ;
2007-11-27 14:04:03 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrRenameMachineInDomain failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result , WERR_NOT_SUPPORTED ,
" NetrRenameMachineInDomain failed " ) ;
return true ;
}
static bool test_NetrRenameMachineInDomain2_name ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
const char * new_name )
{
NTSTATUS status ;
struct wkssvc_NetrRenameMachineInDomain2 r ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 14:04:03 +03:00
r . in . server_name = dcerpc_server_name ( p ) ;
r . in . NewMachineName = new_name ;
r . in . Account = NULL ;
r . in . EncryptedPassword = NULL ;
r . in . RenameOptions = 0 ;
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrRenameMachineInDomain2_r ( b , tctx , & r ) ;
2007-11-27 14:04:03 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrRenameMachineInDomain2 failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetrRenameMachineInDomain2 failed " ) ;
return true ;
}
static bool test_NetrRenameMachineInDomain2 ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
const char * * names_o = NULL , * * names = NULL ;
2014-11-14 16:12:26 +03:00
size_t num_names_o = 0 , num_names = 0 ;
2007-11-27 14:04:03 +03:00
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrRenameMachineInDomain2 \n " ) ;
2007-11-27 14:04:03 +03:00
if ( ! test_NetrEnumerateComputerNames_level ( tctx , p ,
NetPrimaryComputerName ,
& names_o , & num_names_o ) )
{
return false ;
}
if ( num_names_o ! = 1 ) {
return false ;
}
if ( ! test_NetrRenameMachineInDomain2_name ( tctx , p ,
SMBTORTURE_MACHINE_NAME ) )
{
return false ;
}
if ( ! test_NetrEnumerateComputerNames_level ( tctx , p ,
NetPrimaryComputerName ,
& names , & num_names ) )
{
return false ;
}
if ( num_names ! = 1 ) {
return false ;
}
if ( strequal ( names [ 0 ] , names_o [ 0 ] ) ) {
test_NetrRenameMachineInDomain2_name ( tctx , p , names_o [ 0 ] ) ;
return false ;
}
if ( ! strequal ( names [ 0 ] , SMBTORTURE_MACHINE_NAME ) ) {
test_NetrRenameMachineInDomain2_name ( tctx , p , names_o [ 0 ] ) ;
return false ;
}
if ( ! test_NetrRenameMachineInDomain2_name ( tctx , p , names_o [ 0 ] ) )
{
return false ;
}
if ( ! test_NetrEnumerateComputerNames_level ( tctx , p ,
NetPrimaryComputerName ,
& names , & num_names ) )
{
return false ;
}
if ( num_names ! = 1 ) {
return false ;
}
if ( ! strequal ( names [ 0 ] , names_o [ 0 ] ) ) {
return false ;
}
return true ;
}
2007-11-27 13:31:09 +03:00
2007-11-27 13:14:51 +03:00
static bool test_NetrWorkstationStatisticsGet ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrWorkstationStatisticsGet r ;
struct wkssvc_NetrWorkstationStatistics * info ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 13:14:51 +03:00
ZERO_STRUCT ( r ) ;
info = talloc_zero ( tctx , struct wkssvc_NetrWorkstationStatistics ) ;
r . in . server_name = dcerpc_server_name ( p ) ;
r . out . info = & info ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrWorkstationStatisticsGet \n " ) ;
2007-11-27 13:14:51 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrWorkstationStatisticsGet_r ( b , tctx , & r ) ;
2007-11-27 13:14:51 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrWorkstationStatisticsGet failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetrWorkstationStatisticsGet failed " ) ;
return true ;
}
2007-11-27 13:20:34 +03:00
/* only succeeds as long as the local messenger service is running - Guenther */
static bool test_NetrMessageBufferSend ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrMessageBufferSend r ;
const char * message = SMBTORTURE_MESSAGE ;
size_t size ;
2009-10-30 14:13:21 +03:00
uint16_t * msg ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 13:20:34 +03:00
2009-10-30 14:13:21 +03:00
if ( ! push_ucs2_talloc ( tctx , & msg , message , & size ) ) {
return false ;
}
2007-11-27 13:20:34 +03:00
r . in . server_name = dcerpc_server_name ( p ) ;
r . in . message_name = dcerpc_server_name ( p ) ;
r . in . message_sender_name = dcerpc_server_name ( p ) ;
2009-10-30 14:13:21 +03:00
r . in . message_buffer = ( uint8_t * ) msg ;
2007-11-27 13:20:34 +03:00
r . in . message_size = size ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrMessageBufferSend \n " ) ;
2007-11-27 13:20:34 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrMessageBufferSend_r ( b , tctx , & r ) ;
2007-11-27 13:20:34 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrMessageBufferSend failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetrMessageBufferSend failed " ) ;
return true ;
}
2007-11-27 14:08:01 +03:00
static bool test_NetrGetJoinInformation ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrGetJoinInformation r ;
enum wkssvc_NetJoinStatus join_status ;
const char * name_buffer = " " ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 14:08:01 +03:00
r . in . server_name = dcerpc_server_name ( p ) ;
r . in . name_buffer = r . out . name_buffer = & name_buffer ;
r . out . name_type = & join_status ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrGetJoinInformation \n " ) ;
2007-11-27 14:08:01 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrGetJoinInformation_r ( b , tctx , & r ) ;
2007-11-27 14:08:01 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrGetJoinInformation failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetrGetJoinInformation failed " ) ;
return true ;
}
2007-11-30 01:09:37 +03:00
static bool test_GetJoinInformation ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
enum wkssvc_NetJoinStatus * join_status_p ,
const char * * name )
{
NTSTATUS status ;
struct wkssvc_NetrGetJoinInformation r ;
enum wkssvc_NetJoinStatus join_status ;
const char * name_buffer = " " ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-30 01:09:37 +03:00
r . in . server_name = dcerpc_server_name ( p ) ;
r . in . name_buffer = r . out . name_buffer = & name_buffer ;
r . out . name_type = & join_status ;
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrGetJoinInformation_r ( b , tctx , & r ) ;
2007-11-30 01:09:37 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrGetJoinInformation failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetrGetJoinInformation failed " ) ;
if ( join_status_p ) {
* join_status_p = join_status ;
}
if ( * name ) {
* name = talloc_strdup ( tctx , name_buffer ) ;
}
return true ;
}
2007-11-27 14:18:23 +03:00
static bool test_NetrGetJoinableOus ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrGetJoinableOus r ;
uint32_t num_ous = 0 ;
const char * * ous = NULL ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 14:18:23 +03:00
r . in . server_name = dcerpc_server_name ( p ) ;
2010-07-16 08:32:42 +04:00
r . in . domain_name = lpcfg_workgroup ( tctx - > lp_ctx ) ;
2007-11-27 14:18:23 +03:00
r . in . Account = NULL ;
r . in . unknown = NULL ;
r . in . num_ous = r . out . num_ous = & num_ous ;
r . out . ous = & ous ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrGetJoinableOus \n " ) ;
2007-11-27 14:18:23 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrGetJoinableOus_r ( b , tctx , & r ) ;
2007-11-27 14:18:23 +03:00
torture_assert_ntstatus_ok ( tctx , status , " NetrGetJoinableOus failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result ,
WERR_NOT_SUPPORTED ,
" NetrGetJoinableOus failed " ) ;
return true ;
}
static bool test_NetrGetJoinableOus2 ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrGetJoinableOus2 r ;
uint32_t num_ous = 0 ;
const char * * ous = NULL ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-27 14:18:23 +03:00
r . in . server_name = dcerpc_server_name ( p ) ;
2010-07-16 08:32:42 +04:00
r . in . domain_name = lpcfg_workgroup ( tctx - > lp_ctx ) ;
2007-11-27 14:18:23 +03:00
r . in . Account = NULL ;
r . in . EncryptedPassword = NULL ;
r . in . num_ous = r . out . num_ous = & num_ous ;
r . out . ous = & ous ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrGetJoinableOus2 \n " ) ;
2007-11-27 14:18:23 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrGetJoinableOus2_r ( b , tctx , & r ) ;
2007-11-27 14:18:23 +03:00
torture_assert_ntstatus_ok ( tctx , status , " NetrGetJoinableOus2 failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result ,
2015-12-12 02:15:45 +03:00
W_ERROR ( HRES_ERROR_V ( HRES_RPC_E_REMOTE_DISABLED ) ) ,
2007-11-27 14:18:23 +03:00
" NetrGetJoinableOus2 failed " ) ;
return true ;
}
2007-11-29 23:52:20 +03:00
static bool test_NetrUnjoinDomain ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrUnjoinDomain r ;
2020-12-02 19:24:22 +03:00
struct cli_credentials * creds = samba_cmdline_get_creds ( ) ;
2007-11-29 23:52:20 +03:00
const char * user = cli_credentials_get_username ( creds ) ;
const char * admin_account = NULL ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-29 23:52:20 +03:00
admin_account = talloc_asprintf ( tctx , " %s \\ %s " ,
2010-07-16 08:32:42 +04:00
lpcfg_workgroup ( tctx - > lp_ctx ) ,
2007-11-29 23:52:20 +03:00
user ) ;
r . in . server_name = dcerpc_server_name ( p ) ;
r . in . Account = admin_account ;
r . in . password = NULL ;
r . in . unjoin_flags = 0 ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrUnjoinDomain \n " ) ;
2007-11-29 23:52:20 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrUnjoinDomain_r ( b , tctx , & r ) ;
2007-11-29 23:52:20 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrUnjoinDomain failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result , WERR_NOT_SUPPORTED ,
" NetrUnjoinDomain failed " ) ;
return true ;
}
static bool test_NetrJoinDomain ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrJoinDomain r ;
2020-12-02 19:24:22 +03:00
struct cli_credentials * creds = samba_cmdline_get_creds ( ) ;
2007-11-29 23:52:20 +03:00
const char * user = cli_credentials_get_username ( creds ) ;
const char * admin_account = NULL ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-29 23:52:20 +03:00
admin_account = talloc_asprintf ( tctx , " %s \\ %s " ,
2010-07-16 08:32:42 +04:00
lpcfg_workgroup ( tctx - > lp_ctx ) ,
2007-11-29 23:52:20 +03:00
user ) ;
r . in . server_name = dcerpc_server_name ( p ) ;
2010-07-16 08:32:42 +04:00
r . in . domain_name = lpcfg_dnsdomain ( tctx - > lp_ctx ) ;
2007-11-29 23:52:20 +03:00
r . in . account_ou = NULL ;
r . in . Account = admin_account ;
r . in . password = NULL ;
r . in . join_flags = 0 ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrJoinDomain \n " ) ;
2007-11-29 23:52:20 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrJoinDomain_r ( b , tctx , & r ) ;
2007-11-29 23:52:20 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrJoinDomain failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result , WERR_NOT_SUPPORTED ,
" NetrJoinDomain failed " ) ;
return true ;
}
2007-11-30 11:49:20 +03:00
/*
* prerequisites for remotely joining an unjoined XP SP2 workstation :
* - firewall needs to be disabled ( or open for ncacn_np access )
* - HKLM \ System \ CurrentControlSet \ Control \ Lsa \ forceguest needs to 0
* see also :
* http : //support.microsoft.com/kb/294355/EN-US/ and
* http : //support.microsoft.com/kb/290403/EN-US/
*/
2007-11-30 01:09:37 +03:00
static bool test_NetrJoinDomain2 ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrJoinDomain2 r ;
const char * domain_admin_account = NULL ;
const char * domain_admin_password = NULL ;
2007-11-30 01:22:49 +03:00
const char * domain_name = NULL ;
2009-03-17 06:03:02 +03:00
struct wkssvc_PasswordBuffer * pwd_buf ;
2007-11-30 01:09:37 +03:00
enum wkssvc_NetJoinStatus join_status ;
const char * join_name = NULL ;
2007-11-30 01:22:49 +03:00
WERROR expected_err ;
2019-05-29 16:50:45 +03:00
WERROR werr ;
2007-11-30 15:04:59 +03:00
DATA_BLOB session_key ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-30 01:09:37 +03:00
/* FIXME: this test assumes to join workstations / servers and does not
2015-12-03 17:24:39 +03:00
* handle DCs ( WERR_NERR_SETUPDOMAINCONTROLLER ) */
2007-11-30 01:09:37 +03:00
if ( ! test_GetJoinInformation ( tctx , p , & join_status , & join_name ) )
{
return false ;
}
switch ( join_status ) {
2008-10-15 19:04:19 +04:00
case NET_SETUP_DOMAIN_NAME :
2015-12-03 17:24:38 +03:00
expected_err = WERR_NERR_SETUPALREADYJOINED ;
2007-11-30 01:09:37 +03:00
break ;
2008-10-15 18:48:53 +04:00
case NET_SETUP_UNKNOWN_STATUS :
case NET_SETUP_UNJOINED :
case NET_SETUP_WORKGROUP_NAME :
2007-11-30 01:22:49 +03:00
default :
expected_err = WERR_OK ;
2007-11-30 01:09:37 +03:00
break ;
}
2007-12-03 00:32:11 +03:00
domain_admin_account = torture_setting_string ( tctx , " domain_admin_account " , NULL ) ;
2007-11-30 01:09:37 +03:00
2007-12-03 00:32:11 +03:00
domain_admin_password = torture_setting_string ( tctx , " domain_admin_password " , NULL ) ;
2007-11-30 01:09:37 +03:00
2007-12-03 00:32:11 +03:00
domain_name = torture_setting_string ( tctx , " domain_name " , NULL ) ;
2007-11-30 01:22:49 +03:00
if ( ( domain_admin_account = = NULL ) | |
( domain_admin_password = = NULL ) | |
( domain_name = = NULL ) ) {
torture_comment ( tctx , " not enough input parameter \n " ) ;
return false ;
}
2024-09-14 15:31:58 +03:00
status = dcerpc_binding_handle_transport_session_key ( b , tctx , & session_key ) ;
2007-11-30 15:04:59 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2007-11-30 01:09:37 +03:00
return false ;
}
2019-05-29 16:50:45 +03:00
werr = encode_wkssvc_join_password_buffer ( tctx ,
domain_admin_password ,
& session_key ,
& pwd_buf ) ;
if ( ! W_ERROR_IS_OK ( werr ) ) {
return false ;
}
2007-11-30 15:04:59 +03:00
2007-11-30 01:09:37 +03:00
r . in . server_name = dcerpc_server_name ( p ) ;
2007-11-30 01:22:49 +03:00
r . in . domain_name = domain_name ;
2007-11-30 01:09:37 +03:00
r . in . account_ou = NULL ;
r . in . admin_account = domain_admin_account ;
2009-03-17 06:03:02 +03:00
r . in . encrypted_password = pwd_buf ;
2007-11-30 01:09:37 +03:00
r . in . join_flags = WKSSVC_JOIN_FLAGS_JOIN_TYPE |
WKSSVC_JOIN_FLAGS_ACCOUNT_CREATE ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrJoinDomain2 (assuming non-DC) \n " ) ;
2007-11-30 01:09:37 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrJoinDomain2_r ( b , tctx , & r ) ;
2007-11-30 01:09:37 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrJoinDomain2 failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result , expected_err ,
" NetrJoinDomain2 failed " ) ;
2007-11-30 11:53:20 +03:00
if ( ! test_GetJoinInformation ( tctx , p , & join_status , & join_name ) )
{
return false ;
}
2008-10-15 19:04:19 +04:00
if ( join_status ! = NET_SETUP_DOMAIN_NAME ) {
2007-11-30 11:53:20 +03:00
torture_comment ( tctx ,
" Join verify failed: got %d \n " , join_status ) ;
return false ;
}
2007-11-30 01:09:37 +03:00
return true ;
}
2007-11-30 11:55:15 +03:00
static bool test_NetrUnjoinDomain2 ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrUnjoinDomain2 r ;
const char * domain_admin_account = NULL ;
const char * domain_admin_password = NULL ;
2009-03-17 06:03:02 +03:00
struct wkssvc_PasswordBuffer * pwd_buf ;
2007-11-30 11:55:15 +03:00
enum wkssvc_NetJoinStatus join_status ;
const char * join_name = NULL ;
WERROR expected_err ;
2019-05-29 16:50:45 +03:00
WERROR werr ;
2007-11-30 15:04:59 +03:00
DATA_BLOB session_key ;
2010-03-15 12:19:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-30 11:55:15 +03:00
/* FIXME: this test assumes to join workstations / servers and does not
2015-12-03 17:24:39 +03:00
* handle DCs ( WERR_NERR_SETUPDOMAINCONTROLLER ) */
2007-11-30 11:55:15 +03:00
if ( ! test_GetJoinInformation ( tctx , p , & join_status , & join_name ) )
{
return false ;
}
switch ( join_status ) {
2008-10-15 19:04:19 +04:00
case NET_SETUP_UNJOINED :
2015-12-03 17:24:39 +03:00
expected_err = WERR_NERR_SETUPNOTJOINED ;
2007-11-30 11:55:15 +03:00
break ;
2008-10-15 19:04:19 +04:00
case NET_SETUP_DOMAIN_NAME :
case NET_SETUP_UNKNOWN_STATUS :
case NET_SETUP_WORKGROUP_NAME :
2007-11-30 11:55:15 +03:00
default :
expected_err = WERR_OK ;
break ;
}
2007-12-03 00:32:11 +03:00
domain_admin_account = torture_setting_string ( tctx , " domain_admin_account " , NULL ) ;
2007-11-30 11:55:15 +03:00
2007-12-03 00:32:11 +03:00
domain_admin_password = torture_setting_string ( tctx , " domain_admin_password " , NULL ) ;
2007-11-30 11:55:15 +03:00
if ( ( domain_admin_account = = NULL ) | |
( domain_admin_password = = NULL ) ) {
torture_comment ( tctx , " not enough input parameter \n " ) ;
return false ;
}
2024-09-14 15:31:58 +03:00
status = dcerpc_binding_handle_transport_session_key ( b , tctx , & session_key ) ;
2007-11-30 15:04:59 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2007-11-30 11:55:15 +03:00
return false ;
}
2019-05-29 16:50:45 +03:00
werr = encode_wkssvc_join_password_buffer ( tctx ,
domain_admin_password ,
& session_key ,
& pwd_buf ) ;
if ( ! W_ERROR_IS_OK ( werr ) ) {
return false ;
}
2007-11-30 15:04:59 +03:00
2007-11-30 11:55:15 +03:00
r . in . server_name = dcerpc_server_name ( p ) ;
r . in . account = domain_admin_account ;
2009-03-17 06:03:02 +03:00
r . in . encrypted_password = pwd_buf ;
2007-11-30 11:55:15 +03:00
r . in . unjoin_flags = 0 ;
2010-04-11 03:39:06 +04:00
torture_comment ( tctx , " Testing NetrUnjoinDomain2 (assuming non-DC) \n " ) ;
2007-11-30 11:55:15 +03:00
2010-03-15 12:19:02 +03:00
status = dcerpc_wkssvc_NetrUnjoinDomain2_r ( b , tctx , & r ) ;
2007-11-30 11:55:15 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetrUnjoinDomain2 failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result , expected_err ,
" NetrUnjoinDomain2 failed " ) ;
if ( ! test_GetJoinInformation ( tctx , p , & join_status , & join_name ) )
{
return false ;
}
switch ( join_status ) {
2008-10-15 19:04:19 +04:00
case NET_SETUP_UNJOINED :
case NET_SETUP_WORKGROUP_NAME :
2007-11-30 11:55:15 +03:00
break ;
2008-10-15 19:04:19 +04:00
case NET_SETUP_UNKNOWN_STATUS :
case NET_SETUP_DOMAIN_NAME :
2007-11-30 11:55:15 +03:00
default :
torture_comment ( tctx ,
" Unjoin verify failed: got %d \n " , join_status ) ;
return false ;
}
return true ;
}
2007-08-28 23:03:08 +04:00
struct torture_suite * torture_rpc_wkssvc ( TALLOC_CTX * mem_ctx )
2003-11-17 15:43:18 +03:00
{
2006-10-16 17:06:41 +04:00
struct torture_suite * suite ;
2007-08-28 20:24:18 +04:00
struct torture_rpc_tcase * tcase ;
2007-11-27 13:31:09 +03:00
struct torture_test * test ;
2003-11-18 06:28:01 +03:00
2010-12-11 05:26:31 +03:00
suite = torture_suite_create ( mem_ctx , " wkssvc " ) ;
2007-04-12 15:35:00 +04:00
tcase = torture_suite_add_rpc_iface_tcase ( suite , " wkssvc " ,
2007-08-20 01:23:03 +04:00
& ndr_table_wkssvc ) ;
2003-11-22 11:11:32 +03:00
2007-11-27 11:35:10 +03:00
torture_rpc_tcase_add_test ( tcase , " NetWkstaGetInfo " ,
test_NetWkstaGetInfo ) ;
2007-11-27 11:49:19 +03:00
2007-11-27 11:35:10 +03:00
torture_rpc_tcase_add_test ( tcase , " NetWkstaTransportEnum " ,
2007-04-12 15:35:00 +04:00
test_NetWkstaTransportEnum ) ;
2007-11-27 11:49:19 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrWkstaTransportDel " ,
test_NetrWkstaTransportDel ) ;
torture_rpc_tcase_add_test ( tcase , " NetrWkstaTransportAdd " ,
test_NetrWkstaTransportAdd ) ;
2007-11-27 11:35:10 +03:00
torture_rpc_tcase_add_test ( tcase , " NetWkstaEnumUsers " ,
test_NetWkstaEnumUsers ) ;
2007-11-27 11:41:50 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrWkstaUserGetInfo " ,
test_NetrWkstaUserGetInfo ) ;
2007-11-27 11:35:10 +03:00
2007-11-27 12:18:00 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrUseDel " ,
test_NetrUseDel ) ;
2007-11-27 14:56:10 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrUseGetInfo " ,
test_NetrUseGetInfo ) ;
2007-11-27 12:07:00 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrUseEnum " ,
test_NetrUseEnum ) ;
2007-11-27 12:18:00 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrUseAdd " ,
test_NetrUseAdd ) ;
2007-11-27 12:07:00 +03:00
2007-11-27 12:34:53 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrValidateName " ,
test_NetrValidateName ) ;
torture_rpc_tcase_add_test ( tcase , " NetrValidateName2 " ,
test_NetrValidateName2 ) ;
2007-11-27 12:29:19 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrLogonDomainNameDel " ,
test_NetrLogonDomainNameDel ) ;
torture_rpc_tcase_add_test ( tcase , " NetrLogonDomainNameAdd " ,
test_NetrLogonDomainNameAdd ) ;
2007-11-27 13:04:51 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrRemoveAlternateComputerName " ,
test_NetrRemoveAlternateComputerName ) ;
torture_rpc_tcase_add_test ( tcase , " NetrAddAlternateComputerName " ,
test_NetrAddAlternateComputerName ) ;
2007-11-27 13:31:09 +03:00
test = torture_rpc_tcase_add_test ( tcase , " NetrSetPrimaryComputername " ,
test_NetrSetPrimaryComputername ) ;
test - > dangerous = true ;
2007-11-27 14:04:03 +03:00
test = torture_rpc_tcase_add_test ( tcase , " NetrRenameMachineInDomain " ,
test_NetrRenameMachineInDomain ) ;
test - > dangerous = true ;
test = torture_rpc_tcase_add_test ( tcase , " NetrRenameMachineInDomain2 " ,
test_NetrRenameMachineInDomain2 ) ;
test - > dangerous = true ;
2007-11-27 12:42:50 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrEnumerateComputerNames " ,
test_NetrEnumerateComputerNames ) ;
2007-11-27 12:29:19 +03:00
2007-11-30 01:09:37 +03:00
test = torture_rpc_tcase_add_test ( tcase , " NetrJoinDomain2 " ,
test_NetrJoinDomain2 ) ;
test - > dangerous = true ;
2007-11-30 11:55:15 +03:00
test = torture_rpc_tcase_add_test ( tcase , " NetrUnjoinDomain2 " ,
test_NetrUnjoinDomain2 ) ;
test - > dangerous = true ;
2007-11-30 01:09:37 +03:00
2007-11-29 23:52:20 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrJoinDomain " ,
test_NetrJoinDomain ) ;
test - > dangerous = true ;
torture_rpc_tcase_add_test ( tcase , " NetrUnjoinDomain " ,
test_NetrUnjoinDomain ) ;
test - > dangerous = true ;
2007-11-27 14:08:01 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrGetJoinInformation " ,
test_NetrGetJoinInformation ) ;
2007-11-27 14:18:23 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrGetJoinableOus " ,
test_NetrGetJoinableOus ) ;
torture_rpc_tcase_add_test ( tcase , " NetrGetJoinableOus2 " ,
test_NetrGetJoinableOus2 ) ;
2007-11-27 14:08:01 +03:00
2007-11-27 13:14:51 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrWorkstationStatisticsGet " ,
test_NetrWorkstationStatisticsGet ) ;
2007-11-27 13:20:34 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrMessageBufferSend " ,
test_NetrMessageBufferSend ) ;
2007-11-27 13:14:51 +03:00
2006-10-16 17:06:41 +04:00
return suite ;
2003-11-17 15:43:18 +03:00
}