summaryrefslogtreecommitdiff
path: root/libpam
diff options
context:
space:
mode:
authorAndrew G. Morgan <morgan@kernel.org>2002-05-26 23:58:23 +0000
committerAndrew G. Morgan <morgan@kernel.org>2002-05-26 23:58:23 +0000
commit6daa9f4e4eecb8efb60879a5c98135aa0c4d4081 (patch)
treec671c12a42a99ed1d8626399156b49a48fe872ee /libpam
parent7b89c0b53be5361615639c5b3a5bf2cbb40f46bc (diff)
Relevant BUGIDs: 517064
Purpose of commit: feature Commit summary: --------------- document old feature and add '\]' parsing to make it a better feature. The feature is that we can accept spaces in module arguments by enclosing the whole argument inside square brackets. For example a module argument like this: "[hello [you\], this is me]" will be parsed as "hello [you], this is me" Not very interesting, but you get the idea. Thanks to Russell Kliese for requesting this.
Diffstat (limited to 'libpam')
-rw-r--r--libpam/pam_misc.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/libpam/pam_misc.c b/libpam/pam_misc.c
index 2d93a946..bd4ed958 100644
--- a/libpam/pam_misc.c
+++ b/libpam/pam_misc.c
@@ -43,7 +43,7 @@ char *_pam_StrTok(char *from, const char *format, char **next)
for (i=1; i<256; table[i++] = '\0');
for (i=0; format[i] ; table[(int)format[i++]] = 'y');
- /* look for first non-blank char */
+ /* look for first non-format char */
while (*from && table[(int)*from]) {
++from;
}
@@ -53,10 +53,22 @@ char *_pam_StrTok(char *from, const char *format, char **next)
* special case, "[...]" is considered to be a single
* object. Note, however, if one of the format[] chars is
* '[' this single string will not be read correctly.
+ * Note, any '[' inside the outer "[...]" pair will survive.
+ * Note, the first ']' will terminate this string, but
+ * that "\]" will get compressed into "]". That is:
+ *
+ * "[..[..\]..]..." --> "..[..].."
*/
- for (end=++from; *end && *end != ']'; ++end) {
+ char *to;
+ for (to=end=++from; *end && *end != ']'; ++to, ++end) {
if (*end == '\\' && end[1] == ']')
++end;
+ if (to != end) {
+ *to = *end;
+ }
+ }
+ if (to != end) {
+ *to = '\0';
}
/* note, this string is stripped of its edges: "..." is what
remains */