import ledmon-0.92-7.el8

This commit is contained in:
CentOS Sources 2019-11-05 15:22:38 -05:00 committed by Andrew Lukoshko
parent 2acdb31ca3
commit 2c4d32e884
8 changed files with 360 additions and 44 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/ledmon-0.90.tar.gz
SOURCES/ledmon-0.92.tar.gz

View File

@ -1 +1 @@
2db38c084173806d779e6f5556c795b039d47067 SOURCES/ledmon-0.90.tar.gz
1abf8102caa411baf39e8613080df54f13d8f7db SOURCES/ledmon-0.92.tar.gz

View File

@ -0,0 +1,192 @@
From e44a22e2226a059bb46b06aae47a0f6d1c1284e9 Mon Sep 17 00:00:00 2001
From: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Date: Tue, 7 May 2019 16:13:00 +0200
Subject: [PATCH] fix segfault when a value is missing from ibpi_str[]
Replace all usages of ibpi_str[] with ibpi2str(), which always returns a
valid string.
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
---
src/ibpi.h | 3 ++-
src/ledctl.c | 4 ++--
src/ledmon.c | 10 +++++-----
src/scsi.c | 2 +-
src/smp.c | 8 ++++----
src/sysfs.c | 2 +-
src/utils.c | 18 ++++++++++++++++++
src/utils.h | 4 ++++
9 files changed, 38 insertions(+), 15 deletions(-)
diff --git a/src/ibpi.h b/src/ibpi.h
index 776fba3..109f112 100644
--- a/src/ibpi.h
+++ b/src/ibpi.h
@@ -93,8 +93,9 @@ enum ibpi_pattern {
SES_REQ_DEV_OFF,
SES_REQ_FAULT,
SES_REQ_PRDFAIL,
+ ibpi_pattern_count,
};
-extern const char *ibpi_str[];
+extern const char *ibpi_str[ibpi_pattern_count];
#endif /* _IBPI_H_INCLUDED_ */
diff --git a/src/ledctl.c b/src/ledctl.c
index 2aa1abc..4dada8e 100644
--- a/src/ledctl.c
+++ b/src/ledctl.c
@@ -267,7 +267,7 @@ static void _determine(struct ibpi_state *state)
} else {
log_warning
("IBPI %s: missing block device(s)... pattern ignored.",
- ibpi_str[state->ibpi]);
+ ibpi2str(state->ibpi));
}
}
@@ -458,7 +458,7 @@ static status_t _ibpi_state_add_block(struct ibpi_state *state, char *name)
list_append(&state->block_list, blk1);
else
log_info("%s: %s: device already on the list.",
- ibpi_str[state->ibpi], path);
+ ibpi2str(state->ibpi), path);
return STATUS_SUCCESS;
}
diff --git a/src/ledmon.c b/src/ledmon.c
index 0ea2583..b775e6f 100644
--- a/src/ledmon.c
+++ b/src/ledmon.c
@@ -667,8 +667,8 @@ static void _add_block(struct block_device *block)
if (ibpi != temp->ibpi && ibpi <= IBPI_PATTERN_REMOVED) {
log_info("CHANGE %s: from '%s' to '%s'.",
- temp->sysfs_path, ibpi_str[ibpi],
- ibpi_str[temp->ibpi]);
+ temp->sysfs_path, ibpi2str(ibpi),
+ ibpi2str(temp->ibpi));
}
/* Check if name of the device changed.*/
if (strcmp(temp->sysfs_path, block->sysfs_path)) {
@@ -682,7 +682,7 @@ static void _add_block(struct block_device *block)
temp = block_device_duplicate(block);
if (temp != NULL) {
log_info("NEW %s: state '%s'.", temp->sysfs_path,
- ibpi_str[temp->ibpi]);
+ ibpi2str(temp->ibpi));
list_append(&ledmon_block_list, temp);
}
}
@@ -714,8 +714,8 @@ static void _send_msg(struct block_device *block)
block->ibpi == IBPI_PATTERN_REMOVED) {
if (block->ibpi != IBPI_PATTERN_FAILED_DRIVE) {
log_info("CHANGE %s: from '%s' to '%s'.",
- block->sysfs_path, ibpi_str[block->ibpi],
- ibpi_str[IBPI_PATTERN_FAILED_DRIVE]);
+ block->sysfs_path, ibpi2str(block->ibpi),
+ ibpi2str(IBPI_PATTERN_FAILED_DRIVE));
block->ibpi = IBPI_PATTERN_FAILED_DRIVE;
} else {
char *host = strstr(block->sysfs_path, "host");
diff --git a/src/scsi.c b/src/scsi.c
index 3267076..03b43dd 100644
--- a/src/scsi.c
+++ b/src/scsi.c
@@ -673,7 +673,7 @@ int scsi_ses_write(struct block_device *device, enum ibpi_pattern ibpi)
if (ret) {
log_warning
("Unable to send %s message to %s. Device is missing?",
- ibpi_str[ibpi], strstr(device->sysfs_path, "host"));
+ ibpi2str(ibpi), strstr(device->sysfs_path, "host"));
return ret;
}
diff --git a/src/smp.c b/src/smp.c
index 038fe02..6023b0a 100644
--- a/src/smp.c
+++ b/src/smp.c
@@ -468,16 +468,16 @@ int scsi_smp_fill_buffer(struct block_device *device, enum ibpi_pattern ibpi)
if (c++) {
log_debug
("pattern %s not supported for device (/dev/%s)",
- ibpi_str[ibpi], c);
+ ibpi2str(ibpi), c);
fprintf(stderr,
"%s(): pattern %s not supported for device (/dev/%s)\n",
- __func__, ibpi_str[ibpi], c);
+ __func__, ibpi2str(ibpi), c);
} else {
log_debug("pattern %s not supported for device %s",
- ibpi_str[ibpi], device->sysfs_path);
+ ibpi2str(ibpi), device->sysfs_path);
fprintf(stderr,
"%s(): pattern %s not supported for device\n\t(%s)\n",
- __func__, ibpi_str[ibpi], device->sysfs_path);
+ __func__, ibpi2str(ibpi), device->sysfs_path);
}
__set_errno_and_return(ENOTSUP);
}
diff --git a/src/sysfs.c b/src/sysfs.c
index 694878a..d4622dc 100644
--- a/src/sysfs.c
+++ b/src/sysfs.c
@@ -487,7 +487,7 @@ static void _set_block_state(struct block_device *block, enum ibpi_pattern ibpi)
char *debug_dev = strrchr(block->sysfs_path, '/');
debug_dev = debug_dev ? debug_dev + 1 : block->sysfs_path;
log_debug("(%s): device: %s, state: %s", __func__, debug_dev,
- ibpi_str[ibpi]);
+ ibpi2str(ibpi));
if (block->ibpi < ibpi)
block->ibpi = ibpi;
}
diff --git a/src/utils.c b/src/utils.c
index eb189b1..2920fba 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -616,3 +616,21 @@ status_t set_verbose_level(int log_level)
}
return STATUS_CMDLINE_ERROR;
}
+
+const char *ibpi2str(enum ibpi_pattern ibpi)
+{
+ static char buf[20];
+ const char *ret;
+
+ if (ibpi >= 0 && ibpi < ibpi_pattern_count)
+ ret = ibpi_str[ibpi];
+ else
+ ret = NULL;
+
+ if (!ret) {
+ snprintf(buf, sizeof(buf), "(unknown: %d)", ibpi);
+ ret = buf;
+ }
+
+ return ret;
+}
diff --git a/src/utils.h b/src/utils.h
index 720447a..67a211c 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -27,6 +27,7 @@
#include "list.h"
#include "status.h"
#include "syslog.h"
+#include "ibpi.h"
/**
* Maximum number of bytes in temporary buffer. It is used for local variables.
@@ -354,4 +355,7 @@ void setup_options(struct option **longopt, char **shortopt, int *options,
int options_nr);
int get_option_id(const char *optarg);
status_t set_verbose_level(int log_level);
+
+const char *ibpi2str(enum ibpi_pattern ibpi);
+
#endif /* _UTILS_H_INCLUDED_ */
--
2.20.1

