Previously, both network and progress IPC sockets defaulted to
/run/swupdate if no runtime directory was set. This caused CI failures
on non-systemd or containerized environments where /run may not exist
or be writable.
This updates get_ctrl_socket() and get_prog_socket() to:
1. Prefer RUNTIME_DIRECTORY if set.
2. Fallback to TMPDIR environment variable.
3. Fallback to /run/swupdate only if it exists and is writable.
4. Otherwise, fallback to /tmp.
This ensures that IPC socket paths are always valid and writable,
especially in containerized or non-systemd environments.
Fixes: 9f7ff0d4 (ipc: use /run/swupdate as default socket directory instead of /tmp)
Signed-off-by: Badrikesh Prusty <
badrikes...@siemens.com>
---
ipc/network_ipc.c | 10 +++++++---
ipc/progress_ipc.c | 7 +++++--
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/ipc/network_ipc.c b/ipc/network_ipc.c
index e167d0b1..9c05849d 100644
--- a/ipc/network_ipc.c
+++ b/ipc/network_ipc.c
@@ -31,8 +31,12 @@ char *get_ctrl_socket(void) {
if(!socketdir){
socketdir = getenv("TMPDIR");
}
- if (!socketdir)
- socketdir = "/run/swupdate";
+ if (!socketdir) {
+ if (access("/run/swupdate", W_OK) == 0)
+ socketdir = "/run/swupdate";
+ else
+ socketdir = "/tmp";
+ }
if (asprintf(&SOCKET_CTRL_PATH, "%s/%s", socketdir, SOCKET_CTRL_DEFAULT) == -1)
return (char *)"/tmp/"SOCKET_CTRL_DEFAULT;
}
@@ -336,7 +340,7 @@ int ipc_wait_for_complete(getstatus callback)
RECOVERY_STATUS status = IDLE;
ipc_message message;
int ret;
-
+
message.data.status.last_result = FAILURE;
do {
diff --git a/ipc/progress_ipc.c b/ipc/progress_ipc.c
index 382a83c9..4ab5289b 100644
--- a/ipc/progress_ipc.c
+++ b/ipc/progress_ipc.c
@@ -40,8 +40,11 @@ char *get_prog_socket(void) {
if(!socketdir){
socketdir = getenv("TMPDIR");
}
- if(!socketdir){
- socketdir = "/run/swupdate";
+ if (!socketdir) {
+ if (access("/run/swupdate", W_OK) == 0)
+ socketdir = "/run/swupdate";
+ else
+ socketdir = "/tmp";
}
if (asprintf(&SOCKET_PROGRESS_PATH, "%s/%s", socketdir, SOCKET_PROGRESS_DEFAULT) == -1)
return (char *)"/tmp/"SOCKET_PROGRESS_DEFAULT;
--
2.39.5