summaryrefslogtreecommitdiff
path: root/security/priv
diff options
context:
space:
mode:
authorkim <kim@pkgsrc.org>2021-02-16 09:42:06 +0000
committerkim <kim@pkgsrc.org>2021-02-16 09:42:06 +0000
commita1e94c1e54ec4dd31f4dc54a25ae8a0027ea1357 (patch)
treef880a88256f502eade62a79131aa7f24910e5d4a /security/priv
parentea7609abadeca46b77de2045431f90591916b197 (diff)
downloadpkgsrc-a1e94c1e54ec4dd31f4dc54a25ae8a0027ea1357.tar.gz
Use setusercontext(3)
Using setusercontext(3) makes per-user tmp work. Fixes PR 55765.
Diffstat (limited to 'security/priv')
-rw-r--r--security/priv/Makefile8
-rw-r--r--security/priv/distinfo9
-rw-r--r--security/priv/patches/patch-Makefile.in (renamed from security/priv/patches/patch-aa)2
-rw-r--r--security/priv/patches/patch-ab17
-rw-r--r--security/priv/patches/patch-configure.in23
-rw-r--r--security/priv/patches/patch-priv.c32
-rw-r--r--security/priv/patches/patch-priv.h35
7 files changed, 100 insertions, 26 deletions
diff --git a/security/priv/Makefile b/security/priv/Makefile
index 558a57e1e52..f3a7740cbc3 100644
--- a/security/priv/Makefile
+++ b/security/priv/Makefile
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.21 2021/02/05 13:18:48 nia Exp $
+# $NetBSD: Makefile,v 1.22 2021/02/16 09:42:06 kim Exp $
#
DISTNAME= priv-1.0-beta2
PKGNAME= priv-1.0beta2
-PKGREVISION= 4
+PKGREVISION= 5
CATEGORIES= security
MASTER_SITES= ftp://ftp.thistledown.com.au/pub/simonb/
@@ -11,6 +11,7 @@ MAINTAINER= simonb@NetBSD.org
COMMENT= Execute commands as a different user
LICENSE= original-bsd
+USE_TOOLS= autoconf automake autoreconf
GNU_CONFIGURE= YES
CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR:Q}
@@ -26,4 +27,7 @@ SPECIAL_PERMS+= bin/priv ${SETUID_ROOT_PERMS}
OWN_DIRS= ${PKG_SYSCONFDIR}/priv
+pre-configure:
+ cd "${WRKSRC}" && autoreconf -fi
+
.include "../../mk/bsd.pkg.mk"
diff --git a/security/priv/distinfo b/security/priv/distinfo
index ec5898bb160..b0a19229410 100644
--- a/security/priv/distinfo
+++ b/security/priv/distinfo
@@ -1,9 +1,10 @@
-$NetBSD: distinfo,v 1.9 2021/02/05 13:18:48 nia Exp $
+$NetBSD: distinfo,v 1.10 2021/02/16 09:42:06 kim Exp $
SHA1 (priv-1.0-beta2.tar.gz) = dee75baaf320c5dee112376cca0bb08a635f2806
RMD160 (priv-1.0-beta2.tar.gz) = 635e0e2cf64c0bdbbdc790a4833e650700473448
SHA512 (priv-1.0-beta2.tar.gz) = 0319471c4654c1806dd1516f1fc146b63fb4fe22d2e40238f1f6dc078adb201ae7dd82b07054ed01af861818a64529ed2451ceb60d477ee16ef4528fa2d6d359
Size (priv-1.0-beta2.tar.gz) = 34507 bytes
-SHA1 (patch-aa) = 2a1252d2593333ceb048baa269dbe1b2e9a5d1e4
-SHA1 (patch-ab) = e6f89b30954ac9dbe0243e755287f5f8a37011bd
-SHA1 (patch-priv.c) = 4baea1e9233e3e8d3ac450a6a51fefa622ebed06
+SHA1 (patch-Makefile.in) = 2a1252d2593333ceb048baa269dbe1b2e9a5d1e4
+SHA1 (patch-configure.in) = a1df31e1a3bb64a9a782132566be223eaab1e454
+SHA1 (patch-priv.c) = efcab7c1890bb8be930e4dafb47c31df148d6a6a
+SHA1 (patch-priv.h) = 460670e323e9c14eb55674b2593046900f4455b3
diff --git a/security/priv/patches/patch-aa b/security/priv/patches/patch-Makefile.in
index b123988b0ad..88a9c423bd2 100644
--- a/security/priv/patches/patch-aa
+++ b/security/priv/patches/patch-Makefile.in
@@ -1,4 +1,4 @@
-$NetBSD: patch-aa,v 1.3 2010/02/15 17:06:18 joerg Exp $
+$NetBSD: patch-Makefile.in,v 1.1 2021/02/16 09:42:06 kim Exp $
--- Makefile.in.orig 1997-07-08 06:19:04.000000000 +0000
+++ Makefile.in
diff --git a/security/priv/patches/patch-ab b/security/priv/patches/patch-ab
deleted file mode 100644
index 256c192ad2c..00000000000
--- a/security/priv/patches/patch-ab
+++ /dev/null
@@ -1,17 +0,0 @@
-$NetBSD: patch-ab,v 1.1 2004/03/11 01:41:49 uebayasi Exp $
-
---- priv.h.orig Tue Jul 8 15:19:07 1997
-+++ priv.h Tue Mar 9 00:49:58 2004
-@@ -140,10 +140,10 @@
- #ifndef HAVE_STRERROR
- char *strerror(int errnum);
- #endif
--#ifdef HAVE_STRSPN
-+#ifndef HAVE_STRSPN
- size_t strspn(const char *s, const char *charset);
- #endif
--#ifdef HAVE_STRTOUL
-+#ifndef HAVE_STRTOUL
- unsigned long strtoul(const char *nptr, char **endptr, int base);
- #endif
-
diff --git a/security/priv/patches/patch-configure.in b/security/priv/patches/patch-configure.in
new file mode 100644
index 00000000000..403e233e3c0
--- /dev/null
+++ b/security/priv/patches/patch-configure.in
@@ -0,0 +1,23 @@
+$NetBSD: patch-configure.in,v 1.1 2021/02/16 09:42:06 kim Exp $
+
+Check for setusercontext(3), which is needed for per-user tmp to work.
+
+--- configure.in.orig 1997-07-08 06:19:05.000000000 +0000
++++ configure.in
+@@ -40,13 +40,14 @@ AC_DEFINE_UNQUOTED(PATH_SU, "$SU_PROG")
+
+ dnl Checks for libraries
+ dnl ====================
++AC_SEARCH_LIBS(setusercontext, util)
+
+ dnl Checks for header files
+ dnl =======================
+ AC_HEADER_STDC
+ AC_HEADER_TIME
+-AC_CHECK_HEADERS(limits.h stdarg.h stdlib.h string.h stringlist.h syslog.h \
+- unistd.h sys/syslog.h)
++AC_CHECK_HEADERS(err.h limits.h login_cap.h stdarg.h stdlib.h string.h \
++ stringlist.h syslog.h unistd.h sys/syslog.h)
+
+ dnl Checks for typedefs, structures, and compiler characteristics
+ dnl =============================================================
diff --git a/security/priv/patches/patch-priv.c b/security/priv/patches/patch-priv.c
index 5dcd0985162..88efb1b2e3b 100644
--- a/security/priv/patches/patch-priv.c
+++ b/security/priv/patches/patch-priv.c
@@ -1,10 +1,38 @@
-$NetBSD: patch-priv.c,v 1.1 2021/02/05 13:27:42 nia Exp $
+$NetBSD: patch-priv.c,v 1.2 2021/02/16 09:42:06 kim Exp $
+
+Use setusercontext(3), which is needed for per-user tmp to work.
Do not directly pass user input to a printf function.
--- priv.c.orig 2004-02-09 04:37:07.000000000 +0000
+++ priv.c
-@@ -370,8 +370,8 @@ main(int argc, char **argv, char **envp)
+@@ -318,6 +318,17 @@ main(int argc, char **argv, char **envp)
+ }
+
+ /* Set up the permissions */
++#ifdef HAVE_LOGIN_CAP_H
++ if (setusercontext(NULL, pw, pw->pw_uid, LOGIN_SETGROUP |
++ LOGIN_SETPRIORITY | LOGIN_SETRESOURCES | LOGIN_SETUMASK |
++ LOGIN_SETUSER) != 0) {
++ sverr = errno;
++ syslog(LOG_NOTICE, "%s: not ok: setusercontext failed: %m",
++ myfullname);
++ errno = sverr;
++ err(EXIT_VAL, "setusercontext failed");
++ }
++#else
+ if (setgid(pw->pw_gid) < 0) {
+ sverr = errno;
+ syslog(LOG_NOTICE, "%s: not ok: setgid failed: %m", myfullname);
+@@ -337,6 +348,7 @@ main(int argc, char **argv, char **envp)
+ errno = sverr;
+ err(EXIT_VAL, "setuid failed");
+ }
++#endif
+
+ /* Check for sym-link */
+ if (!(nflags & F_SYMLINK)) {
+@@ -370,8 +382,8 @@ main(int argc, char **argv, char **envp)
}
/* All's well so far, get ready to execute the command. */
diff --git a/security/priv/patches/patch-priv.h b/security/priv/patches/patch-priv.h
new file mode 100644
index 00000000000..c40faa14180
--- /dev/null
+++ b/security/priv/patches/patch-priv.h
@@ -0,0 +1,35 @@
+$NetBSD: patch-priv.h,v 1.1 2021/02/16 09:42:06 kim Exp $
+
+Include login_cap.h for setusercontext(3), which is needed for per-user
+tmp to work.
+
+--- priv.h.orig 1997-07-08 06:19:07.000000000 +0000
++++ priv.h
+@@ -89,6 +89,14 @@
+ # endif
+ #endif
+
++#ifdef HAVE_LOGIN_CAP_H
++# include <login_cap.h>
++#endif
++
++#ifdef HAVE_ERR_H
++# include <err.h>
++#endif
++
+ #define DEFPATH "/bin:/usr/bin"
+ #define SYSLOGNAME "priv" /* name used with syslog */
+ #define LOGBUFSIZ 2048 + 256 /* number of chars to log */
+@@ -140,10 +148,10 @@ char *strsep(char **, const char *);
+ #ifndef HAVE_STRERROR
+ char *strerror(int errnum);
+ #endif
+-#ifdef HAVE_STRSPN
++#ifndef HAVE_STRSPN
+ size_t strspn(const char *s, const char *charset);
+ #endif
+-#ifdef HAVE_STRTOUL
++#ifndef HAVE_STRTOUL
+ unsigned long strtoul(const char *nptr, char **endptr, int base);
+ #endif
+