View File

@ -0,0 +1,97 @@
From 7d57e3844af6aec97aef0757c85a4b82e999f199 Mon Sep 17 00:00:00 2001
From: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Date: Wed, 8 May 2019 11:08:36 +0200
Subject: [PATCH] fix the _ledmon_status() function
Remove a wrong strncat() usage and simplify the whole function while at
it. Don't print an exit message when the parent is exiting - it always
exits immediately after fork with status = EXIT_SUCCESS.
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
---
src/ledmon.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/ledmon.c b/src/ledmon.c
index b775e6f..bbe04fc 100644
--- a/src/ledmon.c
+++ b/src/ledmon.c
@@ -178,34 +178,31 @@ static void _ledmon_fini(int __attribute__ ((unused)) status, void *program_name
*
* @param[in] status Status given in the last call to exit()
* function.
- * @param[in] ignore Pointer to placeholder where ignore flag is
- * stored. If flag is set 0 then parent process
- * is exiting, otherwise a child is exiting.
- * This argument must not be NULL pointer.
+ * @param[in] arg Argument passed to on_exit().
*
* @return The function does not return a value.
*/
-static void _ledmon_status(int status, void *ignore)
+static void _ledmon_status(int status, void *arg)
{
- struct log_level_info *lli;
int log_level;
char message[4096];
+ int ignore = *((int *)arg);
- memset(message, 0, 4096);
- if (*((int *)ignore) != 0) {
+ if (ignore)
+ return;
+
+ if (status == STATUS_SUCCESS)
log_level = LOG_LEVEL_INFO;
- } else if (status != STATUS_SUCCESS) {
+ else
log_level = LOG_LEVEL_ERROR;
- snprintf(message, sizeof(message), "parent ");
- } else
- return;
- strncat(message, "exit status is", sizeof(message));
- lli = &log_level_infos[log_level];
+ snprintf(message, sizeof(message), "exit status is %s.",
+ strstatus(status));
+
if (get_log_fd() >= 0)
- _log(log_level, "%s %s.", message, strstatus(status));
+ _log(log_level, message);
else
- syslog(lli->priority, "%s %s.", message, strstatus(status));
+ syslog(log_level_infos[log_level].priority, message);
}
/**
@@ -854,13 +851,14 @@ static void _close_parent_fds(void)
int main(int argc, char *argv[])
{
status_t status = STATUS_SUCCESS;
+ int ignore = 0;
setup_options(&longopt, &shortopt, possible_params,
possible_params_size);
set_invocation_name(argv[0]);
openlog(progname, LOG_PID | LOG_PERROR, LOG_DAEMON);
- if (on_exit(_ledmon_status, &terminate))
+ if (on_exit(_ledmon_status, &ignore))
return STATUS_ONEXIT_ERROR;
if (_cmdline_parse_non_daemonise(argc, argv) != STATUS_SUCCESS)
@@ -900,8 +898,10 @@ int main(int argc, char *argv[])
log_debug("main(): fork() failed (errno=%d).", errno);
exit(EXIT_FAILURE);
}
- if (pid > 0)
+ if (pid > 0) {
+ ignore = 1; /* parent: don't print exit status */
exit(EXIT_SUCCESS);
+ }
pid_t sid = setsid();
--
2.20.1

