Gentoo Archives: gentoo-commits

From: Georgy Yakovlev <gyakovlev@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/zfs/, sys-fs/zfs/files/
Date: Fri, 25 Sep 2020 20:28:39
Message-Id: 1601065700.c10c708ba999cd9aa08aae373d4103522ad7d358.gyakovlev@gentoo
1 commit: c10c708ba999cd9aa08aae373d4103522ad7d358
2 Author: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
3 AuthorDate: Fri Sep 25 20:24:26 2020 +0000
4 Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
5 CommitDate: Fri Sep 25 20:28:20 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c10c708b
7
8 sys-fs/zfs: add exports.d patch
9
10 Closes: https://bugs.gentoo.org/742503
11 Package-Manager: Portage-3.0.8, Repoman-3.0.1
12 Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>
13
14 .../files/2.0.0_rc2-exports-d-permissions.patch | 189 +++++++++++++++++++++
15 ...fs-2.0.0_rc2.ebuild => zfs-2.0.0_rc2-r1.ebuild} | 5 +-
16 2 files changed, 193 insertions(+), 1 deletion(-)
17
18 diff --git a/sys-fs/zfs/files/2.0.0_rc2-exports-d-permissions.patch b/sys-fs/zfs/files/2.0.0_rc2-exports-d-permissions.patch
19 new file mode 100644
20 index 00000000000..4acaf465a7b
21 --- /dev/null
22 +++ b/sys-fs/zfs/files/2.0.0_rc2-exports-d-permissions.patch
23 @@ -0,0 +1,189 @@
24 +From fe413a4d901a243d98cfef16ea330f7114a104ea Mon Sep 17 00:00:00 2001
25 +From: George Wilson <george.wilson@×××××××.com>
26 +Date: Tue, 15 Sep 2020 22:57:16 -0400
27 +Subject: [PATCH] zpool command complains about /etc/exports.d
28 +
29 +If the /etc/exports.d directory does not exist, then we should only
30 +create it when we're performing an action which already requires root
31 +privileges.
32 +
33 +This commit moves the directory creation to the enable/disable code
34 +path which ensures that we have the appropriate privileges.
35 +
36 +Signed-off-by: George Wilson <gwilson@×××××××.com>
37 +Closes #10785
38 +---
39 + lib/libshare/os/freebsd/nfs.c | 36 +++++++++++-------
40 + lib/libshare/os/linux/nfs.c | 71 ++++++++++++++++++++---------------
41 + 2 files changed, 64 insertions(+), 43 deletions(-)
42 +
43 +diff --git a/lib/libshare/os/freebsd/nfs.c b/lib/libshare/os/freebsd/nfs.c
44 +index 65f3b11bf9b..5951b9eafa2 100644
45 +--- a/lib/libshare/os/freebsd/nfs.c
46 ++++ b/lib/libshare/os/freebsd/nfs.c
47 +@@ -228,21 +228,33 @@ nfs_copy_entries(char *filename, const char *mountpoint)
48 + int error = SA_OK;
49 + char *line;
50 +
51 +- /*
52 +- * If the file doesn't exist then there is nothing more
53 +- * we need to do.
54 +- */
55 + FILE *oldfp = fopen(ZFS_EXPORTS_FILE, "r");
56 +- if (oldfp == NULL)
57 +- return (SA_OK);
58 +-
59 + FILE *newfp = fopen(filename, "w+");
60 ++ if (newfp == NULL) {
61 ++ fprintf(stderr, "failed to open %s file: %s", filename,
62 ++ strerror(errno));
63 ++ fclose(oldfp);
64 ++ return (SA_SYSTEM_ERR);
65 ++ }
66 + fputs(FILE_HEADER, newfp);
67 +- while ((line = zgetline(oldfp, mountpoint)) != NULL)
68 +- fprintf(newfp, "%s\n", line);
69 +- if (ferror(oldfp) != 0) {
70 +- error = ferror(oldfp);
71 ++
72 ++ /*
73 ++ * The ZFS_EXPORTS_FILE may not exist yet. If that's the
74 ++ * case then just write out the new file.
75 ++ */
76 ++ if (oldfp != NULL) {
77 ++ while ((line = zgetline(oldfp, mountpoint)) != NULL)
78 ++ fprintf(newfp, "%s\n", line);
79 ++ if (ferror(oldfp) != 0) {
80 ++ error = ferror(oldfp);
81 ++ }
82 ++ if (fclose(oldfp) != 0) {
83 ++ fprintf(stderr, "Unable to close file %s: %s\n",
84 ++ filename, strerror(errno));
85 ++ error = error != 0 ? error : SA_SYSTEM_ERR;
86 ++ }
87 + }
88 ++
89 + if (error == 0 && ferror(newfp) != 0) {
90 + error = ferror(newfp);
91 + }
92 +@@ -252,8 +264,6 @@ nfs_copy_entries(char *filename, const char *mountpoint)
93 + filename, strerror(errno));
94 + error = error != 0 ? error : SA_SYSTEM_ERR;
95 + }
96 +- fclose(oldfp);
97 +-
98 + return (error);
99 + }
100 +
101 +diff --git a/lib/libshare/os/linux/nfs.c b/lib/libshare/os/linux/nfs.c
102 +index a6a9b33d765..1efa321b7bc 100644
103 +--- a/lib/libshare/os/linux/nfs.c
104 ++++ b/lib/libshare/os/linux/nfs.c
105 +@@ -393,6 +393,14 @@ static char *
106 + nfs_init_tmpfile(void)
107 + {
108 + char *tmpfile = NULL;
109 ++ struct stat sb;
110 ++
111 ++ if (stat(ZFS_EXPORTS_DIR, &sb) < 0 &&
112 ++ mkdir(ZFS_EXPORTS_DIR, 0755) < 0) {
113 ++ fprintf(stderr, "failed to create %s: %s\n",
114 ++ ZFS_EXPORTS_DIR, strerror(errno));
115 ++ return (NULL);
116 ++ }
117 +
118 + if (asprintf(&tmpfile, "%s%s", ZFS_EXPORTS_FILE, ".XXXXXXXX") == -1) {
119 + fprintf(stderr, "Unable to allocate temporary file\n");
120 +@@ -481,36 +489,49 @@ nfs_copy_entries(char *filename, const char *mountpoint)
121 + size_t buflen = 0;
122 + int error = SA_OK;
123 +
124 +- /*
125 +- * If the file doesn't exist then there is nothing more
126 +- * we need to do.
127 +- */
128 + FILE *oldfp = fopen(ZFS_EXPORTS_FILE, "r");
129 +- if (oldfp == NULL)
130 +- return (SA_OK);
131 +-
132 + FILE *newfp = fopen(filename, "w+");
133 ++ if (newfp == NULL) {
134 ++ fprintf(stderr, "failed to open %s file: %s", filename,
135 ++ strerror(errno));
136 ++ fclose(oldfp);
137 ++ return (SA_SYSTEM_ERR);
138 ++ }
139 + fputs(FILE_HEADER, newfp);
140 +- while ((getline(&buf, &buflen, oldfp)) != -1) {
141 +- char *space = NULL;
142 +
143 +- if (buf[0] == '\n' || buf[0] == '#')
144 +- continue;
145 +-
146 +- if ((space = strchr(buf, ' ')) != NULL) {
147 +- int mountpoint_len = strlen(mountpoint);
148 ++ /*
149 ++ * The ZFS_EXPORTS_FILE may not exist yet. If that's the
150 ++ * case then just write out the new file.
151 ++ */
152 ++ if (oldfp != NULL) {
153 ++ while (getline(&buf, &buflen, oldfp) != -1) {
154 ++ char *space = NULL;
155 +
156 +- if (space - buf == mountpoint_len &&
157 +- strncmp(mountpoint, buf, mountpoint_len) == 0) {
158 ++ if (buf[0] == '\n' || buf[0] == '#')
159 + continue;
160 ++
161 ++ if ((space = strchr(buf, ' ')) != NULL) {
162 ++ int mountpoint_len = strlen(mountpoint);
163 ++
164 ++ if (space - buf == mountpoint_len &&
165 ++ strncmp(mountpoint, buf,
166 ++ mountpoint_len) == 0) {
167 ++ continue;
168 ++ }
169 + }
170 ++ fputs(buf, newfp);
171 + }
172 +- fputs(buf, newfp);
173 +- }
174 +
175 +- if (oldfp != NULL && ferror(oldfp) != 0) {
176 +- error = ferror(oldfp);
177 ++ if (ferror(oldfp) != 0) {
178 ++ error = ferror(oldfp);
179 ++ }
180 ++ if (fclose(oldfp) != 0) {
181 ++ fprintf(stderr, "Unable to close file %s: %s\n",
182 ++ filename, strerror(errno));
183 ++ error = error != 0 ? error : SA_SYSTEM_ERR;
184 ++ }
185 + }
186 ++
187 + if (error == 0 && ferror(newfp) != 0) {
188 + error = ferror(newfp);
189 + }
190 +@@ -521,8 +542,6 @@ nfs_copy_entries(char *filename, const char *mountpoint)
191 + filename, strerror(errno));
192 + error = error != 0 ? error : SA_SYSTEM_ERR;
193 + }
194 +- fclose(oldfp);
195 +-
196 + return (error);
197 + }
198 +
199 +@@ -701,13 +720,5 @@ static const sa_share_ops_t nfs_shareops = {
200 + void
201 + libshare_nfs_init(void)
202 + {
203 +- struct stat sb;
204 +-
205 + nfs_fstype = register_fstype("nfs", &nfs_shareops);
206 +-
207 +- if (stat(ZFS_EXPORTS_DIR, &sb) < 0 &&
208 +- mkdir(ZFS_EXPORTS_DIR, 0755) < 0) {
209 +- fprintf(stderr, "failed to create %s: %s\n",
210 +- ZFS_EXPORTS_DIR, strerror(errno));
211 +- }
212 + }
213
214 diff --git a/sys-fs/zfs/zfs-2.0.0_rc2.ebuild b/sys-fs/zfs/zfs-2.0.0_rc2-r1.ebuild
215 similarity index 98%
216 rename from sys-fs/zfs/zfs-2.0.0_rc2.ebuild
217 rename to sys-fs/zfs/zfs-2.0.0_rc2-r1.ebuild
218 index d2f00419b0c..1f9d81f16e6 100644
219 --- a/sys-fs/zfs/zfs-2.0.0_rc2.ebuild
220 +++ b/sys-fs/zfs/zfs-2.0.0_rc2-r1.ebuild
221 @@ -76,7 +76,10 @@ REQUIRED_USE="
222
223 RESTRICT="test"
224
225 -PATCHES=( "${FILESDIR}/bash-completion-sudo.patch" )
226 +PATCHES=(
227 + "${FILESDIR}/bash-completion-sudo.patch"
228 + "${FILESDIR}/${PV}-exports-d-permissions.patch"
229 +)
230
231 pkg_setup() {
232 if use kernel_linux && use test-suite; then