Commit 191d7bb1 authored by jan.koester's avatar jan.koester
Browse files

uuid extended support

parent 2286da34
Loading
Loading
Loading
Loading
+6 −1
Changes for src/smb.cpp: 6 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -295,12 +295,14 @@ void subAuth(uint32_t out[3]) {
    }
}

#ifndef SHAREDD_UID_R
// passwd entry of an SMB account name (SMB user names are case-insensitive)
struct passwd *lookupUser(const std::string &account) {
    if (struct passwd *pw = getpwnam(account.c_str())) return pw;
    std::string l = lower(account);
    return l != account ? getpwnam(l.c_str()) : nullptr;
}
#endif

// An SMB account: classic ids, or (FenrirOS uid_r) a UUID or GUID user or
// group, which only a kernel with the *_r calls -- and ksmbd's login
@@ -364,6 +366,7 @@ bool locked(const char *name) {
    return l;
}

#ifndef SHAREDD_UID_R
std::vector<gid_t> groupsOf(const char *name, gid_t gid) {
    int n = 64;
    std::vector<gid_t> groups(n);
@@ -374,6 +377,7 @@ std::vector<gid_t> groupsOf(const char *name, gid_t gid) {
    groups.resize(n > 0 ? n : 0);
    return groups;
}
#endif

#ifdef SHAREDD_UID_R
// all groups of an account (primary first), UUID and GUID ones too
@@ -421,7 +425,7 @@ bool userAllowed(const Share &share, const std::string &account) {
            if (uid_r_eq(&g, &want)) return true;
    }
    return false;
#endif
#else
    struct passwd *pw = lookupUser(account);
    if (!pw) return false;
    std::string name = pw->pw_name;
@@ -442,6 +446,7 @@ bool userAllowed(const Share &share, const std::string &account) {
        if (gr->gr_gid == gid || std::find(groups.begin(), groups.end(), gr->gr_gid) != groups.end()) return true;
    }
    return false;
#endif
}

} // namespace