master - deamonize: restore detection of errors
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d19084af2565b1cbfe9...
Commit: d19084af2565b1cbfe990835aca73c6709a1a034
Parent: 3071837e21fae8907c1d584f9181e0589b9ce7e2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 4 14:09:58 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Sep 6 11:19:38 2017 +0200
deamonize: restore detection of errors
Keep forked environment for daemon more strick and check even
for nearly impossible to happen errors.
---
daemons/clvmd/clvmd.c | 16 +++++++++++-----
libdaemon/server/daemon-server.c | 19 +++++++++++++------
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index 46f5f44..9dbda89 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -1111,12 +1111,18 @@ static void be_daemon(int timeout)
}
/* Detach ourself from the calling environment */
- (void) dup2(devnull, STDIN_FILENO);
- (void) dup2(devnull, STDOUT_FILENO);
- (void) dup2(devnull, STDERR_FILENO);
+ if ((dup2(devnull, STDIN_FILENO) == -1) ||
+ (dup2(devnull, STDOUT_FILENO) == -1) ||
+ (dup2(devnull, STDERR_FILENO) == -1)) {
+ perror("Error setting terminal FDs to /dev/null");
+ log_error("Error setting terminal FDs to /dev/null: %m");
+ exit(5);
+ }
- if (devnull > STDERR_FILENO)
- (void) close(devnull);
+ if ((devnull > STDERR_FILENO) && close(devnull)) {
+ log_sys_error("close", "/dev/null");
+ exit(7);
+ }
if (chdir("/")) {
log_error("Error setting current directory to /: %m");
diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c
index 0950c2e..0b32931 100644
--- a/libdaemon/server/daemon-server.c
+++ b/libdaemon/server/daemon-server.c
@@ -377,15 +377,22 @@ static void _daemonise(daemon_state s)
exit(WEXITSTATUS(child_status));
}
- if (chdir("/"))
+ if (chdir("/")) {
+ perror("chdir", "/");
exit(1);
+ }
- (void) dup2(fd, STDIN_FILENO);
- (void) dup2(fd, STDOUT_FILENO);
- (void) dup2(fd, STDERR_FILENO);
+ if ((dup2(fd, STDIN_FILENO) == -1) ||
+ (dup2(fd, STDOUT_FILENO) == -1) ||
+ (dup2(fd, STDERR_FILENO) == -1)) {
+ perror("Error setting terminal FDs to /dev/null");
+ exit(2);
+ }
- if (fd > STDERR_FILENO)
- (void) close(fd);
+ if ((fd > STDERR_FILENO) && close(fd)) {
+ perror("Failed to close /dev/null descriptor");
+ exit(3);
+ }
/* Switch to sysconf(_SC_OPEN_MAX) ?? */
if (getrlimit(RLIMIT_NOFILE, &rlim) < 0)
6 years, 8 months
master - lvmlockd: always disallow mirror splitting
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3071837e21fae8907c1...
Commit: 3071837e21fae8907c1d584f9181e0589b9ce7e2
Parent: 09c792c20667aa8d7fb2799e484d913a5eb8a147
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Sep 5 10:26:58 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Sep 5 10:28:33 2017 -0500
lvmlockd: always disallow mirror splitting
lv_raid_split() was correctly prevented in a shared VG,
but lv_raid_split_and_track() was missing that check.
---
WHATS_NEW | 1 +
lib/metadata/raid_manip.c | 6 ++++++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 32bbc41..e6cc18d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.174 -
=================================
+ Prevent raid1 split with trackchanges in a shared VG.
Avoid double unlocking of client & lockspace mutexes in lvmlockd.
Fix leaking of file descriptor for non-blocking filebased locking.
Fix check for 2nd mda at end of disk fits if using pvcreate --restorefile.
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 0432928..72223ca 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -3426,6 +3426,12 @@ int lv_raid_split_and_track(struct logical_volume *lv,
int s;
struct lv_segment *seg = first_seg(lv);
+ if (is_lockd_type(lv->vg->lock_type)) {
+ log_error("Splitting raid image is not allowed with lock_type %s.",
+ lv->vg->lock_type);
+ return 0;
+ }
+
if (!seg_is_mirrored(seg)) {
log_error("Unable to split images from non-mirrored RAID.");
return 0;
6 years, 8 months