diff options
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0026-Handle-missing-gshadow.patch')
-rw-r--r-- | meta/recipes-core/systemd/systemd/0026-Handle-missing-gshadow.patch | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0026-Handle-missing-gshadow.patch b/meta/recipes-core/systemd/systemd/0026-Handle-missing-gshadow.patch new file mode 100644 index 0000000000..4180afb08e --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0026-Handle-missing-gshadow.patch | |||
@@ -0,0 +1,173 @@ | |||
1 | From 47bf88f74717b417e4adbcc04256334b2335c873 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 26/26] 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 | [Rebased for v247] | ||
12 | Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com> | ||
13 | --- | ||
14 | src/shared/user-record-nss.c | 20 ++++++++++++++++++++ | ||
15 | src/shared/user-record-nss.h | 4 ++++ | ||
16 | src/shared/userdb.c | 6 ++++++ | ||
17 | 3 files changed, 30 insertions(+) | ||
18 | |||
19 | diff --git a/src/shared/user-record-nss.c b/src/shared/user-record-nss.c | ||
20 | index 88b8fc2f8f..a819d41bac 100644 | ||
21 | --- a/src/shared/user-record-nss.c | ||
22 | +++ b/src/shared/user-record-nss.c | ||
23 | @@ -331,8 +331,10 @@ int nss_group_to_group_record( | ||
24 | if (isempty(grp->gr_name)) | ||
25 | return -EINVAL; | ||
26 | |||
27 | +#if ENABLE_GSHADOW | ||
28 | if (sgrp && !streq_ptr(sgrp->sg_namp, grp->gr_name)) | ||
29 | return -EINVAL; | ||
30 | +#endif | ||
31 | |||
32 | g = group_record_new(); | ||
33 | if (!g) | ||
34 | @@ -348,6 +350,7 @@ int nss_group_to_group_record( | ||
35 | |||
36 | g->gid = grp->gr_gid; | ||
37 | |||
38 | +#if ENABLE_GSHADOW | ||
39 | if (sgrp) { | ||
40 | if (looks_like_hashed_password(utf8_only(sgrp->sg_passwd))) { | ||
41 | g->hashed_password = strv_new(sgrp->sg_passwd); | ||
42 | @@ -363,6 +366,7 @@ int nss_group_to_group_record( | ||
43 | if (r < 0) | ||
44 | return r; | ||
45 | } | ||
46 | +#endif | ||
47 | |||
48 | r = json_build(&g->json, JSON_BUILD_OBJECT( | ||
49 | JSON_BUILD_PAIR("groupName", JSON_BUILD_STRING(g->group_name)), | ||
50 | @@ -388,6 +392,7 @@ int nss_sgrp_for_group(const struct group *grp, struct sgrp *ret_sgrp, char **re | ||
51 | assert(ret_sgrp); | ||
52 | assert(ret_buffer); | ||
53 | |||
54 | +#if ENABLE_GSHADOW | ||
55 | for (;;) { | ||
56 | _cleanup_free_ char *buf = NULL; | ||
57 | struct sgrp sgrp, *result; | ||
58 | @@ -416,6 +421,9 @@ int nss_sgrp_for_group(const struct group *grp, struct sgrp *ret_sgrp, char **re | ||
59 | buflen *= 2; | ||
60 | buf = mfree(buf); | ||
61 | } | ||
62 | +#else | ||
63 | + return -ESRCH; | ||
64 | +#endif | ||
65 | } | ||
66 | |||
67 | int nss_group_record_by_name( | ||
68 | @@ -427,7 +435,9 @@ int nss_group_record_by_name( | ||
69 | struct group grp, *result; | ||
70 | bool incomplete = false; | ||
71 | size_t buflen = 4096; | ||
72 | +#if ENABLE_GSHADOW | ||
73 | struct sgrp sgrp, *sresult = NULL; | ||
74 | +#endif | ||
75 | int r; | ||
76 | |||
77 | assert(name); | ||
78 | @@ -457,6 +467,7 @@ int nss_group_record_by_name( | ||
79 | buf = mfree(buf); | ||
80 | } | ||
81 | |||
82 | +#if ENABLE_GSHADOW | ||
83 | if (with_shadow) { | ||
84 | r = nss_sgrp_for_group(result, &sgrp, &sbuf); | ||
85 | if (r < 0) { | ||
86 | @@ -468,6 +479,9 @@ int nss_group_record_by_name( | ||
87 | incomplete = true; | ||
88 | |||
89 | r = nss_group_to_group_record(result, sresult, ret); | ||
90 | +#else | ||
91 | + r = nss_group_to_group_record(result, NULL, ret); | ||
92 | +#endif | ||
93 | if (r < 0) | ||
94 | return r; | ||
95 | |||
96 | @@ -484,7 +498,9 @@ int nss_group_record_by_gid( | ||
97 | struct group grp, *result; | ||
98 | bool incomplete = false; | ||
99 | size_t buflen = 4096; | ||
100 | +#if ENABLE_GSHADOW | ||
101 | struct sgrp sgrp, *sresult = NULL; | ||
102 | +#endif | ||
103 | int r; | ||
104 | |||
105 | assert(ret); | ||
106 | @@ -512,6 +528,7 @@ int nss_group_record_by_gid( | ||
107 | buf = mfree(buf); | ||
108 | } | ||
109 | |||
110 | +#if ENABLE_GSHADOW | ||
111 | if (with_shadow) { | ||
112 | r = nss_sgrp_for_group(result, &sgrp, &sbuf); | ||
113 | if (r < 0) { | ||
114 | @@ -523,6 +540,9 @@ int nss_group_record_by_gid( | ||
115 | incomplete = true; | ||
116 | |||
117 | r = nss_group_to_group_record(result, sresult, ret); | ||
118 | +#else | ||
119 | + r = nss_group_to_group_record(result, NULL, ret); | ||
120 | +#endif | ||
121 | if (r < 0) | ||
122 | return r; | ||
123 | |||
124 | diff --git a/src/shared/user-record-nss.h b/src/shared/user-record-nss.h | ||
125 | index 22ab04d6ee..4e52e7a911 100644 | ||
126 | --- a/src/shared/user-record-nss.h | ||
127 | +++ b/src/shared/user-record-nss.h | ||
128 | @@ -2,7 +2,11 @@ | ||
129 | #pragma once | ||
130 | |||
131 | #include <grp.h> | ||
132 | +#if ENABLE_GSHADOW | ||
133 | #include <gshadow.h> | ||
134 | +#else | ||
135 | +struct sgrp; | ||
136 | +#endif | ||
137 | #include <pwd.h> | ||
138 | #include <shadow.h> | ||
139 | |||
140 | diff --git a/src/shared/userdb.c b/src/shared/userdb.c | ||
141 | index 2d480283d1..0d19764f2e 100644 | ||
142 | --- a/src/shared/userdb.c | ||
143 | +++ b/src/shared/userdb.c | ||
144 | @@ -929,13 +929,16 @@ int groupdb_iterator_get(UserDBIterator *iterator, GroupRecord **ret) { | ||
145 | if (gr) { | ||
146 | _cleanup_free_ char *buffer = NULL; | ||
147 | bool incomplete = false; | ||
148 | +#if ENABLE_GSHADOW | ||
149 | struct sgrp sgrp; | ||
150 | +#endif | ||
151 | |||
152 | if (streq_ptr(gr->gr_name, "root")) | ||
153 | iterator->synthesize_root = false; | ||
154 | if (gr->gr_gid == GID_NOBODY) | ||
155 | iterator->synthesize_nobody = false; | ||
156 | |||
157 | +#if ENABLE_GSHADOW | ||
158 | r = nss_sgrp_for_group(gr, &sgrp, &buffer); | ||
159 | if (r < 0) { | ||
160 | log_debug_errno(r, "Failed to acquire shadow entry for group %s, ignoring: %m", gr->gr_name); | ||
161 | @@ -943,6 +946,9 @@ int groupdb_iterator_get(UserDBIterator *iterator, GroupRecord **ret) { | ||
162 | } | ||
163 | |||
164 | r = nss_group_to_group_record(gr, r >= 0 ? &sgrp : NULL, ret); | ||
165 | +#else | ||
166 | + r = nss_group_to_group_record(gr, NULL, ret); | ||
167 | +#endif | ||
168 | if (r < 0) | ||
169 | return r; | ||
170 | |||
171 | -- | ||
172 | 2.27.0 | ||
173 | |||