Check getcap in flatpak too
This commit is contained in:
parent
11ba5d6027
commit
31e8ba837a
@ -191,29 +191,28 @@ int gsr_kms_client_init(gsr_kms_client *self, const char *card_path) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_perm = 0;
|
|
||||||
const bool inside_flatpak = getenv("FLATPAK_ID") != NULL;
|
const bool inside_flatpak = getenv("FLATPAK_ID") != NULL;
|
||||||
if(!inside_flatpak) {
|
|
||||||
if(geteuid() == 0) {
|
bool has_perm = 0;
|
||||||
has_perm = true;
|
if(geteuid() == 0) {
|
||||||
} else {
|
has_perm = true;
|
||||||
cap_t kms_server_cap = cap_get_file(server_filepath);
|
} else {
|
||||||
if(kms_server_cap) {
|
cap_t kms_server_cap = cap_get_file(server_filepath);
|
||||||
cap_flag_value_t res = 0;
|
if(kms_server_cap) {
|
||||||
cap_get_flag(kms_server_cap, CAP_SYS_ADMIN, CAP_PERMITTED, &res);
|
cap_flag_value_t res = 0;
|
||||||
if(res == CAP_SET) {
|
cap_get_flag(kms_server_cap, CAP_SYS_ADMIN, CAP_PERMITTED, &res);
|
||||||
//fprintf(stderr, "has permission!\n");
|
if(res == CAP_SET) {
|
||||||
has_perm = true;
|
//fprintf(stderr, "has permission!\n");
|
||||||
} else {
|
has_perm = true;
|
||||||
//fprintf(stderr, "No permission:(\n");
|
|
||||||
}
|
|
||||||
cap_free(kms_server_cap);
|
|
||||||
} else {
|
} else {
|
||||||
if(errno == ENODATA)
|
//fprintf(stderr, "No permission:(\n");
|
||||||
fprintf(stderr, "gsr info: gsr_kms_client_init: gsr-kms-server is missing sys_admin cap and will require root authentication. To bypass this automatically, run: sudo setcap cap_sys_admin+ep '%s'\n", server_filepath);
|
|
||||||
else
|
|
||||||
fprintf(stderr, "gsr info: gsr_kms_client_init: failed to get cap\n");
|
|
||||||
}
|
}
|
||||||
|
cap_free(kms_server_cap);
|
||||||
|
} else {
|
||||||
|
if(errno == ENODATA)
|
||||||
|
fprintf(stderr, "gsr info: gsr_kms_client_init: gsr-kms-server is missing sys_admin cap and will require root authentication. To bypass this automatically, run: sudo setcap cap_sys_admin+ep '%s'\n", server_filepath);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "gsr info: gsr_kms_client_init: failed to get cap\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user