[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Allowing regular expression in --allow-root option
From: |
Christian BAYLE |
Subject: |
Allowing regular expression in --allow-root option |
Date: |
Thu, 04 Oct 2001 23:23:11 +0200 |
This is not a bug, but as my message was rejected by the dev list
with recommendation to send there
I do it
I found this patch that allow the use of regular expression with
--allow-root option
These have been done by Gavin Walker
I find this usefull
Can this be added in cvs?
--- root.c.orig Sun Mar 7 21:17:02 1999
+++ root.c Thu Dec 14 11:53:55 2000
@@ -261,9 +261,34 @@
}
for (i = 0; i < root_allow_count; ++i)
- if (strcmp (root_allow_vector[i], arg) == 0)
+ if (strncmp (root_allow_vector[i], arg, strlen
(root_allow_vector[i]) ) == 0
+ && root_allow_ok_match(&arg[strlen(root_allow_vector[i])],
"^/[a-zA-Z][a-zA-Z0-9 -]+$"))
return 1;
return 0;
+}
+
+/*
+ * Match string against the extended regular expression in
+ * pattern, treating errors as no match.
+ *
+ * return 1 for match, 0 for no match
+ */
+
+int
+root_allow_ok_match (char * string, char * pattern)
+{
+ int status;
+ regex_t re;
+
+ if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) != 0) {
+ return 0; /* report error */
+ }
+ status = regexec(&re, string, (size_t) 0, NULL, 0);
+ regfree(&re);
+ if (status != 0) {
+ return 0; /* report error */
+ }
+ return 1;
}
/* This global variable holds the global -d option. It is NULL if -d
Many thank if it's possible
Christian Bayle
- Allowing regular expression in --allow-root option,
Christian BAYLE <=