[NIS] Can we remove --with-automount (default: yes)

Andreas Schneider asn at samba.org
Tue Jan 9 11:03:16 UTC 2018


On Tuesday, 9 January 2018 11:44:17 CET Andreas Schneider via samba-technical 
wrote:
> On Tuesday, 9 January 2018 11:41:18 CET Andreas Schneider via
> samba-technical
> wrote:
> > Hello,
> > 
> > can we remove --with-automount or at least the NIS code automount_lookup()
> > or is someone still using NIS?
> 
> The --help from configure says the default is one, but checking config.h it
> isn't there.
> 
> grep HAVE_AUTOMOUNT bin/default/include/config.h
> 
> This doesn't show anything. I think this code hasn't been compiled for a
> long time ...

Ah no, it is WITH_AUTOMOUNT, that's set to 1 by default but HAVE_NETGROUP 
isn't found at least on my machine.

However, attached is a patch to remove the stuff.

-- 
Andreas Schneider                   GPG-ID: CC014E3D
Samba Team                             asn at samba.org
www.samba.org
-------------- next part --------------
>From 24e96f32160cf3689fbcd2f92914346b7d847d35 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Tue, 9 Jan 2018 11:55:32 +0100
Subject: [PATCH] s3: Remove NIS automount support

Signed-off-by: Andreas Schneider <asn at samba.org>
---
 docs-xml/manpages/smb.conf.5.xml        |  15 ----
 docs-xml/smbdotconf/misc/homedirmap.xml |  27 ------
 docs-xml/smbdotconf/misc/nishomedir.xml |  32 -------
 source3/include/proto.h                 |   2 -
 source3/lib/substitute.c                | 125 ---------------------------
 source3/lib/util.c                      | 149 --------------------------------
 source3/param/loadparm.c                |   9 --
 source3/wscript                         |   3 -
 8 files changed, 362 deletions(-)
 delete mode 100644 docs-xml/smbdotconf/misc/homedirmap.xml
 delete mode 100644 docs-xml/smbdotconf/misc/nishomedir.xml

diff --git a/docs-xml/manpages/smb.conf.5.xml b/docs-xml/manpages/smb.conf.5.xml
index f72833c003f..3fab115a790 100644
--- a/docs-xml/manpages/smb.conf.5.xml
+++ b/docs-xml/manpages/smb.conf.5.xml
@@ -592,21 +592,6 @@ chmod 1770 /usr/local/samba/lib/usershares
 		<term>%H</term>
 		<listitem><para>the home directory of the user given by %u.</para></listitem>
 		</varlistentry>
-
-		<varlistentry>
-		<term>%N</term>
-		<listitem><para>
-			the name of your NIS home directory server.  This is obtained from your NIS auto.map entry. 
-			If you have not compiled Samba with the <emphasis>--with-automount</emphasis> option, this
-			value will be the same as %L.</para></listitem>
-		</varlistentry>
-	
-		<varlistentry>
-		<term>%p</term>
-		<listitem><para>
-			the path of the service's home directory, obtained from your NIS auto.map entry. The NIS
-			auto.map entry is split up as <literal>%N:%p</literal>.</para></listitem>
-		</varlistentry>
 	</variablelist>
 	
 	<para>
