$darkmode
Elektra 0.11.0
Plugin: passwd

This plugin parses passwd files, e.g. /etc/passwd.

Installation

See installation. The package is called libelektra5-experimental.

Implementation Details

The non-POSIX function fgetpwent (GNU_SOURCE) will be used to read the file supplied by the resolver. As a fallback we implemented our own version based on musls fgetpwent.

For writing putpwent (GNU_SOURCE) will be used. If it is not available the plugin will write straight to the config file.

Requirements

For the plugin to be build at least POSIX_C_SOURCE >= 200809L compatibility is required.

Configuration

If the config key index is set to name passwd entries will be sorted by name, if not set or set to uid passwd entries will be sorted by uid

Fields

Usage

To mount the passwd file you can run

1 sudo kdb mount /etc/passwd system:/tests/passwd passwd index=name

To see which entries for the root user exist you can run

1 kdb ls system:/tests/passwd/root
2 #> system:/tests/passwd/root
3 #> system:/tests/passwd/root/gecos
4 #> system:/tests/passwd/root/gid
5 #> system:/tests/passwd/root/home
6 #> system:/tests/passwd/root/passwd
7 #> system:/tests/passwd/root/shell
8 #> system:/tests/passwd/root/uid

If you want to receive one specific value you can run for example

1 kdb get system:/tests/passwd/root/gecos

You can also export it as whole in any format you like, for example JSON

1 kdb export system:/tests/passwd/root json
2 # {
3 # "gecos": "root",
4 # "gid": "0",
5 # "home": "/root",
6 # "passwd": "x",
7 # "shell": "/bin/bash",
8 # "uid": "0"
9 # }

To unmount it, you can run

1 sudo kdb umount system:/tests/passwd