Line data Source code
1 : /* 2 : Unix SMB/CIFS implementation. 3 : RAP handlers 4 : 5 : Copyright (C) Volker Lendecke 2004 6 : 7 : This program is free software; you can redistribute it and/or modify 8 : it under the terms of the GNU General Public License as published by 9 : the Free Software Foundation; either version 3 of the License, or 10 : (at your option) any later version. 11 : 12 : This program is distributed in the hope that it will be useful, 13 : but WITHOUT ANY WARRANTY; without even the implied warranty of 14 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 : GNU General Public License for more details. 16 : 17 : You should have received a copy of the GNU General Public License 18 : along with this program. If not, see <http://www.gnu.org/licenses/>. 19 : */ 20 : 21 : #include "includes.h" 22 : #include "param/share.h" 23 : #include "../librpc/gen_ndr/rap.h" 24 : #include "libcli/raw/interfaces.h" 25 : #include "librpc/gen_ndr/srvsvc.h" 26 : #include "librpc/gen_ndr/dcerpc.h" 27 : #include "rpc_server/common/common.h" 28 : #include "rpc_server/common/share.h" 29 : #include "param/param.h" 30 : #include "ntvfs/ipc/proto.h" 31 : 32 : /* At this moment these are just dummy functions, but you might get the 33 : * idea. */ 34 : 35 0 : NTSTATUS rap_netshareenum(TALLOC_CTX *mem_ctx, 36 : struct tevent_context *event_ctx, 37 : struct loadparm_context *lp_ctx, 38 : struct rap_NetShareEnum *r) 39 : { 40 0 : NTSTATUS nterr; 41 0 : const char **snames; 42 0 : struct share_context *sctx; 43 0 : struct share_config *scfg; 44 0 : int i, j, count; 45 : 46 0 : r->out.status = 0; 47 0 : r->out.available = 0; 48 0 : r->out.info = NULL; 49 : 50 0 : nterr = share_get_context(mem_ctx, lp_ctx, &sctx); 51 0 : if (!NT_STATUS_IS_OK(nterr)) { 52 0 : return nterr; 53 : } 54 : 55 0 : nterr = share_list_all(mem_ctx, sctx, &count, &snames); 56 0 : if (!NT_STATUS_IS_OK(nterr)) { 57 0 : return nterr; 58 : } 59 : 60 0 : r->out.available = count; 61 0 : r->out.info = talloc_array(mem_ctx, 62 : union rap_share_info, r->out.available); 63 : 64 0 : for (i = 0, j = 0; i < r->out.available; i++) { 65 0 : size_t sname_len; 66 : 67 0 : if (!NT_STATUS_IS_OK(share_get_config(mem_ctx, sctx, snames[i], &scfg))) { 68 0 : DEBUG(3, ("WARNING: Service [%s] disappeared after enumeration!\n", snames[i])); 69 0 : continue; 70 : } 71 : /* Make sure we have NUL-termination */ 72 0 : sname_len = MIN(strlen(snames[i]), 73 : sizeof(r->out.info[j].info1.share_name)); 74 0 : strlcpy((char *)r->out.info[j].info1.share_name, 75 0 : snames[i], 76 : sname_len); 77 0 : r->out.info[i].info1.reserved1 = 0; 78 0 : r->out.info[i].info1.share_type = dcesrv_common_get_share_type(mem_ctx, NULL, scfg); 79 0 : r->out.info[i].info1.comment = share_string_option(mem_ctx, scfg, SHARE_COMMENT, ""); 80 0 : talloc_free(scfg); 81 0 : j++; 82 : } 83 0 : r->out.available = j; 84 : 85 0 : return NT_STATUS_OK; 86 : } 87 : 88 0 : NTSTATUS rap_netserverenum2(TALLOC_CTX *mem_ctx, 89 : struct loadparm_context *lp_ctx, 90 : struct rap_NetServerEnum2 *r) 91 : { 92 0 : r->out.status = 0; 93 0 : r->out.available = 0; 94 0 : return NT_STATUS_OK; 95 : }