summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2020-12-14 11:52:09 +0100
committerSimon Rettberg2020-12-14 11:52:09 +0100
commit25d06b304ffd2c9c5dc89399df369d493a56abd8 (patch)
tree423d8c9787628e9174796ea5f589a4739c7f5fe8
parentFilter mSMQSignCertificates (diff)
downloadldadp-25d06b304ffd2c9c5dc89399df369d493a56abd8.tar.gz
ldadp-25d06b304ffd2c9c5dc89399df369d493a56abd8.tar.xz
ldadp-25d06b304ffd2c9c5dc89399df369d493a56abd8.zip
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.
-rw-r--r--proxy.c23
1 files changed, 12 insertions, 11 deletions
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