From d45597e104fa3bd80a6f1922f2fdeaa6a0eff724 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 22 Jul 2023 23:12:08 +0200 Subject: Exit with exit code 10 if pkexec fails --- kms/client/kms_client.c | 12 ++++++++++-- kms/server/kms_server.c | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'kms') diff --git a/kms/client/kms_client.c b/kms/client/kms_client.c index ff8a3d5..aab5b01 100644 --- a/kms/client/kms_client.c +++ b/kms/client/kms_client.c @@ -140,6 +140,7 @@ static bool find_program_in_path(const char *program_name, char *filepath, int f } int gsr_kms_client_init(gsr_kms_client *self, const char *card_path) { + int result = -1; self->kms_server_pid = -1; self->socket_fd = -1; self->client_fd = -1; @@ -248,12 +249,19 @@ int gsr_kms_client_init(gsr_kms_client *self, const char *card_path) { } break; } else { - int status; + int status = 0; 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; + } else if(WIFEXITED(status)) { + int exit_code = WEXITSTATUS(status); + fprintf(stderr, "gsr error: gsr_kms_client_init: kms server died or never started, exit code: %d\n", exit_code); + self->kms_server_pid = -1; + if(exit_code != 0) + result = exit_code; + goto err; } } } @@ -263,7 +271,7 @@ int gsr_kms_client_init(gsr_kms_client *self, const char *card_path) { err: gsr_kms_client_deinit(self); - return -1; + return result; } void gsr_kms_client_deinit(gsr_kms_client *self) { diff --git a/kms/server/kms_server.c b/kms/server/kms_server.c index d2eb4e8..0ff0b03 100644 --- a/kms/server/kms_server.c +++ b/kms/server/kms_server.c @@ -338,7 +338,7 @@ int main(int argc, char **argv) { if(drmSetClientCap(drm.drmfd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1) != 0) { fprintf(stderr, "kms server error: drmSetClientCap DRM_CLIENT_CAP_UNIVERSAL_PLANES failed, error: %s\n", strerror(errno)); close(drm.drmfd); - return 2; + return 10; } if(drmSetClientCap(drm.drmfd, DRM_CLIENT_CAP_ATOMIC, 1) != 0) { -- cgit v1.2.3