Commit 4da35e9b authored by jan.koester's avatar jan.koester
Browse files

test

parent 773ffd0e
Loading
Loading
Loading
Loading
+5 −2
Changes for src/config.cpp: 5 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -137,11 +137,14 @@ bool validNfsClient(const std::string &c) {
    return inet_pton(AF_INET, addr.c_str(), buf) == 1 || inet_pton(AF_INET6, addr.c_str(), buf) == 1;
}

/* local names, and those of other sources (adconnect: user@domain, AD
 * groups like "domain users@example.com", computer accounts ending in $) */
bool validUserName(const std::string &u) {
    std::string n = u[0] == '@' ? u.substr(1) : u;
    if (n.empty() || n.size() > 32) return false;
    if (n.empty() || n.size() > 256 || n[0] == '@' || n[0] == ' ' || n.back() == ' ') return false;
    for (char c : n)
        if (!(isalnum((unsigned char)c) || c == '_' || c == '-' || c == '.')) return false;
        if (!(isalnum((unsigned char)c) || c == '_' || c == '-' || c == '.' || c == '@' || c == ' ' || c == '$'))
            return false;
    return true;
}