From d31dc61e1a1358fa6b0960d699f2a55e39854096 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 16 Feb 2024 20:03:03 +0100 Subject: Create ~/.local/bin as regular user --- README.md | 2 +- main.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bda467a..28f8c51 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,6 @@ This program is meant to be ran with flatpak-spawn --host. This program is not m When this program is first run, it executes itself with pkexec and in that case it sets CAP_SYS_ADMIN capability on itself after copying self to ~/.local/bin and launches gsr-kms-server (in flatpak location). When this program is run after that it will check if its run from ~/.local/bin or launch that and it will see that the program has CAP_SYS_ADMIN capability -and will launch gsr-kms-server (in flatpak location). +and will launch gsr-kms-server (in flatpak location). This program also sets CAP_SYS_ADMIN on gsr-kms-server in the flatpak app directory. The depends directory contains libcap from the libcap project, available here: https://mirrors.edge.kernel.org/pub/linux/libs/security/linux-privs/libcap2/. The version used is libcap-2.69. \ No newline at end of file diff --git a/main.c b/main.c index 924f6fa..35ff830 100644 --- a/main.c +++ b/main.c @@ -120,7 +120,7 @@ int main(int argc, char **argv) { return 1; char kms_server_proxy_local_filepath[PATH_MAX]; - snprintf(kms_server_proxy_local_filepath, sizeof(kms_server_proxy_local_filepath), "%s/.local/bin/kms-server-proxy", user_homepath); + snprintf(kms_server_proxy_local_filepath, sizeof(kms_server_proxy_local_filepath), "%s/.local/bin/kms-server-proxy-1", user_homepath); if(file_has_sys_admin_capability(gsr_kms_server_filepath)) { const char *args[] = { gsr_kms_server_filepath, initial_socket_path, card_path, NULL }; @@ -141,13 +141,13 @@ int main(int argc, char **argv) { return execvp(args[0], (char *const*)args); } else if(geteuid() == 0) { /* is current user root */ file_set_sys_admin_capability(gsr_kms_server_filepath, 0); - - if(create_local_kms_server_proxy_directory(user_homepath)) - create_local_kms_server_proxy_file(self_path, kms_server_proxy_local_filepath); + create_local_kms_server_proxy_file(self_path, kms_server_proxy_local_filepath); const char *args[] = { gsr_kms_server_filepath, initial_socket_path, card_path, NULL }; return execv(args[0], (char *const*)args); } else { + create_local_kms_server_proxy_directory(user_homepath); + const char *args[] = { "pkexec", self_path, initial_socket_path, card_path, user_homepath, NULL }; return execvp(args[0], (char *const*)args); } -- cgit v1.2.3