LCOV - code coverage report
Current view: top level - source3/lib/netapi - wkstainfo.c (source / functions) Hit Total Coverage
Test: coverage report for master 98b443d9 Lines: 0 65 0.0 %
Date: 2024-05-31 13:13:24 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /*
       2             :  *  Unix SMB/CIFS implementation.
       3             :  *  NetApi Workstation Support
       4             :  *  Copyright (C) Guenther Deschner 2007
       5             :  *  Copyright (C) Hans Leidekker 2013
       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, see <http://www.gnu.org/licenses/>.
      19             :  */
      20             : 
      21             : #include "includes.h"
      22             : 
      23             : #include "librpc/gen_ndr/libnetapi.h"
      24             : #include "lib/netapi/netapi.h"
      25             : #include "lib/netapi/netapi_private.h"
      26             : #include "lib/netapi/libnetapi.h"
      27             : #include "../librpc/gen_ndr/ndr_wkssvc_c.h"
      28             : #include "lib/smbconf/smbconf.h"
      29             : #include "lib/smbconf/smbconf_reg.h"
      30             : 
      31             : /****************************************************************
      32             : ****************************************************************/
      33             : 
      34           0 : WERROR NetWkstaGetInfo_l(struct libnetapi_ctx *ctx,
      35             :                          struct NetWkstaGetInfo *r)
      36             : {
      37           0 :         LIBNETAPI_REDIRECT_TO_LOCALHOST(ctx, r, NetWkstaGetInfo);
      38             : }
      39             : 
      40             : /****************************************************************
      41             : ****************************************************************/
      42             : 
      43           0 : static NTSTATUS map_wksta_info_to_WKSTA_INFO_buffer(TALLOC_CTX *mem_ctx,
      44             :                                                     uint32_t level,
      45             :                                                     union wkssvc_NetWkstaInfo *i,
      46             :                                                     uint8_t **buffer)
      47             : {
      48           0 :         struct WKSTA_INFO_100 i100;
      49           0 :         struct WKSTA_INFO_101 i101;
      50           0 :         struct WKSTA_INFO_102 i102;
      51           0 :         uint32_t num_info = 0;
      52             : 
      53           0 :         switch (level) {
      54           0 :         case 100:
      55           0 :                 i100.wki100_platform_id         = i->info100->platform_id;
      56           0 :                 i100.wki100_computername        = talloc_strdup(mem_ctx, i->info100->server_name);
      57           0 :                 i100.wki100_langroup            = talloc_strdup(mem_ctx, i->info100->domain_name);
      58           0 :                 i100.wki100_ver_major           = i->info100->version_major;
      59           0 :                 i100.wki100_ver_minor           = i->info100->version_minor;
      60             : 
      61           0 :                 ADD_TO_ARRAY(mem_ctx, struct WKSTA_INFO_100, i100,
      62             :                              (struct WKSTA_INFO_100 **)buffer,
      63             :                              &num_info);
      64           0 :                 break;
      65             : 
      66           0 :         case 101:
      67           0 :                 i101.wki101_platform_id         = i->info101->platform_id;
      68           0 :                 i101.wki101_computername        = talloc_strdup(mem_ctx, i->info101->server_name);
      69           0 :                 i101.wki101_langroup            = talloc_strdup(mem_ctx, i->info101->domain_name);
      70           0 :                 i101.wki101_ver_major           = i->info101->version_major;
      71           0 :                 i101.wki101_ver_minor           = i->info101->version_minor;
      72           0 :                 i101.wki101_lanroot             = talloc_strdup(mem_ctx, i->info101->lan_root);
      73             : 
      74           0 :                 ADD_TO_ARRAY(mem_ctx, struct WKSTA_INFO_101, i101,
      75             :                              (struct WKSTA_INFO_101 **)buffer,
      76             :                              &num_info);
      77           0 :                 break;
      78             : 
      79           0 :         case 102:
      80           0 :                 i102.wki102_platform_id         = i->info102->platform_id;
      81           0 :                 i102.wki102_computername        = talloc_strdup(mem_ctx, i->info102->server_name);
      82           0 :                 i102.wki102_langroup            = talloc_strdup(mem_ctx, i->info102->domain_name);
      83           0 :                 i102.wki102_ver_major           = i->info102->version_major;
      84           0 :                 i102.wki102_ver_minor           = i->info102->version_minor;
      85           0 :                 i102.wki102_lanroot             = talloc_strdup(mem_ctx, i->info102->lan_root);
      86           0 :                 i102.wki102_logged_on_users     = i->info102->logged_on_users;
      87             : 
      88           0 :                 ADD_TO_ARRAY(mem_ctx, struct WKSTA_INFO_102, i102,
      89             :                              (struct WKSTA_INFO_102 **)buffer,
      90             :                              &num_info);
      91           0 :                 break;
      92             : 
      93           0 :         default:
      94           0 :                 return NT_STATUS_NOT_SUPPORTED;
      95             :         }
      96             : 
      97           0 :         return NT_STATUS_OK;
      98             : }
      99             : 
     100             : /****************************************************************
     101             : ****************************************************************/
     102             : 
     103           0 : WERROR NetWkstaGetInfo_r(struct libnetapi_ctx *ctx,
     104             :                          struct NetWkstaGetInfo *r)
     105             : {
     106           0 :         NTSTATUS status;
     107           0 :         WERROR werr;
     108           0 :         union wkssvc_NetWkstaInfo info;
     109           0 :         struct dcerpc_binding_handle *b;
     110             : 
     111           0 :         if (!r->out.buffer) {
     112           0 :                 return WERR_INVALID_PARAMETER;
     113             :         }
     114             : 
     115           0 :         switch (r->in.level) {
     116           0 :                 case 100:
     117             :                 case 101:
     118             :                 case 102:
     119           0 :                         break;
     120           0 :                 default:
     121           0 :                         return WERR_INVALID_LEVEL;
     122             :         }
     123             : 
     124           0 :         werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     125             :                                             &ndr_table_wkssvc,
     126             :                                             &b);
     127           0 :         if (!W_ERROR_IS_OK(werr)) {
     128           0 :                 goto done;
     129             :         }
     130             : 
     131           0 :         status = dcerpc_wkssvc_NetWkstaGetInfo(b, talloc_tos(),
     132             :                                                r->in.server_name,
     133             :                                                r->in.level,
     134             :                                                &info,
     135             :                                                &werr);
     136           0 :         if (!NT_STATUS_IS_OK(status)) {
     137           0 :                 werr = ntstatus_to_werror(status);
     138           0 :                 goto done;
     139             :         }
     140             : 
     141           0 :         if (!W_ERROR_IS_OK(werr)) {
     142           0 :                 goto done;
     143             :         }
     144             : 
     145           0 :         status = map_wksta_info_to_WKSTA_INFO_buffer(ctx, r->in.level, &info,
     146             :                                                      r->out.buffer);
     147           0 :         if (!NT_STATUS_IS_OK(status)) {
     148           0 :                 werr = ntstatus_to_werror(status);
     149           0 :                 goto done;
     150             :         }
     151             : 
     152           0 :  done:
     153           0 :         return werr;
     154             : }

Generated by: LCOV version 1.14