|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
--- nut-2.7.4/common/parseconf.c.cloexec 2018-12-07 15:56:22.989381441 -0800
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+++ nut-2.7.4/common/parseconf.c 2018-12-07 16:48:33.912337591 -0800
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
@@ -83,6 +83,7 @@
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
#include <stdlib.h>
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
#include <string.h>
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
#include <unistd.h>
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+#include <fcntl.h>
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
#include "parseconf.h"
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
@@ -443,6 +444,9 @@
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
return 0;
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
}
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+ /* prevent fd leaking to child processes */
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+ fcntl(fileno(ctx->f), F_SETFD, FD_CLOEXEC);
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
return 1; /* OK */
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
}
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
--- nut-2.7.4/clients/upsmon.c.cloexec 2018-12-07 16:22:42.185376803 -0800
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+++ nut-2.7.4/clients/upsmon.c 2018-12-07 17:18:44.662093479 -0800
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
@@ -24,6 +24,8 @@
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
#include <sys/stat.h>
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
#include <sys/wait.h>
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
#include <sys/socket.h>
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+#include <unistd.h>
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+#include <fcntl.h>
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
#include "upsclient.h"
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
#include "upsmon.h"
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
@@ -1432,6 +1434,9 @@
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
/* we're definitely connected now */
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
setflag(&ups->status, ST_CONNECTED);
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+ /* prevent connection leaking to NOTIFYCMD */
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+ fcntl(upscli_fd(&ups->conn), F_SETFD, FD_CLOEXEC);
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
/* now try to authenticate to upsd */
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
ret = do_upsd_auth(ups);
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
@@ -1715,6 +1720,9 @@
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
}
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
close(pipefd[0]);
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+ /* prevent pipe leaking to NOTIFYCMD */
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+ fcntl(pipefd[1], F_SETFD, FD_CLOEXEC);
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
}
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
static void delete_ups(utype_t *target)
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
--- nut-2.7.4/clients/upssched.c.cloexec 2018-12-07 17:09:13.081914570 -0800
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+++ nut-2.7.4/clients/upssched.c 2018-12-07 18:28:54.380512191 -0800
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
@@ -46,6 +46,8 @@
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
#include <sys/socket.h>
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
#include <sys/un.h>
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
#include <netinet/in.h>
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+#include <unistd.h>
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+#include <fcntl.h>
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
#include "upssched.h"
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
#include "timehead.h"
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
@@ -297,6 +299,9 @@
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
if (ret < 0)
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
fatal_with_errno(EXIT_FAILURE, "listen(%d, %d) failed", fd, US_LISTEN_BACKLOG);
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+ /* don't leak socket to CMDSCRIPT */
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
return fd;
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
}
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
@@ -370,6 +375,9 @@
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
return;
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
}
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+ /* don't leak connection to CMDSCRIPT */
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+ fcntl(acc, F_SETFD, FD_CLOEXEC);
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
+
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
/* enable nonblocking I/O */
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
|
|
![](https://seccdn.libravatar.org/avatar/61a12734645841e91723eabc6bd107c284a53a31f5e482f6ca304be5cbc5209c?s=16&d=retro) |
e7cad98 |
ret = fcntl(acc, F_GETFL, 0);
|