@@ -21,7 +21,7 @@ static int (*fp_pam_authenticate)(pam_handle_t *, int) = NULL;
2121static int (* fp_pam_end )(pam_handle_t * , int ) = NULL ;
2222static int (* fp_pam_setcred )(pam_handle_t * , int ) = NULL ;
2323
24- static bool load_pam_library (void ) {
24+ bool load_pam_library (void ) {
2525 pam_handle = dlopen ("libpam.so.0" , RTLD_NOW );
2626 if (!pam_handle ) {
2727 swaylock_log (LOG_ERROR , "Failed to load libpam.so.0: %s" , dlerror ());
@@ -42,14 +42,18 @@ static bool load_pam_library(void) {
4242 return true;
4343}
4444
45+ bool is_pam_loaded (void ) {
46+ return pam_handle != NULL ;
47+ }
48+
4549static void unload_pam_library (void ) {
4650 if (pam_handle ) {
4751 dlclose (pam_handle );
4852 pam_handle = NULL ;
4953 }
5054}
5155
52- void initialize_pw_backend (int argc , char * * argv ) {
56+ void initialize_pam_backend (int argc , char * * argv ) {
5357 if (getuid () != geteuid () || getgid () != getegid ()) {
5458 swaylock_log (LOG_ERROR ,
5559 "swaylock is setuid, but was compiled with the PAM"
@@ -107,11 +111,7 @@ static const char *get_pam_auth_error(int pam_status) {
107111 }
108112}
109113
110- void run_pw_backend_child (void ) {
111- if (!load_pam_library ()) {
112- exit (EXIT_FAILURE ); // Fall back or exit if desired
113- }
114-
114+ void run_pam_backend_child (void ) {
115115 struct passwd * passwd = getpwuid (getuid ());
116116 if (!passwd ) {
117117 swaylock_log_errno (LOG_ERROR , "getpwuid failed" );
0 commit comments