This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
this implements a CIFS->CIFS NTVFS filesystem backend.
#include "libcli/raw/libcliraw.h"
#include "libcli/smb_composite/smb_composite.h"
#include "auth/auth.h"
+#include "auth/credentials/credentials.h"
#include "ntvfs/ntvfs.h"
-#include "include/dlinklist.h"
+#include "lib/util/dlinklist.h"
+#include "param/param.h"
struct cvfs_file {
struct cvfs_file *prev, *next;
SETUP_FILE; \
} while (0)
+#define CIFS_SERVER "cifs:server"
+#define CIFS_USER "cifs:user"
+#define CIFS_PASSWORD "cifs:password"
+#define CIFS_DOMAIN "cifs:domain"
+#define CIFS_SHARE "cifs:share"
+#define CIFS_USE_MACHINE_ACCT "cifs:use-machine-account"
+#define CIFS_MAP_GENERIC "cifs:map-generic"
+#define CIFS_MAP_TRANS2 "cifs:map-trans2"
+
+#define CIFS_USE_MACHINE_ACCT_DEFAULT False
+#define CIFS_MAP_GENERIC_DEFAULT False
+#define CIFS_MAP_TRANS2_DEFAULT True
+
/*
a handler for oplock break events from the server - these need to be passed
along to the client
const char *host, *user, *pass, *domain, *remote_share;
struct smb_composite_connect io;
struct composite_context *creq;
- int snum = ntvfs->ctx->config.snum;
+ struct share_config *scfg = ntvfs->ctx->config;
struct cli_credentials *credentials;
BOOL machine_account;
* For now we use parametric options, type cifs.
* Later we will use security=server and auth_server.c.
*/
- host = lp_parm_string(snum, "cifs", "server");
- user = lp_parm_string(snum, "cifs", "user");
- pass = lp_parm_string(snum, "cifs", "password");
- domain = lp_parm_string(snum, "cifs", "domain");
- remote_share = lp_parm_string(snum, "cifs", "share");
+ host = share_string_option(scfg, CIFS_SERVER, NULL);
+ user = share_string_option(scfg, CIFS_USER, NULL);
+ pass = share_string_option(scfg, CIFS_PASSWORD, NULL);
+ domain = share_string_option(scfg, CIFS_DOMAIN, NULL);
+ remote_share = share_string_option(scfg, CIFS_SHARE, NULL);
if (!remote_share) {
remote_share = sharename;
}
- machine_account = lp_parm_bool(snum, "cifs", "use_machine_account", False);
+ machine_account = share_bool_option(scfg, CIFS_USE_MACHINE_ACCT, CIFS_USE_MACHINE_ACCT_DEFAULT);
private = talloc_zero(ntvfs, struct cvfs_private);
if (!private) {
if (!credentials) {
return NT_STATUS_NO_MEMORY;
}
- cli_credentials_set_conf(credentials);
+ cli_credentials_set_event_context(credentials, ntvfs->ctx->event_ctx);
+ cli_credentials_set_conf(credentials, global_loadparm);
cli_credentials_set_username(credentials, user, CRED_SPECIFIED);
if (domain) {
cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED);
} else if (machine_account) {
DEBUG(5, ("CIFS backend: Using machine account\n"));
credentials = cli_credentials_init(private);
- cli_credentials_set_conf(credentials);
+ cli_credentials_set_event_context(credentials, ntvfs->ctx->event_ctx);
+ cli_credentials_set_conf(credentials, global_loadparm);
if (domain) {
cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED);
}
DEBUG(5, ("CIFS backend: Using delegated credentials\n"));
credentials = req->session_info->credentials;
} else {
- DEBUG(1,("CIFS backend: You must supply server, user and password and or have delegated credentials\n"));
+ DEBUG(1,("CIFS backend: NO delegated credentials found: You must supply server, user and password or the client must supply delegated credentials\n"));
return NT_STATUS_INVALID_PARAMETER;
}
io.in.called_name = host;
io.in.credentials = credentials;
io.in.fallback_to_anonymous = False;
- io.in.workgroup = lp_workgroup();
+ io.in.workgroup = lp_workgroup(global_loadparm);
io.in.service = remote_share;
io.in.service_type = "?????";
/* we need to receive oplock break requests from the server */
smbcli_oplock_handler(private->transport, oplock_handler, private);
- private->map_generic = lp_parm_bool(ntvfs->ctx->config.snum,
- "cifs", "mapgeneric", False);
+ private->map_generic = share_bool_option(scfg, CIFS_MAP_GENERIC, CIFS_MAP_GENERIC_DEFAULT);
- private->map_trans2 = lp_parm_bool(ntvfs->ctx->config.snum,
- "cifs", "maptrans2", True);
+ private->map_trans2 = share_bool_option(scfg, CIFS_MAP_TRANS2, CIFS_MAP_TRANS2_DEFAULT);
return NT_STATUS_OK;
}
/*
destroy an async info structure
*/
-static int async_info_destructor(void *p)
+static int async_info_destructor(struct async_info *async)
{
- struct async_info *async = talloc_get_type(p, struct async_info);
DLIST_REMOVE(async->cvfs->pending, async);
return 0;
}
/* find the matching request */
for (a=private->pending;a;a=a->next) {
- if (a->req->smbmid == req->smbmid) {
+ if (a->req == req) {
break;
}
}
static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs,
struct ntvfs_request *req, union smb_search_first *io,
void *search_private,
- BOOL (*callback)(void *, union smb_search_data *))
+ BOOL (*callback)(void *, const union smb_search_data *))
{
struct cvfs_private *private = ntvfs->private_data;
static NTSTATUS cvfs_search_next(struct ntvfs_module_context *ntvfs,
struct ntvfs_request *req, union smb_search_next *io,
void *search_private,
- BOOL (*callback)(void *, union smb_search_data *))
+ BOOL (*callback)(void *, const union smb_search_data *))
{
struct cvfs_private *private = ntvfs->private_data;
/* change notify request - always async */
static NTSTATUS cvfs_notify(struct ntvfs_module_context *ntvfs,
struct ntvfs_request *req,
- struct smb_notify *io)
+ union smb_notify *io)
{
struct cvfs_private *private = ntvfs->private_data;
struct smbcli_request *c_req;
int saved_timeout = private->transport->options.request_timeout;
struct cvfs_file *f;
+ if (io->nttrans.level != RAW_NOTIFY_NTTRANS) {
+ return NT_STATUS_NOT_IMPLEMENTED;
+ }
+
SETUP_PID;
- f = ntvfs_handle_get_backend_data(io->in.file.ntvfs, ntvfs);
+ f = ntvfs_handle_get_backend_data(io->nttrans.in.file.ntvfs, ntvfs);
if (!f) return NT_STATUS_INVALID_HANDLE;
- io->in.file.fnum = f->fnum;
+ io->nttrans.in.file.fnum = f->fnum;
/* this request doesn't make sense unless its async */
if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {