summaryrefslogtreecommitdiff
path: root/source4/ntvfs
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2019-05-21 13:57:57 +1200
committerGary Lockyer <gary@samba.org>2019-05-22 07:15:43 +0000
commit31de52ed2efe598e7fab72d90a742d4f9e03c97e (patch)
tree76fd98ca0b310933ac83ba757211368b46e99769 /source4/ntvfs
parent679227d6063074aabb986d78fab42b856db265e3 (diff)
downloadsamba-31de52ed2efe598e7fab72d90a742d4f9e03c97e.tar.gz
s4-ntvfs: Remove untested ntvfs_cifsposix backend
It had a note: WARNING: All file access is done as user root!!! Only use this module for testing, with only test data!!! Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Autobuild-User(master): Gary Lockyer <gary@samba.org> Autobuild-Date(master): Wed May 22 07:15:43 UTC 2019 on sn-devel-184
Diffstat (limited to 'source4/ntvfs')
-rw-r--r--source4/ntvfs/cifs_posix_cli/README12
-rw-r--r--source4/ntvfs/cifs_posix_cli/cifsposix.h38
-rw-r--r--source4/ntvfs/cifs_posix_cli/svfs_util.c195
-rw-r--r--source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c1112
-rw-r--r--source4/ntvfs/wscript_build9
5 files changed, 0 insertions, 1366 deletions
diff --git a/source4/ntvfs/cifs_posix_cli/README b/source4/ntvfs/cifs_posix_cli/README
deleted file mode 100644
index 2bc92834180..00000000000
--- a/source4/ntvfs/cifs_posix_cli/README
+++ /dev/null
@@ -1,12 +0,0 @@
-This module (ntvfs 'cifsposix') provides a simple posix backend which
-provides better semantics for clients which implement the cifs unix
-extensions or the newer cifs posix extensions
-
-WARNING: All file access is done as user 'root'!!!
- Only use this module for testing, with only test data!!!
-
-For activating this module use:
-
-[testshare]
- path = /tmp/testshare
- nfvfs handler = cifsposix
diff --git a/source4/ntvfs/cifs_posix_cli/cifsposix.h b/source4/ntvfs/cifs_posix_cli/cifsposix.h
deleted file mode 100644
index bf9e588b74f..00000000000
--- a/source4/ntvfs/cifs_posix_cli/cifsposix.h
+++ /dev/null
@@ -1,38 +0,0 @@
-
-struct cifspsx_private {
- struct ntvfs_module_context *ntvfs;
-
- /* the base directory */
- char *connectpath;
-
- /* a linked list of open searches */
- struct search_state *search;
-
- /* next available search handle */
- uint16_t next_search_handle;
-
- struct cifspsx_file *open_files;
-};
-
-struct cifspsx_dir {
- unsigned int count;
- char *unix_dir;
- struct cifspsx_dirfile {
- char *name;
- struct stat st;
- } *files;
-};
-
-struct cifspsx_file {
- struct cifspsx_file *next, *prev;
- int fd;
- struct ntvfs_handle *handle;
- char *name;
-};
-
-struct search_state {
- struct search_state *next, *prev;
- uint16_t handle;
- unsigned int current_index;
- struct cifspsx_dir *dir;
-};
diff --git a/source4/ntvfs/cifs_posix_cli/svfs_util.c b/source4/ntvfs/cifs_posix_cli/svfs_util.c
deleted file mode 100644
index 0efab832199..00000000000
--- a/source4/ntvfs/cifs_posix_cli/svfs_util.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- simpler Samba VFS filesystem backend for clients which support the
- CIFS Unix Extensions or newer CIFS POSIX protocol extensions
-
-
- Copyright (C) Andrew Tridgell 2003
- Copyright (C) Steve French 2006
-
- 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 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- 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, see <http://www.gnu.org/licenses/>.
-*/
-/*
- utility functions for cifs posix backend
-*/
-
-#include "includes.h"
-#include "system/filesys.h"
-#include "cifsposix.h"
-#include "system/time.h"
-#include "system/dir.h"
-#include "ntvfs/ntvfs.h"
-#include "ntvfs/cifs_posix_cli/proto.h"
-
-/*
- convert a windows path to a unix path - don't do any manging or case sensitive handling
-*/
-char *cifspsx_unix_path(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, const char *name)
-{
- struct cifspsx_private *p = ntvfs->private_data;
- char *ret;
- char *name_lower = strlower_talloc(p, name);
-
- if (*name != '\\') {
- ret = talloc_asprintf(req, "%s/%s", p->connectpath, name_lower);
- } else {
- ret = talloc_asprintf(req, "%s%s", p->connectpath, name_lower);
- }
- all_string_sub(ret, "\\", "/", 0);
- talloc_free(name_lower);
- return ret;
-}
-
-
-/*
- read a directory and find all matching file names and stat info
- returned names are separate unix and DOS names. The returned names
- are relative to the directory
-*/
-struct cifspsx_dir *cifspsx_list_unix(TALLOC_CTX *mem_ctx, struct ntvfs_request *req, const char *unix_path)
-{
- char *p, *mask;
- struct cifspsx_dir *dir;
- DIR *odir;
- struct dirent *dent;
- unsigned int allocated = 0;
- char *low_mask;
-
- dir = talloc(mem_ctx, struct cifspsx_dir);
- if (!dir) { return NULL; }
-
- dir->count = 0;
- dir->files = 0;
-
- /* find the base directory */
- p = strrchr(unix_path, '/');
- if (!p) { return NULL; }
-
- dir->unix_dir = talloc_strndup(mem_ctx, unix_path, PTR_DIFF(p, unix_path));
- if (!dir->unix_dir) { return NULL; }
-
- /* the wildcard pattern is the last part */
- mask = p+1;
-
- low_mask = strlower_talloc(mem_ctx, mask);
- if (!low_mask) { return NULL; }
-
- odir = opendir(dir->unix_dir);
- if (!odir) { return NULL; }
-
- while ((dent = readdir(odir))) {
- unsigned int i = dir->count;
- char *full_name;
- char *low_name;
- int ret;
-
- if (strchr(dent->d_name, ':') && !strchr(unix_path, ':')) {
- /* don't show streams in dir listing */
- continue;
- }
-
- low_name = strlower_talloc(mem_ctx, dent->d_name);
- if (!low_name) { continue; }
-
- /* check it matches the wildcard pattern */
- if (ms_fnmatch_protocol(low_mask, low_name, PROTOCOL_NT1,
- false) != 0) {
- continue;
- }
-
- if (dir->count >= allocated) {
- allocated = (allocated + 100) * 1.2;
- dir->files = talloc_realloc(dir, dir->files, struct cifspsx_dirfile, allocated);
- if (!dir->files) {
- closedir(odir);
- return NULL;
- }
- }
-
- dir->files[i].name = low_name;
- if (!dir->files[i].name) { continue; }
-
- ret = asprintf(&full_name, "%s/%s", dir->unix_dir, dir->files[i].name);
- if (ret == -1) {
- continue;
- }
-
- if (!full_name) { continue; }
-
- if (stat(full_name, &dir->files[i].st) == 0) {
- dir->count++;
- }
-
- free(full_name);
- }
-
- closedir(odir);
-
- return dir;
-}
-
-/*
- read a directory and find all matching file names and stat info
- returned names are separate unix and DOS names. The returned names
- are relative to the directory
-*/
-struct cifspsx_dir *cifspsx_list(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *pattern)
-{
- struct cifspsx_private *p = ntvfs->private_data;
- char *unix_path;
-
- unix_path = cifspsx_unix_path(ntvfs, req, pattern);
- if (!unix_path) { return NULL; }
-
- return cifspsx_list_unix(p, req, unix_path);
-}
-
-
-/*******************************************************************
-set the time on a file via file descriptor
-*******************************************************************/
-int cifspsx_file_utime(int fd, struct utimbuf *times)
-{
- char *fd_path = NULL;
- int ret;
-
- ret = asprintf(&fd_path, "/proc/self/%d", fd);
- if (ret == -1) {
- return -1;
- }
-
- if (!fd_path) {
- errno = ENOMEM;
- return -1;
- }
-
- ret = utime(fd_path, times);
- free(fd_path);
- return ret;
-}
-
-
-/*
- map a unix file attrib to a DOS attribute
-*/
-uint16_t cifspsx_unix_to_dos_attrib(mode_t mode)
-{
- uint16_t ret = 0;
- if (S_ISDIR(mode)) ret |= FILE_ATTRIBUTE_DIRECTORY;
- if (!(mode & S_IWUSR)) ret |= FILE_ATTRIBUTE_READONLY;
- return ret;
-}
-
diff --git a/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c b/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c
deleted file mode 100644
index 83f02c0e877..00000000000
--- a/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c
+++ /dev/null
@@ -1,1112 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- simpler Samba VFS filesystem backend for clients which support the
- CIFS Unix Extensions or newer CIFS POSIX protocol extensions
-
- Copyright (C) Andrew Tridgell 2003
- Copyright (C) Steve French 2006
-
- 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 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- 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, see <http://www.gnu.org/licenses/>.
-*/
-/*
- this implements a very simple NTVFS filesystem backend.
- this backend largely ignores the POSIX -> CIFS mappings, just doing absolutely
- minimal work to give a working backend.
-*/
-
-#include "includes.h"
-#include "system/dir.h"
-#include "system/filesys.h"
-#include "cifsposix.h"
-#include "system/time.h"
-#include "../lib/util/dlinklist.h"
-#include "ntvfs/ntvfs.h"
-#include "ntvfs/cifs_posix_cli/proto.h"
-
-#ifndef O_DIRECTORY
-#define O_DIRECTORY 0
-#endif
-
-#define CHECK_READ_ONLY(req) do { if (share_bool_option(ntvfs->ctx->config, SHARE_READONLY, true)) return NT_STATUS_ACCESS_DENIED; } while (0)
-
-/*
- connect to a share - used when a tree_connect operation comes
- in. For a disk based backend we needs to ensure that the base
- directory exists (tho it doesn't need to be accessible by the user,
- that comes later)
-*/
-static NTSTATUS cifspsx_connect(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req,
- union smb_tcon* tcon)
-{
- struct stat st;
- struct cifspsx_private *p;
- struct share_config *scfg = ntvfs->ctx->config;
- const char *sharename;
-
- switch (tcon->generic.level) {
- case RAW_TCON_TCON:
- sharename = tcon->tcon.in.service;
- break;
- case RAW_TCON_TCONX:
- sharename = tcon->tconx.in.path;
- break;
- case RAW_TCON_SMB2:
- sharename = tcon->smb2.in.path;
- break;
- default:
- return NT_STATUS_INVALID_LEVEL;
- }
-
- if (strncmp(sharename, "\\\\", 2) == 0) {
- char *str = strchr(sharename+2, '\\');
- if (str) {
- sharename = str + 1;
- }
- }
-
- p = talloc(ntvfs, struct cifspsx_private);
- NT_STATUS_HAVE_NO_MEMORY(p);
- p->ntvfs = ntvfs;
- p->next_search_handle = 0;
- p->connectpath = share_string_option(p, scfg, SHARE_PATH, "");
- p->open_files = NULL;
- p->search = NULL;
-
- /* the directory must exist */
- if (stat(p->connectpath, &st) != 0 || !S_ISDIR(st.st_mode)) {
- DEBUG(0,("'%s' is not a directory, when connecting to [%s]\n",
- p->connectpath, sharename));
- return NT_STATUS_BAD_NETWORK_NAME;
- }
-
- ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS");
- NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type);
- ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:");
- NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type);
-
- if (tcon->generic.level == RAW_TCON_TCONX) {
- tcon->tconx.out.fs_type = ntvfs->ctx->fs_type;
- tcon->tconx.out.dev_type = ntvfs->ctx->dev_type;
- }
-
- ntvfs->private_data = p;
-
- DEBUG(0,("WARNING: ntvfs cifs posix: connect to share [%s] with ROOT privileges!!!\n",sharename));
-
- return NT_STATUS_OK;
-}
-
-/*
- disconnect from a share
-*/
-static NTSTATUS cifspsx_disconnect(struct ntvfs_module_context *ntvfs)
-{
- return NT_STATUS_OK;
-}
-
-/*
- find open file handle given fd
-*/
-static struct cifspsx_file *find_fd(struct cifspsx_private *cp, struct ntvfs_handle *handle)
-{
- struct cifspsx_file *f;
- void *p;
-
- p = ntvfs_handle_get_backend_data(handle, cp->ntvfs);
- if (!p) return NULL;
-
- f = talloc_get_type(p, struct cifspsx_file);
- if (!f) return NULL;
-
- return f;
-}
-
-/*
- delete a file - the dirtype specifies the file types to include in the search.
- The name can contain CIFS wildcards, but rarely does (except with OS/2 clients)
-*/
-static NTSTATUS cifspsx_unlink(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req,
- union smb_unlink *unl)
-{
- char *unix_path;
-
- CHECK_READ_ONLY(req);
-
- unix_path = cifspsx_unix_path(ntvfs, req, unl->unlink.in.pattern);
-
- /* ignoring wildcards ... */
- if (unlink(unix_path) == -1) {
- return map_nt_error_from_unix_common(errno);
- }
-
- return NT_STATUS_OK;
-}
-
-
-/*
- ioctl interface - we don't do any
-*/
-static NTSTATUS cifspsx_ioctl(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_ioctl *io)
-{
- return NT_STATUS_INVALID_PARAMETER;
-}
-
-/*
- check if a directory exists
-*/
-static NTSTATUS cifspsx_chkpath(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req,
- union smb_chkpath *cp)
-{
- char *unix_path;
- struct stat st;
-
- unix_path = cifspsx_unix_path(ntvfs, req, cp->chkpath.in.path);
-
- if (stat(unix_path, &st) == -1) {
- return map_nt_error_from_unix_common(errno);
- }
-
- if (!S_ISDIR(st.st_mode)) {
- return NT_STATUS_NOT_A_DIRECTORY;
- }
-
- return NT_STATUS_OK;
-}
-
-/*
- build a file_id from a stat struct
-*/
-static uint64_t cifspsx_file_id(struct stat *st)
-{
- uint64_t ret = st->st_ino;
- ret <<= 32;
- ret |= st->st_dev;
- return ret;
-}
-
-/*
- approximately map a struct stat to a generic fileinfo struct
-*/
-static NTSTATUS cifspsx_map_fileinfo(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_fileinfo *info,
- struct stat *st, const char *unix_path)
-{
- struct cifspsx_dir *dir = NULL;
- char *pattern = NULL;
- int i, ret;
- const char *s, *short_name;
-
- s = strrchr(unix_path, '/');
- if (s) {
- short_name = s+1;
- } else {
- short_name = "";
- }
-
- ret = asprintf(&pattern, "%s:*", unix_path);
- if (ret == -1) {
- return NT_STATUS_NO_MEMORY;
- }
-
- if (pattern) {
- dir = cifspsx_list_unix(req, req, pattern);
- }
-
- unix_to_nt_time(&info->generic.out.create_time, st->st_ctime);
- unix_to_nt_time(&info->generic.out.access_time, st->st_atime);
- unix_to_nt_time(&info->generic.out.write_time, st->st_mtime);
- unix_to_nt_time(&info->generic.out.change_time, st->st_mtime);
- info->generic.out.alloc_size = st->st_size;
- info->generic.out.size = st->st_size;
- info->generic.out.attrib = cifspsx_unix_to_dos_attrib(st->st_mode);
- info->generic.out.alloc_size = st->st_blksize * st->st_blocks;
- info->generic.out.nlink = st->st_nlink;
- info->generic.out.directory = S_ISDIR(st->st_mode) ? 1 : 0;
- info->generic.out.file_id = cifspsx_file_id(st);
- /* REWRITE: TODO stuff in here */
- info->generic.out.delete_pending = 0;
- info->generic.out.ea_size = 0;
- info->generic.out.num_eas = 0;
- info->generic.out.fname.s = talloc_strdup(req, short_name);
- info->generic.out.alt_fname.s = talloc_strdup(req, short_name);
- info->generic.out.compressed_size = 0;
- info->generic.out.format = 0;
- info->generic.out.unit_shift = 0;
- info->generic.out.chunk_shift = 0;
- info->generic.out.cluster_shift = 0;
-
- info->generic.out.access_flags = 0;
- info->generic.out.position = 0;
- info->generic.out.mode = 0;
- info->generic.out.alignment_requirement = 0;
- info->generic.out.reparse_tag = 0;
- info->generic.out.num_streams = 0;
- /* setup a single data stream */
- info->generic.out.num_streams = 1 + (dir?dir->count:0);
- info->generic.out.streams = talloc_array(req,
- struct stream_struct,
- info->generic.out.num_streams);
- if (!info->generic.out.streams) {
- return NT_STATUS_NO_MEMORY;
- }
- info->generic.out.streams[0].size = st->st_size;
- info->generic.out.streams[0].alloc_size = st->st_size;
- info->generic.out.streams[0].stream_name.s = talloc_strdup(req,"::$DATA");
-
- for (i=0;dir && i<dir->count;i++) {
- s = strchr(dir->files[i].name, ':');
- info->generic.out.streams[1+i].size = dir->files[i].st.st_size;
- info->generic.out.streams[1+i].alloc_size = dir->files[i].st.st_size;
- info->generic.out.streams[1+i].stream_name.s = s?s:dir->files[i].name;
- }
-
- return NT_STATUS_OK;
-}
-
-/*
- return info on a pathname
-*/
-static NTSTATUS cifspsx_qpathinfo(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_fileinfo *info)
-{
- char *unix_path;
- struct stat st;
-
- DEBUG(19,("cifspsx_qpathinfo: file %s level 0x%x\n", info->generic.in.file.path, info->generic.level));
- if (info->generic.level != RAW_FILEINFO_GENERIC) {
- return ntvfs_map_qpathinfo(ntvfs, req, info);
- }
-
- unix_path = cifspsx_unix_path(ntvfs, req, info->generic.in.file.path);
- DEBUG(19,("cifspsx_qpathinfo: file %s\n", unix_path));
- if (stat(unix_path, &st) == -1) {
- DEBUG(19,("cifspsx_qpathinfo: file %s errno=%d\n", unix_path, errno));
- return map_nt_error_from_unix_common(errno);
- }
- DEBUG(19,("cifspsx_qpathinfo: file %s, stat done\n", unix_path));
- return cifspsx_map_fileinfo(ntvfs, req, info, &st, unix_path);
-}
-
-/*
- query info on a open file
-*/
-static NTSTATUS cifspsx_qfileinfo(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_fileinfo *info)
-{
- struct cifspsx_private *p = ntvfs->private_data;
- struct cifspsx_file *f;
- struct stat st;
-
- if (info->generic.level != RAW_FILEINFO_GENERIC) {
- return ntvfs_map_qfileinfo(ntvfs, req, info);
- }
-
- f = find_fd(p, info->generic.in.file.ntvfs);
- if (!f) {
- return NT_STATUS_INVALID_HANDLE;
- }
-
- if (fstat(f->fd, &st) == -1) {
- return map_nt_error_from_unix_common(errno);
- }
-
- return cifspsx_map_fileinfo(ntvfs, req,info, &st, f->name);
-}
-
-
-/*
- open a file
-*/
-static NTSTATUS cifspsx_open(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_open *io)
-{
- struct cifspsx_private *p = ntvfs->private_data;
- char *unix_path;
- struct stat st;
- int fd, flags;
- struct cifspsx_file *f;
- int create_flags, rdwr_flags;
- bool readonly;
- NTSTATUS status;
- struct ntvfs_handle *handle;
-
- if (io->generic.level != RAW_OPEN_GENERIC) {
- return ntvfs_map_open(ntvfs, req, io);
- }
-
- readonly = share_bool_option(ntvfs->ctx->config, SHARE_READONLY, SHARE_READONLY_DEFAULT);
- if (readonly) {
- create_flags = 0;
- rdwr_flags = O_RDONLY;
- } else {
- create_flags = O_CREAT;
- rdwr_flags = O_RDWR;
- }
-
- unix_path = cifspsx_unix_path(ntvfs, req, io->ntcreatex.in.fname);
-
- switch (io->generic.in.open_disposition) {
- case NTCREATEX_DISP_SUPERSEDE:
- case NTCREATEX_DISP_OVERWRITE_IF:
- flags = create_flags | O_TRUNC;
- break;
- case NTCREATEX_DISP_OPEN:
- case NTCREATEX_DISP_OVERWRITE:
- flags = 0;
- break;
- case NTCREATEX_DISP_CREATE:
- flags = create_flags | O_EXCL;
- break;
- case NTCREATEX_DISP_OPEN_IF:
- flags = create_flags;
- break;
- default:
- flags = 0;
- break;
- }
-
- flags |= rdwr_flags;
-
- if (io->generic.in.create_options & NTCREATEX_OPTIONS_DIRECTORY) {
- flags = O_RDONLY | O_DIRECTORY;
- if (readonly) {
- goto do_open;
- }
- switch (io->generic.in.open_disposition) {
- case NTCREATEX_DISP_CREATE:
- if (mkdir(unix_path, 0755) == -1) {
- DEBUG(9,("cifspsx_open: mkdir %s errno=%d\n", unix_path, errno));
- return map_nt_error_from_unix_common(errno);
- }
- break;
- case NTCREATEX_DISP_OPEN_IF:
- if (mkdir(unix_path, 0755) == -1 && errno != EEXIST) {
- DEBUG(9,("cifspsx_open: mkdir %s errno=%d\n", unix_path, errno));
- return map_nt_error_from_unix_common(errno);
- }
- break;
- }
- }
-
-do_open:
- fd = open(unix_path, flags, 0644);
- if (fd == -1) {
- return map_nt_error_from_unix_common(errno);
- }
-
- if (fstat(fd, &st) == -1) {
- DEBUG(9,("cifspsx_open: fstat errno=%d\n", errno));
- close(fd);
- return map_nt_error_from_unix_common(errno);
- }
-
- status = ntvfs_handle_new(ntvfs, req, &handle);
- NT_STATUS_NOT_OK_RETURN(status);
-
- f = talloc(handle, struct cifspsx_file);
- NT_STATUS_HAVE_NO_MEMORY(f);
- f->fd = fd;
- f->name = talloc_strdup(f, unix_path);
- NT_STATUS_HAVE_NO_MEMORY(f->name);
-
- DLIST_ADD(p->open_files, f);
-
- status = ntvfs_handle_set_backend_data(handle, ntvfs, f);
- NT_STATUS_NOT_OK_RETURN(status);
-
- ZERO_STRUCT(io->generic.out);
-
- unix_to_nt_time(&io->generic.out.create_time, st.st_ctime);
- unix_to_nt_time(&io->generic.out.access_time, st.st_atime);
- unix_to_nt_time(&io->generic.out.write_time, st.st_mtime);
- unix_to_nt_time(&io->generic.out.change_time, st.st_mtime);
- io->generic.out.file.ntvfs = handle;
- io->generic.out.alloc_size = st.st_size;
- io->generic.out.size = st.st_size;
- io->generic.out.attrib = cifspsx_unix_to_dos_attrib(st.st_mode);
- io->generic.out.is_directory = S_ISDIR(st.st_mode) ? 1 : 0;
-
- return NT_STATUS_OK;
-}
-
-/*
- create a directory
-*/
-static NTSTATUS cifspsx_mkdir(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_mkdir *md)
-{
- char *unix_path;
-
- CHECK_READ_ONLY(req);
-
- if (md->generic.level != RAW_MKDIR_MKDIR) {
- return NT_STATUS_INVALID_LEVEL;
- }
-
- unix_path = cifspsx_unix_path(ntvfs, req, md->mkdir.in.path);
-
- if (mkdir(unix_path, 0777) == -1) {
- return map_nt_error_from_unix_common(errno);
- }
-
- return NT_STATUS_OK;
-}
-
-/*
- remove a directory
-*/
-static NTSTATUS cifspsx_rmdir(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, struct smb_rmdir *rd)
-{
- char *unix_path;
-
- CHECK_READ_ONLY(req);
-
- unix_path = cifspsx_unix_path(ntvfs, req, rd->in.path);
-
- if (rmdir(unix_path) == -1) {
- return map_nt_error_from_unix_common(errno);
- }
-
- return NT_STATUS_OK;
-}
-
-/*
- rename a set of files
-*/
-static NTSTATUS cifspsx_rename(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_rename *ren)
-{
- char *unix_path1, *unix_path2;
-
- CHECK_READ_ONLY(req);
-
- if (ren->generic.level != RAW_RENAME_RENAME) {
- return NT_STATUS_INVALID_LEVEL;
- }
-
- unix_path1 = cifspsx_unix_path(ntvfs, req, ren->rename.in.pattern1);
- unix_path2 = cifspsx_unix_path(ntvfs, req, ren->rename.in.pattern2);
-
- if (rename(unix_path1, unix_path2) == -1) {
- return map_nt_error_from_unix_common(errno);
- }
-
- return NT_STATUS_OK;
-}
-
-/*
- copy a set of files
-*/
-static NTSTATUS cifspsx_copy(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, struct smb_copy *cp)
-{
- return NT_STATUS_NOT_SUPPORTED;
-}
-
-/*
- read from a file
-*/
-static NTSTATUS cifspsx_read(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_read *rd)
-{
- struct cifspsx_private *p = ntvfs->private_data;
- struct cifspsx_file *f;
- ssize_t ret;
-
- if (rd->generic.level != RAW_READ_READX) {
- return NT_STATUS_NOT_SUPPORTED;
- }
-
- f = find_fd(p, rd->readx.in.file.ntvfs);
- if (!f) {
- return NT_STATUS_INVALID_HANDLE;
- }
-
- ret = pread(f->fd,
- rd->readx.out.data,
- rd->readx.in.maxcnt,
- rd->readx.in.offset);
- if (ret == -1) {
- return map_nt_error_from_unix_common(errno);
- }
-
- rd->readx.out.nread = ret;
- rd->readx.out.remaining = 0; /* should fill this in? */
- rd->readx.out.compaction_mode = 0;
-
- return NT_STATUS_OK;
-}
-
-/*
- write to a file
-*/
-static NTSTATUS cifspsx_write(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_write *wr)
-{
- struct cifspsx_private *p = ntvfs->private_data;
- struct cifspsx_file *f;
- ssize_t ret;
-
- if (wr->generic.level != RAW_WRITE_WRITEX) {
- return ntvfs_map_write(ntvfs, req, wr);
- }
-
- CHECK_READ_ONLY(req);
-
- f = find_fd(p, wr->writex.in.file.ntvfs);
- if (!f) {
- return NT_STATUS_INVALID_HANDLE;
- }
-
- ret = pwrite(f->fd,
- wr->writex.in.data,
- wr->writex.in.count,
- wr->writex.in.offset);
- if (ret == -1) {
- return map_nt_error_from_unix_common(errno);
- }
-
- wr->writex.out.nwritten = ret;
- wr->writex.out.remaining = 0; /* should fill this in? */
-
- return NT_STATUS_OK;
-}
-
-/*
- seek in a file
-*/
-static NTSTATUS cifspsx_seek(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req,
- union smb_seek *io)
-{
- return NT_STATUS_NOT_SUPPORTED;
-}
-
-/*
- flush a file
-*/
-static NTSTATUS cifspsx_flush(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req,
- union smb_flush *io)
-{
- struct cifspsx_private *p = ntvfs->private_data;
- struct cifspsx_file *f;
-
- switch (io->generic.level) {
- case RAW_FLUSH_FLUSH:
- case RAW_FLUSH_SMB2:
- /* ignore the additional unknown option in SMB2 */
- f = find_fd(p, io->generic.in.file.ntvfs);
- if (!f) {
- return NT_STATUS_INVALID_HANDLE;
- }
- fsync(f->fd);
- return NT_STATUS_OK;
-
- case RAW_FLUSH_ALL:
- for (f=p->open_files;f;f=f->next) {
- fsync(f->fd);
- }
- return NT_STATUS_OK;
- }
-
- return NT_STATUS_INVALID_LEVEL;
-}
-
-/*
- close a file
-*/
-static NTSTATUS cifspsx_close(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req,
- union smb_close *io)
-{
- struct cifspsx_private *p = ntvfs->private_data;
- struct cifspsx_file *f;
-
- if (io->generic.level != RAW_CLOSE_CLOSE) {
- /* we need a mapping function */
- return NT_STATUS_INVALID_LEVEL;
- }
-
- f = find_fd(p, io->close.in.file.ntvfs);
- if (!f) {
- return NT_STATUS_INVALID_HANDLE;
- }
-
- if (close(f->fd) == -1) {
- return map_nt_error_from_unix_common(errno);
- }
-
- DLIST_REMOVE(p->open_files, f);
- talloc_free(f->name);
- talloc_free(f);
-
- return NT_STATUS_OK;
-}
-
-/*
- exit - closing files
-*/
-static NTSTATUS cifspsx_exit(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req)
-{
- return NT_STATUS_NOT_SUPPORTED;
-}
-
-/*
- logoff - closing files
-*/
-static NTSTATUS cifspsx_logoff(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req)
-{
- return NT_STATUS_NOT_SUPPORTED;
-}
-
-/*
- setup for an async call
-*/
-static NTSTATUS cifspsx_async_setup(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req,
- void *private_data)
-{
- return NT_STATUS_OK;
-}
-
-/*
- cancel an async call
-*/
-static NTSTATUS cifspsx_cancel(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req)
-{
- return NT_STATUS_UNSUCCESSFUL;
-}
-
-/*
- lock a byte range
-*/
-static NTSTATUS cifspsx_lock(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_lock *lck)
-{
- DEBUG(0,("REWRITE: not doing byte range locking!\n"));
- return NT_STATUS_OK;
-}
-
-/*
- set info on a pathname
-*/
-static NTSTATUS cifspsx_setpathinfo(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_setfileinfo *st)
-{
- CHECK_READ_ONLY(req);
-
- return NT_STATUS_NOT_SUPPORTED;
-}
-
-/*
- set info on a open file
-*/
-static NTSTATUS cifspsx_setfileinfo(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req,
- union smb_setfileinfo *info)
-{
- struct cifspsx_private *p = ntvfs->private_data;
- struct cifspsx_file *f;
- struct utimbuf unix_times;
-
- CHECK_READ_ONLY(req);
-
- f = find_fd(p, info->generic.in.file.ntvfs);
- if (!f) {
- return NT_STATUS_INVALID_HANDLE;
- }
-
- switch (info->generic.level) {
- case RAW_SFILEINFO_END_OF_FILE_INFO:
- case RAW_SFILEINFO_END_OF_FILE_INFORMATION:
- if (ftruncate(f->fd,
- info->end_of_file_info.in.size) == -1) {
- return map_nt_error_from_unix_common(errno);
- }
- break;
- case RAW_SFILEINFO_SETATTRE:
- unix_times.actime = info->setattre.in.access_time;
- unix_times.modtime = info->setattre.in.write_time;
-
- if (unix_times.actime == 0 && unix_times.modtime == 0) {
- break;
- }
-
- /* set modify time = to access time if modify time was 0 */
- if (unix_times.actime != 0 && unix_times.modtime == 0) {
- unix_times.modtime = unix_times.actime;
- }
-
- /* Set the date on this file */
- if (cifspsx_file_utime(f->fd, &unix_times) != 0) {
- return NT_STATUS_ACCESS_DENIED;
- }
- break;
- default:
- DEBUG(2,("cifspsx_setfileinfo: level %d not implemented\n",
- info->generic.level));
- return NT_STATUS_NOT_IMPLEMENTED;
- }
- return NT_STATUS_OK;
-}
-
-
-/*
- return filesystem space info
-*/
-static NTSTATUS cifspsx_fsinfo(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_fsinfo *fs)
-{
- struct cifspsx_private *p = ntvfs->private_data;
- struct stat st;
-
- if (fs->generic.level != RAW_QFS_GENERIC) {
- return ntvfs_map_fsinfo(ntvfs, req, fs);
- }
-
- if (sys_fsusage(p->connectpath,
- &fs->generic.out.blocks_free,
- &fs->generic.out.blocks_total) == -1) {
- return map_nt_error_from_unix_common(errno);
- }
-
- fs->generic.out.block_size = 512;
-
- if (stat(p->connectpath, &st) != 0) {
- return NT_STATUS_DISK_CORRUPT_ERROR;
- }
-
- fs->generic.out.fs_id = st.st_ino;
- unix_to_nt_time(&fs->generic.out.create_time, st.st_ctime);
- fs->generic.out.serial_number = st.st_ino;
- fs->generic.out.fs_attr = 0;
- fs->generic.out.max_file_component_length = 255;
- fs->generic.out.device_type = 0;
- fs->generic.out.device_characteristics = 0;
- fs->generic.out.quota_soft = 0;
- fs->generic.out.quota_hard = 0;
- fs->generic.out.quota_flags = 0;
- fs->generic.out.volume_name = talloc_strdup(req, ntvfs->ctx->config->name);
- fs->generic.out.fs_type = ntvfs->ctx->fs_type;
-
- return NT_STATUS_OK;
-}
-
-#if 0
-/*
- return filesystem attribute info
-*/
-static NTSTATUS cifspsx_fsattr(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_fsattr *fs)
-{
- struct stat st;
- struct cifspsx_private *p = ntvfs->private_data;
-
- if (fs->generic.level != RAW_FSATTR_GENERIC) {
- return ntvfs_map_fsattr(ntvfs, req, fs);
- }
-
- if (stat(p->connectpath, &st) == -1) {
- return map_nt_error_from_unix_common(errno);
- }
-
- unix_to_nt_time(&fs->generic.out.create_time, st.st_ctime);
- fs->generic.out.fs_attr =
- FILE_CASE_PRESERVED_NAMES |
- FILE_CASE_SENSITIVE_SEARCH |
- FILE_PERSISTENT_ACLS;
- fs->generic.out.max_file_component_length = 255;
- fs->generic.out.serial_number = 1;
- fs->generic.out.fs_type = talloc_strdup(req, "NTFS");
- fs->generic.out.volume_name = talloc_strdup(req,
- lpcfg_servicename(req->tcon->service));
-
- return NT_STATUS_OK;
-}
-#endif
-
-/*
- return print queue info
-*/
-static NTSTATUS cifspsx_lpq(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_lpq *lpq)
-{
- return NT_STATUS_NOT_SUPPORTED;
-}
-
-/*
- list files in a directory matching a wildcard pattern
-*/
-static NTSTATUS cifspsx_search_first(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_search_first *io,
- void *search_private,
- bool (*callback)(void *, const union smb_search_data *))
-{
- struct cifspsx_dir *dir;
- int i;
- struct cifspsx_private *p = ntvfs->private_data;
- struct search_state *search;
- union smb_search_data file;
- unsigned int max_count;
-
- if (io->generic.level != RAW_SEARCH_TRANS2) {
- return NT_STATUS_NOT_SUPPORTED;
- }
-
- if (io->generic.data_level != RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO) {
- return NT_STATUS_NOT_SUPPORTED;
- }
-
- search = talloc_zero(p, struct search_state);
- if (!search) {
- return NT_STATUS_NO_MEMORY;
- }
-
- max_count = io->t2ffirst.in.max_count;
-
- dir = cifspsx_list(ntvfs, req, io->t2ffirst.in.pattern);
- if (!dir) {
- return NT_STATUS_FOOBAR;
- }
-
- search->handle = p->next_search_handle;
- search->dir = dir;
-
- if (dir->count < max_count) {
- max_count = dir->count;
- }
-
- for (i=0; i < max_count;i++) {
- ZERO_STRUCT(file);
- unix_to_nt_time(&file.both_directory_info.create_time, dir->files[i].st.st_ctime);
- unix_to_nt_time(&file.both_directory_info.access_time, dir->files[i].st.st_atime);
- unix_to_nt_time(&file.both_directory_info.write_time, dir->files[i].st.st_mtime);
- unix_to_nt_time(&file.both_directory_info.change_time, dir->files[i].st.st_mtime);
- file.both_directory_info.name.s = dir->files[i].name;
- file.both_directory_info.short_name.s = dir->files[i].name;
- file.both_directory_info.size = dir->files[i].st.st_size;
- file.both_directory_info.attrib = cifspsx_unix_to_dos_attrib(dir->files[i].st.st_mode);
-
- if (!callback(search_private, &file)) {
- break;
- }
- }
-
- search->current_index = i;
-
- io->t2ffirst.out.count = i;
- io->t2ffirst.out.handle = search->handle;
- io->t2ffirst.out.end_of_search = (i == dir->count) ? 1 : 0;
-
- /* work out if we are going to keep the search state */
- if ((io->t2ffirst.in.flags & FLAG_TRANS2_FIND_CLOSE) ||
- ((io->t2ffirst.in.flags & FLAG_TRANS2_FIND_CLOSE_IF_END) && (i == dir->count))) {
- talloc_free(search);
- } else {
- p->next_search_handle++;
- DLIST_ADD(p->search, search);
- }
-
- return NT_STATUS_OK;
-}
-
-/* continue a search */
-static NTSTATUS cifspsx_search_next(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_search_next *io,
- void *search_private,
- bool (*callback)(void *, const union smb_search_data *))
-{
- struct cifspsx_dir *dir;
- int i;
- struct cifspsx_private *p = ntvfs->private_data;
- struct search_state *search;
- union smb_search_data file;
- unsigned int max_count;
-
- if (io->generic.level != RAW_SEARCH_TRANS2) {
- return NT_STATUS_NOT_SUPPORTED;
- }
-
- if (io->generic.data_level != RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO) {
- return NT_STATUS_NOT_SUPPORTED;
- }
-
- for (search=p->search; search; search = search->next) {
- if (search->handle == io->t2fnext.in.handle) break;
- }
-
- if (!search) {
- /* we didn't find the search handle */
- return NT_STATUS_FOOBAR;
- }
-
- dir = search->dir;
-
- /* the client might be asking for something other than just continuing
- with the search */
- if (!(io->t2fnext.in.flags & FLAG_TRANS2_FIND_CONTINUE) &&
- (io->t2fnext.in.flags & FLAG_TRANS2_FIND_REQUIRE_RESUME) &&
- io->t2fnext.in.last_name && *io->t2fnext.in.last_name) {
- /* look backwards first */
- for (i=search->current_index; i > 0; i--) {
- if (strcmp(io->t2fnext.in.last_name, dir->files[i-1].name) == 0) {
- search->current_index = i;
- goto found;
- }
- }
-
- /* then look forwards */
- for (i=search->current_index+1; i <= dir->count; i++) {
- if (strcmp(io->t2fnext.in.last_name, dir->files[i-1].name) == 0) {
- search->current_index = i;
- goto found;
- }
- }
- }
-
-found:
- max_count = search->current_index + io->t2fnext.in.max_count;
-
- if (max_count > dir->count) {
- max_count = dir->count;
- }
-
- for (i = search->current_index; i < max_count;i++) {
- ZERO_STRUCT(file);
- unix_to_nt_time(&file.both_directory_info.create_time, dir->files[i].st.st_ctime);
- unix_to_nt_time(&file.both_directory_info.access_time, dir->files[i].st.st_atime);
- unix_to_nt_time(&file.both_directory_info.write_time, dir->files[i].st.st_mtime);
- unix_to_nt_time(&file.both_directory_info.change_time, dir->files[i].st.st_mtime);
- file.both_directory_info.name.s = dir->files[i].name;
- file.both_directory_info.short_name.s = dir->files[i].name;
- file.both_directory_info.size = dir->files[i].st.st_size;
- file.both_directory_info.attrib = cifspsx_unix_to_dos_attrib(dir->files[i].st.st_mode);
-
- if (!callback(search_private, &file)) {
- break;
- }
- }
-
- io->t2fnext.out.count = i - search->current_index;
- io->t2fnext.out.end_of_search = (i == dir->count) ? 1 : 0;
-
- search->current_index = i;
-
- /* work out if we are going to keep the search state */
- if ((io->t2fnext.in.flags & FLAG_TRANS2_FIND_CLOSE) ||
- ((io->t2fnext.in.flags & FLAG_TRANS2_FIND_CLOSE_IF_END) && (i == dir->count))) {
- DLIST_REMOVE(p->search, search);
- talloc_free(search);
- }
-
- return NT_STATUS_OK;
-}
-
-/* close a search */
-static NTSTATUS cifspsx_search_close(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, union smb_search_close *io)
-{
- struct cifspsx_private *p = ntvfs->private_data;
- struct search_state *search;
-
- for (search=p->search; search; search = search->next) {
- if (search->handle == io->findclose.in.handle) break;
- }
-
- if (!search) {
- /* we didn't find the search handle */
- return NT_STATUS_FOOBAR;
- }
-
- DLIST_REMOVE(p->search, search);
- talloc_free(search);
-
- return NT_STATUS_OK;
-}
-
-/* SMBtrans - not used on file shares */
-static NTSTATUS cifspsx_trans(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req, struct smb_trans2 *trans2)
-{
- return NT_STATUS_ACCESS_DENIED;
-}
-
-
-/*
- initialialise the POSIX disk backend, registering ourselves with the ntvfs subsystem
- */
-NTSTATUS ntvfs_cifs_posix_init(TALLOC_CTX *ctx)
-{
- NTSTATUS ret;
- struct ntvfs_ops ops;
- NTVFS_CURRENT_CRITICAL_SIZES(vers);
-
- ZERO_STRUCT(ops);
-
- /* fill in all the operations */
- ops.connect_fn = cifspsx_connect;
- ops.disconnect_fn = cifspsx_disconnect;
- ops.unlink_fn = cifspsx_unlink;
- ops.chkpath_fn = cifspsx_chkpath;
- ops.qpathinfo_fn = cifspsx_qpathinfo;
- ops.setpathinfo_fn = cifspsx_setpathinfo;
- ops.open_fn = cifspsx_open;
- ops.mkdir_fn = cifspsx_mkdir;
- ops.rmdir_fn = cifspsx_rmdir;
- ops.rename_fn = cifspsx_rename;
- ops.copy_fn = cifspsx_copy;
- ops.ioctl_fn = cifspsx_ioctl;
- ops.read_fn = cifspsx_read;
- ops.write_fn = cifspsx_write;
- ops.seek_fn = cifspsx_seek;
- ops.flush_fn = cifspsx_flush;
- ops.close_fn = cifspsx_close;
- ops.exit_fn = cifspsx_exit;
- ops.lock_fn = cifspsx_lock;
- ops.setfileinfo_fn = cifspsx_setfileinfo;
- ops.qfileinfo_fn = cifspsx_qfileinfo;
- ops.fsinfo_fn = cifspsx_fsinfo;
- ops.lpq_fn = cifspsx_lpq;
- ops.search_first_fn = cifspsx_search_first;
- ops.search_next_fn = cifspsx_search_next;
- ops.search_close_fn = cifspsx_search_close;
- ops.trans_fn = cifspsx_trans;
- ops.logoff_fn = cifspsx_logoff;
- ops.async_setup_fn = cifspsx_async_setup;
- ops.cancel_fn = cifspsx_cancel;
-
- /* register ourselves with the NTVFS subsystem. We register
- under names 'cifsposix'
- */
-
- ops.type = NTVFS_DISK;
- ops.name = "cifsposix";
- ret = ntvfs_register(&ops, &vers);
-
- if (!NT_STATUS_IS_OK(ret)) {
- DEBUG(0,("Failed to register cifs posix backend with name: %s!\n",
- ops.name));
- }
-
- return ret;
-}
diff --git a/source4/ntvfs/wscript_build b/source4/ntvfs/wscript_build
index d053649aac3..3b8121676fa 100644
--- a/source4/ntvfs/wscript_build
+++ b/source4/ntvfs/wscript_build
@@ -31,15 +31,6 @@ if bld.CONFIG_SET('WITH_NTVFS_FILESERVER'):
)
- bld.SAMBA_MODULE('ntvfs_cifsposix',
- source='cifs_posix_cli/vfs_cifs_posix.c cifs_posix_cli/svfs_util.c',
- autoproto='cifs_posix_cli/proto.h',
- subsystem='ntvfs',
- init_function='ntvfs_cifs_posix_init',
- deps='talloc'
- )
-
-
bld.SAMBA_MODULE('ntvfs_ipc',
source='ipc/vfs_ipc.c ipc/ipc_rap.c ipc/rap_server.c',
autoproto='ipc/proto.h',