File pam-bsc1218475-pam_namespace-O_DIRECTORY-flag.patch of Package pam.32004

--- Linux-PAM-1.3.0.old/modules/pam_namespace/pam_namespace.c	2024-01-02 22:59:07.885482449 +0100
+++ Linux-PAM-1.3.0/modules/pam_namespace/pam_namespace.c	2024-01-02 23:01:56.195614994 +0100
@@ -1027,7 +1027,7 @@ static int protect_dir(const char *path,
 	int dfd = AT_FDCWD;
 	int dfd_next;
 	int save_errno;
-	int flags = O_RDONLY;
+	int flags = O_RDONLY | O_DIRECTORY;
 	int rv = -1;
 	struct stat st;
 
@@ -1081,22 +1081,6 @@ static int protect_dir(const char *path,
 		rv = openat(dfd, dir, flags);
 	}
 
-	if (rv != -1) {
-		if (fstat(rv, &st) != 0) {
-			save_errno = errno;
-			close(rv);
-			rv = -1;
-			errno = save_errno;
-			goto error;
-		}
-		if (!S_ISDIR(st.st_mode)) {
-			close(rv);
-			errno = ENOTDIR;
-			rv = -1;
-			goto error;
-		}
-	}
-
 	if (flags & O_NOFOLLOW) {
 		/* we are inside user-owned dir - protect */
 		if (protect_mount(rv, p, idata) == -1) {
openSUSE Build Service is sponsored by