Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12:Update
apcupsd
apcupsd-3.14.1-cloexec.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File apcupsd-3.14.1-cloexec.patch of Package apcupsd
--- apcupsd-3.14.11.orig/src/apcnis.c +++ apcupsd-3.14.11/src/apcnis.c @@ -155,6 +155,9 @@ void do_server(UPSINFO *ups) sleep(5 * 60); } + /* Close the socket on exec - avoid leaked file descriptors */ + fcntl(sockfd, F_SETFD, FD_CLOEXEC); + /* Reuse old sockets */ #ifndef HAVE_MINGW if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (void*)&turnon, sizeof(turnon)) < 0) { --- apcupsd-3.14.11.orig/src/apcupsd.c +++ apcupsd-3.14.11/src/apcupsd.c @@ -272,6 +272,9 @@ int main(int argc, char *argv[]) if (ups->event_fd < 0) { log_event(ups, LOG_WARNING, "Could not open events file %s: %s\n", ups->eventfile, strerror(errno)); + } else { + /* Close the file on exec - avoid leaked file descriptors */ + fcntl(ups->event_fd, F_SETFD, FD_CLOEXEC); } } --- apcupsd-3.14.11.orig/src/drivers/usb/linux/linux-usb.c +++ apcupsd-3.14.11/src/drivers/usb/linux/linux-usb.c @@ -164,8 +164,11 @@ int LinuxUsbUpsDriver::open_usb_device() /* Retry 10 times */ for (i = 0; i < 10; i++) { _fd = open_device(_ups->device); - if (_fd != -1) + if (_fd != -1) { + /* Close the device on exec - avoid leaked file descriptors */ + fcntl(_fd, F_SETFD, FD_CLOEXEC); return 1; + } sleep(1); } @@ -188,6 +191,8 @@ auto_detect: asnprintf(devname, sizeof(devname), "%s%d", hiddev[j], k); _fd = open_device(devname); if (_fd != -1) { + /* Close the device on exec - avoid leaked file descriptors */ + fcntl(_fd, F_SETFD, FD_CLOEXEC); /* Successful open, save device name and return */ astrncpy(_ups->device, devname, sizeof(_ups->device)); return 1;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor