s3-lsa: Fix static list of luids in our privileges implementation.
[Samba/ekacnet.git] / source4 / rpc_server / srvsvc / srvsvc_ntvfs.c
blobda1a65047c8e5063ef59e9593cf0e4bb3b9c36a2
1 /*
2 Unix SMB/CIFS implementation.
4 srvsvc pipe ntvfs helper functions
6 Copyright (C) Stefan (metze) Metzmacher 2006
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.
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.
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/>.
21 #include "includes.h"
22 #include "ntvfs/ntvfs.h"
23 #include "rpc_server/dcerpc_server.h"
24 #include "param/param.h"
26 struct srvsvc_ntvfs_ctx {
27 struct ntvfs_context *ntvfs;
30 static int srvsvc_ntvfs_ctx_destructor(struct srvsvc_ntvfs_ctx *c)
32 ntvfs_disconnect(c->ntvfs);
33 return 0;
36 NTSTATUS srvsvc_create_ntvfs_context(struct dcesrv_call_state *dce_call,
37 TALLOC_CTX *mem_ctx,
38 const char *share,
39 struct ntvfs_context **_ntvfs)
41 NTSTATUS status;
42 struct srvsvc_ntvfs_ctx *c;
43 struct ntvfs_request *ntvfs_req;
44 enum ntvfs_type type;
45 struct share_context *sctx;
46 struct share_config *scfg;
47 const char *sharetype;
48 union smb_tcon tcon;
49 const struct tsocket_address *local_address;
50 const struct tsocket_address *remote_address;
52 status = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
53 if (!NT_STATUS_IS_OK(status)) {
54 return status;
57 status = share_get_config(mem_ctx, sctx, share, &scfg);
58 if (!NT_STATUS_IS_OK(status)) {
59 DEBUG(0,("srvsvc_create_ntvfs_context: couldn't find service %s\n", share));
60 return status;
63 #if 0 /* TODO: fix access cecking */
64 if (!socket_check_access(dce_call->connection->socket,
65 scfg->name,
66 share_string_list_option(scfg, SHARE_HOSTS_ALLOW),
67 share_string_list_option(scfg, SHARE_HOSTS_DENY))) {
68 return NT_STATUS_ACCESS_DENIED;
70 #endif
72 /* work out what sort of connection this is */
73 sharetype = share_string_option(scfg, SHARE_TYPE, SHARE_TYPE_DEFAULT);
74 if (sharetype && strcmp(sharetype, "IPC") == 0) {
75 type = NTVFS_IPC;
76 } else if (sharetype && strcmp(sharetype, "PRINTER")) {
77 type = NTVFS_PRINT;
78 } else {
79 type = NTVFS_DISK;
82 c = talloc(mem_ctx, struct srvsvc_ntvfs_ctx);
83 NT_STATUS_HAVE_NO_MEMORY(c);
85 /* init ntvfs function pointers */
86 status = ntvfs_init_connection(c, scfg, type,
87 PROTOCOL_NT1,
88 0,/* ntvfs_client_caps */
89 dce_call->event_ctx,
90 dce_call->conn->msg_ctx,
91 dce_call->conn->dce_ctx->lp_ctx,
92 dce_call->conn->server_id,
93 &c->ntvfs);
94 if (!NT_STATUS_IS_OK(status)) {
95 DEBUG(0, ("srvsvc_create_ntvfs_context: ntvfs_init_connection failed for service %s\n",
96 scfg->name));
97 return status;
99 talloc_set_destructor(c, srvsvc_ntvfs_ctx_destructor);
102 * NOTE: we only set the addr callbacks as we're not interesseted in oplocks or in getting file handles
104 local_address = dcesrv_connection_get_local_address(dce_call->conn);
105 remote_address = dcesrv_connection_get_remote_address(dce_call->conn);
106 status = ntvfs_set_addresses(c->ntvfs, local_address, remote_address);
107 if (!NT_STATUS_IS_OK(status)) {
108 DEBUG(0,("srvsvc_create_ntvfs_context: NTVFS failed to set the addr callbacks!\n"));
109 return status;
112 ntvfs_req = ntvfs_request_create(c->ntvfs, mem_ctx,
113 dce_call->conn->auth_state.session_info,
114 0, /* TODO: fill in PID */
115 dce_call->time,
116 NULL, NULL, 0);
117 NT_STATUS_HAVE_NO_MEMORY(ntvfs_req);
119 /* Invoke NTVFS connection hook */
120 tcon.tcon.level = RAW_TCON_TCON;
121 ZERO_STRUCT(tcon.tcon.in);
122 tcon.tcon.in.service = scfg->name;
123 status = ntvfs_connect(ntvfs_req, &tcon);
124 if (!NT_STATUS_IS_OK(status)) {
125 DEBUG(0,("srvsvc_create_ntvfs_context: NTVFS ntvfs_connect() failed!\n"));
126 return status;
129 *_ntvfs = c->ntvfs;
130 return NT_STATUS_OK;