--- pam_rundir.c
+++ pam_rundir.c
@@ -24,6 +24,8 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/file.h>
+#include <sys/prctl.h>
+#include <linux/securebits.h>
 #include <string.h>
 #include <pwd.h>
 #include <fcntl.h>
@@ -396,6 +398,9 @@ pam_sm_open_session (pam_handle_t *pamh, int flags, int argc, const char **argv)
             goto done;
         }

+        /* to bypass permission checks for mkdir, in case it isn't group
+         * writable */
+        prctl (PR_SET_SECUREBITS, SECBIT_NO_SETUID_FIXUP);
         /* set euid so if we do create the dir, it is own by the user */
         if (seteuid (pw->pw_uid) < 0)
         {
