Commit b87a619d authored by jan.koester's avatar jan.koester
Browse files

tes

parent 7ed62bdf
Loading
Loading
Loading
Loading
Loading
+16 −3
Changes for src/cluster.cpp: 16 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -58,7 +58,11 @@ namespace authdb {

    // --- SessionBlock serialization ---

    // Session block magic: "SESS" (0x53455353)
    static constexpr uint8_t SESSION_MAGIC[4] = { 0x53, 0x45, 0x53, 0x53 };

    // Wire format:
    //   [4B magic "SESS"]
    //   [16B sid][16B uid][16B did]
    //   [4B member_count]
    //   [16B * member_count member uuids]
@@ -83,13 +87,17 @@ namespace authdb {
        std::vector<std::pair<uuid::uuid, bool>> gpo_results;
        sess.getGPOResults(gpo_results);

        // Header: 16+16+16 + 4 + members*16 + 4 + username + 4 + gpos*17
        size_t total = 48 + 4 + (members.size() * 16) + 4 + username_len
        // Header: 4(magic) + 16+16+16 + 4 + members*16 + 4 + username + 4 + gpos*17
        size_t total = 4 + 48 + 4 + (members.size() * 16) + 4 + username_len
                     + 4 + (gpo_results.size() * 17);

        std::vector<uint8_t> buf(total);
        size_t pos = 0;

        // Magic
        std::memcpy(buf.data() + pos, SESSION_MAGIC, 4);
        pos += 4;

        // SID
        std::memcpy(buf.data() + pos, sid.value, 16);
        pos += 16;
@@ -143,10 +151,15 @@ namespace authdb {
                                    std::vector<uuid::uuid> &members,
                                    std::string &username,
                                    std::vector<std::pair<uuid::uuid, bool>> &gpo_results) {
        if (data.size() < 56) return false;
        if (data.size() < 60) return false;

        size_t pos = 0;

        // Check magic
        if (std::memcmp(data.data(), SESSION_MAGIC, 4) != 0)
            return false;
        pos += 4;

        std::memcpy(sid.value, data.data() + pos, 16);
        pos += 16;