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

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