diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-02-16 20:03:03 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-02-16 20:06:38 +0100 |
commit | d31dc61e1a1358fa6b0960d699f2a55e39854096 (patch) | |
tree | 8b19f7e056bc9d6ba4abb57899cfa72eb1e84350 | |
parent | 08693e6095cfa79a80faa8e9d0c76e0f183929fd (diff) |
Create ~/.local/bin as regular user
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | main.c | 8 |
2 files changed, 5 insertions, 5 deletions
@@ -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 @@ -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); } |