[PATCH] Remove undocumented code, fix bug 12707
Volker Lendecke
vl at samba.org
Tue Mar 21 15:13:28 UTC 2017
Hi!
As I don't even remember how this module works, it is far
better to remove it but to write false documentation or leave
it undocumented.
Review appreciated!
Thanks, Volker
-------------- next part --------------
>From b7156b9c3828ce823369912c597d10d703172120 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 21 Mar 2017 16:07:13 +0100
Subject: [PATCH] smbd: Fix bug 12707
Nobody discovered the missing documentation in the last 12 years. This can
not have been used at all. Remove the offending code.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=12707
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/vfs_expand_msdfs.c | 234 -------------------------------------
source3/modules/wscript_build | 8 --
source3/wscript | 2 +-
3 files changed, 1 insertion(+), 243 deletions(-)
delete mode 100644 source3/modules/vfs_expand_msdfs.c
diff --git a/source3/modules/vfs_expand_msdfs.c b/source3/modules/vfs_expand_msdfs.c
deleted file mode 100644
index e42d0098b32..00000000000
--- a/source3/modules/vfs_expand_msdfs.c
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Expand msdfs targets based on client IP
- *
- * Copyright (C) Volker Lendecke, 2004
- *
- * 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/>.
- */
-
-#include "includes.h"
-#include "system/filesys.h"
-#include "smbd/smbd.h"
-#include "../librpc/gen_ndr/ndr_netlogon.h"
-#include "smbd/globals.h"
-#include "auth.h"
-#include "../lib/tsocket/tsocket.h"
-
-#undef DBGC_CLASS
-#define DBGC_CLASS DBGC_VFS
-
-/**********************************************************
- Under mapfile we expect a table of the following format:
-
- IP-Prefix whitespace expansion
-
- For example:
- 192.168.234 local.samba.org
- 192.168 remote.samba.org
- default.samba.org
-
- This is to redirect a DFS client to a host close to it.
-***********************************************************/
-
-static char *read_target_host(TALLOC_CTX *ctx, const char *mapfile,
- const char *clientaddr)
-{
- FILE *f;
- char buf[1024];
- char *space = buf;
- bool found = false;
-
- f = fopen(mapfile, "r");
-
- if (f == NULL) {
- DEBUG(0,("can't open IP map %s. Error %s\n",
- mapfile, strerror(errno) ));
- return NULL;
- }
-
- DEBUG(10, ("Scanning mapfile [%s]\n", mapfile));
-
- while (fgets(buf, sizeof(buf), f) != NULL) {
-
- if ((strlen(buf) > 0) && (buf[strlen(buf)-1] == '\n'))
- buf[strlen(buf)-1] = '\0';
-
- DEBUG(10, ("Scanning line [%s]\n", buf));
-
- space = strchr_m(buf, ' ');
-
- if (space == NULL) {
- DEBUG(0, ("Ignoring invalid line %s\n", buf));
- continue;
- }
-
- *space = '\0';
-
- if (strncmp(clientaddr, buf, strlen(buf)) == 0) {
- found = true;
- break;
- }
- }
-
- fclose(f);
-
- if (!found) {
- return NULL;
- }
-
- space += 1;
-
- while (isspace(*space))
- space += 1;
-
- return talloc_strdup(ctx, space);
-}
-
-/**********************************************************
-
- Expand the msdfs target host using read_target_host
- explained above. The syntax used in the msdfs link is
-
- msdfs:@table-filename@/share
-
- Everything between and including the two @-signs is
- replaced by the substitution string found in the table
- described above.
-
-***********************************************************/
-
-static char *expand_msdfs_target(TALLOC_CTX *ctx,
- connection_struct *conn,
- char *target)
-{
- char *mapfilename = NULL;
- char *filename_start = strchr_m(target, '@');
- char *filename_end = NULL;
- int filename_len = 0;
- char *targethost = NULL;
- char *new_target = NULL;
- char *raddr;
-
- if (filename_start == NULL) {
- DEBUG(10, ("No filename start in %s\n", target));
- return NULL;
- }
-
- filename_end = strchr_m(filename_start+1, '@');
-
- if (filename_end == NULL) {
- DEBUG(10, ("No filename end in %s\n", target));
- return NULL;
- }
-
- filename_len = PTR_DIFF(filename_end, filename_start+1);
- mapfilename = talloc_strdup(ctx, filename_start+1);
- if (!mapfilename) {
- return NULL;
- }
- mapfilename[filename_len] = '\0';
-
- DEBUG(10, ("Expanding from table [%s]\n", mapfilename));
-
- raddr = tsocket_address_inet_addr_string(conn->sconn->remote_address,
- ctx);
- if (raddr == NULL) {
- return NULL;
- }
-
- targethost = read_target_host(ctx, mapfilename, raddr);
- if (targethost == NULL) {
- DEBUG(1, ("Could not expand target host from file %s\n",
- mapfilename));
- return NULL;
- }
-
- targethost = talloc_sub_advanced(ctx,
- lp_servicename(talloc_tos(), SNUM(conn)),
- conn->session_info->unix_info->unix_name,
- conn->connectpath,
- conn->session_info->unix_token->gid,
- conn->session_info->unix_info->sanitized_username,
- conn->session_info->info->domain_name,
- targethost);
-
- DEBUG(10, ("Expanded targethost to %s\n", targethost));
-
- /* Replace the part between '@...@' */
- *filename_start = '\0';
- new_target = talloc_asprintf(ctx,
- "%s%s%s",
- target,
- targethost,
- filename_end+1);
- if (!new_target) {
- return NULL;
- }
-
- DEBUG(10, ("New DFS target: %s\n", new_target));
- return new_target;
-}
-
-static int expand_msdfs_readlink(struct vfs_handle_struct *handle,
- const char *path, char *buf, size_t bufsiz)
-{
- TALLOC_CTX *ctx = talloc_tos();
- int result;
- char *target = talloc_array(ctx, char, PATH_MAX+1);
- size_t len;
-
- if (!target) {
- errno = ENOMEM;
- return -1;
- }
- if (bufsiz == 0) {
- errno = EINVAL;
- return -1;
- }
-
- result = SMB_VFS_NEXT_READLINK(handle, path, target,
- PATH_MAX);
-
- if (result <= 0)
- return result;
-
- target[result] = '\0';
-
- if ((strncmp(target, "msdfs:", 6) == 0) &&
- (strchr_m(target, '@') != NULL)) {
- target = expand_msdfs_target(ctx, handle->conn, target);
- if (!target) {
- errno = ENOENT;
- return -1;
- }
- }
-
- len = MIN(bufsiz, strlen(target));
-
- memcpy(buf, target, len);
-
- TALLOC_FREE(target);
- return len;
-}
-
-static struct vfs_fn_pointers vfs_expand_msdfs_fns = {
- .readlink_fn = expand_msdfs_readlink
-};
-
-NTSTATUS vfs_expand_msdfs_init(void);
-NTSTATUS vfs_expand_msdfs_init(void)
-{
- return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "expand_msdfs",
- &vfs_expand_msdfs_fns);
-}
diff --git a/source3/modules/wscript_build b/source3/modules/wscript_build
index a5d84075872..03a35c02314 100644
--- a/source3/modules/wscript_build
+++ b/source3/modules/wscript_build
@@ -118,14 +118,6 @@ bld.SAMBA3_MODULE('vfs_cap',
internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_cap'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_cap'))
-bld.SAMBA3_MODULE('vfs_expand_msdfs',
- subsystem='vfs',
- source='vfs_expand_msdfs.c',
- deps='samba-util',
- init_function='',
- internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_expand_msdfs'),
- enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_expand_msdfs'))
-
bld.SAMBA3_MODULE('vfs_shadow_copy',
subsystem='vfs',
source='vfs_shadow_copy.c',
diff --git a/source3/wscript b/source3/wscript
index 78753687431..df02718fff7 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -1677,7 +1677,7 @@ main() {
default_shared_modules.extend(TO_LIST('''
vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
- vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2
+ vfs_shadow_copy vfs_shadow_copy2
vfs_readahead vfs_xattr_tdb
vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
vfs_preopen vfs_catia
--
2.11.0
More information about the samba-technical
mailing list