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

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