diff --git a/docs-xml/smbdotconf/misc/homedirmap.xml b/docs-xml/smbdotconf/misc/homedirmap.xml
deleted file mode 100644
index 279b0b6e52e..00000000000
--- a/docs-xml/smbdotconf/misc/homedirmap.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<samba:parameter name="homedir map"
-                 context="G"
-                 type="string"
-                 xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
- <description>
-	<para>
-	If <smbconfoption name="nis homedir"/> is <constant>yes</constant>, and <citerefentry><refentrytitle>smbd</refentrytitle>
-	<manvolnum>8</manvolnum></citerefentry> is also acting 	as a Win95/98 <parameter moreinfo="none">logon server</parameter> 
-	then this parameter specifies the NIS (or YP) map from which the server for the user's 	home directory should be extracted.  
-	At present, only the Sun auto.home map format is understood. The form of the map is:
-<programlisting>
-<command moreinfo="none">username server:/some/file/system</command>
-</programlisting>
-	and the program will extract the servername from before the first ':'.  There should probably be a better parsing system 
-	that copes with different map formats and also Amd (another automounter) maps.
-	</para>
-		
-	<note><para>
-	A working NIS client is required on the system for this option to work.
-	</para></note>
-</description>
-<related>nis homedir</related>
-<related>domain logons</related>
-
-<value type="default"></value>
-<value type="example">amd.homedir</value>
-</samba:parameter>
diff --git a/docs-xml/smbdotconf/misc/nishomedir.xml b/docs-xml/smbdotconf/misc/nishomedir.xml
deleted file mode 100644
index ace84759fb2..00000000000
--- a/docs-xml/smbdotconf/misc/nishomedir.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<samba:parameter name="NIS homedir"
-                 context="G"
-                 type="boolean"
-                 xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
-<description>
-	<para>Get the home share server from a NIS map. For 
-	UNIX systems that use an automounter, the user's home directory 
-	will often be mounted on a workstation on demand from a remote 
-	server. </para>
-
-	<para>When the Samba logon server is not the actual home directory 
-	server, but is mounting the home directories via NFS then two 
-	network hops would be required to access the users home directory 
-	if the logon server told the client to use itself as the SMB server 
-	for home directories (one over SMB and one over NFS). This can 
-	be very slow.</para>
-
-	<para>This option allows Samba to return the home share as 
-	being on a different server to the logon server and as 
-	long as a Samba daemon is running on the home directory server, 
-	it will be mounted on the Samba client directly from the directory 
-	server. When Samba is returning the home share to the client, it 
-	will consult the NIS map specified in
-	<smbconfoption name="homedir map"/> and return the server 
-	listed there.</para>
-
-	<para>Note that for this option to work there must be a working 
-	NIS system and the Samba server with this option must also 
-	be a logon server.</para>
-</description>
-<value type="default">no</value>
-</samba:parameter>
diff --git a/source3/include/proto.h b/source3/include/proto.h
index fa87407ff24..a42c6cc516b 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -348,8 +348,6 @@ void add_to_large_array(TALLOC_CTX *mem_ctx, size_t element_size,
 			ssize_t *array_size);
 char *get_myname(TALLOC_CTX *ctx);
 char *get_mydnsdomname(TALLOC_CTX *ctx);
-char *automount_lookup(TALLOC_CTX *ctx, const char *user_name);
-char *automount_lookup(TALLOC_CTX *ctx, const char *user_name);
 bool process_exists(const struct server_id pid);
 const char *uidtoname(uid_t uid);
 char *gidtoname(gid_t gid);
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
index 9fdc5ca1edc..a68edd15f5e 100644
--- a/source3/lib/substitute.c
+++ b/source3/lib/substitute.c
@@ -335,107 +335,6 @@ static char *realloc_expand_env_var(char *str, char *p)
 	return r;
 }
 
