Skip to content

[BUG] create_users_groups_json.py creates incorrect /etc/subgid files #343

@gwolski

Description

@gwolski

the script create_users_groups_json.py creates subuid and subgid files. The subuid files are of the correct format, but the subgid files are not. The subgid files are created based on the group names from the /etc/group (or wherever group files are defined in this program).

The format of the /etc/subgid file is of the form

<username>:<start_gid>:<count>

Just like the subuid file. In fact, it is my understanding that usually the /etc/subuid and /etc/subgid file are the same.

I think the code in create_users_groups_json.py for subgid creation needs to be updated to either copy the created subuid to subgid, or just create it the same way. I have modified the subgid file creation section from:

    subgid_fh = open(subgid_filename, 'w')
    next_gid = 65536
    for gid in config['gids']:
        subgid_fh.write(f"# {config['gids'][gid]}" + "\n")
        subgid_fh.write(f"{gid}:{next_gid}:65536" + "\n")
        next_gid += 65536
    subgid_fh.close()

to:

    import shutil
    shutil.copy(subuid_filename, subgid_filename)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions