import ledmon-0.92-7.el8

This commit is contained in:
CentOS Sources 2019-08-02 12:03:36 -04:00 committed by Stepan Oksanichenko
commit 17481908ac
7 changed files with 512 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
SOURCES/ledmon-0.92.tar.gz

1
.ledmon.metadata Normal file
View File

@ -0,0 +1 @@
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

@ -0,0 +1,18 @@
--- 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+=-std=gnu99
-CWFLAGS=-Wall
-CFLAGS=$(CXFLAGS) $(CWFLAGS)
-
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 -lrt
SOURCES:=$(shell find -name "*.[cC]" -print)

167
SPECS/ledmon.spec Normal file
View File

@ -0,0 +1,167 @@
Summary: Enclosure LED Utilities
Name: ledmon
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: 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.
BuildRequires: systemd-devel
Obsoletes: ledctl = 0.1-1
Provides: ledctl = %{version}-%{release}
Requires: sg3_utils-libs
%description
The ledmon and ledctl are user space applications design to control LED
associated with each slot in an enclosure or a drive bay. There are two
types of system: 2-LED system (Activity LED, Status LED) and 3-LED system
(Activity LED, Locate LED, Fail LED). User must have root privileges to
use this application.
%prep
%setup -q
%patch0 -p1 -b .cflags
%patch1 -p1
%patch2 -p1
%patch3 -p1
%build
# can't use smp_flags because -j4 makes the build fail
make CFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_LD_FLAGS"
%install
make install INSTALL="%{__install} -p" DESTDIR=$RPM_BUILD_ROOT SBIN_DIR=$RPM_BUILD_ROOT/%{_sbindir} MANDIR=$RPM_BUILD_ROOT%{_mandir}
%files
%doc README COPYING
%{_sbindir}/ledctl
%{_sbindir}/ledmon
%{_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)
* Tue Aug 7 2018 Jan Synáček <jsynacek@redhat.com> - 0.90-2
- fix manpage generation (#1612711)
* Wed Mar 14 2018 Jan Synáček <jsynacek@redhat.com> - 0.90-1
- update to 0.90 (#1555099)
* Mon Feb 26 2018 Jan Synáček <jsynacek@redhat.com> - 0.80-6
- use distribution LDFLAGS during build (#1548551)
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.80-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.80-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.80-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.80-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Tue Dec 6 2016 Jan Synáček <jsynacek@redhat.com> - 0.80-1
- Update to 0.80 (#1401924)
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.79-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.79-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.79-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.79-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Thu Nov 28 2013 Michal Sekletar <msekleta@redhat.com> - 0.79-1
- update to 0.79
* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.78-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
* Wed Jul 03 2013 Michal Sekletar <msekleta@redhat.com> - 0.78-1
- Update to 0.78
* Fri Apr 19 2013 Jan Synáček <jsynacek@redhat.com> - 0.77-1
- Update to 0.77
- Documentation enhancements
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.75-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
* Mon Jan 07 2013 Jan Synáček <jsynacek@redhat.com> - 0.75-1
- Update to 0.75 and drop upstreamed patch
* Thu Nov 15 2012 Jan Synáček <jsynacek@redhat.com> - 0.74-3
- Some coverity fixes
* Fri Oct 19 2012 Jan Synáček <jsynacek@redhat.com> - 0.74-2
- Require sg3_utils-libs
* Mon Aug 13 2012 Jan Synáček <jsynacek@redhat.com> - 0.74-1
- Update to 0.74
- Resolves: #847072
* Tue Aug 07 2012 Jan Synáček <jsynacek@redhat.com> - 0.72-1
- Update to 0.72 and update patch
- Resolves: #846018
* Wed Jul 25 2012 Jan Synáček <jsynacek@redhat.com> - 0.40-1
- Update to 0.40
- Resolves: #838086
- Make spec fedora-review friendly
* Thu Jul 19 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.32-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
* Mon Mar 05 2012 Jan Synáček <jsynacek@redhat.com> - 0.32-1
- Update to 0.32
* Fri Feb 10 2012 Jan Synáček <jsynacek@redhat.com> - 0.31-1
- Update to 0.31
* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
* Mon Feb 07 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
* Fri Jan 14 2011 Jiri Moskovcak <jmoskovc@redhat.com> 0.1-2
- renamed to ledmon, because ledctl is taken
* Fri Jan 07 2011 Jiri Moskovcak <jmoskovc@redhat.com> 0.1-1
- initial release