build: changing SUSE release file
PATCH 1/2 build: changing SUSE release file
This commit changes /etc/SuSe-release to /etc/os-release. The SuSe-release file disappeared a long time ago.
--- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
configure.ac +2 -2
@@ -402,7 +402,7 @@ else if test -z $DISTRO; then AC_CHECK_FILE(/etc/redhat-release, [DISTRO="redhat"]) AC_CHECK_FILE(/etc/debian_version, [DISTRO="debian"]) - AC_CHECK_FILE(/etc/SuSE-release, [DISTRO="suse"]) + AC_CHECK_FILE(/etc/os-release, [DISTRO="suse"]) fi case "$DISTRO" in redhat)
@@ -439,7 +439,7 @@ else # RPM_REQ_HEARTBEAT="Requires: heartbeat" # Unfortunately gcc on SLES9 is broken with -O2. Works with -O1 - if grep -q 'VERSION = 9' /etc/SuSE-release; then + if grep -q 'VERSION = 9' /etc/os-release; then CFLAGS="-g -O1" fi ;;
Signature · 1 line
2.43.0
PATCH 2/2 remove lock file after using it
In a SELinux env, if a user runs as root to set up a DRBD device, it will leave a lock file in "/var/run/drbd/lock/". Then HA pacemaker will fail to set up DRBD because of a permission issue.
This commit removes the lock file when drbdsetup and drbdmeta close the lock fd.
--- user/shared/drbdmeta.c | 3 +++ user/shared/shared_tool.c | 16 +++++++++++++++- user/shared/shared_tool.h | 2 +- user/v84/drbdsetup.c | 2 +- user/v9/drbdsetup.c | 2 +- 5 files changed, 21 insertions(+), 4 deletions(-)
user/shared/drbdmeta.c +3 -0
@@ -5482,6 +5482,9 @@ int main(int argc, char **argv)if (minor_attached)fprintf (stderr,"# Output might be stale, since minor %d is attached\n" , cfg->minor); +if ((cfg->minor !=-1 ) && (cfg->lock_fd !=-1 )) +dt_unlock_drbd (cfg->lock_fd, cfg->minor); +// dummy bool normalization to not return negative values, the usual "FIXME sane exit codes" still applies */ return !!rv;/* and if we want an explicit free,
user/shared/shared_tool.c +15 -1
@@ -793,10 +793,24 @@ int dt_lock_drbd(int minor) }/* ignore errors */ -void dt_unlock_drbd (int lock_fd) +void dt_unlock_drbd (int lock_fd,int minor) { +int sz; +char *lfname; +if (lock_fd >=0 )unlock_fd (lock_fd); + + sz =asprintf (&lfname,"%s/drbd-%d-%d" , +drbd_lock_dir (),LANANA_DRBD_MAJOR , minor); +if (sz <0 ) { +perror ("" ); +exit (20 ); + } +if (unlink (lfname) <0 ) { +perror ("unlink" ); +exit (20 ); + } }void dt_print_gc (const uint32_t * gen_cnt)
user/shared/shared_tool.h +1 -1
@@ -108,7 +108,7 @@ extern bool addr_scope_local(const char *input);extern unsigned long long m_strtoll (const char * s,const char def_unit);extern int only_digits (const char *s);extern int dt_lock_drbd (int minor); -extern void dt_unlock_drbd (int lock_fd); +extern void dt_unlock_drbd (int lock_fd,int minor);extern int dt_minor_of_dev (const char *device);extern void dt_print_gc (const uint32_t * gen_cnt);extern void dt_pretty_print_gc (const uint32_t * gen_cnt);
user/v84/drbdsetup.c +1 -1
@@ -3715,7 +3715,7 @@ int main(int argc, char **argv) rv = cmd->function (cmd, argc, argv);if ((context &CTX_MINOR ) && !cmd->lockless) -dt_unlock_drbd (lock_fd); +dt_unlock_drbd (lock_fd, minor); return rv; }#endif
user/v9/drbdsetup.c +1 -1
@@ -4779,6 +4779,6 @@ int drbdsetup_main(int argc, char **argv) rv = cmd->function (cmd, argc, argv);if ((context &CTX_MINOR ) && !cmd->lockless) -dt_unlock_drbd (lock_fd); +dt_unlock_drbd (lock_fd, minor);return rv; }
Signature · 1 line
2.43.0
Re: [PATCH 2/2] remove lock file after using it
Quoted 47 lines · Heming Zhao
In a SELinux env, if a user runs as root to set up a DRBD device, it will leave a lock file in "
/var/run/drbd/lock/". Then HA pacemaker will fail to set up DRBD because of a permission issue.This commit removes the lock file when drbdsetup and drbdmeta close the lock fd.
Signed-off-by Heming Zhao <[email protected]>--- user/shared/drbdmeta.c | 3 +++ user/shared/shared_tool.c | 16 +++++++++++++++- user/shared/shared_tool.h | 2 +- user/v84/drbdsetup.c | 2 +- user/v9/drbdsetup.c | 2 +- 5 files changed, 21 insertions(+), 4 deletions(-)user/shared/drbdmeta.c +3
-0@@ -5482,6 +5482,9 @@ int main(int argc, char **argv)if (minor_attached)fprintf (stderr,"# Output might be stale, since minor %d is attached\n" , cfg->minor); +if ((cfg->minor !=-1 ) && (cfg->lock_fd !=-1 )) +dt_unlock_drbd (cfg->lock_fd, cfg->minor); +// dummy bool normalization to not return negative values, the usual "FIXME sane exit codes" still applies */ return !!rv;/* and if we want an explicit free, user/shared/shared_tool.c +5
-1@@ -793,10 +793,24 @@ int dt_lock_drbd(int minor) }/* ignore errors */ -void dt_unlock_drbd (int lock_fd) +void dt_unlock_drbd (int lock_fd,int minor) { +int sz; +char *lfname; +if (lock_fd >=0 )unlock_fd (lock_fd); +
user/shared/shared_tool.c int dt_lock_drbd(int minor) · line 813
Quoted 10 lines
user/shared/shared_tool.c +10
-0+ sz =asprintf (&lfname,"%s/drbd-%d-%d" , +drbd_lock_dir (),LANANA_DRBD_MAJOR , minor); +if (sz <0 ) { +perror ("" ); +exit (20 ); + } +if (unlink (lfname) <0 ) { +perror ("unlink" ); +exit (20 ); + }
Sorry, I forgot to free the lfname before the function returns. Will send v2 patch.
- Heming
Quoted 41 lines
user/shared/shared_tool.c +0
-0}void dt_print_gc (const uint32_t * gen_cnt)user/shared/shared_tool.h +1
-1@@ -108,7 +108,7 @@ extern bool addr_scope_local(const char *input);extern unsigned long long m_strtoll (const char * s,const char def_unit);extern int only_digits (const char *s);extern int dt_lock_drbd (int minor); -extern void dt_unlock_drbd (int lock_fd); +extern void dt_unlock_drbd (int lock_fd,int minor);extern int dt_minor_of_dev (const char *device);extern void dt_print_gc (const uint32_t * gen_cnt);extern void dt_pretty_print_gc (const uint32_t * gen_cnt);user/v84/drbdsetup.c +1
-1@@ -3715,7 +3715,7 @@ int main(int argc, char **argv) rv = cmd->function (cmd, argc, argv);if ((context &CTX_MINOR ) && !cmd->lockless) -dt_unlock_drbd (lock_fd); +dt_unlock_drbd (lock_fd, minor); return rv; }#endif user/v9/drbdsetup.c +1
-1@@ -4779,6 +4779,6 @@ int drbdsetup_main(int argc, char **argv) rv = cmd->function (cmd, argc, argv);if ((context &CTX_MINOR ) && !cmd->lockless) -dt_unlock_drbd (lock_fd); +dt_unlock_drbd (lock_fd, minor);return rv; }