Description: Fix warning: ignoring return value of 'chdir' declared with attribute 'warn_unused_result' [-Wunused-result]
Author: Agustin Martin <agmartin@debian.org>
Forwarded: not-needed
Last-Update: 2025-03-06

Properly handle `chdir' return value.

pam_encfs.c:585:13: warning: ignoring return value of 'chdir' declared with attribute 'warn_unused_result' [-Wunused-result]
  585 |             chdir(targetpath);
      |             ^~~~~~~~~~~~~~~~~

--- a/pam_encfs.c
+++ b/pam_encfs.c
@@ -582,7 +582,10 @@ PAM_EXTERN int pam_sm_authenticate(pam_h
             close(inpipe[WRITE_END]);
 
             // For some reason the current directory has to be set to targetpath (or path?) before exec'ing encfs through gdm
-            chdir(targetpath);
+	    if ( chdir(targetpath)  == -1 )
+	      fprintf(stderr, "changing working directory; %s\n",
+		      strerror(errno));
+
             execvp("encfs", arg);
             char errstr[128];
 
