aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Beich <jbeich@FreeBSD.org>2021-03-29 22:50:34 +0000
committerJan Beich <jbeich@FreeBSD.org>2021-05-04 22:35:50 +0000
commitd255158645dae682063e973978f2f6843b9c4dd4 (patch)
tree5562968ad647f67bfa7e6cd3c9425557a3d0878c
parent81bb1c7e2197256fd724e3edf056ad780c039b26 (diff)
downloadports-d255158645da.tar.gz
ports-d255158645da.zip
sysutils/pam_xdg: add new port
Complete XDG Base Directories support via PAM, including injection of according environment variables into user sessions, as well as creation support for per-user $XDG_RUNTIME_DIR. https://www.sdaoden.eu/code.html#s-toolbox
-rw-r--r--sysutils/Makefile1
-rw-r--r--sysutils/pam_xdg/Makefile34
-rw-r--r--sysutils/pam_xdg/distinfo3
-rw-r--r--sysutils/pam_xdg/files/patch-pam__xdg.832
-rw-r--r--sysutils/pam_xdg/files/patch-pam__xdg.c44
-rw-r--r--sysutils/pam_xdg/pkg-descr5
-rw-r--r--sysutils/pam_xdg/pkg-message13
7 files changed, 132 insertions, 0 deletions
diff --git a/sysutils/Makefile b/sysutils/Makefile
index 09d8933c5171..dd753d7c5e2d 100644
--- a/sysutils/Makefile
+++ b/sysutils/Makefile
@@ -891,6 +891,7 @@
SUBDIR += paicc
SUBDIR += paladin
SUBDIR += pam_mount
+ SUBDIR += pam_xdg
SUBDIR += panicmail
SUBDIR += parafly
SUBDIR += parallel
diff --git a/sysutils/pam_xdg/Makefile b/sysutils/pam_xdg/Makefile
new file mode 100644
index 000000000000..c7e107f1018c
--- /dev/null
+++ b/sysutils/pam_xdg/Makefile
@@ -0,0 +1,34 @@
+PORTNAME= pam_xdg
+PORTVERSION= s20210329
+CATEGORIES= sysutils
+
+MAINTAINER= jbeich@FreeBSD.org
+COMMENT= PAM module to manage XDG Base Directories
+
+LICENSE= ISCL
+
+USES= uidfix
+USE_GITHUB= yes
+GH_ACCOUNT= jbeich # mirror
+GH_PROJECT= s-toolbox
+GH_TAGNAME= 2433f8b
+PLIST_FILES= lib/${PORTNAME}.so \
+ share/man/man8/${PORTNAME}.8.gz
+
+# pam_xdg.makefile is too crufty, so roll our own
+MAKEFILE= bsd.lib.mk
+MAKE_ARGS+= SHLIB_NAME="${PORTNAME}.so" MAN="${PORTNAME}.8" \
+ SRCS="${PORTNAME}.c" LDADD="-lpam" \
+ LIBDIR="${PREFIX}/lib" SHAREDIR="${PREFIX}/share"
+LDFLAGS+= -Wl,-z,defs
+
+post-patch:
+ @${REINPLACE_CMD} \
+ -e '/#define/ { \
+ s,/etc,${PREFIX}&,; \
+ s,/usr/local,${PREFIX},; \
+ s,/run,/var&,; \
+ }' \
+ ${WRKSRC}/${PORTNAME}.c
+
+.include <bsd.port.mk>
diff --git a/sysutils/pam_xdg/distinfo b/sysutils/pam_xdg/distinfo
new file mode 100644
index 000000000000..cd9a5a2a68c9
--- /dev/null
+++ b/sysutils/pam_xdg/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1617058234
+SHA256 (jbeich-s-toolbox-s20210329-2433f8b_GH0.tar.gz) = c7797a449e98bf32a82f60555bc3e63bf60b4636e264d651d59cfe7c8347c7b4
+SIZE (jbeich-s-toolbox-s20210329-2433f8b_GH0.tar.gz) = 97722
diff --git a/sysutils/pam_xdg/files/patch-pam__xdg.8 b/sysutils/pam_xdg/files/patch-pam__xdg.8
new file mode 100644
index 000000000000..27faf14757ea
--- /dev/null
+++ b/sysutils/pam_xdg/files/patch-pam__xdg.8
@@ -0,0 +1,32 @@
+- Chase option name used in the source
+- Switch to OpenPAM include for local sessions
+
+--- pam_xdg.8.orig 2021-03-29 22:50:34 UTC
++++ pam_xdg.8
+@@ -28,7 +28,7 @@
+ .Sh SYNOPSIS
+ .
+ .Nm
+-.Op Ar rundir
++.Op Ar runtime
+ .Op Ar notroot
+ .
+ .
+@@ -47,7 +47,7 @@ into user sessions.
+ When linked into the PAM session system the runtime directory will be
+ created once a user creates his or her first login session.
+ Unless
+-.Ar rundir
++.Ar runtime
+ was given all XDG related environment variables will be created in all
+ user sessions with their default or computed values, otherwise only
+ .Ev XDG_RUNTIME_DIR .
+@@ -61,7 +61,7 @@ In order to make use of this script, place the followi
+ file of desire under
+ .Pa /etc/pam.d ,
+ best maybe
+-.Pa /etc/pam.d/common-session
++.Pa /etc/pam.d/system
+ if that exists (possibly adjusting paths):
+ .
+ .Bd -literal -offset indent
diff --git a/sysutils/pam_xdg/files/patch-pam__xdg.c b/sysutils/pam_xdg/files/patch-pam__xdg.c
new file mode 100644
index 000000000000..417d054f009d
--- /dev/null
+++ b/sysutils/pam_xdg/files/patch-pam__xdg.c
@@ -0,0 +1,44 @@
+- Prefer system PATH_MAX
+- Add OpenPAM support
+- Relax O_PATH optimization
+
+--- pam_xdg.c.orig 2021-03-29 22:50:34 UTC
++++ pam_xdg.c
+@@ -52,6 +52,7 @@
+
+ #include <errno.h>
+ #include <fcntl.h>
++#include <limits.h> /* PATH_MAX */
+ #include <pwd.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+@@ -60,11 +61,29 @@
+ #include <unistd.h>
+
+ #include <security/pam_modules.h>
++#if __has_include(<security/pam_ext.h>)
+ #include <security/pam_ext.h>
++#else
++#include <security/pam_appl.h>
++/* From freebsd-src/sys/contrib/openzfs/contrib/pam_zfs_key/pam_zfs_key.c */
++static void
++pam_syslog(pam_handle_t *pamh __unused, int loglevel, const char *fmt, ...)
++{
++ va_list args;
++ va_start(args, fmt);
++ vsyslog(loglevel, fmt, args);
++ va_end(args);
++}
++#endif
+
+ /* _XOPEN_PATH_MAX POSIX 2008/Cor 1-2013 */
+ #ifndef PATH_MAX
+ # define PATH_MAX 1024
++#endif
++
++/* Linux extension adopted by FreeBSD 13.1 */
++#ifndef O_PATH
++# define O_PATH 0
+ #endif
+
+ static int a_xdg(int isopen, pam_handle_t *pamh, int flags, int argc,
diff --git a/sysutils/pam_xdg/pkg-descr b/sysutils/pam_xdg/pkg-descr
new file mode 100644
index 000000000000..547ecba2419c
--- /dev/null
+++ b/sysutils/pam_xdg/pkg-descr
@@ -0,0 +1,5 @@
+Complete XDG Base Directories support via PAM, including injection of
+according environment variables into user sessions, as well as creation
+support for per-user $XDG_RUNTIME_DIR.
+
+WWW: https://www.sdaoden.eu/code.html#s-toolbox
diff --git a/sysutils/pam_xdg/pkg-message b/sysutils/pam_xdg/pkg-message
new file mode 100644
index 000000000000..9834b6e76b46
--- /dev/null
+++ b/sysutils/pam_xdg/pkg-message
@@ -0,0 +1,13 @@
+[
+{ type: install
+ message: <<EOM
+XDG_RUNTIME_DIR on Wayland maybe used as a fallback for anonymous
+shared memory. For better performance and to avoid posix_fallocate(2)
+issues on ZFS moving the directory to tmpfs(5) is recommended:
+
+ # echo "none /var/run/user tmpfs rw" >>/etc/fstab
+ # mkdir -p /var/run/user
+ # mount -a
+EOM
+}
+]