View File

@ -0,0 +1,36 @@
From d787b0e649df63b89e5d7b597f35caa3712ffeff Mon Sep 17 00:00:00 2001
From: Jan Synacek <jsynacek@redhat.com>
Date: Wed, 22 May 2019 14:38:37 +0200
Subject: [PATCH] use proper format string with syslog()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fixes the following:
$ CFLAGS="-Wall -Werror=format-security" make
...
ledmon.c: In function _ledmon_status:
ledmon.c:205:47: error: format not a string literal and no format arguments [-Werror=format-security]
syslog(log_level_infos[log_level].priority, message);
^~~~~~~
---
src/ledmon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ledmon.c b/src/ledmon.c
index bbe04fc..677af7f 100644
--- a/src/ledmon.c
+++ b/src/ledmon.c
@@ -202,7 +202,7 @@ static void _ledmon_status(int status, void *arg)
if (get_log_fd() >= 0)
_log(log_level, message);
else
- syslog(log_level_infos[log_level].priority, message);
+ syslog(log_level_infos[log_level].priority, "%s", message);
}
/**
--
2.20.1

View File

@ -1,34 +0,0 @@
commit c57e7d6d2dabe9e9d17d2e3aa4a2e77f7dc70acd
Author: Michal Zylowski <michal.zylowski@intel.com>
Date: Tue Mar 27 20:27:19 2018 +0200
Recognize RAID volume under reshape as DEVICE_TYPE_VOLUME
Ledmon detects RAID device type by parsing value of sysfs file
"metadata_version" (/sys/block/mdXXX/md/metadata_version). When IMSM
RAID volume is under reshape, metadata_version file has value
"external:-md127/0". In current ledmon version this md device will be
wrongly recognized as container.
Recognize volumes under reshape as DEVICE_TYPE_VOLUME not
DEVICE_TYPE_CONTAINER.
This patch also fixes problem with blinking during reshape on some
environments.
Signed-off-by: Michal Zylowski <michal.zylowski@intel.com>
Resolves: #1669232
diff --git a/src/sysfs.c b/src/sysfs.c
index 1a18a8b..f42be09 100644
--- a/src/sysfs.c
+++ b/src/sysfs.c
@@ -125,7 +125,7 @@ static enum device_type _get_device_type(const char *path)
if (p != NULL) {
if (strlen(p) > 0) {
if (strncmp(p, "external:", 9) == 0) {
- if (p[9] == '/')
+ if (p[9] == '/' || p[9] == '-')
result = DEVICE_TYPE_VOLUME;
else
result = DEVICE_TYPE_CONTAINER;

View File

@ -1,18 +1,18 @@
--- ledmon-0.90/src/Makefile 2018-02-14 12:26:04.000000000 +0100
+++ ledmon-0.90-new/src/Makefile 2018-03-14 09:45:12.887450849 +0100
--- ledmon-0.92/src/Makefile 2019-04-12 11:49:04.000000000 +0200
+++ ledmon-0.92-new/src/Makefile 2019-04-15 11:34:45.842774001 +0200
@@ -64,15 +64,10 @@ TEST_CONFIG_OBJECTS=\
$(OUTDIR)/list.o \
$(OUTDIR)/utils.o
-CXFLAGS=-O0 -g -std=gnu99
-CXFLAGS+=-std=gnu99
-CWFLAGS=-Wall
-CFLAGS=$(CXFLAGS) $(CWFLAGS)
-
DEFFLAGS=-D_DEBUG -D_GNU_SOURCE -D_DEFAULT_SOURCE -DDMALLOC_DISABLE
DEFFLAGS=-D_DEBUG -D_GNU_SOURCE -D_DEFAULT_SOURCE -DDMALLOC_DISABLE -DBUILD_LABEL=\""$(BUILD_LABEL)"\"
CPPFLAGS=$(DEFFLAGS)
ALL_CPPFLAGS=$(CPPFLAGS) -I../config
-LDFLAGS=$(CXFLAGS)
LDLIBS=-lsgutils2 -ludev
LDLIBS=-lsgutils2 -ludev -lrt
SOURCES:=$(shell find -name "*.[cC]" -print)

View File

@ -1,14 +1,16 @@
Summary: Enclosure LED Utilities
Name: ledmon
Version: 0.90
Release: 3%{?dist}
Version: 0.92
Release: 7%{?dist}
License: GPLv2+
Group: Applications/System
URL: https://github.com/intel/ledmon
Source0: https://github.com/intel/ledmon/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Patch0: ledmon_cflags.patch
Patch1: ledmon-raid-led.patch
Patch1: 0001-fix-segfault-when-a-value-is-missing-from-ibpi_str.patch
Patch2: 0002-fix-the-_ledmon_status-function.patch
Patch3: 0003-use-proper-format-string-with-syslog.patch
BuildRequires: perl-interpreter perl-podlators
BuildRequires: sg3_utils-devel
# Needed for the udev dependency.
@ -28,6 +30,8 @@ use this application.
%setup -q
%patch0 -p1 -b .cflags
%patch1 -p1
%patch2 -p1
%patch3 -p1
%build
# can't use smp_flags because -j4 makes the build fail
@ -43,6 +47,27 @@ make install INSTALL="%{__install} -p" DESTDIR=$RPM_BUILD_ROOT SBIN_DIR=$RPM_BUI
%{_mandir}/*/*
%changelog
* Tue Jun 4 2019 Jan Synáček <jsynacek@redhat.com> - 0.92-7
- tests: fix tests (#1681030)
* Tue Jun 4 2019 Jan Synáček <jsynacek@redhat.com> - 0.92-6
- tests: fix tests (#1681030)
* Mon Jun 3 2019 Jan Synáček <jsynacek@redhat.com> - 0.92-5
- tests: skip tests on unsupported devices (#1681030)
* Mon May 27 2019 Jan Synáček <jsynacek@redhat.com> - 0.92-4
- fix the _ledmon_status() function (#1681030)
* Mon May 20 2019 Jan Synáček <jsynacek@redhat.com> - 0.92-3
- tests: fix segfault when a value is missing from ibpi_str[] (#1681030)
* Mon May 6 2019 Jan Synáček <jsynacek@redhat.com> - 0.92-2
- tests: add PURPOSE target (#1681030)
* Mon Apr 15 2019 Jan Synáček <jsynacek@redhat.com> - 0.92-1
- update to 0.92 (#1661204)
* Fri Feb 15 2019 Jan Synáček <jsynacek@redhat.com> - 0.90-3
- LEDs do not work properly during migration (#1669232)