-/*******************************************************************
- Patch from jkf at soton.ac.uk
- Added this to implement %p (NIS auto-map version of %H)
-*******************************************************************/
-
-static const char *automount_path(const char *user_name)
-{
-	TALLOC_CTX *ctx = talloc_tos();
-	const char *server_path;
-
-	/* use the passwd entry as the default */
-	/* this will be the default if WITH_AUTOMOUNT is not used or fails */
-
-	server_path = talloc_strdup(ctx, get_user_home_dir(ctx, user_name));
-	if (!server_path) {
-		return "";
-	}
-
-#if (defined(HAVE_NETGROUP) && defined (WITH_AUTOMOUNT))
-
-	if (lp_nis_homedir()) {
-		const char *home_path_start;
-		char *automount_value = automount_lookup(ctx, user_name);
-
-		if(automount_value && strlen(automount_value) > 0) {
-			home_path_start = strchr_m(automount_value,':');
-			if (home_path_start != NULL) {
-				DEBUG(5, ("NIS lookup succeeded. "
-					"Home path is: %s\n",
-					home_path_start ?
-						(home_path_start+1):""));
-				server_path = talloc_strdup(ctx,
-							home_path_start+1);
-				if (!server_path) {
-					server_path = "";
-				}
-			}
-		} else {
-			/* NIS key lookup failed: default to
-			 * user home directory from password file */
-			DEBUG(5, ("NIS lookup failed. Using Home path from "
-			"passwd file. Home path is: %s\n", server_path ));
-		}
-	}
-#endif
-
-	DEBUG(4,("Home server path: %s\n", server_path));
-	return server_path;
-}
-
-/*******************************************************************
- Patch from jkf at soton.ac.uk
- This is Luke's original function with the NIS lookup code
- moved out to a separate function.
-*******************************************************************/
-
-static const char *automount_server(const char *user_name)
-{
-	TALLOC_CTX *ctx = talloc_tos();
-	const char *server_name;
-	const char *local_machine_name = get_local_machine_name();
-
-	/* use the local machine name as the default */
-	/* this will be the default if WITH_AUTOMOUNT is not used or fails */
-	if (local_machine_name && *local_machine_name) {
-		server_name = talloc_strdup(ctx, local_machine_name);
-	} else {
-		server_name = talloc_strdup(ctx, lp_netbios_name());
-	}
-
-	if (!server_name) {
-		return "";
-	}
-
-#if (defined(HAVE_NETGROUP) && defined (WITH_AUTOMOUNT))
-	if (lp_nis_homedir()) {
-		char *p;
-		char *srv;
-		char *automount_value = automount_lookup(ctx, user_name);
-		if (!automount_value) {
-			return "";
-		}
-		srv = talloc_strdup(ctx, automount_value);
-		if (!srv) {
-			return "";
-		}
-		p = strchr_m(srv, ':');
-		if (!p) {
-			return "";
-		}
-		*p = '\0';
-		server_name = srv;
-		DEBUG(5, ("NIS lookup succeeded.  Home server %s\n",
-					server_name));
-	}
-#endif
-
-	DEBUG(4,("Home server: %s\n", server_name));
-	return server_name;
-}
-
 /****************************************************************************
  Do some standard substitutions in a string.
  len is the length in bytes of the space allowed in string str. If zero means
@@ -593,9 +492,6 @@ char *talloc_sub_basic(TALLOC_CTX *mem_ctx,
 				a_string = realloc_string_sub(a_string, "%L", lp_netbios_name());
 			}
 			break;
-		case 'N':
-			a_string = realloc_string_sub(a_string, "%N", automount_server(smb_name));
-			break;
 		case 'M' :
 			a_string = realloc_string_sub(a_string, "%M",
 						      sub_peername ? sub_peername : "");
@@ -747,11 +643,6 @@ char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
 			a_string = talloc_string_sub(tmp_ctx, a_string,
 						     "%D", domain);
 			break;
-		case 'N' : 
-			a_string = talloc_string_sub(
-				tmp_ctx, a_string, "%N",
-				automount_server(username)); 
-			break;
 		default: 
 			break;
 		}
@@ -798,9 +689,6 @@ char *talloc_sub_advanced(TALLOC_CTX *ctx,
 		b = a_string;
 
 		switch (*(p+1)) {
-		case 'N' :
-			a_string = realloc_string_sub(a_string, "%N", automount_server(user));
-			break;
 		case 'H': {
 			char *h;
 			if ((h = get_user_home_dir(talloc_tos(), user)))
@@ -820,19 +708,6 @@ char *talloc_sub_advanced(TALLOC_CTX *ctx,
 		case 'u': 
 			a_string = realloc_string_sub(a_string, "%u", user); 
 			break;
-
-			/* Patch from jkf at soton.ac.uk Left the %N (NIS
-			 * server name) in standard_sub_basic as it is
-			 * a feature for logon servers, hence uses the
-			 * username.  The %p (NIS server path) code is
-			 * here as it is used instead of the default
-			 * "path =" string in [homes] and so needs the
-			 * service name, not the username.  */
-		case 'p': 
-			a_string = realloc_string_sub(a_string, "%p",
-						      automount_path(servicename)); 
-			break;
-
 		default: 
 			break;
 		}
