--- auth.c.orig 2024-09-04 23:09:59.029709000 +0000 +++ auth.c 2024-09-04 23:13:30.773140000 +0000 @@ -51,7 +51,7 @@ #include -#if defined(HAVE_POLKIT) && defined(SO_PEERCRED) +#if defined(HAVE_POLKIT) && (defined(SO_PEERCRED) || defined(LOCAL_PEERCRED)) #include #include @@ -61,7 +61,11 @@ /* Returns non zero when the client is authorized */ unsigned IsClientAuthorized(int socket, const char* action, const char* reader) { +#ifdef LOCAL_PEERCRED + struct xucred cr; +#else struct ucred cr; +#endif socklen_t cr_len; int ret; PolkitSubject *subject; @@ -77,7 +81,11 @@ snprintf(action_name, sizeof(action_name), "org.debian.pcsc-lite.%s", action); cr_len = sizeof(cr); +#ifdef LOCAL_PEERCRED + ret = getsockopt(socket, SOL_LOCAL, LOCAL_PEERCRED, &cr, &cr_len); +#else ret = getsockopt(socket, SOL_SOCKET, SO_PEERCRED, &cr, &cr_len); +#endif if (ret == -1) { #ifndef NO_LOG @@ -97,7 +105,11 @@ return 0; } +#ifdef LOCAL_PEERCRED + subject = polkit_unix_process_new_for_owner(cr.cr_pid, 0, cr.cr_uid); +#else subject = polkit_unix_process_new_for_owner(cr.pid, 0, cr.uid); +#endif if (subject == NULL) { Log1(PCSC_LOG_CRITICAL, "polkit_unix_process_new_for_owner failed"); @@ -144,7 +156,11 @@ { Log4(PCSC_LOG_CRITICAL, "Process %u (user: %u) is NOT authorized for action: %s", +#ifdef LOCAL_PEERCRED + (unsigned)cr.cr_pid, (unsigned)cr.cr_uid, action); +#else (unsigned)cr.pid, (unsigned)cr.uid, action); +#endif } if (result)