Skip to content

Commit

Permalink
pam_rundir: fix conditional and set the user gid for the dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
travankor committed Feb 25, 2022
1 parent 5b19696 commit 8378166
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
1 change: 0 additions & 1 deletion srcpkgs/pam_rundir/patches/fix.patch
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@
+ prctl (PR_SET_SECUREBITS, (unsigned long) secbits);
close (fd); /* also unlocks */
}

15 changes: 15 additions & 0 deletions srcpkgs/pam_rundir/patches/fix2.patch
Original file line number Diff line number Diff line change
@@ -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);
26 changes: 26 additions & 0 deletions srcpkgs/pam_rundir/patches/setegid.patch
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion srcpkgs/pam_rundir/template
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 8378166

Please sign in to comment.