diff -ru -x Makefile -x autom4te.cache -x config.h -x config.h.in -x 'config.h.in~' -x config.log -x config.status -x configure priv-1.0-beta2.orig/configure.in priv-1.0-beta2/configure.in --- priv-1.0-beta2.orig/configure.in 1997-07-08 09:19:05.000000000 +0300 +++ priv-1.0-beta2/configure.in 2020-10-22 00:26:22.154975620 +0300 @@ -40,13 +40,14 @@ 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 -ru -x Makefile -x autom4te.cache -x config.h -x config.h.in -x 'config.h.in~' -x config.log -x config.status -x configure priv-1.0-beta2.orig/priv.c priv-1.0-beta2/priv.c --- priv-1.0-beta2.orig/priv.c 2004-02-09 06:37:07.000000000 +0200 +++ priv-1.0-beta2/priv.c 2020-10-22 00:45:12.008980777 +0300 @@ -318,6 +318,17 @@ } /* 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 @@ errno = sverr; err(EXIT_VAL, "setuid failed"); } +#endif /* Check for sym-link */ if (!(nflags & F_SYMLINK)) { diff -ru -x Makefile -x autom4te.cache -x config.h -x config.h.in -x 'config.h.in~' -x config.log -x config.status -x configure priv-1.0-beta2.orig/priv.h priv-1.0-beta2/priv.h --- priv-1.0-beta2.orig/priv.h 1997-07-08 09:19:07.000000000 +0300 +++ priv-1.0-beta2/priv.h 2020-10-22 00:26:45.589106034 +0300 @@ -89,6 +89,14 @@ # endif #endif +#ifdef HAVE_LOGIN_CAP_H +# include +#endif + +#ifdef HAVE_ERR_H +# include +#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 @@ #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