From 8ed491ded189c13ea319b6dc1e09cf7819144bc1 Mon Sep 17 00:00:00 2001 From: travankor Date: Thu, 20 Jan 2022 10:41:10 -0700 Subject: [PATCH] pam_rundir: fix conditional and set the user gid for the dir. --- srcpkgs/pam_rundir/patches/fix.patch | 1 - srcpkgs/pam_rundir/patches/fix2.patch | 15 ++++++++++++++ srcpkgs/pam_rundir/patches/setegid.patch | 26 ++++++++++++++++++++++++ srcpkgs/pam_rundir/template | 2 +- 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 srcpkgs/pam_rundir/patches/fix2.patch create mode 100644 srcpkgs/pam_rundir/patches/setegid.patch diff --git a/srcpkgs/pam_rundir/patches/fix.patch b/srcpkgs/pam_rundir/patches/fix.patch index 3ef75edfea6..25226758493 100644 --- a/srcpkgs/pam_rundir/patches/fix.patch +++ b/srcpkgs/pam_rundir/patches/fix.patch @@ -37,4 +37,3 @@ + prctl (PR_SET_SECUREBITS, (unsigned long) secbits); close (fd); /* also unlocks */ } - diff --git a/srcpkgs/pam_rundir/patches/fix2.patch b/srcpkgs/pam_rundir/patches/fix2.patch new file mode 100644 index 00000000000..99e5e02658b --- /dev/null +++ b/srcpkgs/pam_rundir/patches/fix2.patch @@ -0,0 +1,15 @@ +from https://github.com/jjk-jacky/pam_rundir/pull/5 + +diff --git a/pam_rundir.c b/pam_rundir.c +index 2d2c201..67c7ca6 100644 +--- a/pam_rundir.c ++++ b/pam_rundir.c +@@ -197,7 +197,7 @@ write_counter (int fd, int count) + r = write (fd, buf + w, l - w); + if (r < 0) + { +- if (errno = EINTR) ++ if (errno == EINTR) + continue; + if (w > 0) + emergency_invalidate_counter (fd); diff --git a/srcpkgs/pam_rundir/patches/setegid.patch b/srcpkgs/pam_rundir/patches/setegid.patch new file mode 100644 index 00000000000..3c573cd41a5 --- /dev/null +++ b/srcpkgs/pam_rundir/patches/setegid.patch @@ -0,0 +1,26 @@ +backport of https://github.com/jjk-jacky/pam_rundir/pull/8 + +diff --git a/pam_rundir.c b/pam_rundir.c +index d36584d..f92c73e 100644 +--- a/pam_rundir.c ++++ b/pam_rundir.c +@@ -404,8 +404,8 @@ + secbits = prctl (PR_GET_SECUREBITS); + if (secbits != -1) + prctl (PR_SET_SECUREBITS, (unsigned long) secbits | 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) ++ /* set euid and egid so if we do create the dir, it is owned by the user */ ++ if (seteuid (pw->pw_uid) < 0 || setegid (pw->pw_gid) < 0) + { + r = -1; + goto done; +@@ -422,7 +422,7 @@ + pam_putenv (pamh, buf); + } + /* restore */ +- if (seteuid (0) < 0) ++ if (seteuid (0) < 0 || setegid (0) < 0) + { + r = -1; + goto done; diff --git a/srcpkgs/pam_rundir/template b/srcpkgs/pam_rundir/template index f08238ddb5f..080be5afca3 100644 --- a/srcpkgs/pam_rundir/template +++ b/srcpkgs/pam_rundir/template @@ -1,7 +1,7 @@ # Template file for 'pam_rundir' pkgname=pam_rundir version=1.0.0 -revision=5 +revision=6 build_style=configure configure_args="--prefix=/usr --with-parentdir=/run/user" makedepends="pam-devel"