@@ -103,22 +103,24 @@ to be used with NSS.
103
103
104
104
6. Perform NSS queries to validate the installation, for example using the built-in `getent` tool.
105
105
106
- Some sample commands to test your implementation:
106
+ Some sample commands to test your implementation:
107
107
```
108
108
getent group
109
109
getent passwd
110
110
getent shadow
111
111
getent group <groupname>
112
112
```
113
- A very basic test config is available that will respond to `getent group` calls with a fake group (see the demo GIF
114
- at the top of this file):
115
-
116
- curl -sLo /etc/libnss_shim/config.json https://raw.githubusercontent.com/xenago/libnss_shim/main/default_config/sample_custom_config .json
113
+ A very basic test config is available that will respond to `getent group` calls with a fake group (see the demo GIF
114
+ at the top of this file):
115
+
116
+ curl -sLo /etc/libnss_shim/config.json https://raw.githubusercontent.com/xenago/libnss_shim/main/samples/basic/custom_config .json
117
117
getent group | tail -1
118
-
119
- If the installation worked, the output should look like:
120
-
121
- testgroup::1008:fake-username,another-user
118
+
119
+ If the installation worked, the output should look like:
120
+
121
+ test-shim-group::1008:fake-username,another-user
122
+
123
+ A more complex configuration example can be found at [`samples/advanced`](samples/advanced), with a `Dockerfile`.
122
124
123
125
## Uninstall
124
126
@@ -163,7 +165,7 @@ commands run by `libnss_shim`:
163
165
- `<$uid>`
164
166
165
167
Using only that information, here is the
166
- [extremely basic test example of `config.json`](default_config/sample_custom_config .json) - one database is defined,
168
+ [extremely basic test example of `config.json`](samples/basic/custom_config .json) - one database is defined,
167
169
`group`, with just a single function, `get_all_entries`:
168
170
169
171
```
@@ -172,7 +174,7 @@ Using only that information, here is the
172
174
"group": {
173
175
"functions": {
174
176
"get_all_entries": {
175
- "command": "echo 'testgroup ::1008: fake-username ,another-user'"
177
+ "command": "echo 'test-shim-group ::1008: fake-username ,another-user'"
176
178
}
177
179
}
178
180
}
@@ -181,7 +183,7 @@ Using only that information, here is the
181
183
```
182
184
183
185
The command defined for `get_all_entries` prints out a single line to `stdout`, describing a fake group
184
- called `testgroup ` with `gid=1008` and two members. That output is then captured by `libss_shim` and returned
186
+ called `test-shim-group ` with `gid=1008` and two members. That output is then captured by `libss_shim` and returned
185
187
to `NSS` whenever a call is made requesting all the group entries (e.g. `getent group`).
186
188
187
189
To support command execution, the following options can be set globally and overridden for specific databases and/or
@@ -359,9 +361,16 @@ and `usize` are platform-dependent and can be 32 or 64-bits):
359
361
360
362
## Security
361
363
362
- This NSS plugin runs commands defined in the file `/etc/libnss_shim/config.json`, which is only accessible to `root` by
363
- default. Ensure that this file, the commands defined inside it, and any other related resources remain inaccessible to
364
- other users, or the system may be vulnerable to privilege escalation attacks.
364
+ This NSS plugin runs commands defined in the file `/etc/libnss_shim/config.json`, which is only writable by the `root`
365
+ user by default. Ensure that this file, the commands defined inside it, and any other related resources remain read-only
366
+ to other users, or the system may be vulnerable to privilege escalation attacks.
367
+
368
+ To enable non-root users to access resources defined by `libnss_shim`, they must be able to access the commands defined
369
+ in `config.json`. For example, if a file `script.py` is being used, it will need to be readable (along with the Python
370
+ interpreter used to run it):
371
+
372
+ sudo chown root:root /path/to/custom/script.py
373
+ sudo chmod 644 /path/to/custom/script.py
365
374
366
375
It is recommended to pass data (like `<$name>`) using environment variables rather than arguments, except for
367
376
testing purposes. Environment variables are generally private, whereas commands/launch args are not.
0 commit comments