From: "Georgy Yakovlev" <gyakovlev@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/zfs/, sys-fs/zfs/files/
Date: Fri, 25 Sep 2020 20:28:35 +0000 (UTC) [thread overview]
Message-ID: <1601065700.c10c708ba999cd9aa08aae373d4103522ad7d358.gyakovlev@gentoo> (raw)
commit: c10c708ba999cd9aa08aae373d4103522ad7d358
Author: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 25 20:24:26 2020 +0000
Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
CommitDate: Fri Sep 25 20:28:20 2020 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c10c708b
sys-fs/zfs: add exports.d patch
Closes: https://bugs.gentoo.org/742503
Package-Manager: Portage-3.0.8, Repoman-3.0.1
Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>
.../files/2.0.0_rc2-exports-d-permissions.patch | 189 +++++++++++++++++++++
...fs-2.0.0_rc2.ebuild => zfs-2.0.0_rc2-r1.ebuild} | 5 +-
2 files changed, 193 insertions(+), 1 deletion(-)
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
new file mode 100644
index 00000000000..4acaf465a7b
--- /dev/null
+++ b/sys-fs/zfs/files/2.0.0_rc2-exports-d-permissions.patch
@@ -0,0 +1,189 @@
+From fe413a4d901a243d98cfef16ea330f7114a104ea Mon Sep 17 00:00:00 2001
+From: George Wilson <george.wilson@delphix.com>
+Date: Tue, 15 Sep 2020 22:57:16 -0400
+Subject: [PATCH] zpool command complains about /etc/exports.d
+
+If the /etc/exports.d directory does not exist, then we should only
+create it when we're performing an action which already requires root
+privileges.
+
+This commit moves the directory creation to the enable/disable code
+path which ensures that we have the appropriate privileges.
+
+Signed-off-by: George Wilson <gwilson@delphix.com>
+Closes #10785
+---
+ lib/libshare/os/freebsd/nfs.c | 36 +++++++++++-------
+ lib/libshare/os/linux/nfs.c | 71 ++++++++++++++++++++---------------
+ 2 files changed, 64 insertions(+), 43 deletions(-)
+
+diff --git a/lib/libshare/os/freebsd/nfs.c b/lib/libshare/os/freebsd/nfs.c
+index 65f3b11bf9b..5951b9eafa2 100644
+--- a/lib/libshare/os/freebsd/nfs.c
++++ b/lib/libshare/os/freebsd/nfs.c
+@@ -228,21 +228,33 @@ nfs_copy_entries(char *filename, const char *mountpoint)
+ int error = SA_OK;
+ char *line;
+
+- /*
+- * If the file doesn't exist then there is nothing more
+- * we need to do.
+- */
+ FILE *oldfp = fopen(ZFS_EXPORTS_FILE, "r");
+- if (oldfp == NULL)
+- return (SA_OK);
+-
+ FILE *newfp = fopen(filename, "w+");
++ if (newfp == NULL) {
++ fprintf(stderr, "failed to open %s file: %s", filename,
++ strerror(errno));
++ fclose(oldfp);
++ return (SA_SYSTEM_ERR);
++ }
+ fputs(FILE_HEADER, newfp);
+- while ((line = zgetline(oldfp, mountpoint)) != NULL)
+- fprintf(newfp, "%s\n", line);
+- if (ferror(oldfp) != 0) {
+- error = ferror(oldfp);
++
++ /*
++ * The ZFS_EXPORTS_FILE may not exist yet. If that's the
++ * case then just write out the new file.
++ */
++ if (oldfp != NULL) {
++ while ((line = zgetline(oldfp, mountpoint)) != NULL)
++ fprintf(newfp, "%s\n", line);
++ if (ferror(oldfp) != 0) {
++ error = ferror(oldfp);
++ }
++ if (fclose(oldfp) != 0) {
++ fprintf(stderr, "Unable to close file %s: %s\n",
++ filename, strerror(errno));
++ error = error != 0 ? error : SA_SYSTEM_ERR;
++ }
+ }
++
+ if (error == 0 && ferror(newfp) != 0) {
+ error = ferror(newfp);
+ }
+@@ -252,8 +264,6 @@ nfs_copy_entries(char *filename, const char *mountpoint)
+ filename, strerror(errno));
+ error = error != 0 ? error : SA_SYSTEM_ERR;
+ }
+- fclose(oldfp);
+-
+ return (error);
+ }
+
+diff --git a/lib/libshare/os/linux/nfs.c b/lib/libshare/os/linux/nfs.c
+index a6a9b33d765..1efa321b7bc 100644
+--- a/lib/libshare/os/linux/nfs.c
++++ b/lib/libshare/os/linux/nfs.c
+@@ -393,6 +393,14 @@ static char *
+ nfs_init_tmpfile(void)
+ {
+ char *tmpfile = NULL;
++ struct stat sb;
++
++ if (stat(ZFS_EXPORTS_DIR, &sb) < 0 &&
++ mkdir(ZFS_EXPORTS_DIR, 0755) < 0) {
++ fprintf(stderr, "failed to create %s: %s\n",
++ ZFS_EXPORTS_DIR, strerror(errno));
++ return (NULL);
++ }
+
+ if (asprintf(&tmpfile, "%s%s", ZFS_EXPORTS_FILE, ".XXXXXXXX") == -1) {
+ fprintf(stderr, "Unable to allocate temporary file\n");
+@@ -481,36 +489,49 @@ nfs_copy_entries(char *filename, const char *mountpoint)
+ size_t buflen = 0;
+ int error = SA_OK;
+
+- /*
+- * If the file doesn't exist then there is nothing more
+- * we need to do.
+- */
+ FILE *oldfp = fopen(ZFS_EXPORTS_FILE, "r");
+- if (oldfp == NULL)
+- return (SA_OK);
+-
+ FILE *newfp = fopen(filename, "w+");
++ if (newfp == NULL) {
++ fprintf(stderr, "failed to open %s file: %s", filename,
++ strerror(errno));
++ fclose(oldfp);
++ return (SA_SYSTEM_ERR);
++ }
+ fputs(FILE_HEADER, newfp);
+- while ((getline(&buf, &buflen, oldfp)) != -1) {
+- char *space = NULL;
+
+- if (buf[0] == '\n' || buf[0] == '#')
+- continue;
+-
+- if ((space = strchr(buf, ' ')) != NULL) {
+- int mountpoint_len = strlen(mountpoint);
++ /*
++ * The ZFS_EXPORTS_FILE may not exist yet. If that's the
++ * case then just write out the new file.
++ */
++ if (oldfp != NULL) {
++ while (getline(&buf, &buflen, oldfp) != -1) {
++ char *space = NULL;
+
+- if (space - buf == mountpoint_len &&
+- strncmp(mountpoint, buf, mountpoint_len) == 0) {
++ if (buf[0] == '\n' || buf[0] == '#')
+ continue;
++
++ if ((space = strchr(buf, ' ')) != NULL) {
++ int mountpoint_len = strlen(mountpoint);
++
++ if (space - buf == mountpoint_len &&
++ strncmp(mountpoint, buf,
++ mountpoint_len) == 0) {
++ continue;
++ }
+ }
++ fputs(buf, newfp);
+ }
+- fputs(buf, newfp);
+- }
+
+- if (oldfp != NULL && ferror(oldfp) != 0) {
+- error = ferror(oldfp);
++ if (ferror(oldfp) != 0) {
++ error = ferror(oldfp);
++ }
++ if (fclose(oldfp) != 0) {
++ fprintf(stderr, "Unable to close file %s: %s\n",
++ filename, strerror(errno));
++ error = error != 0 ? error : SA_SYSTEM_ERR;
++ }
+ }
++
+ if (error == 0 && ferror(newfp) != 0) {
+ error = ferror(newfp);
+ }
+@@ -521,8 +542,6 @@ nfs_copy_entries(char *filename, const char *mountpoint)
+ filename, strerror(errno));
+ error = error != 0 ? error : SA_SYSTEM_ERR;
+ }
+- fclose(oldfp);
+-
+ return (error);
+ }
+
+@@ -701,13 +720,5 @@ static const sa_share_ops_t nfs_shareops = {
+ void
+ libshare_nfs_init(void)
+ {
+- struct stat sb;
+-
+ nfs_fstype = register_fstype("nfs", &nfs_shareops);
+-
+- if (stat(ZFS_EXPORTS_DIR, &sb) < 0 &&
+- mkdir(ZFS_EXPORTS_DIR, 0755) < 0) {
+- fprintf(stderr, "failed to create %s: %s\n",
+- ZFS_EXPORTS_DIR, strerror(errno));
+- }
+ }
diff --git a/sys-fs/zfs/zfs-2.0.0_rc2.ebuild b/sys-fs/zfs/zfs-2.0.0_rc2-r1.ebuild
similarity index 98%
rename from sys-fs/zfs/zfs-2.0.0_rc2.ebuild
rename to sys-fs/zfs/zfs-2.0.0_rc2-r1.ebuild
index d2f00419b0c..1f9d81f16e6 100644
--- a/sys-fs/zfs/zfs-2.0.0_rc2.ebuild
+++ b/sys-fs/zfs/zfs-2.0.0_rc2-r1.ebuild
@@ -76,7 +76,10 @@ REQUIRED_USE="
RESTRICT="test"
-PATCHES=( "${FILESDIR}/bash-completion-sudo.patch" )
+PATCHES=(
+ "${FILESDIR}/bash-completion-sudo.patch"
+ "${FILESDIR}/${PV}-exports-d-permissions.patch"
+)
pkg_setup() {
if use kernel_linux && use test-suite; then
next reply other threads:[~2020-09-25 20:28 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-25 20:28 Georgy Yakovlev [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-02-23 6:33 [gentoo-commits] repo/gentoo:master commit in: sys-fs/zfs/, sys-fs/zfs/files/ Sam James
2023-12-16 10:06 Sam James
2023-07-03 21:03 Sam James
2022-12-25 0:24 Georgy Yakovlev
2022-12-08 19:48 Georgy Yakovlev
2022-10-04 5:07 Sam James
2022-09-17 22:16 Georgy Yakovlev
2022-09-16 23:09 Georgy Yakovlev
2022-07-01 7:34 Sam James
2022-06-07 18:56 Georgy Yakovlev
2021-12-26 22:35 Georgy Yakovlev
2021-12-23 22:28 Georgy Yakovlev
2021-12-16 2:51 Georgy Yakovlev
2021-11-07 23:59 Georgy Yakovlev
2021-06-04 2:14 Georgy Yakovlev
2020-11-03 20:07 Georgy Yakovlev
2020-05-26 23:58 Georgy Yakovlev
2019-11-26 20:32 Georgy Yakovlev
2019-09-27 19:16 Georgy Yakovlev
2019-03-31 3:53 Georgy Yakovlev
2018-02-14 20:39 Matt Thode
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1601065700.c10c708ba999cd9aa08aae373d4103522ad7d358.gyakovlev@gentoo \
--to=gyakovlev@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox