LCOV - code coverage report
Current view: top level - source4/torture/rpc - dfs.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 11 273 4.0 %
Date: 2021-09-23 10:06:22 Functions: 1 25 4.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    test suite for rpc dfs operations
       4             : 
       5             :    Copyright (C) Andrew Tridgell 2003
       6             : 
       7             :    This program is free software; you can redistribute it and/or modify
       8             :    it under the terms of the GNU General Public License as published by
       9             :    the Free Software Foundation; either version 3 of the License, or
      10             :    (at your option) any later version.
      11             : 
      12             :    This program is distributed in the hope that it will be useful,
      13             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15             :    GNU General Public License for more details.
      16             : 
      17             :    You should have received a copy of the GNU General Public License
      18             :    along with this program; if not, write to the Free Software
      19             :    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
      20             : */
      21             : 
      22             : #include "includes.h"
      23             : #include "torture/rpc/torture_rpc.h"
      24             : #include "librpc/gen_ndr/ndr_dfs_c.h"
      25             : #include "libnet/libnet.h"
      26             : #include "torture/util.h"
      27             : #include "libcli/libcli.h"
      28             : #include "lib/cmdline/cmdline.h"
      29             : 
      30             : #define SMBTORTURE_DFS_SHARENAME "smbtorture_dfs_share"
      31             : #define SMBTORTURE_DFS_DIRNAME "\\smbtorture_dfs_dir"
      32             : #define SMBTORTURE_DFS_PATHNAME "C:"SMBTORTURE_DFS_DIRNAME
      33             : 
      34             : #define IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3(x,y)\
      35             :         if (x == DFS_MANAGER_VERSION_W2K3) {\
      36             :                 if (!W_ERROR_EQUAL(y,WERR_NOT_SUPPORTED)) {\
      37             :                         printf("expected WERR_NOT_SUPPORTED\n");\
      38             :                         return false;\
      39             :                 }\
      40             :                 return true;\
      41             :         }\
      42             : 
      43           0 : static bool test_NetShareAdd(struct torture_context *tctx,
      44             :                              const char *host,
      45             :                              const char *sharename,
      46             :                              const char *dir)
      47             : {
      48             :         NTSTATUS status;
      49             :         struct srvsvc_NetShareInfo2 i;
      50             :         struct libnet_context* libnetctx;
      51             :         struct libnet_AddShare r;
      52             : 
      53           0 :         printf("Creating share %s\n", sharename);
      54             : 
      55           0 :         if (!(libnetctx = libnet_context_init(tctx->ev, tctx->lp_ctx))) {
      56           0 :                 return false;
      57             :         }
      58             : 
      59           0 :         libnetctx->cred = samba_cmdline_get_creds();
      60             : 
      61           0 :         i.name                  = sharename;
      62           0 :         i.type                  = STYPE_DISKTREE;
      63           0 :         i.path                  = dir;
      64           0 :         i.max_users             = (uint32_t) -1;
      65           0 :         i.comment               = "created by smbtorture";
      66           0 :         i.password              = NULL;
      67           0 :         i.permissions           = 0x0;
      68           0 :         i.current_users         = 0x0;
      69             : 
      70           0 :         r.level                 = 2;
      71           0 :         r.in.server_name        = host;
      72           0 :         r.in.share              = i;
      73             : 
      74           0 :         status = libnet_AddShare(libnetctx, tctx, &r);
      75           0 :         if (!NT_STATUS_IS_OK(status)) {
      76           0 :                 d_printf("Failed to add new share: %s (%s)\n",
      77             :                         nt_errstr(status), r.out.error_string);
      78           0 :                 return false;
      79             :         }
      80             : 
      81           0 :         return true;
      82             : }
      83             : 
      84           0 : static bool test_NetShareDel(struct torture_context *tctx,
      85             :                              const char *host,
      86             :                              const char *sharename)
      87             : {
      88             :         NTSTATUS status;
      89             :         struct libnet_context* libnetctx;
      90             :         struct libnet_DelShare r;
      91             : 
      92           0 :         torture_comment(tctx, "Deleting share %s\n", sharename);
      93             : 
      94           0 :         if (!(libnetctx = libnet_context_init(tctx->ev, tctx->lp_ctx))) {
      95           0 :                 return false;
      96             :         }
      97             : 
      98           0 :         libnetctx->cred = samba_cmdline_get_creds();
      99             : 
     100           0 :         r.in.share_name         = sharename;
     101           0 :         r.in.server_name        = host;
     102             : 
     103           0 :         status = libnet_DelShare(libnetctx, tctx, &r);
     104           0 :         if (!NT_STATUS_IS_OK(status)) {
     105           0 :                 d_printf("Failed to delete share: %s (%s)\n",
     106             :                         nt_errstr(status), r.out.error_string);
     107           0 :                 return false;
     108             :         }
     109             : 
     110           0 :         return true;
     111             : }
     112             : 
     113           0 : static bool test_CreateDir(TALLOC_CTX *mem_ctx,
     114             :                            struct smbcli_state **cli,
     115             :                            struct torture_context *tctx,
     116             :                            const char *host,
     117             :                            const char *share,
     118             :                            const char *dir)
     119             : {
     120           0 :         printf("Creating directory %s\n", dir);
     121             : 
     122           0 :         if (!torture_open_connection_share(mem_ctx, cli, tctx, host, share, tctx->ev)) {
     123           0 :                 return false;
     124             :         }
     125             : 
     126           0 :         if (!torture_setup_dir(*cli, dir)) {
     127           0 :                 return false;
     128             :         }
     129             : 
     130           0 :         return true;
     131             : }
     132             : 
     133           0 : static bool test_DeleteDir(struct torture_context *tctx,
     134             :                            struct smbcli_state *cli,
     135             :                            const char *dir)
     136             : {
     137           0 :         torture_comment(tctx, "Deleting directory %s\n", dir);
     138             : 
     139           0 :         if (smbcli_deltree(cli->tree, dir) == -1) {
     140           0 :                 printf("Unable to delete dir %s - %s\n", dir,
     141             :                         smbcli_errstr(cli->tree));
     142           0 :                 return false;
     143             :         }
     144             : 
     145           0 :         return true;
     146             : }
     147             : 
     148           0 : static bool test_GetManagerVersion_opts(struct torture_context *tctx,
     149             :                                         struct dcerpc_binding_handle *b,
     150             :                                         enum dfs_ManagerVersion *version_p)
     151             : {
     152             :         struct dfs_GetManagerVersion r;
     153             :         enum dfs_ManagerVersion version;
     154             : 
     155           0 :         r.out.version = &version;
     156             : 
     157           0 :         torture_assert_ntstatus_ok(tctx,
     158             :                 dcerpc_dfs_GetManagerVersion_r(b, tctx, &r),
     159             :                 "GetManagerVersion failed");
     160             : 
     161           0 :         if (version_p) {
     162           0 :                 *version_p = version;
     163             :         }
     164             : 
     165           0 :         return true;
     166             : }
     167             : 
     168             : 
     169           0 : static bool test_GetManagerVersion(struct torture_context *tctx,
     170             :                                    struct dcerpc_pipe *p)
     171             : {
     172           0 :         struct dcerpc_binding_handle *b = p->binding_handle;
     173             : 
     174           0 :         return test_GetManagerVersion_opts(tctx, b, NULL);
     175             : }
     176             : 
     177           0 : static bool test_ManagerInitialize(struct torture_context *tctx,
     178             :                                    struct dcerpc_pipe *p)
     179             : {
     180             :         enum dfs_ManagerVersion version;
     181             :         struct dfs_ManagerInitialize r;
     182           0 :         struct dcerpc_binding_handle *b = p->binding_handle;
     183           0 :         const char *host = torture_setting_string(tctx, "host", NULL);
     184             : 
     185           0 :         torture_comment(tctx, "Testing ManagerInitialize\n");
     186             : 
     187           0 :         torture_assert(tctx,
     188             :                 test_GetManagerVersion_opts(tctx, b, &version),
     189             :                 "GetManagerVersion failed");
     190             : 
     191           0 :         r.in.servername = host;
     192           0 :         r.in.flags = 0;
     193             : 
     194           0 :         torture_assert_ntstatus_ok(tctx,
     195             :                 dcerpc_dfs_ManagerInitialize_r(b, tctx, &r),
     196             :                 "ManagerInitialize failed");
     197           0 :         if (!W_ERROR_IS_OK(r.out.result)) {
     198           0 :                 torture_warning(tctx, "dfs_ManagerInitialize failed - %s\n",
     199             :                         win_errstr(r.out.result));
     200           0 :                 IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3(version, r.out.result);
     201           0 :                 return false;
     202             :         }
     203             : 
     204           0 :         return true;
     205             : }
     206             : 
     207           0 : static bool test_GetInfoLevel(struct torture_context *tctx,
     208             :                               struct dcerpc_binding_handle *b,
     209             :                               uint16_t level,
     210             :                               const char *root)
     211             : {
     212             :         struct dfs_GetInfo r;
     213             :         union dfs_Info info;
     214             : 
     215           0 :         torture_comment(tctx, "Testing GetInfo level %u on '%s'\n", level, root);
     216             : 
     217           0 :         r.in.dfs_entry_path = root;
     218           0 :         r.in.servername = NULL;
     219           0 :         r.in.sharename = NULL;
     220           0 :         r.in.level = level;
     221           0 :         r.out.info = &info;
     222             : 
     223           0 :         torture_assert_ntstatus_ok(tctx,
     224             :                 dcerpc_dfs_GetInfo_r(b, tctx, &r),
     225             :                 "GetInfo failed");
     226             : 
     227           0 :         if (!W_ERROR_IS_OK(r.out.result) &&
     228           0 :             !W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result)) {
     229           0 :                 torture_warning(tctx, "dfs_GetInfo failed - %s\n", win_errstr(r.out.result));
     230           0 :                 return false;
     231             :         }
     232             : 
     233           0 :         return true;
     234             : }
     235             : 
     236           0 : static bool test_GetInfo(struct torture_context *tctx,
     237             :                          struct dcerpc_binding_handle *b,
     238             :                          const char *root)
     239             : {
     240           0 :         bool ret = true;
     241             :         /* 103, 104, 105, 106 is only available on Set */
     242           0 :         uint16_t levels[] = {1, 2, 3, 4, 5, 6, 7, 100, 101, 102, 103, 104, 105, 106};
     243             :         int i;
     244             : 
     245           0 :         for (i=0;i<ARRAY_SIZE(levels);i++) {
     246           0 :                 if (!test_GetInfoLevel(tctx, b, levels[i], root)) {
     247           0 :                         ret = false;
     248             :                 }
     249             :         }
     250           0 :         return ret;
     251             : }
     252             : 
     253           0 : static bool test_EnumLevelEx(struct torture_context *tctx,
     254             :                              struct dcerpc_binding_handle *b,
     255             :                              uint16_t level,
     256             :                              const char *dfs_name)
     257             : {
     258             :         struct dfs_EnumEx rex;
     259           0 :         uint32_t total=0;
     260             :         struct dfs_EnumStruct e;
     261             :         struct dfs_Info1 s;
     262             :         struct dfs_EnumArray1 e1;
     263           0 :         bool ret = true;
     264             : 
     265           0 :         rex.in.level = level;
     266           0 :         rex.in.bufsize = (uint32_t)-1;
     267           0 :         rex.in.total = &total;
     268           0 :         rex.in.info = &e;
     269           0 :         rex.in.dfs_name = dfs_name;
     270             : 
     271           0 :         e.level = rex.in.level;
     272           0 :         e.e.info1 = &e1;
     273           0 :         e.e.info1->count = 0;
     274           0 :         e.e.info1->s = &s;
     275           0 :         s.path = NULL;
     276             : 
     277           0 :         torture_comment(tctx, "Testing EnumEx level %u on '%s'\n", level, dfs_name);
     278             : 
     279           0 :         torture_assert_ntstatus_ok(tctx,
     280             :                 dcerpc_dfs_EnumEx_r(b, tctx, &rex),
     281             :                 "EnumEx failed");
     282           0 :         torture_assert_werr_ok(tctx, rex.out.result,
     283             :                 "EnumEx failed");
     284             : 
     285           0 :         if (level == 1 && rex.out.total) {
     286             :                 int i;
     287           0 :                 for (i=0;i<*rex.out.total;i++) {
     288           0 :                         const char *root = rex.out.info->e.info1->s[i].path;
     289           0 :                         if (!test_GetInfo(tctx, b, root)) {
     290           0 :                                 ret = false;
     291             :                         }
     292             :                 }
     293             :         }
     294             : 
     295           0 :         if (level == 300 && rex.out.total) {
     296             :                 int i,k;
     297           0 :                 for (i=0;i<*rex.out.total;i++) {
     298           0 :                         uint16_t levels[] = {1, 2, 3, 4, 200}; /* 300 */
     299           0 :                         const char *root = rex.out.info->e.info300->s[i].dom_root;
     300           0 :                         for (k=0;k<ARRAY_SIZE(levels);k++) {
     301           0 :                                 if (!test_EnumLevelEx(tctx, b,
     302           0 :                                                       levels[k], root))
     303             :                                 {
     304           0 :                                         ret = false;
     305             :                                 }
     306             :                         }
     307           0 :                         if (!test_GetInfo(tctx, b, root)) {
     308           0 :                                 ret = false;
     309             :                         }
     310             :                 }
     311             :         }
     312             : 
     313           0 :         return ret;
     314             : }
     315             : 
     316             : 
     317           0 : static bool test_EnumLevel(struct torture_context *tctx,
     318             :                            struct dcerpc_binding_handle *b,
     319             :                            uint16_t level)
     320             : {
     321             :         struct dfs_Enum r;
     322           0 :         uint32_t total=0;
     323             :         struct dfs_EnumStruct e;
     324             :         struct dfs_Info1 s;
     325             :         struct dfs_EnumArray1 e1;
     326           0 :         bool ret = true;
     327             : 
     328           0 :         r.in.level = level;
     329           0 :         r.in.bufsize = (uint32_t)-1;
     330           0 :         r.in.total = &total;
     331           0 :         r.in.info = &e;
     332             : 
     333           0 :         e.level = r.in.level;
     334           0 :         e.e.info1 = &e1;
     335           0 :         e.e.info1->count = 0;
     336           0 :         e.e.info1->s = &s;
     337           0 :         s.path = NULL;
     338             : 
     339           0 :         torture_comment(tctx, "Testing Enum level %u\n", level);
     340             : 
     341           0 :         torture_assert_ntstatus_ok(tctx,
     342             :                 dcerpc_dfs_Enum_r(b, tctx, &r),
     343             :                 "Enum failed");
     344             : 
     345           0 :         if (!W_ERROR_IS_OK(r.out.result) &&
     346           0 :             !W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result)) {
     347           0 :                 torture_warning(tctx, "dfs_Enum failed - %s\n", win_errstr(r.out.result));
     348           0 :                 return false;
     349             :         }
     350             : 
     351           0 :         if (level == 1 && r.out.total) {
     352             :                 int i;
     353           0 :                 for (i=0;i<*r.out.total;i++) {
     354           0 :                         const char *root = r.out.info->e.info1->s[i].path;
     355           0 :                         if (!test_GetInfo(tctx, b, root)) {
     356           0 :                                 ret = false;
     357             :                         }
     358             :                 }
     359             :         }
     360             : 
     361           0 :         return ret;
     362             : }
     363             : 
     364             : 
     365           0 : static bool test_Enum(struct torture_context *tctx,
     366             :                       struct dcerpc_pipe *p)
     367             : {
     368           0 :         bool ret = true;
     369           0 :         uint16_t levels[] = {1, 2, 3, 4, 5, 6, 200, 300};
     370             :         int i;
     371           0 :         struct dcerpc_binding_handle *b = p->binding_handle;
     372             : 
     373           0 :         for (i=0;i<ARRAY_SIZE(levels);i++) {
     374           0 :                 if (!test_EnumLevel(tctx, b, levels[i])) {
     375           0 :                         ret = false;
     376             :                 }
     377             :         }
     378             : 
     379           0 :         return ret;
     380             : }
     381             : 
     382           0 : static bool test_EnumEx(struct torture_context *tctx,
     383             :                         struct dcerpc_pipe *p)
     384             : {
     385           0 :         bool ret = true;
     386           0 :         uint16_t levels[] = {1, 2, 3, 4, 5, 6, 200, 300};
     387             :         int i;
     388           0 :         struct dcerpc_binding_handle *b = p->binding_handle;
     389           0 :         const char *host = torture_setting_string(tctx, "host", NULL);
     390             : 
     391           0 :         for (i=0;i<ARRAY_SIZE(levels);i++) {
     392           0 :                 if (!test_EnumLevelEx(tctx, b, levels[i], host)) {
     393           0 :                         ret = false;
     394             :                 }
     395             :         }
     396             : 
     397           0 :         return ret;
     398             : }
     399             : 
     400           0 : static bool test_RemoveStdRoot(struct torture_context *tctx,
     401             :                                struct dcerpc_binding_handle *b,
     402             :                                const char *host,
     403             :                                const char *sharename)
     404             : {
     405             :         struct dfs_RemoveStdRoot r;
     406             : 
     407           0 :         torture_comment(tctx, "Testing RemoveStdRoot\n");
     408             : 
     409           0 :         r.in.servername = host;
     410           0 :         r.in.rootshare  = sharename;
     411           0 :         r.in.flags      = 0;
     412             : 
     413           0 :         torture_assert_ntstatus_ok(tctx,
     414             :                 dcerpc_dfs_RemoveStdRoot_r(b, tctx, &r),
     415             :                 "RemoveStdRoot failed");
     416           0 :         torture_assert_werr_ok(tctx, r.out.result,
     417             :                 "dfs_RemoveStdRoot failed");
     418             : 
     419           0 :         return true;
     420             : }
     421             : 
     422           0 : static bool test_AddStdRoot(struct torture_context *tctx,
     423             :                             struct dcerpc_binding_handle *b,
     424             :                             const char *host,
     425             :                             const char *sharename)
     426             : {
     427             :         struct dfs_AddStdRoot r;
     428             : 
     429           0 :         torture_comment(tctx, "Testing AddStdRoot\n");
     430             : 
     431           0 :         r.in.servername = host;
     432           0 :         r.in.rootshare  = sharename;
     433           0 :         r.in.comment    = "standard dfs standalone DFS root created by smbtorture (dfs_AddStdRoot)";
     434           0 :         r.in.flags      = 0;
     435             : 
     436           0 :         torture_assert_ntstatus_ok(tctx,
     437             :                 dcerpc_dfs_AddStdRoot_r(b, tctx, &r),
     438             :                 "AddStdRoot failed");
     439           0 :         torture_assert_werr_ok(tctx, r.out.result,
     440             :                 "AddStdRoot failed");
     441             : 
     442           0 :         return true;
     443             : }
     444             : 
     445           0 : static bool test_AddStdRootForced(struct torture_context *tctx,
     446             :                                   struct dcerpc_binding_handle *b,
     447             :                                   const char *host,
     448             :                                   const char *sharename)
     449             : {
     450             :         struct dfs_AddStdRootForced r;
     451             :         enum dfs_ManagerVersion version;
     452             : 
     453           0 :         torture_comment(tctx, "Testing AddStdRootForced\n");
     454             : 
     455           0 :         torture_assert(tctx,
     456             :                 test_GetManagerVersion_opts(tctx, b, &version),
     457             :                 "GetManagerVersion failed");
     458             : 
     459           0 :         r.in.servername = host;
     460           0 :         r.in.rootshare  = sharename;
     461           0 :         r.in.comment    = "standard dfs forced standalone DFS root created by smbtorture (dfs_AddStdRootForced)";
     462           0 :         r.in.store      = SMBTORTURE_DFS_PATHNAME;
     463             : 
     464           0 :         torture_assert_ntstatus_ok(tctx,
     465             :                 dcerpc_dfs_AddStdRootForced_r(b, tctx, &r),
     466             :                 "AddStdRootForced failed");
     467           0 :         if (!W_ERROR_IS_OK(r.out.result)) {
     468           0 :                 torture_warning(tctx, "dfs_AddStdRootForced failed - %s\n",
     469             :                         win_errstr(r.out.result));
     470           0 :                 IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3(version, r.out.result);
     471           0 :                 return false;
     472             :         }
     473             : 
     474           0 :         return test_RemoveStdRoot(tctx, b, host, sharename);
     475             : }
     476             : 
     477           0 : static void test_cleanup_stdroot(struct torture_context *tctx,
     478             :                                  struct dcerpc_binding_handle *b,
     479             :                                  const char *host,
     480             :                                  const char *sharename,
     481             :                                  const char *dir)
     482             : {
     483             :         struct smbcli_state *cli;
     484             : 
     485           0 :         torture_comment(tctx, "Cleaning up StdRoot\n");
     486             : 
     487           0 :         test_RemoveStdRoot(tctx, b, host, sharename);
     488           0 :         test_NetShareDel(tctx, host, sharename);
     489           0 :         if (torture_open_connection_share(tctx, &cli, tctx, host, "C$", tctx->ev)) {
     490           0 :                 test_DeleteDir(tctx, cli, dir);
     491           0 :                 torture_close_connection(cli);
     492             :         }
     493           0 : }
     494             : 
     495           0 : static bool test_StdRoot(struct torture_context *tctx,
     496             :                          struct dcerpc_pipe *p)
     497             : {
     498           0 :         const char *sharename = SMBTORTURE_DFS_SHARENAME;
     499           0 :         const char *dir = SMBTORTURE_DFS_DIRNAME;
     500           0 :         const char *path = SMBTORTURE_DFS_PATHNAME;
     501             :         struct smbcli_state *cli;
     502           0 :         bool ret = true;
     503           0 :         const char *host = torture_setting_string(tctx, "host", NULL);
     504           0 :         struct dcerpc_binding_handle *b = p->binding_handle;
     505             : 
     506           0 :         torture_comment(tctx, "Testing StdRoot\n");
     507             : 
     508           0 :         test_cleanup_stdroot(tctx, b, host, sharename, dir);
     509             : 
     510           0 :         torture_assert(tctx,
     511             :                 test_CreateDir(tctx, &cli, tctx, host, "C$", dir),
     512             :                 "failed to connect C$ share and to create directory");
     513           0 :         torture_assert(tctx,
     514             :                 test_NetShareAdd(tctx, host, sharename, path),
     515             :                 "failed to create new share");
     516             : 
     517           0 :         ret &= test_AddStdRoot(tctx, b, host, sharename);
     518           0 :         ret &= test_RemoveStdRoot(tctx, b, host, sharename);
     519           0 :         ret &= test_AddStdRootForced(tctx, b, host, sharename);
     520           0 :         ret &= test_NetShareDel(tctx, host, sharename);
     521           0 :         ret &= test_DeleteDir(tctx, cli, dir);
     522             : 
     523           0 :         torture_close_connection(cli);
     524             : 
     525           0 :         return ret;
     526             : }
     527             : 
     528           0 : static bool test_GetDcAddress(struct torture_context *tctx,
     529             :                               struct dcerpc_binding_handle *b,
     530             :                               const char *host)
     531             : {
     532             :         struct dfs_GetDcAddress r;
     533           0 :         uint8_t is_root = 0;
     534           0 :         uint32_t ttl = 0;
     535             :         const char *ptr;
     536             : 
     537           0 :         torture_comment(tctx, "Testing GetDcAddress\n");
     538             : 
     539           0 :         ptr = host;
     540             : 
     541           0 :         r.in.servername = host;
     542           0 :         r.in.server_fullname = r.out.server_fullname = &ptr;
     543           0 :         r.in.is_root = r.out.is_root = &is_root;
     544           0 :         r.in.ttl = r.out.ttl = &ttl;
     545             : 
     546           0 :         torture_assert_ntstatus_ok(tctx,
     547             :                 dcerpc_dfs_GetDcAddress_r(b, tctx, &r),
     548             :                 "GetDcAddress failed");
     549           0 :         torture_assert_werr_ok(tctx, r.out.result,
     550             :                 "dfs_GetDcAddress failed");
     551             : 
     552           0 :         return true;
     553             : }
     554             : 
     555           0 : static bool test_SetDcAddress(struct torture_context *tctx,
     556             :                               struct dcerpc_binding_handle *b,
     557             :                               const char *host)
     558             : {
     559             :         struct dfs_SetDcAddress r;
     560             : 
     561           0 :         torture_comment(tctx, "Testing SetDcAddress\n");
     562             : 
     563           0 :         r.in.servername = host;
     564           0 :         r.in.server_fullname = host;
     565           0 :         r.in.flags = 0;
     566           0 :         r.in.ttl = 1000;
     567             : 
     568           0 :         torture_assert_ntstatus_ok(tctx,
     569             :                 dcerpc_dfs_SetDcAddress_r(b, tctx, &r),
     570             :                 "SetDcAddress failed");
     571           0 :         torture_assert_werr_ok(tctx, r.out.result,
     572             :                 "dfs_SetDcAddress failed");
     573             : 
     574           0 :         return true;
     575             : }
     576             : 
     577           0 : static bool test_DcAddress(struct torture_context *tctx,
     578             :                            struct dcerpc_pipe *p)
     579             : {
     580           0 :         const char *host = torture_setting_string(tctx, "host", NULL);
     581           0 :         struct dcerpc_binding_handle *b = p->binding_handle;
     582             : 
     583           0 :         if (!test_GetDcAddress(tctx, b, host)) {
     584           0 :                 return false;
     585             :         }
     586             : 
     587           0 :         if (!test_SetDcAddress(tctx, b, host)) {
     588           0 :                 return false;
     589             :         }
     590             : 
     591           0 :         return true;
     592             : }
     593             : 
     594           0 : static bool test_FlushFtTable(struct torture_context *tctx,
     595             :                               struct dcerpc_binding_handle *b,
     596             :                               const char *host,
     597             :                               const char *sharename)
     598             : {
     599             :         struct dfs_FlushFtTable r;
     600             :         enum dfs_ManagerVersion version;
     601             : 
     602           0 :         torture_comment(tctx, "Testing FlushFtTable\n");
     603             : 
     604           0 :         torture_assert(tctx,
     605             :                 test_GetManagerVersion_opts(tctx, b, &version),
     606             :                 "GetManagerVersion failed");
     607             : 
     608           0 :         r.in.servername = host;
     609           0 :         r.in.rootshare = sharename;
     610             : 
     611           0 :         torture_assert_ntstatus_ok(tctx,
     612             :                 dcerpc_dfs_FlushFtTable_r(b, tctx, &r),
     613             :                 "FlushFtTable failed");
     614           0 :         if (!W_ERROR_IS_OK(r.out.result)) {
     615           0 :                 torture_warning(tctx, "dfs_FlushFtTable failed - %s\n",
     616             :                         win_errstr(r.out.result));
     617           0 :                 IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3(version, r.out.result);
     618           0 :                 return false;
     619             :         }
     620             : 
     621           0 :         return true;
     622             : }
     623             : 
     624           0 : static bool test_FtRoot(struct torture_context *tctx,
     625             :                         struct dcerpc_pipe *p)
     626             : {
     627           0 :         const char *sharename = SMBTORTURE_DFS_SHARENAME;
     628           0 :         const char *host = torture_setting_string(tctx, "host", NULL);
     629           0 :         struct dcerpc_binding_handle *b = p->binding_handle;
     630             : 
     631           0 :         return test_FlushFtTable(tctx, b, host, sharename);
     632             : }
     633             : 
     634        2355 : struct torture_suite *torture_rpc_dfs(TALLOC_CTX *mem_ctx)
     635             : {
     636             :         struct torture_rpc_tcase *tcase;
     637        2355 :         struct torture_suite *suite = torture_suite_create(mem_ctx, "dfs");
     638             : 
     639        2355 :         tcase = torture_suite_add_rpc_iface_tcase(suite, "netdfs",
     640             :                                                   &ndr_table_netdfs);
     641             : 
     642        2355 :         torture_rpc_tcase_add_test(tcase, "GetManagerVersion", test_GetManagerVersion);
     643        2355 :         torture_rpc_tcase_add_test(tcase, "ManagerInitialize", test_ManagerInitialize);
     644        2355 :         torture_rpc_tcase_add_test(tcase, "Enum", test_Enum);
     645        2355 :         torture_rpc_tcase_add_test(tcase, "EnumEx", test_EnumEx);
     646        2355 :         torture_rpc_tcase_add_test(tcase, "StdRoot", test_StdRoot);
     647        2355 :         torture_rpc_tcase_add_test(tcase, "FtRoot", test_FtRoot);
     648        2355 :         torture_rpc_tcase_add_test(tcase, "DcAddress", test_DcAddress);
     649             : 
     650        2355 :         return suite;
     651             : }

Generated by: LCOV version 1.13