From 4a9c910ff718d3aff52c1c8c7457b8ccb11b79e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Mon, 14 Feb 2022 13:55:54 +0200 Subject: [PATCH] add missing headers --- README.md | 56 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index d153fce..e8ec77c 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,12 @@ Library (glibc). Turbonss implements lookup for `user` and `passwd` database entries (i.e. system users, groups, and group memberships). It's main goal is performance, with focus on making [`id(1)`][id] run as fast as possible. +Turbonss is optimized for reading. If the data changes in any way, the whole +file will need to be regenerated (and tooling only supports only full +generation). It was created, and best suited, for environments that have a +central user & group database which then needs to be distributed to many +servers/services. + To understand more about name service switch, start with [`nsswitch.conf(5)`][nsswitch]. @@ -153,12 +159,15 @@ OFFSET TYPE NAME DESCRIPTION 7 u8 padding 8 u32 num_users number of passwd entries 12 u32 num_groups number of group entries - 16 u32 offset_cmph_gid2group - 20 u32 offset_cmph_uid2user - 24 u32 offset_cmph_groupname2group - 28 u32 offset_cmph_username2user - 32 u32 offset_groupmembers - 36 u32 offset_additional_gids + 16 u32 offset_cmph_uid2user + 20 u32 offset_cmph_groupname2group + 24 u32 offset_cmph_username2user + 28 u32 offset_idx offset to the first idx_ section + 32 u32 offset_groups + 36 u32 offset_users + 40 u32 offset_shells + 44 u32 offset_groupmembers + 48 u32 offset_additional_gids ``` `magic` is 0xf09fa4b7, and `version` must be `0`. All integers are @@ -173,6 +182,11 @@ offsets are always pointing to the beginning of an 64-byte "block". Therefore, all `offset_*` values could be `u26`. As `u32` is easier to visualize with xxd, and the header block fits to 64 bytes anyway, we are keeping them as u32 now. +Sections whose lengths can be calculated do not have a corresponding `offset_*` +header field. For example, `cmph_gid2group` comes immediately after the header, +and `idx_groupname2group` comes after `idx_gid2group`, whose offset is +`offset_idx`, and size can be calculated. + Primitive types --------------- @@ -299,21 +313,21 @@ entries are 8-byte aligned, 3 bits are saved from every element. Each section is padded to 64 bytes. ``` -SECTION SIZE DESCRIPTION -Header 40 see "Turbonss header" section -idx_gid2group len(group)*4*29/32 list of gid2group indices -idx_groupname2group len(group)*4*29/32 list of groupname2group indices -idx_uid2user len(user)*4*29/32 list of uid2user indices -idx_username2user len(user)*4*29/32 list of username2user indices -Groups ? list of Group entries -Users ? list of User entries -Shells ? See "Shells" section -cmph_gid2group ? offset by offset_cmph_gid2group -cmph_uid2user ? offset by offset_cmph_uid2user -cmph_groupname2group ? offset by offset_cmph_groupname2group -cmph_username2user ? offset by offset_cmph_username2user -groupmembers ? offset by offset_groupmembers -additional_gids ? offset by offset_additional_gids +SECTION SIZE DESCRIPTION +Header 40 see "Turbonss header" section +cmph_gid2group ? gid->group cmph +cmph_uid2user ? uid->user cmph +cmph_groupname2group ? groupname->group cmph +cmph_username2user ? username->user cmph +idx_gid2group len(group)*4*29/32 cmph->offset gid2group +idx_groupname2group len(group)*4*29/32 cmph->offset groupname2group +idx_uid2user len(user)*4*29/32 cmph->offset uid2user +idx_username2user len(user)*4*29/32 cmph->offset username2user +Groups ? packed Group entries (8b padding) +Users ? packed User entries (8b padding) +Shells ? See "Shells" section +groupmembers ? per-group memberlist (32b padding) +additional_gids ? per-user grouplist (8b padding) ``` [git-subtrac]: https://github.com/apenwarr/git-subtrac/