Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 130701790bf2d95e902edf16031ff596 > files > 103

autofs-5.0.1-0.rc2.164.el5_8.src.rpm

autofs-5.0.1 - improve mount location error reporting

From: Ian Kent <raven@themaw.net>

Try and report a more sensible error when an invalid location is
encountered.
---

 modules/parse_sun.c |   32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)


--- autofs-5.0.1.orig/modules/parse_sun.c
+++ autofs-5.0.1/modules/parse_sun.c
@@ -848,7 +848,7 @@ add_offset_entry(struct autofs_point *ap
 	return ret;
 }
 
-static int validate_location(char *loc)
+static int validate_location(unsigned int logopt, char *loc)
 {
 	char *ptr = loc;
 
@@ -861,13 +861,21 @@ static int validate_location(char *loc)
 	 * for those special file systems like sshfs which use "#",
 	 * "@" and ":" in the host name part.
 	 */
-	if (check_colon(ptr)) {
+	if (!check_colon(ptr)) {
+		error(logopt,
+		      "expected colon delimeter not found in location %s",
+		      loc);
+		return 0;
+	} else {
 		while (*ptr && strncmp(ptr, ":/", 2)) {
 			if (!(isalnum(*ptr) ||
 			    *ptr == '-' || *ptr == '.' || *ptr == '_' ||
 			    *ptr == ',' || *ptr == '(' || *ptr == ')' ||
-			    *ptr == '#' || *ptr == '@' || *ptr == ':'))
+			    *ptr == '#' || *ptr == '@' || *ptr == ':')) {
+				error(logopt, "invalid character \"%c\" "
+				      "found in location %s", *ptr, loc);
 				return 0;
+			}
 			ptr++;
 		}
 
@@ -876,8 +884,10 @@ static int validate_location(char *loc)
 	}
 
 	/* Must always be something following */
-	if (!*ptr)
+	if (!*ptr) {
+		error(logopt, "invalid location %s", loc);
 		return 0;
+	}
 
 	return 1;
 }
@@ -943,8 +953,7 @@ static int parse_mapent(const char *ent,
 		return 0;
 	}
 
-	if (!validate_location(loc)) {
-		warn(logopt, MODPREFIX "invalid location %s", loc);
+	if (!validate_location(logopt, loc)) {
 		free(myoptions);
 		free(loc);
 		return 0;
@@ -976,9 +985,7 @@ static int parse_mapent(const char *ent,
 			return 0;
 		}
 
-		if (!validate_location(ent)) {
-			warn(logopt,
-			      MODPREFIX "invalid location %s", ent);
+		if (!validate_location(logopt, ent)) {
 			free(ent);
 			free(myoptions);
 			free(loc);
@@ -1679,8 +1686,7 @@ int parse_mount(struct autofs_point *ap,
 			return 1;
 		}
 
-		if (!validate_location(loc)) {
-			warn(ap->logopt, MODPREFIX "invalid location %s", loc);
+		if (!validate_location(ap->logopt, loc)) {
 			free(loc);
 			free(options);
 			return 1;
@@ -1705,9 +1711,7 @@ int parse_mount(struct autofs_point *ap,
 				return 1;
 			}
 
-			if (!validate_location(ent)) {
-				warn(ap->logopt,
-				     MODPREFIX "invalid location %s", loc);
+			if (!validate_location(ap->logopt, ent)) {
 				free(ent);
 				free(loc);
 				free(options);