Commit Graph

9 Commits

Author SHA1 Message Date
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Zbigniew Jędrzejewski-Szmek 5c0b738012 user-record-nss: check if strings from pwd/spwd/grp/sgrp are valid utf-8
strv_extend_strv_utf8_only() uses a temporary buffer to make the implementation
conscise. Otherwise we'd have to rewrite all of strv_extend_strv() which didn't
seem worth the trouble for this one use outside of a hot path.

If the data is not serializable, we just pretend it doesn't exists.
This fixes #16683 and https://bugs.gentoo.org/735072 in a second way.
2020-09-01 16:48:40 +02:00
Zbigniew Jędrzejewski-Szmek e60775cb7b shared: merge {user,group}-record-nss.{c,h}
They both are both short and contain similar parts and various helper will be
shared between both parts of the code so it's easier to use a single file.
2020-09-01 16:48:40 +02:00
Zbigniew Jędrzejewski-Szmek 8f796e40a5 shared/{user,group}-record-nss: adjust filtering of "valid" passwords
We would reject various passwords that glibc accepts, for example ""
or any descrypted password. Accounts with empty password are definitely
useful, for example for testing or in scenarios where a password is not
needed. Also, using weak encryption methods is probably not a good idea,
it's not the job of our nss helpers to decide that: they should just
faithfully forward whatever data is there.

Also rename the function to make it more obvious that the returned answer
is not in any way certain.
2020-08-31 21:33:16 +02:00
Lennart Poettering 5cd12abaa0 user-record: deal with invalid GECOS fields gracefully
Let's fix up invalid GECOS fields both when we convert from NSS to JSON
and the other way round.

Kinda sucks we have to do that, but NSS does it when writing data to
/etc/passwd, so let's do the same.

Fixes: #16668
2020-08-07 17:36:27 +02:00
Lennart Poettering ed30170ea0 userdb: when doing client-side NSS look-ups optionally avoid shadow look-ups 2020-04-09 14:38:02 +02:00
Zbigniew Jędrzejewski-Szmek ddee3ada46 shared/user-record-nss: use macro to avoid repeats
It's easier to read when each field is intialized in exactly one place.
2020-01-17 08:13:09 +01:00
Zbigniew Jędrzejewski-Szmek 192aee3cae shared/user-record-nss: shorten code a bit
free_and_strdup() already does comparison internally.
2020-01-16 21:57:00 +01:00
Lennart Poettering 9b2d907877 shared: add helpers for converting NSS passwd/group structures to new JSON objects
These new calls may be used to convert classic UNIX/glibc NSS struct
passwd and struct group records into new-style JSON-based user/group
objects.
2020-01-15 15:27:23 +01:00