diff --git a/source3/lib/util.c b/source3/lib/util.c
index fb508842678..0e3a3e52190 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -44,32 +44,6 @@
 /* Max allowable allococation - 256mb - 0x10000000 */
 #define MAX_ALLOC_SIZE (1024*1024*256)
 
-#if (defined(HAVE_NETGROUP) && defined (WITH_AUTOMOUNT))
-#ifdef WITH_NISPLUS_HOME
-#ifdef BROKEN_NISPLUS_INCLUDE_FILES
-/*
- * The following lines are needed due to buggy include files
- * in Solaris 2.6 which define GROUP in both /usr/include/sys/acl.h and
- * also in /usr/include/rpcsvc/nis.h. The definitions conflict. JRA.
- * Also GROUP_OBJ is defined as 0x4 in /usr/include/sys/acl.h and as
- * an enum in /usr/include/rpcsvc/nis.h.
- */
-
-#if defined(GROUP)
-#undef GROUP
-#endif
-
-#if defined(GROUP_OBJ)
-#undef GROUP_OBJ
-#endif
-
-#endif /* BROKEN_NISPLUS_INCLUDE_FILES */
-
-#include <rpcsvc/nis.h>
-
-#endif /* WITH_NISPLUS_HOME */
-#endif /* HAVE_NETGROUP && WITH_AUTOMOUNT */
-
 static enum protocol_types Protocol = PROTOCOL_COREPLUS;
 
 enum protocol_types get_Protocol(void)
@@ -578,129 +552,6 @@ char *get_mydnsdomname(TALLOC_CTX *ctx)
 	}
 }
 
