talos-extensions/power/nut-client/patches/replace_system.patch
Andrey Smirnov 9a57c65d10
feat: bump dependencies
Update pkgs.

```
| Package | Update | Change |
|---|---|---|
| [containerd/stargz-snapshotter](https://togithub.com/containerd/stargz-snapshotter) | minor | `v0.14.3` -> `v0.15.1` |
| [https://github.com/qemu/qemu.git](https://togithub.com/qemu/qemu) | patch | `8.1.1` -> `8.1.2` |
| [https://gitlab.gnome.org/GNOME/glib.git](https://gitlab.gnome.org/GNOME/glib) | patch | `2.78.0` -> `2.78.1` |
| [networkupstools/nut](https://togithub.com/networkupstools/nut) | patch | `2.8.0` -> `v2.8.1` |
| [tailscale/tailscale](https://togithub.com/tailscale/tailscale) | minor | `1.50.0` -> `1.54.0` |
```

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
2023-11-21 17:40:45 +04:00

43 lines
962 B
Diff

--- a/clients/upsmon.c 2022-04-23 04:56:06.000000000 -0700
+++ b/clients/upsmon.c 2022-09-04 13:21:28.072170502 -0700
@@ -26,6 +26,7 @@
#include <sys/socket.h>
#include <unistd.h>
#include <fcntl.h>
+#include <spawn.h>
#else
#include <wincompat.h>
#endif
@@ -1874,6 +1875,22 @@
static void runparent(int fd)
__attribute__((noreturn));
+static int runcmd(const char *cmd)
+{
+ // TODO: Support tokenizing `cmd`.
+ const char *argv[] = {cmd, NULL};
+ const char *env[] = {NULL};
+
+ pid_t pid = 0;
+ int sret = posix_spawn(&pid, cmd, NULL, NULL, argv, env);
+ if (sret != 0)
+ return -1;
+
+ int status;
+ waitpid(pid, &status, 0);
+ return WEXITSTATUS(status);
+}
+
static void runparent(int fd)
{
ssize_t ret;
@@ -1907,7 +1925,7 @@
/* have to do this here - child is unprivileged */
set_pdflag();
- sret = system(shutdowncmd);
+ sret = runcmd(shutdowncmd);
if (sret != 0)
upslogx(LOG_ERR, "parent: Unable to call shutdown command: %s",