LCOV - code coverage report
Current view: top level - source4/rpc_server/srvsvc - dcesrv_srvsvc.c (source / functions) Hit Total Coverage
Test: coverage report for master 6248eab5 Lines: 573 1091 52.5 %
Date: 2021-08-25 13:27:56 Functions: 15 75 20.0 %

          Line data    Source code
       1             : /* 
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    endpoint server for the srvsvc pipe
       5             : 
       6             :    Copyright (C) Stefan (metze) Metzmacher 2004-2006
       7             :    
       8             :    This program is free software; you can redistribute it and/or modify
       9             :    it under the terms of the GNU General Public License as published by
      10             :    the Free Software Foundation; either version 3 of the License, or
      11             :    (at your option) any later version.
      12             :    
      13             :    This program is distributed in the hope that it will be useful,
      14             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :    GNU General Public License for more details.
      17             :    
      18             :    You should have received a copy of the GNU General Public License
      19             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      20             : */
      21             : 
      22             : #include "includes.h"
      23             : #include "ntvfs/ntvfs.h"
      24             : #include "rpc_server/dcerpc_server.h"
      25             : #include "librpc/gen_ndr/ndr_srvsvc.h"
      26             : #include "rpc_server/common/common.h"
      27             : #include "rpc_server/common/share.h"
      28             : #include "auth/auth.h"
      29             : #include "libcli/security/security.h"
      30             : #include "system/time.h"
      31             : #include "rpc_server/srvsvc/proto.h"
      32             : #include "param/param.h"
      33             : 
      34             : #undef strcasecmp
      35             : #undef strncasecmp
      36             : 
      37             : #define SRVSVC_CHECK_ADMIN_ACCESS do { \
      38             :         struct auth_session_info *si = dcesrv_call_session_info(dce_call); \
      39             :         struct security_token *t = si->security_token; \
      40             :         if (!security_token_has_builtin_administrators(t) && \
      41             :             !security_token_has_sid(t, &global_sid_Builtin_Server_Operators)) { \
      42             :                 return WERR_ACCESS_DENIED; \
      43             :         } \
      44             : } while (0)
      45             : 
      46             : /* 
      47             :   srvsvc_NetCharDevEnum 
      48             : */
      49           6 : static WERROR dcesrv_srvsvc_NetCharDevEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
      50             :                                       struct srvsvc_NetCharDevEnum *r)
      51             : {
      52           6 :         *r->out.totalentries = 0;
      53             : 
      54           6 :         switch (r->in.info_ctr->level) {
      55           3 :         case 0:
      56           3 :                 r->out.info_ctr->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetCharDevCtr0);
      57           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr0);
      58             : 
      59           3 :                 r->out.info_ctr->ctr.ctr0->count = 0;
      60           3 :                 r->out.info_ctr->ctr.ctr0->array = NULL;
      61             : 
      62           3 :                 return WERR_NOT_SUPPORTED;
      63             : 
      64           3 :         case 1:
      65           3 :                 r->out.info_ctr->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetCharDevCtr1);
      66           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr1);
      67             : 
      68           3 :                 r->out.info_ctr->ctr.ctr1->count = 0;
      69           3 :                 r->out.info_ctr->ctr.ctr1->array = NULL;
      70             : 
      71           3 :                 return WERR_NOT_SUPPORTED;
      72             : 
      73           0 :         default:
      74           0 :                 return WERR_INVALID_LEVEL;
      75             :         }
      76             : }
      77             : 
      78             : 
      79             : /* 
      80             :   srvsvc_NetCharDevGetInfo 
      81             : */
      82           0 : static WERROR dcesrv_srvsvc_NetCharDevGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
      83             :                        struct srvsvc_NetCharDevGetInfo *r)
      84             : {
      85           0 :         ZERO_STRUCTP(r->out.info);
      86             : 
      87           0 :         switch (r->in.level) {
      88           0 :         case 0:
      89             :         {
      90           0 :                 return WERR_NOT_SUPPORTED;
      91             :         }
      92           0 :         case 1:
      93             :         {
      94           0 :                 return WERR_NOT_SUPPORTED;
      95             :         }
      96           0 :         default:
      97           0 :                 return WERR_INVALID_LEVEL;
      98             :         }
      99             : }
     100             : 
     101             : 
     102             : /* 
     103             :   srvsvc_NetCharDevControl 
     104             : */
     105           0 : static WERROR dcesrv_srvsvc_NetCharDevControl(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     106             :                        struct srvsvc_NetCharDevControl *r)
     107             : {
     108           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
     109             : }
     110             : 
     111             : 
     112             : /* 
     113             :   srvsvc_NetCharDevQEnum 
     114             : */
     115           6 : static WERROR dcesrv_srvsvc_NetCharDevQEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     116             :                                      struct srvsvc_NetCharDevQEnum *r)
     117             : {
     118           6 :         *r->out.totalentries = 0;
     119             : 
     120           6 :         switch (r->in.info_ctr->level) {
     121           3 :         case 0:
     122             :         {
     123           3 :                 r->out.info_ctr->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetCharDevQCtr0);
     124           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr0);
     125             : 
     126           3 :                 r->out.info_ctr->ctr.ctr0->count = 0;
     127           3 :                 r->out.info_ctr->ctr.ctr0->array = NULL;
     128             : 
     129           3 :                 return WERR_NOT_SUPPORTED;
     130             :         }
     131           3 :         case 1:
     132             :         {
     133           3 :                 r->out.info_ctr->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetCharDevQCtr1);
     134           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr1);
     135             : 
     136           3 :                 r->out.info_ctr->ctr.ctr1->count = 0;
     137           3 :                 r->out.info_ctr->ctr.ctr1->array = NULL;
     138             : 
     139           3 :                 return WERR_NOT_SUPPORTED;
     140             :         }
     141           0 :         default:
     142           0 :                 return WERR_INVALID_LEVEL;
     143             :         }
     144             : }
     145             : 
     146             : 
     147             : /* 
     148             :   srvsvc_NetCharDevQGetInfo 
     149             : */
     150           0 : static WERROR dcesrv_srvsvc_NetCharDevQGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     151             :                                         struct srvsvc_NetCharDevQGetInfo *r)
     152             : {
     153           0 :         ZERO_STRUCTP(r->out.info);
     154             : 
     155           0 :         switch (r->in.level) {
     156           0 :         case 0:
     157             :         {
     158           0 :                 return WERR_NOT_SUPPORTED;
     159             :         }
     160           0 :         case 1:
     161             :         {
     162           0 :                 return WERR_NOT_SUPPORTED;
     163             :         }
     164           0 :         default:
     165           0 :                 return WERR_INVALID_LEVEL;
     166             :         }
     167             : }
     168             : 
     169             : 
     170             : /* 
     171             :   srvsvc_NetCharDevQSetInfo 
     172             : */
     173           0 : static WERROR dcesrv_srvsvc_NetCharDevQSetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     174             :                        struct srvsvc_NetCharDevQSetInfo *r)
     175             : {
     176           0 :         switch (r->in.level) {
     177           0 :         case 0:
     178             :         {
     179           0 :                 if (r->in.parm_error) {
     180           0 :                         r->out.parm_error = r->in.parm_error;
     181             :                 }
     182           0 :                 return WERR_NOT_SUPPORTED;
     183             :         }
     184           0 :         case 1:
     185             :         {
     186           0 :                 if (r->in.parm_error) {
     187           0 :                         r->out.parm_error = r->in.parm_error;
     188             :                 }
     189           0 :                 return WERR_NOT_SUPPORTED;
     190             :         }
     191           0 :         default:
     192           0 :                 return WERR_INVALID_LEVEL;
     193             :         }
     194             : }
     195             : 
     196             : 
     197             : /* 
     198             :   srvsvc_NetCharDevQPurge 
     199             : */
     200           0 : static WERROR dcesrv_srvsvc_NetCharDevQPurge(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     201             :                        struct srvsvc_NetCharDevQPurge *r)
     202             : {
     203           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
     204             : }
     205             : 
     206             : 
     207             : /* 
     208             :   srvsvc_NetCharDevQPurgeSelf 
     209             : */
     210           0 : static WERROR dcesrv_srvsvc_NetCharDevQPurgeSelf(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     211             :                                           struct srvsvc_NetCharDevQPurgeSelf *r)
     212             : {
     213           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);        
     214             : }
     215             : 
     216             : 
     217             : /* 
     218             :   srvsvc_NetConnEnum 
     219             : */
     220           6 : static WERROR dcesrv_srvsvc_NetConnEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     221             :                        struct srvsvc_NetConnEnum *r)
     222             : {
     223           6 :         *r->out.totalentries = 0;
     224             : 
     225           6 :         switch (r->in.info_ctr->level) {
     226           3 :         case 0:
     227             :         {
     228           3 :                 r->out.info_ctr->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetConnCtr0);
     229           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr0);
     230             : 
     231           3 :                 r->out.info_ctr->ctr.ctr0->count = 0;
     232           3 :                 r->out.info_ctr->ctr.ctr0->array = NULL;
     233             : 
     234           3 :                 return WERR_NOT_SUPPORTED;
     235             :         }
     236           3 :         case 1:
     237             :         {
     238           3 :                 r->out.info_ctr->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetConnCtr1);
     239           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr1);
     240             : 
     241           3 :                 r->out.info_ctr->ctr.ctr1->count = 0;
     242           3 :                 r->out.info_ctr->ctr.ctr1->array = NULL;
     243             : 
     244           3 :                 return WERR_NOT_SUPPORTED;
     245             :         }
     246           0 :         default:
     247           0 :                 return WERR_INVALID_LEVEL;
     248             :         }
     249             : }
     250             : 
     251             : 
     252             : /* 
     253             :   srvsvc_NetFileEnum 
     254             : */
     255           6 : static WERROR dcesrv_srvsvc_NetFileEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     256             :                                  struct srvsvc_NetFileEnum *r)
     257             : {
     258           6 :         *r->out.totalentries = 0;
     259             : 
     260           6 :         switch (r->in.info_ctr->level) {
     261           3 :         case 2:
     262             :         {
     263           3 :                 r->out.info_ctr->ctr.ctr2 = talloc(mem_ctx, struct srvsvc_NetFileCtr2);
     264           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr2);
     265             : 
     266           3 :                 r->out.info_ctr->ctr.ctr2->count = 0;
     267           3 :                 r->out.info_ctr->ctr.ctr2->array = NULL;
     268             : 
     269           3 :                 return WERR_NOT_SUPPORTED;
     270             :         }
     271           3 :         case 3:
     272             :         {
     273           3 :                 r->out.info_ctr->ctr.ctr3 = talloc(mem_ctx, struct srvsvc_NetFileCtr3);
     274           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr3);
     275             : 
     276           3 :                 r->out.info_ctr->ctr.ctr3->count = 0;
     277           3 :                 r->out.info_ctr->ctr.ctr3->array = NULL;
     278             : 
     279           3 :                 return WERR_NOT_SUPPORTED;
     280             :         }
     281           0 :         default:
     282           0 :                 return WERR_INVALID_LEVEL;
     283             :         }
     284             : }
     285             : 
     286             : 
     287             : /* 
     288             :   srvsvc_NetFileGetInfo 
     289             : */
     290           0 : static WERROR dcesrv_srvsvc_NetFileGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     291             :                                     struct srvsvc_NetFileGetInfo *r)
     292             : {
     293           0 :         ZERO_STRUCTP(r->out.info);
     294             : 
     295           0 :         switch (r->in.level) {
     296           0 :         case 2:
     297             :         {
     298           0 :                 return WERR_NOT_SUPPORTED;
     299             :         }
     300           0 :         case 3:
     301             :         {
     302           0 :                 return WERR_NOT_SUPPORTED;
     303             :         }
     304           0 :         default:
     305           0 :                 return WERR_INVALID_LEVEL;
     306             :         }
     307             : }
     308             : 
     309             : 
     310             : /* 
     311             :   srvsvc_NetFileClose 
     312             : */
     313           0 : static WERROR dcesrv_srvsvc_NetFileClose(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     314             :                        struct srvsvc_NetFileClose *r)
     315             : {
     316           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
     317             : }
     318             : 
     319             : 
     320             : /* 
     321             :   srvsvc_NetSessEnum 
     322             : */
     323          15 : static WERROR dcesrv_srvsvc_NetSessEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     324             :                        struct srvsvc_NetSessEnum *r)
     325             : {
     326          15 :         *r->out.totalentries = 0;
     327             : 
     328          15 :         switch (r->in.info_ctr->level) {
     329           3 :         case 0:
     330             :         {
     331           3 :                 r->out.info_ctr->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetSessCtr0);
     332           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr0);
     333             : 
     334           3 :                 r->out.info_ctr->ctr.ctr0->count = 0;
     335           3 :                 r->out.info_ctr->ctr.ctr0->array = NULL;
     336             : 
     337           3 :                 return WERR_NOT_SUPPORTED;
     338             :         }
     339           3 :         case 1:
     340             :         {
     341           3 :                 r->out.info_ctr->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetSessCtr1);
     342           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr1);
     343             : 
     344           3 :                 r->out.info_ctr->ctr.ctr1->count = 0;
     345           3 :                 r->out.info_ctr->ctr.ctr1->array = NULL;
     346             : 
     347           3 :                 return WERR_NOT_SUPPORTED;
     348             :         }
     349           3 :         case 2:
     350             :         {
     351           3 :                 r->out.info_ctr->ctr.ctr2 = talloc(mem_ctx, struct srvsvc_NetSessCtr2);
     352           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr2);
     353             : 
     354           3 :                 r->out.info_ctr->ctr.ctr2->count = 0;
     355           3 :                 r->out.info_ctr->ctr.ctr2->array = NULL;
     356             : 
     357           3 :                 return WERR_NOT_SUPPORTED;
     358             :         }
     359           3 :         case 10:
     360             :         {
     361           3 :                 r->out.info_ctr->ctr.ctr10 = talloc(mem_ctx, struct srvsvc_NetSessCtr10);
     362           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr10);
     363             : 
     364           3 :                 r->out.info_ctr->ctr.ctr10->count = 0;
     365           3 :                 r->out.info_ctr->ctr.ctr10->array = NULL;
     366             : 
     367           3 :                 return WERR_NOT_SUPPORTED;
     368             :         }
     369           3 :         case 502:
     370             :         {
     371           3 :                 r->out.info_ctr->ctr.ctr502 = talloc(mem_ctx, struct srvsvc_NetSessCtr502);
     372           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.info_ctr->ctr.ctr502);
     373             : 
     374           3 :                 r->out.info_ctr->ctr.ctr502->count = 0;
     375           3 :                 r->out.info_ctr->ctr.ctr502->array = NULL;
     376             : 
     377           3 :                 return WERR_NOT_SUPPORTED;
     378             :         }
     379           0 :         default:
     380           0 :                 return WERR_INVALID_LEVEL;
     381             :         }
     382             : }
     383             : 
     384             : 
     385             : /* 
     386             :   srvsvc_NetSessDel 
     387             : */
     388           0 : static WERROR dcesrv_srvsvc_NetSessDel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     389             :                        struct srvsvc_NetSessDel *r)
     390             : {
     391           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
     392             : }
     393             : 
     394             : 
     395             : /* 
     396             :   srvsvc_NetShareAdd 
     397             : */
     398           0 : static WERROR dcesrv_srvsvc_NetShareAdd(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     399             :                        struct srvsvc_NetShareAdd *r)
     400             : {
     401           0 :         switch (r->in.level) {
     402           0 :         case 0:
     403             :         {
     404           0 :                 if (r->in.parm_error) {
     405           0 :                         r->out.parm_error = r->in.parm_error;
     406             :                 }
     407           0 :                 return WERR_NOT_SUPPORTED;
     408             :         }
     409           0 :         case 1:
     410             :         {
     411           0 :                 if (r->in.parm_error) {
     412           0 :                         r->out.parm_error = r->in.parm_error;
     413             :                 }
     414           0 :                 return WERR_NOT_SUPPORTED;
     415             :         }
     416           0 :         case 2:
     417             :         {
     418             :                 NTSTATUS nterr;
     419             :                 struct share_info *info;
     420             :                 struct share_context *sctx;
     421           0 :                 unsigned int count = 8;
     422             :                 unsigned int i;
     423             : 
     424           0 :                 nterr = share_get_context(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
     425           0 :                 if (!NT_STATUS_IS_OK(nterr)) {
     426           0 :                         return ntstatus_to_werror(nterr);
     427             :                 }
     428             : 
     429             :                 /* there are no more than 8 options in struct srvsvc_NetShareInfo2 */
     430           0 :                 info = talloc_array(mem_ctx, struct share_info, count);
     431           0 :                 W_ERROR_HAVE_NO_MEMORY(info);
     432             : 
     433           0 :                 i = 0;
     434             : 
     435           0 :                 info[i].name = SHARE_TYPE;
     436           0 :                 info[i].type = SHARE_INFO_STRING;
     437           0 :                 switch (r->in.info->info2->type) {
     438           0 :                 case STYPE_DISKTREE:
     439           0 :                         info[i].value = talloc_strdup(info, "DISK");
     440           0 :                         break;
     441           0 :                 case STYPE_PRINTQ:
     442           0 :                         info[i].value = talloc_strdup(info, "PRINTER");
     443           0 :                         break;
     444           0 :                 case STYPE_IPC:
     445           0 :                         info[i].value = talloc_strdup(info, "IPC");
     446           0 :                         break;
     447           0 :                 default:
     448           0 :                         return WERR_INVALID_PARAMETER;
     449             :                 }
     450           0 :                 W_ERROR_HAVE_NO_MEMORY(info[i].value);
     451           0 :                 i++;
     452             : 
     453           0 :                 if (r->in.info->info2->path && r->in.info->info2->path[0]) {
     454           0 :                         info[i].name = SHARE_PATH;
     455           0 :                         info[i].type = SHARE_INFO_STRING;
     456             : 
     457             :                         /* Windows will send a path in a form of C:\example\path */
     458           0 :                         if (r->in.info->info2->path[1] == ':') {
     459           0 :                                 info[i].value = talloc_strdup(info, &r->in.info->info2->path[2]);
     460             :                         } else {
     461             :                                 /* very strange let's try to set as is */
     462           0 :                                 info[i].value = talloc_strdup(info, r->in.info->info2->path);
     463             :                         }
     464           0 :                         W_ERROR_HAVE_NO_MEMORY(info[i].value);
     465           0 :                         all_string_sub((char *)info[i].value, "\\", "/", 0);
     466             : 
     467           0 :                         i++;
     468             :                 }
     469             : 
     470           0 :                 if (r->in.info->info2->comment && r->in.info->info2->comment[0]) {
     471           0 :                         info[i].name = SHARE_COMMENT;
     472           0 :                         info[i].type = SHARE_INFO_STRING;
     473           0 :                         info[i].value = talloc_strdup(info, r->in.info->info2->comment);
     474           0 :                         W_ERROR_HAVE_NO_MEMORY(info[i].value);
     475             : 
     476           0 :                         i++;
     477             :                 }
     478             : 
     479           0 :                 if (r->in.info->info2->password && r->in.info->info2->password[0]) {
     480           0 :                         info[i].name = SHARE_PASSWORD;
     481           0 :                         info[i].type = SHARE_INFO_STRING;
     482           0 :                         info[i].value = talloc_strdup(info, r->in.info->info2->password);
     483           0 :                         W_ERROR_HAVE_NO_MEMORY(info[i].value);
     484             : 
     485           0 :                         i++;
     486             :                 }
     487             : 
     488           0 :                 info[i].name = SHARE_MAX_CONNECTIONS;
     489           0 :                 info[i].type = SHARE_INFO_INT;
     490           0 :                 info[i].value = talloc(info, int);
     491           0 :                 *((int *)info[i].value) = r->in.info->info2->max_users;
     492           0 :                 i++;
     493             : 
     494             :                 /* TODO: security descriptor */
     495             : 
     496           0 :                 nterr = share_create(sctx, r->in.info->info2->name, info, i);
     497           0 :                 if (!NT_STATUS_IS_OK(nterr)) {
     498           0 :                         return ntstatus_to_werror(nterr);
     499             :                 }
     500             : 
     501           0 :                 if (r->in.parm_error) {
     502           0 :                         r->out.parm_error = r->in.parm_error;
     503             :                 }
     504             :                 
     505           0 :                 return WERR_OK;
     506             :         }
     507           0 :         case 501:
     508             :         {       
     509           0 :                 if (r->in.parm_error) {
     510           0 :                         r->out.parm_error = r->in.parm_error;
     511             :                 }
     512           0 :                 return WERR_NOT_SUPPORTED;
     513             :         }
     514           0 :         case 502:
     515             :         {
     516             :                 NTSTATUS nterr;
     517             :                 struct share_info *info;
     518             :                 struct share_context *sctx;
     519           0 :                 unsigned int count = 10;
     520             :                 unsigned int i;
     521             : 
     522           0 :                 nterr = share_get_context(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
     523           0 :                 if (!NT_STATUS_IS_OK(nterr)) {
     524           0 :                         return ntstatus_to_werror(nterr);
     525             :                 }
     526             : 
     527             :                 /* there are no more than 10 options in struct srvsvc_NetShareInfo502 */
     528           0 :                 info = talloc_array(mem_ctx, struct share_info, count);
     529           0 :                 W_ERROR_HAVE_NO_MEMORY(info);
     530             : 
     531           0 :                 i = 0;
     532             : 
     533           0 :                 info[i].name = SHARE_TYPE;
     534           0 :                 info[i].type = SHARE_INFO_STRING;
     535           0 :                 switch (r->in.info->info502->type) {
     536           0 :                 case 0x00:
     537           0 :                         info[i].value = talloc_strdup(info, "DISK");
     538           0 :                         break;
     539           0 :                 case 0x01:
     540           0 :                         info[i].value = talloc_strdup(info, "PRINTER");
     541           0 :                         break;
     542           0 :                 case 0x03:
     543           0 :                         info[i].value = talloc_strdup(info, "IPC");
     544           0 :                         break;
     545           0 :                 default:
     546           0 :                         return WERR_INVALID_PARAMETER;
     547             :                 }
     548           0 :                 W_ERROR_HAVE_NO_MEMORY(info[i].value);
     549           0 :                 i++;
     550             : 
     551           0 :                 if (r->in.info->info502->path && r->in.info->info502->path[0]) {
     552           0 :                         info[i].name = SHARE_PATH;
     553           0 :                         info[i].type = SHARE_INFO_STRING;
     554             : 
     555             :                         /* Windows will send a path in a form of C:\example\path */
     556           0 :                         if (r->in.info->info502->path[1] == ':') {
     557           0 :                                 info[i].value = talloc_strdup(info, &r->in.info->info502->path[2]);
     558             :                         } else {
     559             :                                 /* very strange let's try to set as is */
     560           0 :                                 info[i].value = talloc_strdup(info, r->in.info->info502->path);
     561             :                         }
     562           0 :                         W_ERROR_HAVE_NO_MEMORY(info[i].value);
     563           0 :                         all_string_sub((char *)info[i].value, "\\", "/", 0);
     564             : 
     565           0 :                         i++;
     566             :                 }
     567             : 
     568           0 :                 if (r->in.info->info502->comment && r->in.info->info502->comment[0]) {
     569           0 :                         info[i].name = SHARE_COMMENT;
     570           0 :                         info[i].type = SHARE_INFO_STRING;
     571           0 :                         info[i].value = talloc_strdup(info, r->in.info->info502->comment);
     572           0 :                         W_ERROR_HAVE_NO_MEMORY(info[i].value);
     573             : 
     574           0 :                         i++;
     575             :                 }
     576             : 
     577           0 :                 if (r->in.info->info502->password && r->in.info->info502->password[0]) {
     578           0 :                         info[i].name = SHARE_PASSWORD;
     579           0 :                         info[i].type = SHARE_INFO_STRING;
     580           0 :                         info[i].value = talloc_strdup(info, r->in.info->info502->password);
     581           0 :                         W_ERROR_HAVE_NO_MEMORY(info[i].value);
     582             : 
     583           0 :                         i++;
     584             :                 }
     585             : 
     586           0 :                 info[i].name = SHARE_MAX_CONNECTIONS;
     587           0 :                 info[i].type = SHARE_INFO_INT;
     588           0 :                 info[i].value = talloc(info, int);
     589           0 :                 *((int *)info[i].value) = r->in.info->info502->max_users;
     590           0 :                 i++;
     591             : 
     592             :                 /* TODO: security descriptor */
     593             : 
     594           0 :                 nterr = share_create(sctx, r->in.info->info502->name, info, i);
     595           0 :                 if (!NT_STATUS_IS_OK(nterr)) {
     596           0 :                         return ntstatus_to_werror(nterr);
     597             :                 }
     598             : 
     599           0 :                 if (r->in.parm_error) {
     600           0 :                         r->out.parm_error = r->in.parm_error;
     601             :                 }
     602             :                 
     603           0 :                 return WERR_OK;
     604             :         }
     605           0 :         default:
     606           0 :                 return WERR_INVALID_LEVEL;
     607             :         }
     608             : }
     609             : 
     610         780 : static WERROR dcesrv_srvsvc_fiel_ShareInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     611             :                                     struct share_config *scfg, uint32_t level,
     612             :                                     union srvsvc_NetShareInfo *info)
     613             : {
     614         780 :         struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx;
     615             : 
     616         780 :         switch (level) {
     617         195 :         case 0:
     618             :         {
     619         195 :                 info->info0->name = talloc_strdup(mem_ctx, scfg->name);
     620         195 :                 W_ERROR_HAVE_NO_MEMORY(info->info0->name);
     621             : 
     622         195 :                 return WERR_OK;
     623             :         }
     624         222 :         case 1:
     625             :         {
     626         222 :                 info->info1->name = talloc_strdup(mem_ctx, scfg->name);
     627         222 :                 W_ERROR_HAVE_NO_MEMORY(info->info1->name);
     628         222 :                 info->info1->type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
     629         222 :                 info->info1->comment      = share_string_option(mem_ctx, scfg, SHARE_COMMENT, "");
     630         222 :                 W_ERROR_HAVE_NO_MEMORY(info->info1->comment);
     631             : 
     632         222 :                 return WERR_OK;
     633             :         }
     634         117 :         case 2:
     635             :         {
     636         117 :                 info->info2->name         = talloc_strdup(mem_ctx, scfg->name);
     637         117 :                 W_ERROR_HAVE_NO_MEMORY(info->info2->name);
     638         117 :                 info->info2->type         = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
     639         117 :                 info->info2->comment              = share_string_option(mem_ctx, scfg, SHARE_COMMENT, "");
     640         117 :                 W_ERROR_HAVE_NO_MEMORY(info->info2->comment);
     641         117 :                 info->info2->permissions  = dcesrv_common_get_share_permissions(mem_ctx, dce_ctx, scfg);
     642         117 :                 info->info2->max_users            = share_int_option(scfg, SHARE_MAX_CONNECTIONS, SHARE_MAX_CONNECTIONS_DEFAULT);
     643         117 :                 info->info2->current_users        = dcesrv_common_get_share_current_users(mem_ctx, dce_ctx, scfg);
     644         117 :                 info->info2->path         = dcesrv_common_get_share_path(mem_ctx, dce_ctx, scfg);
     645         117 :                 W_ERROR_HAVE_NO_MEMORY(info->info2->path);
     646         117 :                 info->info2->password             = share_string_option(mem_ctx, scfg, SHARE_PASSWORD, NULL);
     647             : 
     648         117 :                 return WERR_OK;
     649             :         }
     650          84 :         case 501:
     651             :         {
     652          84 :                 info->info501->name               = talloc_strdup(mem_ctx, scfg->name);
     653          84 :                 W_ERROR_HAVE_NO_MEMORY(info->info501->name);
     654          84 :                 info->info501->type               = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
     655          84 :                 info->info501->comment            = share_string_option(mem_ctx, scfg, SHARE_COMMENT, "");
     656          84 :                 W_ERROR_HAVE_NO_MEMORY(info->info501->comment);
     657          84 :                 info->info501->csc_policy = share_int_option(scfg, SHARE_CSC_POLICY, SHARE_CSC_POLICY_DEFAULT);
     658             : 
     659          84 :                 return WERR_OK;
     660             :         }
     661         117 :         case 502:
     662             :         {
     663         117 :                 info->info502->name               = talloc_strdup(mem_ctx, scfg->name);
     664         117 :                 W_ERROR_HAVE_NO_MEMORY(info->info502->name);
     665         117 :                 info->info502->type               = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
     666         117 :                 info->info502->comment            = share_string_option(mem_ctx, scfg, SHARE_COMMENT, "");
     667         117 :                 W_ERROR_HAVE_NO_MEMORY(info->info502->comment);
     668         117 :                 info->info502->permissions        = dcesrv_common_get_share_permissions(mem_ctx, dce_ctx, scfg);
     669         117 :                 info->info502->max_users  = share_int_option(scfg, SHARE_MAX_CONNECTIONS, SHARE_MAX_CONNECTIONS_DEFAULT);
     670         117 :                 info->info502->current_users      = dcesrv_common_get_share_current_users(mem_ctx, dce_ctx, scfg);
     671         117 :                 info->info502->path               = dcesrv_common_get_share_path(mem_ctx, dce_ctx, scfg);
     672         117 :                 W_ERROR_HAVE_NO_MEMORY(info->info502->path);
     673         117 :                 info->info502->password           = share_string_option(mem_ctx, scfg, SHARE_PASSWORD, NULL);
     674         117 :                 info->info502->sd_buf.sd  = dcesrv_common_get_security_descriptor(mem_ctx, dce_ctx, scfg);
     675             : 
     676         117 :                 return WERR_OK;
     677             :         }
     678          45 :         case 1005:
     679             :         {
     680          45 :                 info->info1005->dfs_flags = dcesrv_common_get_share_dfs_flags(mem_ctx, dce_ctx, scfg);
     681             : 
     682          45 :                 return WERR_OK;
     683             :         }
     684           0 :         default:
     685           0 :                 return WERR_INVALID_LEVEL;
     686             :         }
     687             : }
     688             : 
     689             : /* 
     690             :   srvsvc_NetShareEnumAll
     691             : */
     692          32 : static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     693             :                                      struct srvsvc_NetShareEnumAll *r)
     694             : {
     695             :         NTSTATUS nterr;
     696          32 :         int numshares = 0;
     697             :         const char **snames;
     698             :         struct share_context *sctx;
     699             :         struct share_config *scfg;
     700             : 
     701          32 :         *r->out.totalentries = 0;
     702             : 
     703             :         /* TODO: - paging of results 
     704             :          */
     705             : 
     706          32 :         nterr = share_get_context(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
     707          32 :         if (!NT_STATUS_IS_OK(nterr)) {
     708           0 :                 return ntstatus_to_werror(nterr);
     709             :         }
     710             : 
     711          32 :         nterr = share_list_all(mem_ctx, sctx, &numshares, &snames);
     712          32 :         if (!NT_STATUS_IS_OK(nterr)) {
     713           0 :                 return ntstatus_to_werror(nterr);
     714             :         }
     715             : 
     716          32 :         switch (r->in.info_ctr->level) {
     717           6 :         case 0:
     718             :         {
     719             :                 unsigned int i;
     720             :                 struct srvsvc_NetShareCtr0 *ctr0;
     721             : 
     722           6 :                 ctr0 = talloc(mem_ctx, struct srvsvc_NetShareCtr0);
     723           6 :                 W_ERROR_HAVE_NO_MEMORY(ctr0);
     724             : 
     725           6 :                 ctr0->count = numshares;
     726           6 :                 ctr0->array = NULL;
     727             : 
     728           6 :                 if (ctr0->count == 0) {
     729           0 :                         r->out.info_ctr->ctr.ctr0 = ctr0;
     730           0 :                         return WERR_OK;
     731             :                 }
     732             : 
     733           6 :                 ctr0->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo0, ctr0->count);
     734           6 :                 W_ERROR_HAVE_NO_MEMORY(ctr0->array);
     735             : 
     736         168 :                 for (i = 0; i < ctr0->count; i++) {
     737             :                         WERROR status;
     738             :                         union srvsvc_NetShareInfo info;
     739             : 
     740          78 :                         nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
     741          78 :                         if (!NT_STATUS_IS_OK(nterr)) {
     742           0 :                                 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
     743           0 :                                 return WERR_GEN_FAILURE;
     744             :                         }
     745          78 :                         info.info0 = &ctr0->array[i];
     746          78 :                         status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
     747          78 :                         if (!W_ERROR_IS_OK(status)) {
     748           0 :                                 return status;
     749             :                         }
     750          78 :                         talloc_free(scfg);
     751             :                 }
     752           6 :                 talloc_free(snames);
     753             : 
     754           6 :                 r->out.info_ctr->ctr.ctr0 = ctr0;
     755           6 :                 *r->out.totalentries         = r->out.info_ctr->ctr.ctr0->count;
     756           6 :                 return WERR_OK;
     757             :         }
     758           8 :         case 1:
     759             :         {
     760             :                 unsigned int i;
     761             :                 struct srvsvc_NetShareCtr1 *ctr1;
     762             : 
     763           8 :                 ctr1 = talloc(mem_ctx, struct srvsvc_NetShareCtr1);
     764           8 :                 W_ERROR_HAVE_NO_MEMORY(ctr1);
     765             : 
     766           8 :                 ctr1->count = numshares;
     767           8 :                 ctr1->array = NULL;
     768             : 
     769           8 :                 if (ctr1->count == 0) {
     770           0 :                         r->out.info_ctr->ctr.ctr1 = ctr1;
     771           0 :                         return WERR_OK;
     772             :                 }
     773             : 
     774           8 :                 ctr1->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo1, ctr1->count);
     775           8 :                 W_ERROR_HAVE_NO_MEMORY(ctr1->array);
     776             : 
     777         224 :                 for (i=0; i < ctr1->count; i++) {
     778             :                         WERROR status;
     779             :                         union srvsvc_NetShareInfo info;
     780             : 
     781         104 :                         nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
     782         104 :                         if (!NT_STATUS_IS_OK(nterr)) {
     783           0 :                                 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
     784           0 :                                 return WERR_GEN_FAILURE;
     785             :                         }
     786         104 :                         info.info1 = &ctr1->array[i];
     787         104 :                         status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
     788         104 :                         if (!W_ERROR_IS_OK(status)) {
     789           0 :                                 return status;
     790             :                         }
     791         104 :                         talloc_free(scfg);
     792             :                 }
     793           8 :                 talloc_free(snames);
     794             : 
     795           8 :                 r->out.info_ctr->ctr.ctr1 = ctr1;
     796           8 :                 *r->out.totalentries         = r->out.info_ctr->ctr.ctr1->count;
     797             : 
     798           8 :                 return WERR_OK;
     799             :         }
     800           6 :         case 2:
     801             :         {
     802             :                 unsigned int i;
     803             :                 struct srvsvc_NetShareCtr2 *ctr2;
     804             : 
     805           6 :                 SRVSVC_CHECK_ADMIN_ACCESS;
     806             : 
     807           3 :                 ctr2 = talloc(mem_ctx, struct srvsvc_NetShareCtr2);
     808           3 :                 W_ERROR_HAVE_NO_MEMORY(ctr2);
     809             : 
     810           3 :                 ctr2->count = numshares;
     811           3 :                 ctr2->array = NULL;
     812             : 
     813           3 :                 if (ctr2->count == 0) {
     814           0 :                         r->out.info_ctr->ctr.ctr2 = ctr2;
     815           0 :                         return WERR_OK;
     816             :                 }
     817             : 
     818           3 :                 ctr2->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo2, ctr2->count);
     819           3 :                 W_ERROR_HAVE_NO_MEMORY(ctr2->array);
     820             : 
     821          84 :                 for (i=0; i < ctr2->count; i++) {
     822             :                         WERROR status;
     823             :                         union srvsvc_NetShareInfo info;
     824             : 
     825          39 :                         nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
     826          39 :                         if (!NT_STATUS_IS_OK(nterr)) {
     827           0 :                                 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
     828           0 :                                 return WERR_GEN_FAILURE;
     829             :                         }
     830          39 :                         info.info2 = &ctr2->array[i];
     831          39 :                         status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
     832          39 :                         if (!W_ERROR_IS_OK(status)) {
     833           0 :                                 return status;
     834             :                         }
     835          39 :                         talloc_free(scfg);
     836             :                 }
     837           3 :                 talloc_free(snames);
     838             : 
     839           3 :                 r->out.info_ctr->ctr.ctr2 = ctr2;
     840           3 :                 *r->out.totalentries         = r->out.info_ctr->ctr.ctr2->count;
     841             : 
     842           3 :                 return WERR_OK;
     843             :         }
     844           6 :         case 501:
     845             :         {
     846             :                 unsigned int i;
     847             :                 struct srvsvc_NetShareCtr501 *ctr501;
     848             : 
     849           6 :                 SRVSVC_CHECK_ADMIN_ACCESS;
     850             : 
     851           3 :                 ctr501 = talloc(mem_ctx, struct srvsvc_NetShareCtr501);
     852           3 :                 W_ERROR_HAVE_NO_MEMORY(ctr501);
     853             : 
     854           3 :                 ctr501->count = numshares;
     855           3 :                 ctr501->array = NULL;
     856             : 
     857           3 :                 if (ctr501->count == 0) {
     858           0 :                         r->out.info_ctr->ctr.ctr501       = ctr501;
     859           0 :                         return WERR_OK;
     860             :                 }
     861             : 
     862           3 :                 ctr501->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo501, ctr501->count);
     863           3 :                 W_ERROR_HAVE_NO_MEMORY(ctr501->array);
     864             : 
     865          84 :                 for (i=0; i < ctr501->count; i++) {
     866             :                         WERROR status;
     867             :                         union srvsvc_NetShareInfo info;
     868             : 
     869          39 :                         nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
     870          39 :                         if (!NT_STATUS_IS_OK(nterr)) {
     871           0 :                                 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
     872           0 :                                 return WERR_GEN_FAILURE;
     873             :                         }
     874          39 :                         info.info501 = &ctr501->array[i];
     875          39 :                         status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
     876          39 :                         if (!W_ERROR_IS_OK(status)) {
     877           0 :                                 return status;
     878             :                         }
     879          39 :                         talloc_free(scfg);
     880             :                 }
     881           3 :                 talloc_free(snames);
     882             : 
     883           3 :                 r->out.info_ctr->ctr.ctr501       = ctr501;
     884           3 :                 *r->out.totalentries         = r->out.info_ctr->ctr.ctr501->count;
     885             : 
     886           3 :                 return WERR_OK;
     887             :         }
     888           6 :         case 502:
     889             :         {
     890             :                 unsigned int i;
     891             :                 struct srvsvc_NetShareCtr502 *ctr502;
     892             : 
     893           6 :                 SRVSVC_CHECK_ADMIN_ACCESS;
     894             : 
     895           3 :                 ctr502 = talloc(mem_ctx, struct srvsvc_NetShareCtr502);
     896           3 :                 W_ERROR_HAVE_NO_MEMORY(ctr502);
     897             : 
     898           3 :                 ctr502->count = numshares;
     899           3 :                 ctr502->array = NULL;
     900             : 
     901           3 :                 if (ctr502->count == 0) {
     902           0 :                         r->out.info_ctr->ctr.ctr502       = ctr502;
     903           0 :                         return WERR_OK;
     904             :                 }
     905             : 
     906           3 :                 ctr502->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo502, ctr502->count);
     907           3 :                 W_ERROR_HAVE_NO_MEMORY(ctr502->array);
     908             : 
     909          84 :                 for (i=0; i < ctr502->count; i++) {
     910             :                         WERROR status;
     911             :                         union srvsvc_NetShareInfo info;
     912             : 
     913          39 :                         nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
     914          39 :                         if (!NT_STATUS_IS_OK(nterr)) {
     915           0 :                                 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
     916           0 :                                 return WERR_GEN_FAILURE;
     917             :                         }
     918          39 :                         info.info502 = &ctr502->array[i];
     919          39 :                         status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
     920          39 :                         if (!W_ERROR_IS_OK(status)) {
     921           0 :                                 return status;
     922             :                         }
     923          39 :                         talloc_free(scfg);
     924             :                 }
     925           3 :                 talloc_free(snames);
     926             : 
     927           3 :                 r->out.info_ctr->ctr.ctr502       = ctr502;
     928           3 :                 *r->out.totalentries         = r->out.info_ctr->ctr.ctr502->count;
     929             : 
     930           3 :                 return WERR_OK;
     931             :         }
     932           0 :         default:
     933           0 :                 return WERR_INVALID_LEVEL;
     934             :         }
     935             : }
     936             : 
     937             : 
     938             : /* 
     939             :   srvsvc_NetShareGetInfo 
     940             : */
     941         271 : static WERROR dcesrv_srvsvc_NetShareGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
     942             :                                      struct srvsvc_NetShareGetInfo *r)
     943             : {
     944             :         NTSTATUS nterr;
     945         271 :         struct share_context *sctx = NULL;
     946         271 :         struct share_config *scfg = NULL;
     947             : 
     948         271 :         ZERO_STRUCTP(r->out.info);
     949             : 
     950             :         /* TODO: - access check
     951             :          */
     952             : 
     953         271 :         if (strcmp("", r->in.share_name) == 0) {
     954           0 :                 return WERR_INVALID_PARAMETER;
     955             :         }
     956             : 
     957         271 :         nterr = share_get_context(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
     958         271 :         if (!NT_STATUS_IS_OK(nterr)) {
     959           0 :                 return ntstatus_to_werror(nterr);
     960             :         }
     961             : 
     962         271 :         nterr = share_get_config(mem_ctx, sctx, r->in.share_name, &scfg);
     963         271 :         if (!NT_STATUS_IS_OK(nterr)) {
     964           0 :                 return ntstatus_to_werror(nterr);
     965             :         }
     966             : 
     967         271 :         switch (r->in.level) {
     968          45 :         case 0:
     969             :         {
     970             :                 WERROR status;
     971             :                 union srvsvc_NetShareInfo info;
     972             : 
     973          45 :                 info.info0 = talloc(mem_ctx, struct srvsvc_NetShareInfo0);
     974          45 :                 W_ERROR_HAVE_NO_MEMORY(info.info0);
     975             : 
     976          45 :                 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
     977          45 :                 if (!W_ERROR_IS_OK(status)) {
     978           0 :                         return status;
     979             :                 }
     980             : 
     981          45 :                 r->out.info->info0 = info.info0;
     982          45 :                 return WERR_OK;
     983             :         }
     984          46 :         case 1:
     985             :         {
     986             :                 WERROR status;
     987             :                 union srvsvc_NetShareInfo info;
     988             : 
     989          46 :                 info.info1 = talloc(mem_ctx, struct srvsvc_NetShareInfo1);
     990          46 :                 W_ERROR_HAVE_NO_MEMORY(info.info1);
     991             : 
     992          46 :                 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
     993          46 :                 if (!W_ERROR_IS_OK(status)) {
     994           0 :                         return status;
     995             :                 }
     996             : 
     997          46 :                 r->out.info->info1 = info.info1;
     998          46 :                 return WERR_OK;
     999             :         }
    1000          45 :         case 2:
    1001             :         {
    1002             :                 WERROR status;
    1003             :                 union srvsvc_NetShareInfo info;
    1004             : 
    1005          45 :                 SRVSVC_CHECK_ADMIN_ACCESS;
    1006             : 
    1007          42 :                 info.info2 = talloc(mem_ctx, struct srvsvc_NetShareInfo2);
    1008          42 :                 W_ERROR_HAVE_NO_MEMORY(info.info2);
    1009             : 
    1010          42 :                 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
    1011          42 :                 if (!W_ERROR_IS_OK(status)) {
    1012           0 :                         return status;
    1013             :                 }
    1014             : 
    1015          42 :                 r->out.info->info2 = info.info2;
    1016          42 :                 return WERR_OK;
    1017             :         }
    1018          45 :         case 501:
    1019             :         {
    1020             :                 WERROR status;
    1021             :                 union srvsvc_NetShareInfo info;
    1022             : 
    1023          45 :                 info.info501 = talloc(mem_ctx, struct srvsvc_NetShareInfo501);
    1024          45 :                 W_ERROR_HAVE_NO_MEMORY(info.info501);
    1025             : 
    1026          45 :                 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
    1027          45 :                 if (!W_ERROR_IS_OK(status)) {
    1028           0 :                         return status;
    1029             :                 }
    1030             : 
    1031          45 :                 r->out.info->info501 = info.info501;
    1032          45 :                 return WERR_OK;
    1033             :         }
    1034          45 :         case 502:
    1035             :         {
    1036             :                 WERROR status;
    1037             :                 union srvsvc_NetShareInfo info;
    1038             : 
    1039          45 :                 SRVSVC_CHECK_ADMIN_ACCESS;
    1040             : 
    1041          42 :                 info.info502 = talloc(mem_ctx, struct srvsvc_NetShareInfo502);
    1042          42 :                 W_ERROR_HAVE_NO_MEMORY(info.info502);
    1043             : 
    1044          42 :                 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
    1045          42 :                 if (!W_ERROR_IS_OK(status)) {
    1046           0 :                         return status;
    1047             :                 }
    1048             : 
    1049          42 :                 r->out.info->info502 = info.info502;
    1050          42 :                 return WERR_OK;
    1051             :         }
    1052          45 :         case 1005:
    1053             :         {
    1054             :                 WERROR status;
    1055             :                 union srvsvc_NetShareInfo info;
    1056             : 
    1057          45 :                 info.info1005 = talloc(mem_ctx, struct srvsvc_NetShareInfo1005);
    1058          45 :                 W_ERROR_HAVE_NO_MEMORY(info.info1005);
    1059             : 
    1060          45 :                 status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.level, &info);
    1061          45 :                 if (!W_ERROR_IS_OK(status)) {
    1062           0 :                         return status;
    1063             :                 }
    1064             : 
    1065          45 :                 r->out.info->info1005 = info.info1005;
    1066          45 :                 return WERR_OK;
    1067             :         }
    1068           0 :         default:
    1069           0 :                 return WERR_INVALID_LEVEL;
    1070             :         }
    1071             : }
    1072             : 
    1073           0 : static WERROR dcesrv_srvsvc_fill_share_info(struct share_info *info, int *count,
    1074             :                                         const char *share_name, int level,
    1075             :                                         const char *name,
    1076             :                                         const char *path,
    1077             :                                         const char *comment,
    1078             :                                         const char *password,
    1079             :                                         enum srvsvc_ShareType type,
    1080             :                                         int32_t max_users,
    1081             :                                         uint32_t csc_policy,
    1082             :                                         struct security_descriptor *sd)
    1083             : {
    1084           0 :         unsigned int i = 0;
    1085             : 
    1086           0 :         if (level == 501) {
    1087           0 :                 info[i].name = SHARE_CSC_POLICY;
    1088           0 :                 info[i].type = SHARE_INFO_INT;
    1089           0 :                 info[i].value = talloc(info, int);
    1090           0 :                 *((int *)info[i].value) = csc_policy;
    1091           0 :                 i++;
    1092             :         }
    1093             :         
    1094           0 :         switch(level) {
    1095             : 
    1096           0 :         case 502:
    1097             :                 /* TODO: check if unknown is csc_policy */
    1098             : 
    1099             :                 /* TODO: security descriptor */
    1100             : 
    1101             :         case 2:
    1102           0 :                 if (path && path[0]) {
    1103           0 :                         info[i].name = SHARE_PATH;
    1104           0 :                         info[i].type = SHARE_INFO_STRING;
    1105             : 
    1106             :                         /* Windows will send a path in a form of C:\example\path */
    1107           0 :                         if (path[1] == ':') {
    1108           0 :                                 info[i].value = talloc_strdup(info, &path[2]);
    1109             :                         } else {
    1110             :                                 /* very strange let's try to set as is */
    1111           0 :                                 info[i].value = talloc_strdup(info, path);
    1112             :                         }
    1113           0 :                         W_ERROR_HAVE_NO_MEMORY(info[i].value);
    1114           0 :                         all_string_sub((char *)info[i].value, "\\", "/", 0);
    1115             : 
    1116           0 :                         i++;
    1117             :                 }
    1118             : 
    1119           0 :                 if (password && password[0]) {
    1120           0 :                         info[i].name = SHARE_PASSWORD;
    1121           0 :                         info[i].type = SHARE_INFO_STRING;
    1122           0 :                         info[i].value = talloc_strdup(info, password);
    1123           0 :                         W_ERROR_HAVE_NO_MEMORY(info[i].value);
    1124             : 
    1125           0 :                         i++;
    1126             :                 }
    1127             : 
    1128           0 :                 info[i].name = SHARE_MAX_CONNECTIONS;
    1129           0 :                 info[i].type = SHARE_INFO_INT;
    1130           0 :                 info[i].value = talloc(info, int);
    1131           0 :                 *((int *)info[i].value) = max_users;
    1132           0 :                 i++;
    1133             : 
    1134             :                 FALL_THROUGH;
    1135           0 :         case 501:
    1136             :         case 1:
    1137           0 :                 info[i].name = SHARE_TYPE;
    1138           0 :                 info[i].type = SHARE_INFO_STRING;
    1139           0 :                 switch (type) {
    1140           0 :                 case 0x00:
    1141           0 :                         info[i].value = talloc_strdup(info, "DISK");
    1142           0 :                         break;
    1143           0 :                 case 0x01:
    1144           0 :                         info[i].value = talloc_strdup(info, "PRINTER");
    1145           0 :                         break;
    1146           0 :                 case 0x03:
    1147           0 :                         info[i].value = talloc_strdup(info, "IPC");
    1148           0 :                         break;
    1149           0 :                 default:
    1150           0 :                         return WERR_INVALID_PARAMETER;
    1151             :                 }
    1152           0 :                 W_ERROR_HAVE_NO_MEMORY(info[i].value);
    1153           0 :                 i++;
    1154             : 
    1155             :                 FALL_THROUGH;
    1156           0 :         case 1004:
    1157           0 :                 if (comment) {
    1158           0 :                         info[i].name = SHARE_COMMENT;
    1159           0 :                         info[i].type = SHARE_INFO_STRING;
    1160           0 :                         info[i].value = talloc_strdup(info, comment);
    1161           0 :                         W_ERROR_HAVE_NO_MEMORY(info[i].value);
    1162             : 
    1163           0 :                         i++;
    1164             :                 }
    1165             : 
    1166             :                 FALL_THROUGH;
    1167             :         case 0:
    1168           0 :                 if (name &&
    1169           0 :                     strcasecmp(share_name, name) != 0) {
    1170           0 :                         info[i].name = SHARE_NAME;
    1171           0 :                         info[i].type = SHARE_INFO_STRING;
    1172           0 :                         info[i].value = talloc_strdup(info, name);
    1173           0 :                         W_ERROR_HAVE_NO_MEMORY(info[i].value);
    1174           0 :                         i++;
    1175             :                 }
    1176             : 
    1177           0 :                 break;
    1178             : 
    1179           0 :         default:
    1180           0 :                 return WERR_INVALID_LEVEL;
    1181             :         }
    1182             : 
    1183           0 :         *count = i;
    1184             : 
    1185           0 :         return WERR_OK;
    1186             : }
    1187             : 
    1188             : /* 
    1189             :   srvsvc_NetShareSetInfo 
    1190             : */
    1191           0 : static WERROR dcesrv_srvsvc_NetShareSetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    1192             :                        struct srvsvc_NetShareSetInfo *r)
    1193             : {
    1194             :         NTSTATUS nterr;
    1195             :         WERROR status;
    1196           0 :         struct share_context *sctx = NULL;
    1197             :         struct share_info *info;
    1198             :         int count;
    1199             : 
    1200             :         /* TODO: - access check
    1201             :          */
    1202             : 
    1203             :         /* there are no more than 10 options in all struct srvsvc_NetShareInfoXXX */
    1204           0 :         info = talloc_array(mem_ctx, struct share_info, 10);
    1205           0 :         W_ERROR_HAVE_NO_MEMORY(info);
    1206             : 
    1207           0 :         if (strcmp("", r->in.share_name) == 0) {
    1208           0 :                 return WERR_INVALID_PARAMETER;
    1209             :         }
    1210             : 
    1211           0 :         nterr = share_get_context(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
    1212           0 :         if (!NT_STATUS_IS_OK(nterr)) {
    1213           0 :                 return ntstatus_to_werror(nterr);
    1214             :         }
    1215             : 
    1216           0 :         switch (r->in.level) {
    1217           0 :         case 0:
    1218             :         {
    1219           0 :                 status = dcesrv_srvsvc_fill_share_info(info, &count,
    1220           0 :                                         r->in.share_name, r->in.level,
    1221           0 :                                         r->in.info->info0->name,
    1222             :                                         NULL,
    1223             :                                         NULL,
    1224             :                                         NULL,
    1225             :                                         0,
    1226             :                                         0,
    1227             :                                         0,
    1228             :                                         NULL);
    1229           0 :                 if (!W_ERROR_EQUAL(status, WERR_OK)) {
    1230           0 :                         return status;
    1231             :                 }
    1232           0 :                 break;
    1233             :         }
    1234           0 :         case 1:
    1235             :         {
    1236           0 :                 status = dcesrv_srvsvc_fill_share_info(info, &count,
    1237           0 :                                         r->in.share_name, r->in.level,
    1238           0 :                                         r->in.info->info1->name,
    1239             :                                         NULL,
    1240           0 :                                         r->in.info->info1->comment,
    1241             :                                         NULL,
    1242           0 :                                         r->in.info->info1->type,
    1243             :                                         0,
    1244             :                                         0,
    1245             :                                         NULL);
    1246           0 :                 if (!W_ERROR_EQUAL(status, WERR_OK)) {
    1247           0 :                         return status;
    1248             :                 }
    1249           0 :                 break;
    1250             :         }
    1251           0 :         case 2:
    1252             :         {
    1253           0 :                 status = dcesrv_srvsvc_fill_share_info(info, &count,
    1254           0 :                                         r->in.share_name, r->in.level,
    1255           0 :                                         r->in.info->info2->name,
    1256           0 :                                         r->in.info->info2->path,
    1257           0 :                                         r->in.info->info2->comment,
    1258           0 :                                         r->in.info->info2->password,
    1259           0 :                                         r->in.info->info2->type,
    1260           0 :                                         r->in.info->info2->max_users,
    1261             :                                         0,
    1262             :                                         NULL);
    1263           0 :                 if (!W_ERROR_EQUAL(status, WERR_OK)) {
    1264           0 :                         return status;
    1265             :                 }
    1266           0 :                 break;
    1267             :         }
    1268           0 :         case 501:
    1269             :         {
    1270           0 :                 status = dcesrv_srvsvc_fill_share_info(info, &count,
    1271           0 :                                         r->in.share_name, r->in.level,
    1272           0 :                                         r->in.info->info501->name,
    1273             :                                         NULL,
    1274           0 :                                         r->in.info->info501->comment,
    1275             :                                         NULL,
    1276           0 :                                         r->in.info->info501->type,
    1277             :                                         0,
    1278           0 :                                         r->in.info->info501->csc_policy,
    1279             :                                         NULL);
    1280           0 :                 if (!W_ERROR_EQUAL(status, WERR_OK)) {
    1281           0 :                         return status;
    1282             :                 }
    1283           0 :                 break;
    1284             :         }
    1285           0 :         case 502:
    1286             :         {
    1287           0 :                 status = dcesrv_srvsvc_fill_share_info(info, &count,
    1288           0 :                                         r->in.share_name, r->in.level,
    1289           0 :                                         r->in.info->info502->name,
    1290           0 :                                         r->in.info->info502->path,
    1291           0 :                                         r->in.info->info502->comment,
    1292           0 :                                         r->in.info->info502->password,
    1293           0 :                                         r->in.info->info502->type,
    1294           0 :                                         r->in.info->info502->max_users,
    1295             :                                         0,
    1296           0 :                                         r->in.info->info502->sd_buf.sd);
    1297           0 :                 if (!W_ERROR_EQUAL(status, WERR_OK)) {
    1298           0 :                         return status;
    1299             :                 }
    1300           0 :                 break;
    1301             :         }
    1302           0 :         case 1004:
    1303             :         {
    1304           0 :                 status = dcesrv_srvsvc_fill_share_info(info, &count,
    1305           0 :                                         r->in.share_name, r->in.level,
    1306             :                                         NULL,
    1307             :                                         NULL,
    1308           0 :                                         r->in.info->info1004->comment,
    1309             :                                         NULL,
    1310             :                                         0,
    1311             :                                         0,
    1312             :                                         0,
    1313             :                                         NULL);
    1314           0 :                 if (!W_ERROR_EQUAL(status, WERR_OK)) {
    1315           0 :                         return status;
    1316             :                 }
    1317           0 :                 break;
    1318             :         }
    1319           0 :         case 1005:
    1320             :         {
    1321             :                 /* r->in.info.dfs_flags; */
    1322             :                 
    1323           0 :                 if (r->in.parm_error) {
    1324           0 :                         r->out.parm_error = r->in.parm_error;
    1325             :                 }
    1326             : 
    1327           0 :                 return WERR_OK;
    1328             :         }
    1329           0 :         default:
    1330           0 :                 return WERR_INVALID_LEVEL;
    1331             :         }
    1332             : 
    1333           0 :         nterr = share_set(sctx, r->in.share_name, info, count);
    1334           0 :         if (!NT_STATUS_IS_OK(nterr)) {
    1335           0 :                 return ntstatus_to_werror(nterr);
    1336             :         }
    1337             : 
    1338           0 :         if (r->in.parm_error) {
    1339           0 :                 r->out.parm_error = r->in.parm_error;
    1340             :         }
    1341             :                 
    1342           0 :         return WERR_OK;
    1343             : }
    1344             : 
    1345             : 
    1346             : /* 
    1347             :   srvsvc_NetShareDelSticky 
    1348             : */
    1349           0 : static WERROR dcesrv_srvsvc_NetShareDelSticky(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    1350             :                        struct srvsvc_NetShareDelSticky *r)
    1351             : {
    1352           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    1353             : }
    1354             : 
    1355             : 
    1356             : /* 
    1357             :   srvsvc_NetShareCheck 
    1358             : */
    1359          42 : static WERROR dcesrv_srvsvc_NetShareCheck(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    1360             :                        struct srvsvc_NetShareCheck *r)
    1361             : {
    1362             :         NTSTATUS nterr;
    1363          42 :         struct share_context *sctx = NULL;
    1364          42 :         struct share_config *scfg = NULL;
    1365             :         char *device;
    1366             :         const char **names;
    1367             :         int count;
    1368             :         int i;
    1369             : 
    1370          42 :         *r->out.type = 0;
    1371             : 
    1372             :         /* TODO: - access check
    1373             :          */
    1374             : 
    1375          42 :         if (strcmp("", r->in.device_name) == 0) {
    1376           6 :                 *r->out.type = STYPE_IPC;
    1377           6 :                 return WERR_OK;
    1378             :         }
    1379             : 
    1380             :         /* copy the path skipping C:\ */
    1381          36 :         if (strncasecmp(r->in.device_name, "C:", 2) == 0) {
    1382          36 :                 device = talloc_strdup(mem_ctx, &r->in.device_name[2]);
    1383             :         } else {
    1384             :                 /* no chance we have a share that doesn't start with C:\ */
    1385           0 :                 return WERR_NERR_DEVICENOTSHARED;
    1386             :         }
    1387          36 :         all_string_sub(device, "\\", "/", 0);
    1388             : 
    1389          36 :         nterr = share_get_context(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
    1390          36 :         if (!NT_STATUS_IS_OK(nterr)) {
    1391           0 :                 return ntstatus_to_werror(nterr);
    1392             :         }
    1393             : 
    1394          36 :         nterr = share_list_all(mem_ctx, sctx, &count, &names);
    1395          36 :         if (!NT_STATUS_IS_OK(nterr)) {
    1396           0 :                 return ntstatus_to_werror(nterr);
    1397             :         }
    1398             : 
    1399         117 :         for (i = 0; i < count; i++) {
    1400             :                 const char *path;
    1401             :                 const char *type;
    1402             : 
    1403         117 :                 nterr = share_get_config(mem_ctx, sctx, names[i], &scfg);
    1404         117 :                 if (!NT_STATUS_IS_OK(nterr)) {
    1405           0 :                         return ntstatus_to_werror(nterr);
    1406             :                 }
    1407         117 :                 path = share_string_option(mem_ctx, scfg, SHARE_PATH, NULL);
    1408         117 :                 if (!path) continue;
    1409             : 
    1410         117 :                 if (strcmp(device, path) == 0) {
    1411          36 :                         type = share_string_option(mem_ctx, scfg, SHARE_TYPE, NULL);
    1412          36 :                         if (!type) continue;
    1413             : 
    1414          36 :                         if (strcmp(type, "DISK") == 0) {
    1415          36 :                                 *r->out.type = STYPE_DISKTREE;
    1416          36 :                                 return WERR_OK;
    1417             :                         }
    1418             : 
    1419           0 :                         if (strcmp(type, "IPC") == 0) {
    1420           0 :                                 *r->out.type = STYPE_IPC;
    1421           0 :                                 return WERR_OK;
    1422             :                         }
    1423             : 
    1424           0 :                         if (strcmp(type, "PRINTER") == 0) {
    1425           0 :                                 *r->out.type = STYPE_PRINTQ;
    1426           0 :                                 return WERR_OK;
    1427             :                         }
    1428             :                 }
    1429             :         }
    1430             : 
    1431           0 :         return WERR_NERR_DEVICENOTSHARED;
    1432             : }
    1433             : 
    1434             : 
    1435             : /* 
    1436             :   srvsvc_NetSrvGetInfo 
    1437             : */
    1438          16 : static WERROR dcesrv_srvsvc_NetSrvGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    1439             :                        struct srvsvc_NetSrvGetInfo *r)
    1440             : {
    1441          16 :         struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx;
    1442          16 :         struct dcerpc_server_info *server_info = lpcfg_dcerpc_server_info(mem_ctx, dce_ctx->lp_ctx);
    1443          16 :         const struct loadparm_substitution *lp_sub =
    1444             :                 lpcfg_noop_substitution();
    1445             : 
    1446          16 :         ZERO_STRUCTP(r->out.info);
    1447             : 
    1448          16 :         switch (r->in.level) {
    1449           3 :         case 100:
    1450             :         {
    1451             :                 struct srvsvc_NetSrvInfo100 *info100;
    1452             : 
    1453           3 :                 info100 = talloc(mem_ctx, struct srvsvc_NetSrvInfo100);
    1454           3 :                 W_ERROR_HAVE_NO_MEMORY(info100);
    1455             : 
    1456           3 :                 info100->platform_id = dcesrv_common_get_platform_id(mem_ctx, dce_ctx);
    1457           3 :                 info100->server_name = dcesrv_common_get_server_name(mem_ctx, dce_ctx, r->in.server_unc);
    1458           3 :                 W_ERROR_HAVE_NO_MEMORY(info100->server_name);
    1459             : 
    1460           3 :                 r->out.info->info100 = info100;
    1461           3 :                 return WERR_OK;
    1462             :         }
    1463           4 :         case 101:
    1464             :         {
    1465             :                 struct srvsvc_NetSrvInfo101 *info101;
    1466             : 
    1467           4 :                 info101 = talloc(mem_ctx, struct srvsvc_NetSrvInfo101);
    1468           4 :                 W_ERROR_HAVE_NO_MEMORY(info101);
    1469             : 
    1470           4 :                 info101->platform_id = dcesrv_common_get_platform_id(mem_ctx, dce_ctx);
    1471           4 :                 info101->server_name = dcesrv_common_get_server_name(mem_ctx, dce_ctx, r->in.server_unc);
    1472           4 :                 W_ERROR_HAVE_NO_MEMORY(info101->server_name);
    1473             : 
    1474           4 :                 info101->version_major       = server_info->version_major;
    1475           4 :                 info101->version_minor       = server_info->version_minor;
    1476           4 :                 info101->server_type = dcesrv_common_get_server_type(mem_ctx, dce_call->event_ctx, dce_ctx);
    1477           4 :                 info101->comment     = lpcfg_server_string(dce_ctx->lp_ctx, lp_sub, mem_ctx);
    1478           4 :                 W_ERROR_HAVE_NO_MEMORY(info101->comment);
    1479             : 
    1480           4 :                 r->out.info->info101 = info101;
    1481           4 :                 return WERR_OK;
    1482             :         }
    1483           3 :         case 102:
    1484             :         {
    1485             :                 struct srvsvc_NetSrvInfo102 *info102;
    1486             : 
    1487           3 :                 info102 = talloc(mem_ctx, struct srvsvc_NetSrvInfo102);
    1488           3 :                 W_ERROR_HAVE_NO_MEMORY(info102);
    1489             : 
    1490           3 :                 info102->platform_id = dcesrv_common_get_platform_id(mem_ctx, dce_ctx);
    1491           3 :                 info102->server_name = dcesrv_common_get_server_name(mem_ctx, dce_ctx, r->in.server_unc);
    1492           3 :                 W_ERROR_HAVE_NO_MEMORY(info102->server_name);
    1493             : 
    1494           3 :                 info102->version_major       = server_info->version_major;
    1495           3 :                 info102->version_minor       = server_info->version_minor;
    1496           3 :                 info102->server_type = dcesrv_common_get_server_type(mem_ctx, dce_call->event_ctx, dce_ctx);
    1497           3 :                 info102->comment     = lpcfg_server_string(dce_ctx->lp_ctx, lp_sub, mem_ctx);
    1498           3 :                 W_ERROR_HAVE_NO_MEMORY(info102->comment);
    1499             : 
    1500           3 :                 info102->users               = dcesrv_common_get_users(mem_ctx, dce_ctx);
    1501           3 :                 info102->disc                = dcesrv_common_get_disc(mem_ctx, dce_ctx);
    1502           3 :                 info102->hidden              = dcesrv_common_get_hidden(mem_ctx, dce_ctx);
    1503           3 :                 info102->announce    = dcesrv_common_get_announce(mem_ctx, dce_ctx);
    1504           3 :                 info102->anndelta    = dcesrv_common_get_anndelta(mem_ctx, dce_ctx);
    1505           3 :                 info102->licenses    = dcesrv_common_get_licenses(mem_ctx, dce_ctx);
    1506           3 :                 info102->userpath    = dcesrv_common_get_userpath(mem_ctx, dce_ctx);
    1507           3 :                 W_ERROR_HAVE_NO_MEMORY(info102->userpath);
    1508             : 
    1509           3 :                 r->out.info->info102 = info102;
    1510           3 :                 return WERR_OK;
    1511             :         }
    1512           6 :         default:
    1513           6 :                 return WERR_INVALID_LEVEL;
    1514             :         }
    1515             : }
    1516             : 
    1517             : 
    1518             : /* 
    1519             :   srvsvc_NetSrvSetInfo 
    1520             : */
    1521           0 : static WERROR dcesrv_srvsvc_NetSrvSetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    1522             :                        struct srvsvc_NetSrvSetInfo *r)
    1523             : {
    1524           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    1525             : }
    1526             : 
    1527             : 
    1528             : /* 
    1529             :   srvsvc_NetDiskEnum 
    1530             : */
    1531           3 : static WERROR dcesrv_srvsvc_NetDiskEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    1532             :                        struct srvsvc_NetDiskEnum *r)
    1533             : {
    1534           3 :         r->out.info->disks = NULL;
    1535           3 :         r->out.info->count = 0;
    1536           3 :         *r->out.totalentries = 0;
    1537             : 
    1538           3 :         switch (r->in.level) {
    1539           3 :         case 0:
    1540             :         {
    1541             :                 /* we can safely hardcode the reply and report we have only one disk (C:) */
    1542             :                 /* for some reason Windows wants 2 entries with the second being empty */
    1543           3 :                 r->out.info->disks = talloc_array(mem_ctx, struct srvsvc_NetDiskInfo0, 2);
    1544           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.info->disks);
    1545           3 :                 r->out.info->count = 2;
    1546             : 
    1547           3 :                 r->out.info->disks[0].disk = talloc_strdup(mem_ctx, "C:");
    1548           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.info->disks[0].disk);
    1549             : 
    1550           3 :                 r->out.info->disks[1].disk = talloc_strdup(mem_ctx, "");
    1551           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.info->disks[1].disk);
    1552             : 
    1553           3 :                 *r->out.totalentries = 1;
    1554           3 :                 r->out.resume_handle = r->in.resume_handle;
    1555             : 
    1556           3 :                 return WERR_OK;
    1557             :         }
    1558           0 :         default:
    1559           0 :                 return WERR_INVALID_LEVEL;
    1560             :         }
    1561             : }
    1562             : 
    1563             : 
    1564             : /* 
    1565             :   srvsvc_NetServerStatisticsGet 
    1566             : */
    1567           0 : static WERROR dcesrv_srvsvc_NetServerStatisticsGet(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    1568             :                        struct srvsvc_NetServerStatisticsGet *r)
    1569             : {
    1570           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    1571             : }
    1572             : 
    1573             : 
    1574             : /* 
    1575             :   srvsvc_NetTransportAdd 
    1576             : */
    1577           0 : static WERROR dcesrv_srvsvc_NetTransportAdd(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    1578             :                        struct srvsvc_NetTransportAdd *r)
    1579             : {
    1580           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    1581             : }
    1582             : 
    1583             : 
    1584             : /* 
    1585             :   srvsvc_NetTransportEnum 
    1586             : */
    1587           6 : static WERROR dcesrv_srvsvc_NetTransportEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    1588             :                        struct srvsvc_NetTransportEnum *r)
    1589             : {
    1590           6 :         r->out.transports->level = r->in.transports->level;
    1591           6 :         *r->out.totalentries = 0;
    1592           6 :         if (r->out.resume_handle) {
    1593           0 :                 *r->out.resume_handle = 0;
    1594             :         }
    1595             : 
    1596           6 :         switch (r->in.transports->level) {
    1597           3 :         case 0:
    1598             :         {
    1599           3 :                 r->out.transports->ctr.ctr0 = talloc(mem_ctx, struct srvsvc_NetTransportCtr0);
    1600           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.transports->ctr.ctr0);
    1601             : 
    1602           3 :                 r->out.transports->ctr.ctr0->count = 0;
    1603           3 :                 r->out.transports->ctr.ctr0->array = NULL;
    1604             : 
    1605           3 :                 return WERR_NOT_SUPPORTED;
    1606             :         }
    1607           3 :         case 1:
    1608             :         {
    1609           3 :                 r->out.transports->ctr.ctr1 = talloc(mem_ctx, struct srvsvc_NetTransportCtr1);
    1610           3 :                 W_ERROR_HAVE_NO_MEMORY(r->out.transports->ctr.ctr1);
    1611             : 
    1612           3 :                 r->out.transports->ctr.ctr1->count = 0;
    1613           3 :                 r->out.transports->ctr.ctr1->array = NULL;
    1614             : 
    1615           3 :                 return WERR_NOT_SUPPORTED;
    1616             :         }
    1617           0 :         case 2:
    1618             :         {
    1619           0 :                 r->out.transports->ctr.ctr2 = talloc(mem_ctx, struct srvsvc_NetTransportCtr2);
    1620           0 :                 W_ERROR_HAVE_NO_MEMORY(r->out.transports->ctr.ctr2);
    1621             : 
    1622           0 :                 r->out.transports->ctr.ctr2->count = 0;
    1623           0 :                 r->out.transports->ctr.ctr2->array = NULL;
    1624             : 
    1625           0 :                 return WERR_NOT_SUPPORTED;
    1626             :         }
    1627           0 :         case 3:
    1628             :         {
    1629           0 :                 r->out.transports->ctr.ctr3 = talloc(mem_ctx, struct srvsvc_NetTransportCtr3);
    1630           0 :                 W_ERROR_HAVE_NO_MEMORY(r->out.transports->ctr.ctr3);
    1631             : 
    1632           0 :                 r->out.transports->ctr.ctr3->count = 0;
    1633           0 :                 r->out.transports->ctr.ctr3->array = NULL;
    1634             : 
    1635           0 :                 return WERR_NOT_SUPPORTED;
    1636             :         }
    1637           0 :         default:
    1638           0 :                 return WERR_INVALID_LEVEL;
    1639             :         }
    1640             : }
    1641             : 
    1642             : /* 
    1643             :   srvsvc_NetTransportDel 
    1644             : */
    1645           0 : static WERROR dcesrv_srvsvc_NetTransportDel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    1646             :                        struct srvsvc_NetTransportDel *r)
    1647             : {
    1648           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    1649             : }
    1650             : 
    1651             : 
    1652             : /* 
    1653             :   srvsvc_NetRemoteTOD 
    1654             : */
    1655          15 : static WERROR dcesrv_srvsvc_NetRemoteTOD(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    1656             :                        struct srvsvc_NetRemoteTOD *r)
    1657             : {
    1658             :         struct timeval tval;
    1659             :         time_t t;
    1660             :         struct tm tm;
    1661             :         struct srvsvc_NetRemoteTODInfo *info;
    1662             : 
    1663          15 :         info = talloc(mem_ctx, struct srvsvc_NetRemoteTODInfo);
    1664          15 :         W_ERROR_HAVE_NO_MEMORY(info);
    1665             : 
    1666          15 :         GetTimeOfDay(&tval);
    1667          15 :         t = tval.tv_sec;
    1668             : 
    1669          15 :         gmtime_r(&t, &tm);
    1670             : 
    1671          15 :         info->elapsed        = t;
    1672             :         /* TODO: fake the uptime: just return the milliseconds till 0:00:00 today */
    1673          30 :         info->msecs  = (tm.tm_hour*60*60*1000)
    1674          15 :                         + (tm.tm_min*60*1000)
    1675          15 :                         + (tm.tm_sec*1000)
    1676          15 :                         + (tval.tv_usec/1000);
    1677          15 :         info->hours  = tm.tm_hour;
    1678          15 :         info->mins   = tm.tm_min;
    1679          15 :         info->secs   = tm.tm_sec;
    1680          15 :         info->hunds  = tval.tv_usec/10000;
    1681          15 :         info->timezone       = get_time_zone(t)/60;
    1682          15 :         info->tinterval      = 310; /* just return the same as windows */
    1683          15 :         info->day    = tm.tm_mday;
    1684          15 :         info->month  = tm.tm_mon + 1;
    1685          15 :         info->year   = tm.tm_year + 1900;
    1686          15 :         info->weekday        = tm.tm_wday;
    1687             : 
    1688          15 :         *r->out.info = info;
    1689             : 
    1690          15 :         return WERR_OK;
    1691             : }
    1692             : 
    1693             : /* 
    1694             :   srvsvc_NetPathType 
    1695             : */
    1696           0 : static WERROR dcesrv_srvsvc_NetPathType(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    1697             :                        struct srvsvc_NetPathType *r)
    1698             : {
    1699           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    1700             : }
    1701             : 
    1702             : 
    1703             : /* 
    1704             :   srvsvc_NetPathCanonicalize 
    1705             : */
    1706           0 : static WERROR dcesrv_srvsvc_NetPathCanonicalize(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    1707             :                        struct srvsvc_NetPathCanonicalize *r)
    1708             : {
    1709           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    1710             : }
    1711             : 
    1712             : 
    1713             : /* 
    1714             :   srvsvc_NetPathCompare 
    1715             : */
    1716           0 : static WERROR dcesrv_srvsvc_NetPathCompare(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    1717             :                        struct srvsvc_NetPathCompare *r)
    1718             : {
    1719           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    1720             : }
    1721             : 
    1722             : 
    1723             : /* 
    1724             :   srvsvc_NetNameValidate 
    1725             : */
    1726        8424 : static WERROR dcesrv_srvsvc_NetNameValidate(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    1727             :                        struct srvsvc_NetNameValidate *r)
    1728             : {
    1729             :         int len;
    1730             : 
    1731        8424 :         if ((r->in.flags != 0x0) && (r->in.flags != 0x80000000)) {
    1732           0 :                 return WERR_INVALID_NAME;
    1733             :         }
    1734             : 
    1735        8424 :         switch (r->in.name_type) {
    1736        5184 :         case 1:
    1737             :         case 2:
    1738             :         case 3:
    1739             :         case 4:
    1740             :         case 5:
    1741             :         case 6:
    1742             :         case 7:
    1743             :         case 8:
    1744        5184 :                 return WERR_NOT_SUPPORTED;
    1745             : 
    1746         648 :         case 9: /* validate share name */
    1747             : 
    1748         648 :                 len = strlen_m(r->in.name);
    1749         648 :                 if ((r->in.flags == 0x0) && (len > 81)) {
    1750          33 :                         return WERR_INVALID_NAME;
    1751             :                 }
    1752         615 :                 if ((r->in.flags == 0x80000000) && (len > 13)) {
    1753          33 :                         return WERR_INVALID_NAME;
    1754             :                 }
    1755         582 :                 if (! dcesrv_common_validate_share_name(mem_ctx, r->in.name)) {
    1756         102 :                         return WERR_INVALID_NAME;
    1757             :                 }
    1758         480 :                 return WERR_OK;
    1759             : 
    1760        2592 :         case 10:
    1761             :         case 11:
    1762             :         case 12:
    1763             :         case 13:
    1764        2592 :                 return WERR_NOT_SUPPORTED;
    1765           0 :         default:
    1766           0 :                 return WERR_INVALID_PARAMETER;
    1767             :         }
    1768             : }
    1769             : 
    1770             : 
    1771             : /* 
    1772             :   srvsvc_NetPRNameCompare 
    1773             : */
    1774           0 : static WERROR dcesrv_srvsvc_NetPRNameCompare(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    1775             :                        struct srvsvc_NetPRNameCompare *r)
    1776             : {
    1777           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    1778             : }
    1779             : 
    1780             : 
    1781             : /* 
    1782             :   srvsvc_NetShareEnum 
    1783             : */
    1784          30 : static WERROR dcesrv_srvsvc_NetShareEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    1785             :                        struct srvsvc_NetShareEnum *r)
    1786             : {
    1787             :         NTSTATUS nterr;
    1788          30 :         int numshares = 0;
    1789             :         const char **snames;
    1790             :         struct share_context *sctx;
    1791             :         struct share_config *scfg;
    1792          30 :         struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx;
    1793             : 
    1794          30 :         *r->out.totalentries = 0;
    1795             : 
    1796             :         /* TODO: - paging of results 
    1797             :          */
    1798             : 
    1799          30 :         nterr = share_get_context(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
    1800          30 :         if (!NT_STATUS_IS_OK(nterr)) {
    1801           0 :                 return ntstatus_to_werror(nterr);
    1802             :         }
    1803             : 
    1804          30 :         nterr = share_list_all(mem_ctx, sctx, &numshares, &snames);
    1805          30 :         if (!NT_STATUS_IS_OK(nterr)) {
    1806           0 :                 return ntstatus_to_werror(nterr);
    1807             :         }
    1808             : 
    1809          30 :         switch (r->in.info_ctr->level) {
    1810           6 :         case 0:
    1811             :         {
    1812           6 :                 unsigned int i, y = 0;
    1813             :                 unsigned int count;
    1814             :                 struct srvsvc_NetShareCtr0 *ctr0;
    1815             : 
    1816           6 :                 ctr0 = talloc(mem_ctx, struct srvsvc_NetShareCtr0);
    1817           6 :                 W_ERROR_HAVE_NO_MEMORY(ctr0);
    1818             : 
    1819           6 :                 count = numshares;
    1820           6 :                 ctr0->count = count;
    1821           6 :                 ctr0->array = NULL;
    1822             : 
    1823           6 :                 if (ctr0->count == 0) {
    1824           0 :                         r->out.info_ctr->ctr.ctr0 = ctr0;
    1825           0 :                         return WERR_OK;
    1826             :                 }
    1827             : 
    1828           6 :                 ctr0->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo0, count);
    1829           6 :                 W_ERROR_HAVE_NO_MEMORY(ctr0->array);
    1830             : 
    1831          84 :                 for (i=0; i < count; i++) {
    1832             :                         WERROR status;
    1833             :                         union srvsvc_NetShareInfo info;
    1834             :                         enum srvsvc_ShareType type;
    1835             : 
    1836          78 :                         nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
    1837          78 :                         if (!NT_STATUS_IS_OK(nterr)) {
    1838           0 :                                 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
    1839           0 :                                 return WERR_GEN_FAILURE;
    1840             :                         }
    1841             :                         
    1842          78 :                         type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
    1843          78 :                         if (type & STYPE_HIDDEN) {
    1844           6 :                                 ctr0->count--;
    1845           6 :                                 talloc_free(scfg);
    1846           6 :                                 continue;
    1847             :                         }
    1848             : 
    1849          72 :                         info.info0 = &ctr0->array[y];
    1850          72 :                         status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
    1851          72 :                         W_ERROR_NOT_OK_RETURN(status);
    1852          72 :                         talloc_free(scfg);
    1853          72 :                         y++;
    1854             :                 }
    1855           6 :                 talloc_free(snames);
    1856             : 
    1857           6 :                 r->out.info_ctr->ctr.ctr0 = ctr0;
    1858           6 :                 *r->out.totalentries         = r->out.info_ctr->ctr.ctr0->count;
    1859             : 
    1860           6 :                 return WERR_OK;
    1861             :         }
    1862           6 :         case 1:
    1863             :         {
    1864           6 :                 unsigned int i, y = 0;
    1865             :                 unsigned int count;
    1866             :                 struct srvsvc_NetShareCtr1 *ctr1;
    1867             : 
    1868           6 :                 ctr1 = talloc(mem_ctx, struct srvsvc_NetShareCtr1);
    1869           6 :                 W_ERROR_HAVE_NO_MEMORY(ctr1);
    1870             : 
    1871           6 :                 count = numshares;
    1872           6 :                 ctr1->count = count;
    1873           6 :                 ctr1->array = NULL;
    1874             : 
    1875           6 :                 if (ctr1->count == 0) {
    1876           0 :                         r->out.info_ctr->ctr.ctr1 = ctr1;
    1877           0 :                         return WERR_OK;
    1878             :                 }
    1879             : 
    1880           6 :                 ctr1->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo1, count);
    1881           6 :                 W_ERROR_HAVE_NO_MEMORY(ctr1->array);
    1882             : 
    1883          84 :                 for (i=0; i < count; i++) {
    1884             :                         WERROR status;
    1885             :                         union srvsvc_NetShareInfo info;
    1886             :                         enum srvsvc_ShareType type;
    1887             : 
    1888          78 :                         nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
    1889          78 :                         if (!NT_STATUS_IS_OK(nterr)) {
    1890           0 :                                 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
    1891           0 :                                 return WERR_GEN_FAILURE;
    1892             :                         }
    1893             : 
    1894          78 :                         type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
    1895          78 :                         if (type & STYPE_HIDDEN) {
    1896           6 :                                 ctr1->count--;
    1897           6 :                                 talloc_free(scfg);
    1898           6 :                                 continue;
    1899             :                         }
    1900             : 
    1901          72 :                         info.info1 = &ctr1->array[y];
    1902          72 :                         status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
    1903          72 :                         W_ERROR_NOT_OK_RETURN(status);
    1904          72 :                         talloc_free(scfg);
    1905          72 :                         y++;
    1906             :                 }
    1907           6 :                 talloc_free(snames);
    1908             : 
    1909           6 :                 r->out.info_ctr->ctr.ctr1 = ctr1;
    1910           6 :                 *r->out.totalentries         = r->out.info_ctr->ctr.ctr1->count;
    1911             : 
    1912           6 :                 return WERR_OK;
    1913             :         }
    1914           6 :         case 2:
    1915             :         {
    1916           6 :                 unsigned int i, y = 0;
    1917             :                 unsigned int count;
    1918             :                 struct srvsvc_NetShareCtr2 *ctr2;
    1919             : 
    1920           6 :                 SRVSVC_CHECK_ADMIN_ACCESS;
    1921             : 
    1922           3 :                 ctr2 = talloc(mem_ctx, struct srvsvc_NetShareCtr2);
    1923           3 :                 W_ERROR_HAVE_NO_MEMORY(ctr2);
    1924             : 
    1925           3 :                 count = numshares;
    1926           3 :                 ctr2->count = count;
    1927           3 :                 ctr2->array = NULL;
    1928             : 
    1929           3 :                 if (ctr2->count == 0) {
    1930           0 :                         r->out.info_ctr->ctr.ctr2 = ctr2;
    1931           0 :                         return WERR_OK;
    1932             :                 }
    1933             : 
    1934           3 :                 ctr2->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo2, count);
    1935           3 :                 W_ERROR_HAVE_NO_MEMORY(ctr2->array);
    1936             : 
    1937          42 :                 for (i=0; i < count; i++) {
    1938             :                         WERROR status;
    1939             :                         union srvsvc_NetShareInfo info;
    1940             :                         enum srvsvc_ShareType type;
    1941             : 
    1942          39 :                         nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
    1943          39 :                         if (!NT_STATUS_IS_OK(nterr)) {
    1944           0 :                                 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
    1945           0 :                                 return WERR_GEN_FAILURE;
    1946             :                         }
    1947             : 
    1948          39 :                         type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
    1949          39 :                         if (type & STYPE_HIDDEN) {
    1950           3 :                                 ctr2->count--;
    1951           3 :                                 talloc_free(scfg);
    1952           3 :                                 continue;
    1953             :                         }
    1954             : 
    1955          36 :                         info.info2 = &ctr2->array[y];
    1956          36 :                         status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
    1957          36 :                         W_ERROR_NOT_OK_RETURN(status);
    1958          36 :                         talloc_free(scfg);
    1959          36 :                         y++;
    1960             :                 }
    1961           3 :                 talloc_free(snames);
    1962             : 
    1963           3 :                 r->out.info_ctr->ctr.ctr2 = ctr2;
    1964           3 :                 *r->out.totalentries         = r->out.info_ctr->ctr.ctr2->count;
    1965             : 
    1966           3 :                 return WERR_OK;
    1967             :         }
    1968           6 :         case 502:
    1969             :         {
    1970           6 :                 unsigned int i, y = 0;
    1971             :                 unsigned int count;
    1972             :                 struct srvsvc_NetShareCtr502 *ctr502;
    1973             : 
    1974           6 :                 SRVSVC_CHECK_ADMIN_ACCESS;
    1975             : 
    1976           3 :                 ctr502 = talloc(mem_ctx, struct srvsvc_NetShareCtr502);
    1977           3 :                 W_ERROR_HAVE_NO_MEMORY(ctr502);
    1978             : 
    1979           3 :                 count = numshares;
    1980           3 :                 ctr502->count = count;
    1981           3 :                 ctr502->array = NULL;
    1982             : 
    1983           3 :                 if (ctr502->count == 0) {
    1984           0 :                         r->out.info_ctr->ctr.ctr502       = ctr502;
    1985           0 :                         return WERR_OK;
    1986             :                 }
    1987             : 
    1988           3 :                 ctr502->array = talloc_array(mem_ctx, struct srvsvc_NetShareInfo502, count);
    1989           3 :                 W_ERROR_HAVE_NO_MEMORY(ctr502->array);
    1990             : 
    1991          42 :                 for (i=0; i < count; i++) {
    1992             :                         WERROR status;
    1993             :                         union srvsvc_NetShareInfo info;
    1994             :                         enum srvsvc_ShareType type;
    1995             : 
    1996          39 :                         nterr = share_get_config(mem_ctx, sctx, snames[i], &scfg);
    1997          39 :                         if (!NT_STATUS_IS_OK(nterr)) {
    1998           0 :                                 DEBUG(1, ("ERROR: Service [%s] disappeared after enumeration", snames[i]));
    1999           0 :                                 return WERR_GEN_FAILURE;
    2000             :                         }
    2001             : 
    2002          39 :                         type = dcesrv_common_get_share_type(mem_ctx, dce_ctx, scfg);
    2003          39 :                         if (type & STYPE_HIDDEN) {
    2004           3 :                                 ctr502->count--;
    2005           3 :                                 talloc_free(scfg);
    2006           3 :                                 continue;
    2007             :                         }
    2008             : 
    2009          36 :                         info.info502 = &ctr502->array[y];
    2010          36 :                         status = dcesrv_srvsvc_fiel_ShareInfo(dce_call, mem_ctx, scfg, r->in.info_ctr->level, &info);
    2011          36 :                         W_ERROR_NOT_OK_RETURN(status);
    2012          36 :                         talloc_free(scfg);
    2013          36 :                         y++;
    2014             :                 }
    2015           3 :                 talloc_free(snames);
    2016             : 
    2017           3 :                 r->out.info_ctr->ctr.ctr502       = ctr502;
    2018           3 :                 *r->out.totalentries         = r->out.info_ctr->ctr.ctr502->count;
    2019             : 
    2020           3 :                 return WERR_OK;
    2021             :         }
    2022           6 :         default:
    2023           6 :                 return WERR_INVALID_LEVEL;
    2024             :         }
    2025             : }
    2026             : 
    2027             : 
    2028             : /* 
    2029             :   srvsvc_NetShareDelStart 
    2030             : */
    2031           0 : static WERROR dcesrv_srvsvc_NetShareDelStart(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2032             :                        struct srvsvc_NetShareDelStart *r)
    2033             : {
    2034           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    2035             : }
    2036             : 
    2037             : 
    2038             : /* 
    2039             :   srvsvc_NetShareDelCommit 
    2040             : */
    2041           0 : static WERROR dcesrv_srvsvc_NetShareDelCommit(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2042             :                        struct srvsvc_NetShareDelCommit *r)
    2043             : {
    2044           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    2045             : }
    2046             : 
    2047             : 
    2048             : /* 
    2049             :   srvsvc_NetGetFileSecurity 
    2050             : */
    2051           0 : static WERROR dcesrv_srvsvc_NetGetFileSecurity(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2052             :                        struct srvsvc_NetGetFileSecurity *r)
    2053             : {
    2054           0 :         struct auth_session_info *session_info =
    2055             :                 dcesrv_call_session_info(dce_call);
    2056             :         struct sec_desc_buf *sd_buf;
    2057           0 :         struct ntvfs_context *ntvfs_ctx = NULL;
    2058             :         struct ntvfs_request *ntvfs_req;
    2059             :         union smb_fileinfo *io;
    2060             :         NTSTATUS nt_status;
    2061             : 
    2062           0 :         nt_status = srvsvc_create_ntvfs_context(dce_call, mem_ctx, r->in.share, &ntvfs_ctx);
    2063           0 :         if (!NT_STATUS_IS_OK(nt_status)) return ntstatus_to_werror(nt_status);
    2064             : 
    2065           0 :         ntvfs_req = ntvfs_request_create(ntvfs_ctx, mem_ctx,
    2066             :                                          session_info,
    2067             :                                          0,
    2068             :                                          dce_call->time,
    2069             :                                          NULL, NULL, 0);
    2070           0 :         W_ERROR_HAVE_NO_MEMORY(ntvfs_req);
    2071             : 
    2072           0 :         sd_buf = talloc(mem_ctx, struct sec_desc_buf);
    2073           0 :         W_ERROR_HAVE_NO_MEMORY(sd_buf);
    2074             : 
    2075           0 :         io = talloc(mem_ctx, union smb_fileinfo);
    2076           0 :         W_ERROR_HAVE_NO_MEMORY(io);
    2077             : 
    2078           0 :         io->query_secdesc.level                      = RAW_FILEINFO_SEC_DESC;
    2079           0 :         io->query_secdesc.in.file.path               = r->in.file;
    2080           0 :         io->query_secdesc.in.secinfo_flags   = r->in.securityinformation;
    2081             : 
    2082           0 :         nt_status = ntvfs_qpathinfo(ntvfs_req, io);
    2083           0 :         if (!NT_STATUS_IS_OK(nt_status)) return ntstatus_to_werror(nt_status);
    2084             : 
    2085           0 :         sd_buf->sd = io->query_secdesc.out.sd;
    2086             : 
    2087           0 :         *r->out.sd_buf = sd_buf;
    2088           0 :         return WERR_OK;
    2089             : }
    2090             : 
    2091             : 
    2092             : /* 
    2093             :   srvsvc_NetSetFileSecurity 
    2094             : */
    2095           0 : static WERROR dcesrv_srvsvc_NetSetFileSecurity(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2096             :                        struct srvsvc_NetSetFileSecurity *r)
    2097             : {
    2098           0 :         struct auth_session_info *session_info =
    2099             :                 dcesrv_call_session_info(dce_call);
    2100             :         struct ntvfs_context *ntvfs_ctx;
    2101             :         struct ntvfs_request *ntvfs_req;
    2102             :         union smb_setfileinfo *io;
    2103             :         NTSTATUS nt_status;
    2104             : 
    2105           0 :         nt_status = srvsvc_create_ntvfs_context(dce_call, mem_ctx, r->in.share, &ntvfs_ctx);
    2106           0 :         if (!NT_STATUS_IS_OK(nt_status)) return ntstatus_to_werror(nt_status);
    2107             : 
    2108           0 :         ntvfs_req = ntvfs_request_create(ntvfs_ctx, mem_ctx,
    2109             :                                          session_info,
    2110             :                                          0,
    2111             :                                          dce_call->time,
    2112             :                                          NULL, NULL, 0);
    2113           0 :         W_ERROR_HAVE_NO_MEMORY(ntvfs_req);
    2114             : 
    2115           0 :         io = talloc(mem_ctx, union smb_setfileinfo);
    2116           0 :         W_ERROR_HAVE_NO_MEMORY(io);
    2117             : 
    2118           0 :         io->set_secdesc.level                        = RAW_SFILEINFO_SEC_DESC;
    2119           0 :         io->set_secdesc.in.file.path         = r->in.file;
    2120           0 :         io->set_secdesc.in.secinfo_flags     = r->in.securityinformation;
    2121           0 :         io->set_secdesc.in.sd                        = r->in.sd_buf->sd;
    2122             : 
    2123           0 :         nt_status = ntvfs_setpathinfo(ntvfs_req, io);
    2124           0 :         if (!NT_STATUS_IS_OK(nt_status)) return ntstatus_to_werror(nt_status);
    2125             : 
    2126           0 :         return WERR_OK;
    2127             : }
    2128             : 
    2129             : 
    2130             : /* 
    2131             :   srvsvc_NetServerTransportAddEx 
    2132             : */
    2133           0 : static WERROR dcesrv_srvsvc_NetServerTransportAddEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2134             :                        struct srvsvc_NetServerTransportAddEx *r)
    2135             : {
    2136           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    2137             : }
    2138             : 
    2139             : 
    2140             : /* 
    2141             :   srvsvc_NetServerSetServiceBitsEx 
    2142             : */
    2143           0 : static WERROR dcesrv_srvsvc_NetServerSetServiceBitsEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2144             :                        struct srvsvc_NetServerSetServiceBitsEx *r)
    2145             : {
    2146           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    2147             : }
    2148             : 
    2149             : 
    2150             : /* 
    2151             :   srvsvc_NETRDFSGETVERSION 
    2152             : */
    2153           0 : static WERROR dcesrv_srvsvc_NETRDFSGETVERSION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2154             :                        struct srvsvc_NETRDFSGETVERSION *r)
    2155             : {
    2156           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    2157             : }
    2158             : 
    2159             : 
    2160             : /* 
    2161             :   srvsvc_NETRDFSCREATELOCALPARTITION 
    2162             : */
    2163           0 : static WERROR dcesrv_srvsvc_NETRDFSCREATELOCALPARTITION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2164             :                        struct srvsvc_NETRDFSCREATELOCALPARTITION *r)
    2165             : {
    2166           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    2167             : }
    2168             : 
    2169             : 
    2170             : /* 
    2171             :   srvsvc_NETRDFSDELETELOCALPARTITION 
    2172             : */
    2173           0 : static WERROR dcesrv_srvsvc_NETRDFSDELETELOCALPARTITION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2174             :                        struct srvsvc_NETRDFSDELETELOCALPARTITION *r)
    2175             : {
    2176           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    2177             : }
    2178             : 
    2179             : 
    2180             : /* 
    2181             :   srvsvc_NETRDFSSETLOCALVOLUMESTATE 
    2182             : */
    2183           0 : static WERROR dcesrv_srvsvc_NETRDFSSETLOCALVOLUMESTATE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2184             :                        struct srvsvc_NETRDFSSETLOCALVOLUMESTATE *r)
    2185             : {
    2186           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    2187             : }
    2188             : 
    2189             : 
    2190             : /* 
    2191             :   srvsvc_NETRDFSSETSERVERINFO 
    2192             : */
    2193           0 : static WERROR dcesrv_srvsvc_NETRDFSSETSERVERINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2194             :                        struct srvsvc_NETRDFSSETSERVERINFO *r)
    2195             : {
    2196           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    2197             : }
    2198             : 
    2199             : 
    2200             : /* 
    2201             :   srvsvc_NETRDFSCREATEEXITPOINT 
    2202             : */
    2203           0 : static WERROR dcesrv_srvsvc_NETRDFSCREATEEXITPOINT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2204             :                        struct srvsvc_NETRDFSCREATEEXITPOINT *r)
    2205             : {
    2206           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    2207             : }
    2208             : 
    2209             : 
    2210             : /* 
    2211             :   srvsvc_NETRDFSDELETEEXITPOINT 
    2212             : */
    2213           0 : static WERROR dcesrv_srvsvc_NETRDFSDELETEEXITPOINT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2214             :                        struct srvsvc_NETRDFSDELETEEXITPOINT *r)
    2215             : {
    2216           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    2217             : }
    2218             : 
    2219             : 
    2220             : /* 
    2221             :   srvsvc_NETRDFSMODIFYPREFIX 
    2222             : */
    2223           0 : static WERROR dcesrv_srvsvc_NETRDFSMODIFYPREFIX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2224             :                        struct srvsvc_NETRDFSMODIFYPREFIX *r)
    2225             : {
    2226           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    2227             : }
    2228             : 
    2229             : 
    2230             : /* 
    2231             :   srvsvc_NETRDFSFIXLOCALVOLUME 
    2232             : */
    2233           0 : static WERROR dcesrv_srvsvc_NETRDFSFIXLOCALVOLUME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2234             :                        struct srvsvc_NETRDFSFIXLOCALVOLUME *r)
    2235             : {
    2236           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    2237             : }
    2238             : 
    2239             : 
    2240             : /* 
    2241             :   srvsvc_NETRDFSMANAGERREPORTSITEINFO 
    2242             : */
    2243           0 : static WERROR dcesrv_srvsvc_NETRDFSMANAGERREPORTSITEINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2244             :                        struct srvsvc_NETRDFSMANAGERREPORTSITEINFO *r)
    2245             : {
    2246           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    2247             : }
    2248             : 
    2249             : 
    2250             : /* 
    2251             :   srvsvc_NETRSERVERTRANSPORTDELEX 
    2252             : */
    2253           0 : static WERROR dcesrv_srvsvc_NETRSERVERTRANSPORTDELEX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2254             :                        struct srvsvc_NETRSERVERTRANSPORTDELEX *r)
    2255             : {
    2256           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    2257             : }
    2258             : 
    2259             : /* 
    2260             :   srvsvc_NetShareDel 
    2261             : */
    2262           0 : static WERROR dcesrv_srvsvc_NetShareDel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2263             :                        struct srvsvc_NetShareDel *r)
    2264             : {
    2265             :         NTSTATUS nterr;
    2266             :         struct share_context *sctx;
    2267             :                 
    2268           0 :         nterr = share_get_context(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
    2269           0 :         if (!NT_STATUS_IS_OK(nterr)) {
    2270           0 :                 return ntstatus_to_werror(nterr);
    2271             :         }
    2272             :                         
    2273           0 :         nterr = share_remove(sctx, r->in.share_name);
    2274           0 :         if (!NT_STATUS_IS_OK(nterr)) {
    2275           0 :                 return ntstatus_to_werror(nterr);
    2276             :         }
    2277             : 
    2278           0 :         return WERR_OK;
    2279             : }
    2280             : 
    2281             : /* 
    2282             :   srvsvc_NetSetServiceBits 
    2283             : */
    2284           0 : static WERROR dcesrv_srvsvc_NetSetServiceBits(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2285             :                        struct srvsvc_NetSetServiceBits *r)
    2286             : {
    2287           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    2288             : }
    2289             : 
    2290             : /* 
    2291             :   srvsvc_NETRPRNAMECANONICALIZE 
    2292             : */
    2293           0 : static WERROR dcesrv_srvsvc_NETRPRNAMECANONICALIZE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
    2294             :                        struct srvsvc_NETRPRNAMECANONICALIZE *r)
    2295             : {
    2296           0 :         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
    2297             : }
    2298             : 
    2299             : /* include the generated boilerplate */
    2300             : #include "librpc/gen_ndr/ndr_srvsvc_s.c"

Generated by: LCOV version 1.13