diff options
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0001-Handle-missing-gshadow.patch')
-rw-r--r-- | meta/recipes-core/systemd/systemd/0001-Handle-missing-gshadow.patch | 171 |
1 files changed, 171 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0001-Handle-missing-gshadow.patch b/meta/recipes-core/systemd/systemd/0001-Handle-missing-gshadow.patch new file mode 100644 index 0000000000..26a597d45b --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0001-Handle-missing-gshadow.patch | |||
@@ -0,0 +1,171 @@ | |||
1 | From ef9580ea1e2f1e57af3c7dcb0ec392ba8dbb5c8d Mon Sep 17 00:00:00 2001 | ||
2 | From: Alex Kiernan <alex.kiernan@gmail.com> | ||
3 | Date: Tue, 10 Mar 2020 11:05:20 +0000 | ||
4 | Subject: [PATCH] Handle missing gshadow | ||
5 | |||
6 | gshadow usage is now present in the userdb code. Mask all uses of it to | ||
7 | allow compilation on musl | ||
8 | |||
9 | Upstream-Status: Inappropriate [musl specific] | ||
10 | Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com> | ||
11 | --- | ||
12 | src/shared/group-record-nss.c | 20 ++++++++++++++++++++ | ||
13 | src/shared/group-record-nss.h | 4 ++++ | ||
14 | src/shared/userdb.c | 6 ++++++ | ||
15 | 3 files changed, 30 insertions(+) | ||
16 | |||
17 | diff --git a/src/shared/group-record-nss.c b/src/shared/group-record-nss.c | ||
18 | index 77924f1c4067..c64490253ff3 100644 | ||
19 | --- a/src/shared/group-record-nss.c | ||
20 | +++ b/src/shared/group-record-nss.c | ||
21 | @@ -19,8 +19,10 @@ int nss_group_to_group_record( | ||
22 | if (isempty(grp->gr_name)) | ||
23 | return -EINVAL; | ||
24 | |||
25 | +#if ENABLE_GSHADOW | ||
26 | if (sgrp && !streq_ptr(sgrp->sg_namp, grp->gr_name)) | ||
27 | return -EINVAL; | ||
28 | +#endif | ||
29 | |||
30 | g = group_record_new(); | ||
31 | if (!g) | ||
32 | @@ -36,6 +38,7 @@ int nss_group_to_group_record( | ||
33 | |||
34 | g->gid = grp->gr_gid; | ||
35 | |||
36 | +#if ENABLE_GSHADOW | ||
37 | if (sgrp) { | ||
38 | if (hashed_password_valid(sgrp->sg_passwd)) { | ||
39 | g->hashed_password = strv_new(sgrp->sg_passwd); | ||
40 | @@ -51,6 +54,7 @@ int nss_group_to_group_record( | ||
41 | if (!g->administrators) | ||
42 | return -ENOMEM; | ||
43 | } | ||
44 | +#endif | ||
45 | |||
46 | r = json_build(&g->json, JSON_BUILD_OBJECT( | ||
47 | JSON_BUILD_PAIR("groupName", JSON_BUILD_STRING(g->group_name)), | ||
48 | @@ -76,6 +80,7 @@ int nss_sgrp_for_group(const struct group *grp, struct sgrp *ret_sgrp, char **re | ||
49 | assert(ret_sgrp); | ||
50 | assert(ret_buffer); | ||
51 | |||
52 | +#if ENABLE_GSHADOW | ||
53 | for (;;) { | ||
54 | _cleanup_free_ char *buf = NULL; | ||
55 | struct sgrp sgrp, *result; | ||
56 | @@ -104,6 +109,9 @@ int nss_sgrp_for_group(const struct group *grp, struct sgrp *ret_sgrp, char **re | ||
57 | buflen *= 2; | ||
58 | buf = mfree(buf); | ||
59 | } | ||
60 | +#else | ||
61 | + return -ESRCH; | ||
62 | +#endif | ||
63 | } | ||
64 | |||
65 | int nss_group_record_by_name(const char *name, GroupRecord **ret) { | ||
66 | @@ -111,7 +119,9 @@ int nss_group_record_by_name(const char *name, GroupRecord **ret) { | ||
67 | struct group grp, *result; | ||
68 | bool incomplete = false; | ||
69 | size_t buflen = 4096; | ||
70 | +#if ENABLE_GSHADOW | ||
71 | struct sgrp sgrp; | ||
72 | +#endif | ||
73 | int r; | ||
74 | |||
75 | assert(name); | ||
76 | @@ -141,6 +151,7 @@ int nss_group_record_by_name(const char *name, GroupRecord **ret) { | ||
77 | buf = mfree(buf); | ||
78 | } | ||
79 | |||
80 | +#if ENABLE_GSHADOW | ||
81 | r = nss_sgrp_for_group(result, &sgrp, &sbuf); | ||
82 | if (r < 0) { | ||
83 | log_debug_errno(r, "Failed to do shadow lookup for group %s, ignoring: %m", result->gr_name); | ||
84 | @@ -148,6 +159,9 @@ int nss_group_record_by_name(const char *name, GroupRecord **ret) { | ||
85 | } | ||
86 | |||
87 | r = nss_group_to_group_record(result, r >= 0 ? &sgrp : NULL, ret); | ||
88 | +#else | ||
89 | + r = nss_group_to_group_record(result, NULL, ret); | ||
90 | +#endif | ||
91 | if (r < 0) | ||
92 | return r; | ||
93 | |||
94 | @@ -160,7 +174,9 @@ int nss_group_record_by_gid(gid_t gid, GroupRecord **ret) { | ||
95 | struct group grp, *result; | ||
96 | bool incomplete = false; | ||
97 | size_t buflen = 4096; | ||
98 | +#if ENABLE_GSHADOW | ||
99 | struct sgrp sgrp; | ||
100 | +#endif | ||
101 | int r; | ||
102 | |||
103 | assert(ret); | ||
104 | @@ -188,6 +204,7 @@ int nss_group_record_by_gid(gid_t gid, GroupRecord **ret) { | ||
105 | buf = mfree(buf); | ||
106 | } | ||
107 | |||
108 | +#if ENABLE_GSHADOW | ||
109 | r = nss_sgrp_for_group(result, &sgrp, &sbuf); | ||
110 | if (r < 0) { | ||
111 | log_debug_errno(r, "Failed to do shadow lookup for group %s, ignoring: %m", result->gr_name); | ||
112 | @@ -195,6 +212,9 @@ int nss_group_record_by_gid(gid_t gid, GroupRecord **ret) { | ||
113 | } | ||
114 | |||
115 | r = nss_group_to_group_record(result, r >= 0 ? &sgrp : NULL, ret); | ||
116 | +#else | ||
117 | + r = nss_group_to_group_record(result, NULL, ret); | ||
118 | +#endif | ||
119 | if (r < 0) | ||
120 | return r; | ||
121 | |||
122 | diff --git a/src/shared/group-record-nss.h b/src/shared/group-record-nss.h | ||
123 | index 38b2995178ff..d7d95c44cf11 100644 | ||
124 | --- a/src/shared/group-record-nss.h | ||
125 | +++ b/src/shared/group-record-nss.h | ||
126 | @@ -2,7 +2,11 @@ | ||
127 | #pragma once | ||
128 | |||
129 | #include <grp.h> | ||
130 | +#if ENABLE_GSHADOW | ||
131 | #include <gshadow.h> | ||
132 | +#else | ||
133 | +struct sgrp; | ||
134 | +#endif | ||
135 | |||
136 | #include "group-record.h" | ||
137 | |||
138 | diff --git a/src/shared/userdb.c b/src/shared/userdb.c | ||
139 | index 92f8796768d7..5d912862f85c 100644 | ||
140 | --- a/src/shared/userdb.c | ||
141 | +++ b/src/shared/userdb.c | ||
142 | @@ -924,13 +924,16 @@ int groupdb_iterator_get(UserDBIterator *iterator, GroupRecord **ret) { | ||
143 | if (gr) { | ||
144 | _cleanup_free_ char *buffer = NULL; | ||
145 | bool incomplete = false; | ||
146 | +#if ENABLE_GSHADOW | ||
147 | struct sgrp sgrp; | ||
148 | +#endif | ||
149 | |||
150 | if (streq_ptr(gr->gr_name, "root")) | ||
151 | iterator->synthesize_root = false; | ||
152 | if (gr->gr_gid == GID_NOBODY) | ||
153 | iterator->synthesize_nobody = false; | ||
154 | |||
155 | +#if ENABLE_GSHADOW | ||
156 | r = nss_sgrp_for_group(gr, &sgrp, &buffer); | ||
157 | if (r < 0) { | ||
158 | log_debug_errno(r, "Failed to acquire shadow entry for group %s, ignoring: %m", gr->gr_name); | ||
159 | @@ -938,6 +941,9 @@ int groupdb_iterator_get(UserDBIterator *iterator, GroupRecord **ret) { | ||
160 | } | ||
161 | |||
162 | r = nss_group_to_group_record(gr, r >= 0 ? &sgrp : NULL, ret); | ||
163 | +#else | ||
164 | + r = nss_group_to_group_record(gr, NULL, ret); | ||
165 | +#endif | ||
166 | if (r < 0) | ||
167 | return r; | ||
168 | |||
169 | -- | ||
170 | 2.17.1 | ||
171 | |||