From 25d06b304ffd2c9c5dc89399df369d493a56abd8 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 14 Dec 2020 11:52:09 +0100 Subject: Change the numeric hack to check first char only, new prefix Usernames that start with a digit now transparently get prefixed with "_x_", instead of "s", wich also only was applied if the whole username was numeric. To make this transparent to the end user, prefix "_x_" automatically in the greeter. --- proxy.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'proxy.c') diff --git a/proxy.c b/proxy.c index 60c64ce..5652e91 100644 --- a/proxy.c +++ b/proxy.c @@ -70,27 +70,28 @@ static struct string s_bogusfieldname42, s_bogusfieldname43; // Other static struct string str_ADUSER, str_ADUSERDN; -// HACK +// HACK - we pefix usernames that start with something other than a-z_ with "_x_" static void fixUnNumeric(struct string *value) { - if (value == NULL || value->l < 2) return; - if (value->s[0] != 's') return; - if (!isInt(value, 1)) return; - value->s++; - value->l--; + if (value == NULL || value->l < 4) return; + if (value->s[0] != '_' || value->s[1] != 'x' || value->s[2] != '_') return; + value->s += 3; + value->l -= 3; } static void fixNumeric(struct string *value) { size_t i; - if (value == NULL || value->l < 1 || value->l > 18) return; - if (!isInt(value, 0)) return; + if (value == NULL || value->l < 1 || value->l > 27) return; + if (value->s[0] < '0' || value->s[0] > '9') return; char *buf = tmpbuffer_get(); - buf[0] = 's'; + buf[0] = '_'; + buf[1] = 'x'; + buf[2] = '_'; for (i = 0; i < value->l; ++i) { - buf[i+1] = value->s[i]; + buf[i+3] = value->s[i]; } value->s = buf; - value->l++; + value->l += 3; } // END HACK -- cgit v1.2.3-55-g7522