aboutsummaryrefslogtreecommitdiff
path: root/kms/client
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-04-17 23:53:18 +0200
committerdec05eba <dec05eba@protonmail.com>2023-04-17 23:53:18 +0200
commitdf2509c0aaf7ce33de48535b03fc677574b93e14 (patch)
tree80375b7dc1c28114dfd81bf38a0fbfed149ac572 /kms/client
parentc0ebae365d3ee20dc6ed1cf71d998bf040e93149 (diff)
Kms server timeout, move back kms unix domain socket to HOME because flatpak cant access it otherwise
Diffstat (limited to 'kms/client')
-rw-r--r--kms/client/kms_client.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/kms/client/kms_client.c b/kms/client/kms_client.c
index 9c17f80..2d1cd0f 100644
--- a/kms/client/kms_client.c
+++ b/kms/client/kms_client.c
@@ -79,33 +79,18 @@ static int recv_msg_from_server(int server_fd, gsr_kms_response *response) {
return res;
}
+/* We have to use $HOME because in flatpak there is no simple path that is accessible, read and write, that multiple flatpak instances can access */
static bool create_socket_path(char *output_path, size_t output_path_size) {
- // Can't use /tmp because of flatpak, but fallback to it if we fail to get a valid runtime dir
- char runtime_dir_path[PATH_MAX];
- const char *runtime_dir = getenv("XDG_RUNTIME_DIR");
- const char *flatpak_id = getenv("FLATPAK_ID");
- if(runtime_dir) {
- if(flatpak_id)
- snprintf(runtime_dir_path, sizeof(runtime_dir_path), "%s/app/%s", runtime_dir, flatpak_id);
- else
- strcpy(runtime_dir_path, runtime_dir);
- } else {
- const uint32_t uid = getuid();
- if(flatpak_id)
- snprintf(runtime_dir_path, sizeof(runtime_dir_path), "/run/user/%u/app/%s", uid, flatpak_id);
- else
- snprintf(runtime_dir_path, sizeof(runtime_dir_path), "/run/user/%u", uid);
- }
-
- if(access(runtime_dir_path, F_OK) != 0)
- strcpy(runtime_dir_path, "/tmp");
+ const char *home = getenv("HOME");
+ if(!home)
+ home = "/tmp";
char random_characters[11];
random_characters[10] = '\0';
if(!generate_random_characters(random_characters, 10, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62))
return false;
- snprintf(output_path, output_path_size, "%s/gsr-kms-socket-%s", runtime_dir_path, random_characters);
+ snprintf(output_path, output_path_size, "%s/.gsr-kms-socket-%s", home, random_characters);
return true;
}
@@ -221,6 +206,7 @@ int gsr_kms_client_init(gsr_kms_client *self, const char *card_path) {
int wait_result = waitpid(self->kms_server_pid, &status, WNOHANG);
if(wait_result != 0) {
fprintf(stderr, "gsr error: gsr_kms_client_init: kms server died or never started, error: %s\n", strerror(errno));
+ self->kms_server_pid = -1;
goto err;
}
}