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

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