gentoo-overlay/sys-apps/systemd/files/0028-basic-Handle-NIS-compa...

56 lines
2.0 KiB
Diff
Raw Permalink Normal View History

From cbd2cc7bbdbdb336a5443ddbc3d805cd8e9e962c Mon Sep 17 00:00:00 2001
From: "A. Wilcox" <AWilcox@Wilcox-Tech.com>
Date: Sun, 18 Aug 2024 03:16:18 -0500
Subject: [PATCH 28/34] basic: Handle NIS compat entries ourselves
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
This is needed on musl, which will otherwise mangle them.
This cannot be upstreamed.
Signed-off-by: Alexander Miroshnichenko <alex@millerson.name>
---
src/basic/user-util.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/basic/user-util.c b/src/basic/user-util.c
index 42fbabec7892..c08669691800 100644
--- a/src/basic/user-util.c
+++ b/src/basic/user-util.c
@@ -930,6 +930,11 @@ int putpwent_sane(const struct passwd *pw, FILE *stream) {
assert(stream);
errno = 0;
+ if (IN_SET(pw->pw_name[0], '+', '-')) {
+ if (fprintf(stream, "%s:%s:::%s:%s:%s\n",
+ pw->pw_name, pw->pw_passwd, pw->pw_gecos, pw->pw_dir, pw->pw_shell) >= 0) return 0;
+ return errno_or_else(EIO);
+ }
if (putpwent(pw, stream) != 0)
return errno_or_else(EIO);
@@ -952,6 +957,19 @@ int putgrent_sane(const struct group *gr, FILE *stream) {
assert(stream);
errno = 0;
+ if (IN_SET(gr->gr_name[0], '+', '-')) {
+ int r = fprintf(stream, "%s:%s::",
+ gr->gr_name, gr->gr_passwd);
+ if (r < 0) return errno_or_else(EIO);
+ if (gr->gr_mem) {
+ for (size_t i = 0; gr->gr_mem[i] && r >= 0; i++) {
+ r = fprintf(stream, "%s%s", i?",":"", gr->gr_mem[i]);
+ }
+ if (r < 0) return errno_or_else(EIO);
+ }
+ if (fputc('\n', stream) >= 0) return 0;
+ return errno_or_else(EIO);
+ }
if (putgrent(gr, stream) != 0)
return errno_or_else(EIO);
--
2.41.0