-#if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
-/******************************************************************
- Remove any mount options such as -rsize=2048,wsize=2048 etc.
- Based on a fix from <Thomas.Hepper at icem.de>.
- Returns a malloc'ed string.
-*******************************************************************/
-
-static char *strip_mount_options(TALLOC_CTX *ctx, const char *str)
-{
-	if (*str == '-') {
-		const char *p = str;
-		while(*p && !isspace(*p))
-			p++;
-		while(*p && isspace(*p))
-			p++;
-		if(*p) {
-			return talloc_strdup(ctx, p);
-		}
-	}
-	return NULL;
-}
-
-/*******************************************************************
- Patch from jkf at soton.ac.uk
- Split Luke's automount_server into YP lookup and string splitter
- so can easily implement automount_path().
- Returns a malloc'ed string.
-*******************************************************************/
-
-#ifdef WITH_NISPLUS_HOME
-char *automount_lookup(TALLOC_CTX *ctx, const char *user_name)
-{
-	char *value = NULL;
-
-	char *nis_map = (char *)lp_homedir_map();
-
-	char buffer[NIS_MAXATTRVAL + 1];
-	nis_result *result;
-	nis_object *object;
-	entry_obj  *entry;
-
-	snprintf(buffer, sizeof(buffer), "[key=%s],%s", user_name, nis_map);
-	DEBUG(5, ("NIS+ querystring: %s\n", buffer));
-
-	if (result = nis_list(buffer, FOLLOW_PATH|EXPAND_NAME|HARD_LOOKUP, NULL, NULL)) {
-		if (result->status != NIS_SUCCESS) {
-			DEBUG(3, ("NIS+ query failed: %s\n", nis_sperrno(result->status)));
-		} else {
-			object = result->objects.objects_val;
-			if (object->zo_data.zo_type == ENTRY_OBJ) {
-				entry = &object->zo_data.objdata_u.en_data;
-				DEBUG(5, ("NIS+ entry type: %s\n", entry->en_type));
-				DEBUG(3, ("NIS+ result: %s\n", entry->en_cols.en_cols_val[1].ec_value.ec_value_val));
-
-				value = talloc_strdup(ctx,
-						entry->en_cols.en_cols_val[1].ec_value.ec_value_val);
-				if (!value) {
-					nis_freeresult(result);
-					return NULL;
-				}
-				value = talloc_string_sub(ctx,
-						value,
-						"&",
-						user_name);
-			}
-		}
-	}
-	nis_freeresult(result);
-
-	if (value) {
-		value = strip_mount_options(ctx, value);
-		DEBUG(4, ("NIS+ Lookup: %s resulted in %s\n",
-					user_name, value));
-	}
-	return value;
-}
-#else /* WITH_NISPLUS_HOME */
-
-char *automount_lookup(TALLOC_CTX *ctx, const char *user_name)
-{
-	char *value = NULL;
-
-	int nis_error;        /* returned by yp all functions */
-	char *nis_result;     /* yp_match inits this */
-	int nis_result_len;  /* and set this */
-	char *nis_domain;     /* yp_get_default_domain inits this */
-	char *nis_map = lp_homedir_map(talloc_tos());
-
-	if ((nis_error = yp_get_default_domain(&nis_domain)) != 0) {
-		DEBUG(3, ("YP Error: %s\n", yperr_string(nis_error)));
-		return NULL;
-	}
-
-	DEBUG(5, ("NIS Domain: %s\n", nis_domain));
-
-	if ((nis_error = yp_match(nis_domain, nis_map, user_name,
-					strlen(user_name), &nis_result,
-					&nis_result_len)) == 0) {
-		if (nis_result_len > 0 && nis_result[nis_result_len] == '\n') {
-			nis_result[nis_result_len] = '\0';
-		}
-		value = talloc_strdup(ctx, nis_result);
-		if (!value) {
-			return NULL;
-		}
-		value = strip_mount_options(ctx, value);
-	} else if(nis_error == YPERR_KEY) {
-		DEBUG(3, ("YP Key not found:  while looking up \"%s\" in map \"%s\"\n", 
-				user_name, nis_map));
-		DEBUG(3, ("using defaults for server and home directory\n"));
-	} else {
-		DEBUG(3, ("YP Error: \"%s\" while looking up \"%s\" in map \"%s\"\n", 
-				yperr_string(nis_error), user_name, nis_map));
-	}
-
-	if (value) {
-		DEBUG(4, ("YP Lookup: %s resulted in %s\n", user_name, value));
-	}
-	return value;
-}
-#endif /* WITH_NISPLUS_HOME */
-#endif
-
 bool process_exists(const struct server_id pid)
 {
 	return serverid_exists(&pid);
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index a2fcc4246c9..a65da66e544 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -676,15 +676,6 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
 	Globals.machine_password_timeout = 60 * 60 * 24 * 7;	/* 7 days default. */
 	Globals.lm_announce = Auto;	/* = Auto: send only if LM clients found */
 	Globals.lm_interval = 60;
-#if (defined(HAVE_NETGROUP) && defined(WITH_AUTOMOUNT))
-	Globals.nis_homedir = false;
-#ifdef WITH_NISPLUS_HOME
-	lpcfg_string_set(Globals.ctx, &Globals.homedir_map,
-			 "auto_home.org_dir");
-#else
-	lpcfg_string_set(Globals.ctx, &Globals.homedir_map, "auto.home");
-#endif
-#endif
 	Globals.time_server = false;
 	Globals.bind_interfaces_only = false;
 	Globals.unix_password_sync = false;
diff --git a/source3/wscript b/source3/wscript
index 0f8fe5452da..2261bf5daeb 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -51,7 +51,6 @@ def set_options(opt):
     opt.SAMBA3_ADD_OPTION('acl-support')
     opt.SAMBA3_ADD_OPTION('dnsupdate')
     opt.SAMBA3_ADD_OPTION('syslog')
-    opt.SAMBA3_ADD_OPTION('automount')
     opt.SAMBA3_ADD_OPTION('dmapi', default=None) # None means autodetection
     opt.SAMBA3_ADD_OPTION('fam', default=None) # None means autodetection
     opt.SAMBA3_ADD_OPTION('profiling-data', default=False)
@@ -639,8 +638,6 @@ msg.msg_accrightslen = sizeof(fd);
             Logs.warn("--enable-iprint=yes but cups support not sufficient")
     if Options.options.with_syslog:
         conf.DEFINE('WITH_SYSLOG', '1')
-    if Options.options.with_automount:
-        conf.DEFINE('WITH_AUTOMOUNT', '1')
 
     # Check for LDAP
     if Options.options.with_ldap:
-- 
2.15.1



More information about the samba-technical mailing list