mirror of
https://github.com/void-linux/void-packages.git
synced 2025-06-06 15:13:51 +02:00
158 lines
4.9 KiB
Diff
158 lines
4.9 KiB
Diff
From 9bc52f47d34e5686d5608ad2217df99e82f6b438 Mon Sep 17 00:00:00 2001
|
|
From: jane400 <pmos@j4ne.de>
|
|
Date: Sun, 2 Jun 2024 10:07:09 +0200
|
|
Subject: [PATCH] musl: missing gshadow
|
|
|
|
---
|
|
src/basic/gshadow.h | 5 +++++
|
|
src/shared/user-record-nss.c | 20 ++++++++++++++++++++
|
|
src/shared/userdb.c | 7 ++++++-
|
|
3 files changed, 31 insertions(+), 1 deletion(-)
|
|
create mode 100644 src/basic/gshadow.h
|
|
|
|
diff --git a/src/basic/gshadow.h b/src/basic/gshadow.h
|
|
new file mode 100644
|
|
index 00000000000..a6a56f38ce7
|
|
--- /dev/null
|
|
+++ b/src/basic/gshadow.h
|
|
@@ -0,0 +1,5 @@
|
|
+#pragma once
|
|
+
|
|
+#define ENABLE_GSHADOW 0
|
|
+
|
|
+struct sgrp {};
|
|
diff --git a/src/shared/user-record-nss.c b/src/shared/user-record-nss.c
|
|
index ffb57214662..2596c658b39 100644
|
|
--- a/src/shared/user-record-nss.c
|
|
+++ b/src/shared/user-record-nss.c
|
|
@@ -286,8 +286,10 @@ int nss_group_to_group_record(
|
|
if (isempty(grp->gr_name))
|
|
return -EINVAL;
|
|
|
|
+#if ENABLE_GSHADOW
|
|
if (sgrp && !streq_ptr(sgrp->sg_namp, grp->gr_name))
|
|
return -EINVAL;
|
|
+#endif
|
|
|
|
g = group_record_new();
|
|
if (!g)
|
|
@@ -303,6 +305,7 @@ int nss_group_to_group_record(
|
|
|
|
g->gid = grp->gr_gid;
|
|
|
|
+#if ENABLE_GSHADOW
|
|
if (sgrp) {
|
|
if (looks_like_hashed_password(utf8_only(sgrp->sg_passwd))) {
|
|
g->hashed_password = strv_new(sgrp->sg_passwd);
|
|
@@ -318,6 +321,7 @@ int nss_group_to_group_record(
|
|
if (r < 0)
|
|
return r;
|
|
}
|
|
+#endif
|
|
|
|
r = json_build(&g->json, JSON_BUILD_OBJECT(
|
|
JSON_BUILD_PAIR("groupName", JSON_BUILD_STRING(g->group_name)),
|
|
@@ -341,9 +345,12 @@ int nss_sgrp_for_group(const struct group *grp, struct sgrp *ret_sgrp, char **re
|
|
int r;
|
|
|
|
assert(grp);
|
|
+#if ENABLE_GSHADOW
|
|
assert(ret_sgrp);
|
|
+#endif
|
|
assert(ret_buffer);
|
|
|
|
+#if ENABLE_GSHADOW
|
|
for (;;) {
|
|
_cleanup_free_ char *buf = NULL;
|
|
struct sgrp sgrp, *result;
|
|
@@ -372,6 +379,9 @@ int nss_sgrp_for_group(const struct group *grp, struct sgrp *ret_sgrp, char **re
|
|
buflen *= 2;
|
|
buf = mfree(buf);
|
|
}
|
|
+#else
|
|
+ return -ESRCH;
|
|
+#endif
|
|
}
|
|
|
|
int nss_group_record_by_name(
|
|
@@ -391,6 +401,7 @@ int nss_group_record_by_name(
|
|
if (r < 0)
|
|
return r;
|
|
|
|
+#if ENABLE_GSHADOW
|
|
if (with_shadow) {
|
|
r = nss_sgrp_for_group(result, &sgrp, &sbuf);
|
|
if (r < 0) {
|
|
@@ -402,6 +413,9 @@ int nss_group_record_by_name(
|
|
incomplete = true;
|
|
|
|
r = nss_group_to_group_record(result, sresult, ret);
|
|
+#else
|
|
+ r = nss_group_to_group_record(result, NULL, ret);
|
|
+#endif
|
|
if (r < 0)
|
|
return r;
|
|
|
|
@@ -418,13 +432,16 @@ int nss_group_record_by_gid(
|
|
_cleanup_free_ char *sbuf = NULL;
|
|
_cleanup_free_ struct group *result = NULL;
|
|
bool incomplete = false;
|
|
+#if ENABLE_GSHADOW
|
|
struct sgrp sgrp, *sresult = NULL;
|
|
+#endif
|
|
int r;
|
|
|
|
r = getgrgid_malloc(gid, &result);
|
|
if (r < 0)
|
|
return r;
|
|
|
|
+#if ENABLE_GSHADOW
|
|
if (with_shadow) {
|
|
r = nss_sgrp_for_group(result, &sgrp, &sbuf);
|
|
if (r < 0) {
|
|
@@ -436,6 +453,9 @@ int nss_group_record_by_gid(
|
|
incomplete = true;
|
|
|
|
r = nss_group_to_group_record(result, sresult, ret);
|
|
+#else
|
|
+ r = nss_group_to_group_record(result, NULL, ret);
|
|
+#endif
|
|
if (r < 0)
|
|
return r;
|
|
|
|
diff --git a/src/shared/userdb.c b/src/shared/userdb.c
|
|
index 75dece34429..4f4e21a6c4b 100644
|
|
--- a/src/shared/userdb.c
|
|
+++ b/src/shared/userdb.c
|
|
@@ -1038,13 +1038,16 @@ int groupdb_iterator_get(UserDBIterator *iterator, GroupRecord **ret) {
|
|
if (gr) {
|
|
_cleanup_free_ char *buffer = NULL;
|
|
bool incomplete = false;
|
|
+#if ENABLE_GSHADOW
|
|
struct sgrp sgrp;
|
|
+#endif
|
|
|
|
if (streq_ptr(gr->gr_name, "root"))
|
|
iterator->synthesize_root = false;
|
|
if (gr->gr_gid == GID_NOBODY)
|
|
iterator->synthesize_nobody = false;
|
|
|
|
+#if ENABLE_GSHADOW
|
|
if (!FLAGS_SET(iterator->flags, USERDB_SUPPRESS_SHADOW)) {
|
|
r = nss_sgrp_for_group(gr, &sgrp, &buffer);
|
|
if (r < 0) {
|
|
@@ -1055,8 +1058,10 @@ int groupdb_iterator_get(UserDBIterator *iterator, GroupRecord **ret) {
|
|
r = -EUCLEAN;
|
|
incomplete = true;
|
|
}
|
|
+#endif
|
|
+
|
|
+ r = nss_group_to_group_record(gr, NULL, ret);
|
|
|
|
- r = nss_group_to_group_record(gr, r >= 0 ? &sgrp : NULL, ret);
|
|
if (r < 0)
|
|
return r;
|
|
|
|
--
|
|
GitLab
|
|
|