Blame SOURCES/autofs-5.0.7-add-short-host-name-standard-marco-variable.patch

306fa1
autofs-5.0.7 - add short host name standard marco variable
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
Sometimes the short hostname (without the domain part) could be useful.
306fa1
Add this to the standard additional macro variables, in particular, to
306fa1
compliment the ${HOST} macro.
306fa1
---
306fa1
 CHANGELOG           |    1 +
306fa1
 man/autofs.5        |    2 +-
306fa1
 modules/parse_sun.c |   13 +++++++++++++
306fa1
 3 files changed, 15 insertions(+), 1 deletion(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -77,6 +77,7 @@
306fa1
 - fix fix options compare.
306fa1
 - fix max() declaration.
306fa1
 - setup program map env from macro table.
306fa1
+- add short host name standard marco variable.
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/man/autofs.5
306fa1
+++ autofs-5.0.7/man/autofs.5
306fa1
@@ -170,7 +170,7 @@ UID	The user login ID
306fa1
 GROUP	The user group name
306fa1
 GID	The user group ID
306fa1
 HOME	The user home directory
306fa1
-HOST	Hostname (uname -n)
306fa1
+SHOST	Short hostname (domain part removed if present)
306fa1
 .fi
306fa1
 .RE
306fa1
 .sp
306fa1
--- autofs-5.0.7.orig/modules/parse_sun.c
306fa1
+++ autofs-5.0.7/modules/parse_sun.c
306fa1
@@ -107,6 +107,7 @@ static struct substvar *addstdenv(struct
306fa1
 
306fa1
 	tsv = pthread_getspecific(key_thread_stdenv_vars);
306fa1
 	if (tsv) {
306fa1
+		struct substvar *mv;
306fa1
 		int ret;
306fa1
 		long num;
306fa1
 
306fa1
@@ -121,6 +122,17 @@ static struct substvar *addstdenv(struct
306fa1
 		list = macro_addvar(list, "USER", 4, tsv->user);
306fa1
 		list = macro_addvar(list, "GROUP", 5, tsv->group);
306fa1
 		list = macro_addvar(list, "HOME", 4, tsv->home);
306fa1
+		mv = macro_findvar(list, "HOST", 4);
306fa1
+		if (mv) {
306fa1
+			char *shost = strdup(mv->val);
306fa1
+			if (shost) {
306fa1
+				char *dot = strchr(shost, '.');
306fa1
+				if (dot)
306fa1
+					*dot = '\0';
306fa1
+				list = macro_addvar(list, "SHOST", 5, shost);
306fa1
+				free(shost);
306fa1
+			}
306fa1
+		}
306fa1
 	}
306fa1
 	return list;
306fa1
 }
306fa1
@@ -134,6 +146,7 @@ static struct substvar *removestdenv(str
306fa1
 	list = macro_removevar(list, "HOME", 4);
306fa1
 	list = macro_removevar(list, "GID", 3);
306fa1
 	list = macro_removevar(list, "GROUP", 5);
306fa1
+	list = macro_removevar(list, "SHOST", 5);
306fa1
 	return list;
306fa1
 }
306fa1