|
Ian Kent |
ca38f0 |
autofs-5.0.6 - improve mount location error reporting
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
From: Ian Kent <raven@themaw.net>
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
Try and report a more sensible error when an invalid location is
|
|
Ian Kent |
ca38f0 |
encountered.
|
|
Ian Kent |
ca38f0 |
---
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
CHANGELOG | 1 +
|
|
Ian Kent |
ca38f0 |
modules/parse_sun.c | 32 ++++++++++++++++++--------------
|
|
Ian Kent |
ca38f0 |
2 files changed, 19 insertions(+), 14 deletions(-)
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
diff --git a/CHANGELOG b/CHANGELOG
|
|
Ian Kent |
ca38f0 |
index e5dfa83..a178b74 100644
|
|
Ian Kent |
ca38f0 |
--- a/CHANGELOG
|
|
Ian Kent |
ca38f0 |
+++ b/CHANGELOG
|
|
Ian Kent |
ca38f0 |
@@ -1,6 +1,7 @@
|
|
Ian Kent |
ca38f0 |
??/??/20?? autofs-5.0.7
|
|
Ian Kent |
ca38f0 |
=======================
|
|
Ian Kent |
ca38f0 |
- fix ipv6 name for lookup fix.
|
|
Ian Kent |
ca38f0 |
+- improve mount location error reporting.
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
28/06/2011 autofs-5.0.6
|
|
Ian Kent |
ca38f0 |
-----------------------
|
|
Ian Kent |
ca38f0 |
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
|
|
Ian Kent |
ca38f0 |
index 3242e3b..021850d 100644
|
|
Ian Kent |
ca38f0 |
--- a/modules/parse_sun.c
|
|
Ian Kent |
ca38f0 |
+++ b/modules/parse_sun.c
|
|
Ian Kent |
ca38f0 |
@@ -853,7 +853,7 @@ add_offset_entry(struct autofs_point *ap, const char *name,
|
|
Ian Kent |
ca38f0 |
return ret;
|
|
Ian Kent |
ca38f0 |
}
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
-static int validate_location(char *loc)
|
|
Ian Kent |
ca38f0 |
+static int validate_location(unsigned int logopt, char *loc)
|
|
Ian Kent |
ca38f0 |
{
|
|
Ian Kent |
ca38f0 |
char *ptr = loc;
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
@@ -867,14 +867,22 @@ static int validate_location(char *loc)
|
|
Ian Kent |
ca38f0 |
* and "@" in the host name part and ipv6 addresses that
|
|
Ian Kent |
ca38f0 |
* have ":", "[" and "]".
|
|
Ian Kent |
ca38f0 |
*/
|
|
Ian Kent |
ca38f0 |
- if (check_colon(ptr)) {
|
|
Ian Kent |
ca38f0 |
+ if (!check_colon(ptr)) {
|
|
Ian Kent |
ca38f0 |
+ error(logopt,
|
|
Ian Kent |
ca38f0 |
+ "expected colon delimeter not found in location %s",
|
|
Ian Kent |
ca38f0 |
+ loc);
|
|
Ian Kent |
ca38f0 |
+ return 0;
|
|
Ian Kent |
ca38f0 |
+ } else {
|
|
Ian Kent |
ca38f0 |
while (*ptr && strncmp(ptr, ":/", 2)) {
|
|
Ian Kent |
ca38f0 |
if (!(isalnum(*ptr) ||
|
|
Ian Kent |
ca38f0 |
*ptr == '-' || *ptr == '.' || *ptr == '_' ||
|
|
Ian Kent |
ca38f0 |
*ptr == ',' || *ptr == '(' || *ptr == ')' ||
|
|
Ian Kent |
ca38f0 |
*ptr == '#' || *ptr == '@' || *ptr == ':' ||
|
|
Ian Kent |
ca38f0 |
- *ptr == '[' || *ptr == ']'))
|
|
Ian Kent |
ca38f0 |
+ *ptr == '[' || *ptr == ']')) {
|
|
Ian Kent |
ca38f0 |
+ error(logopt, "invalid character \"%c\" "
|
|
Ian Kent |
ca38f0 |
+ "found in location %s", *ptr, loc);
|
|
Ian Kent |
ca38f0 |
return 0;
|
|
Ian Kent |
ca38f0 |
+ }
|
|
Ian Kent |
ca38f0 |
ptr++;
|
|
Ian Kent |
ca38f0 |
}
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
@@ -883,8 +891,10 @@ static int validate_location(char *loc)
|
|
Ian Kent |
ca38f0 |
}
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
/* Must always be something following */
|
|
Ian Kent |
ca38f0 |
- if (!*ptr)
|
|
Ian Kent |
ca38f0 |
+ if (!*ptr) {
|
|
Ian Kent |
ca38f0 |
+ error(logopt, "invalid location %s", loc);
|
|
Ian Kent |
ca38f0 |
return 0;
|
|
Ian Kent |
ca38f0 |
+ }
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
return 1;
|
|
Ian Kent |
ca38f0 |
}
|
|
Ian Kent |
ca38f0 |
@@ -951,8 +961,7 @@ static int parse_mapent(const char *ent, char *g_options, char **options, char *
|
|
Ian Kent |
ca38f0 |
return 0;
|
|
Ian Kent |
ca38f0 |
}
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
- if (!validate_location(loc)) {
|
|
Ian Kent |
ca38f0 |
- warn(logopt, MODPREFIX "invalid location %s", loc);
|
|
Ian Kent |
ca38f0 |
+ if (!validate_location(logopt, loc)) {
|
|
Ian Kent |
ca38f0 |
free(myoptions);
|
|
Ian Kent |
ca38f0 |
free(loc);
|
|
Ian Kent |
ca38f0 |
return 0;
|
|
Ian Kent |
ca38f0 |
@@ -985,9 +994,7 @@ static int parse_mapent(const char *ent, char *g_options, char **options, char *
|
|
Ian Kent |
ca38f0 |
return 0;
|
|
Ian Kent |
ca38f0 |
}
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
- if (!validate_location(ent_chunk)) {
|
|
Ian Kent |
ca38f0 |
- warn(logopt,
|
|
Ian Kent |
ca38f0 |
- MODPREFIX "invalid location %s", ent_chunk);
|
|
Ian Kent |
ca38f0 |
+ if (!validate_location(logopt, ent_chunk)) {
|
|
Ian Kent |
ca38f0 |
free(ent_chunk);
|
|
Ian Kent |
ca38f0 |
free(myoptions);
|
|
Ian Kent |
ca38f0 |
free(loc);
|
|
Ian Kent |
ca38f0 |
@@ -1688,8 +1695,7 @@ int parse_mount(struct autofs_point *ap, const char *name,
|
|
Ian Kent |
ca38f0 |
return 1;
|
|
Ian Kent |
ca38f0 |
}
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
- if (!validate_location(loc)) {
|
|
Ian Kent |
ca38f0 |
- warn(ap->logopt, MODPREFIX "invalid location %s", loc);
|
|
Ian Kent |
ca38f0 |
+ if (!validate_location(ap->logopt, loc)) {
|
|
Ian Kent |
ca38f0 |
free(loc);
|
|
Ian Kent |
ca38f0 |
free(options);
|
|
Ian Kent |
ca38f0 |
return 1;
|
|
Ian Kent |
ca38f0 |
@@ -1714,9 +1720,7 @@ int parse_mount(struct autofs_point *ap, const char *name,
|
|
Ian Kent |
ca38f0 |
return 1;
|
|
Ian Kent |
ca38f0 |
}
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
- if (!validate_location(ent)) {
|
|
Ian Kent |
ca38f0 |
- warn(ap->logopt,
|
|
Ian Kent |
ca38f0 |
- MODPREFIX "invalid location %s", loc);
|
|
Ian Kent |
ca38f0 |
+ if (!validate_location(ap->logopt, ent)) {
|
|
Ian Kent |
ca38f0 |
free(ent);
|
|
Ian Kent |
ca38f0 |
free(loc);
|
|
Ian Kent |
ca38f0 |
free(options);
|