package/linux-pam: enable back on musl
authorFabrice Fontaine <fontaine.fabrice@gmail.com>
Mon, 20 Apr 2020 13:48:45 +0000 (15:48 +0200)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Tue, 21 Apr 2020 06:30:46 +0000 (08:30 +0200)
Add two upstream patches to fix build on musl

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/linux-pam/0003-Replace-strndupa-with-strncpy.patch [new file with mode: 0644]
package/linux-pam/0004-build-ignore-pam_lastlog-when-logwtmp-is-not-available.patch [new file with mode: 0644]
package/linux-pam/Config.in
package/nodm/Config.in
package/openvmtools/Config.in
package/python-pam/Config.in
package/rsh-redone/Config.in
package/util-linux/Config.in

diff --git a/package/linux-pam/0003-Replace-strndupa-with-strncpy.patch b/package/linux-pam/0003-Replace-strndupa-with-strncpy.patch
new file mode 100644 (file)
index 0000000..9793f8c
--- /dev/null
@@ -0,0 +1,75 @@
+From 91d4678388b2a7d768ee2ec8cc569e11fc223ffd Mon Sep 17 00:00:00 2001
+From: Rosen Penev <rosenp@gmail.com>
+Date: Sun, 15 Jul 2018 20:43:44 -0700
+Subject: [PATCH] Replace strndupa with strncpy
+
+glibc only. A static string is better.
+
+Signed-off-by: Rosen Penev <rosenp@gmail.com>
+[Retrieved from:
+https://github.com/linux-pam/linux-pam/commit/91d4678388b2a7d768ee2ec8cc569e11fc223ffd]
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+---
+ modules/pam_exec/pam_exec.c | 31 +++++++++++--------------------
+ 1 file changed, 11 insertions(+), 20 deletions(-)
+
+diff --git a/modules/pam_exec/pam_exec.c b/modules/pam_exec/pam_exec.c
+index 52dc6818..6cad16e4 100644
+--- a/modules/pam_exec/pam_exec.c
++++ b/modules/pam_exec/pam_exec.c
+@@ -102,7 +102,7 @@ call_exec (const char *pam_type, pam_handle_t *pamh,
+   int use_stdout = 0;
+   int optargc;
+   const char *logfile = NULL;
+-  const char *authtok = NULL;
++  char authtok[PAM_MAX_RESP_SIZE] = {};
+   pid_t pid;
+   int fds[2];
+   int stdout_fds[2];
+@@ -180,12 +180,12 @@ call_exec (const char *pam_type, pam_handle_t *pamh,
+             if (resp)
+               {
+                 pam_set_item (pamh, PAM_AUTHTOK, resp);
+-                authtok = strndupa (resp, PAM_MAX_RESP_SIZE);
++                strncpy (authtok, resp, sizeof(authtok) - 1);
+                 _pam_drop (resp);
+               }
+           }
+         else
+-          authtok = strndupa (void_pass, PAM_MAX_RESP_SIZE);
++          strncpy (authtok, void_pass, sizeof(authtok) - 1);
+         if (pipe(fds) != 0)
+           {
+@@ -225,23 +225,14 @@ call_exec (const char *pam_type, pam_handle_t *pamh,
+       if (expose_authtok) /* send the password to the child */
+       {
+-        if (authtok != NULL)
+-          {            /* send the password to the child */
+-            if (debug)
+-              pam_syslog (pamh, LOG_DEBUG, "send password to child");
+-            if (write(fds[1], authtok, strlen(authtok)+1) == -1)
+-              pam_syslog (pamh, LOG_ERR,
+-                          "sending password to child failed: %m");
+-            authtok = NULL;
+-          }
+-        else
+-          {
+-            if (write(fds[1], "", 1) == -1)   /* blank password */
+-              pam_syslog (pamh, LOG_ERR,
+-                          "sending password to child failed: %m");
+-          }
+-        close(fds[0]);       /* close here to avoid possible SIGPIPE above */
+-        close(fds[1]);
++        if (debug)
++          pam_syslog (pamh, LOG_DEBUG, "send password to child");
++        if (write(fds[1], authtok, strlen(authtok)) == -1)
++          pam_syslog (pamh, LOG_ERR,
++                            "sending password to child failed: %m");
++
++          close(fds[0]);       /* close here to avoid possible SIGPIPE above */
++          close(fds[1]);
+       }
+       if (use_stdout)
diff --git a/package/linux-pam/0004-build-ignore-pam_lastlog-when-logwtmp-is-not-available.patch b/package/linux-pam/0004-build-ignore-pam_lastlog-when-logwtmp-is-not-available.patch
new file mode 100644 (file)
index 0000000..8ff0ac1
--- /dev/null
@@ -0,0 +1,60 @@
+From 73bf6d25ddb7a2cb73bceda3d880174b1d1e4a26 Mon Sep 17 00:00:00 2001
+From: Yousong Zhou <yszhou4tech@gmail.com>
+Date: Wed, 17 Jun 2015 21:18:05 +0800
+Subject: [PATCH] build: ignore pam_lastlog when logwtmp is not available.
+
+* configure.ac: check logwtmp and set COND_BUILD_PAM_LASTLOG
+* modules/pam_lastlog/Makefile.am: check COND_BUILD_PAM_LASTLOG
+
+Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
+[Retrieved from:
+https://github.com/linux-pam/linux-pam/commit/73bf6d25ddb7a2cb73bceda3d880174b1d1e4a26]
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+---
+ configure.ac        | 2 ++
+ modules/Makefile.am | 8 ++++++--
+ 2 files changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 69748614..4d1b1965 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -534,8 +534,10 @@ AC_CHECK_FUNCS(getutent_r getpwnam_r getpwuid_r getgrnam_r getgrgid_r getspnam_r
+ AC_CHECK_FUNCS(getgrouplist getline getdelim)
+ AC_CHECK_FUNCS(inet_ntop inet_pton innetgr)
+ AC_CHECK_FUNCS([ruserok_af ruserok], [break])
++AC_CHECK_FUNCS([logwtmp])
+ AM_CONDITIONAL([COND_BUILD_PAM_RHOSTS], [test "$ac_cv_func_ruserok_af" = yes -o "$ac_cv_func_ruserok" = yes])
++AM_CONDITIONAL([COND_BUILD_PAM_LASTLOG], [test "$ac_cv_func_logwtmp" = yes])
+ AC_CHECK_FUNCS(unshare, [UNSHARE=yes], [UNSHARE=no])
+ AM_CONDITIONAL([HAVE_UNSHARE], [test "$UNSHARE" = yes])
+diff --git a/modules/Makefile.am b/modules/Makefile.am
+index 9ad26a9b..b98dc5c8 100644
+--- a/modules/Makefile.am
++++ b/modules/Makefile.am
+@@ -6,9 +6,13 @@ if COND_BUILD_PAM_RHOSTS
+       MAYBE_PAM_RHOSTS = pam_rhosts
+ endif
++if COND_BUILD_PAM_LASTLOG
++      MAYBE_PAM_LASTLOG = pam_lastlog
++endif
++
+ SUBDIRS := pam_access pam_cracklib pam_debug pam_deny pam_echo \
+       pam_env pam_exec pam_faildelay pam_filter pam_ftp \
+-      pam_group pam_issue pam_keyinit pam_lastlog pam_limits \
++      pam_group pam_issue pam_keyinit pam_limits \
+       pam_listfile pam_localuser pam_loginuid pam_mail \
+       pam_mkhomedir pam_motd pam_namespace pam_nologin \
+       pam_permit pam_pwhistory pam_rootok pam_securetty \
+@@ -16,7 +20,7 @@ SUBDIRS := pam_access pam_cracklib pam_debug pam_deny pam_echo \
+       pam_succeed_if pam_tally pam_tally2 pam_time pam_timestamp \
+       pam_tty_audit pam_umask \
+       pam_unix pam_userdb pam_warn pam_wheel pam_xauth \
+-      $(MAYBE_PAM_RHOSTS)
++      $(MAYBE_PAM_RHOSTS) $(MAYBE_PAM_LASTLOG)
+ CLEANFILES = *~
index 1396549366e7ea3355dbd0b56373ae8028d0c99c..84aee5cdd44db1b5b2eae0579002625b781dc792 100644 (file)
@@ -2,7 +2,6 @@ config BR2_PACKAGE_LINUX_PAM
        bool "linux-pam"
        depends on (BR2_ENABLE_LOCALE && BR2_USE_WCHAR)
        depends on !BR2_STATIC_LIBS
-       depends on !BR2_TOOLCHAIN_USES_MUSL
        depends on BR2_USE_MMU # fork()
        select BR2_PACKAGE_FLEX
        help
@@ -11,6 +10,6 @@ config BR2_PACKAGE_LINUX_PAM
 
          http://linux-pam.org
 
-comment "linux-pam needs a uClibc or glibc toolchain w/ wchar, locale, dynamic library"
+comment "linux-pam needs a toolchain w/ wchar, locale, dynamic library"
        depends on !(BR2_ENABLE_LOCALE && BR2_USE_WCHAR) \
-               || BR2_STATIC_LIBS || BR2_TOOLCHAIN_USES_MUSL
+               || BR2_STATIC_LIBS
index 38171e8dcfe28cb33f9c8f358eb5427ccb5a3455..2dd6f1e1cff5aab0a6da6bfab8082562fc168aa8 100644 (file)
@@ -3,7 +3,6 @@ config BR2_PACKAGE_NODM
        depends on BR2_PACKAGE_XORG7
        depends on (BR2_ENABLE_LOCALE && BR2_USE_WCHAR) # linux-pam
        depends on !BR2_STATIC_LIBS # linux-pam
-       depends on !BR2_TOOLCHAIN_USES_MUSL # linux-pam
        depends on BR2_USE_MMU # linux-pam
        select BR2_PACKAGE_XLIB_LIBX11
        select BR2_PACKAGE_LINUX_PAM
@@ -18,7 +17,7 @@ config BR2_PACKAGE_NODM
 
          https://github.com/spanezz/nodm/
 
-comment "nodm needs a glibc or uClibc toolchain w/ wchar, locale, dynamic library"
+comment "nodm needs a toolchain w/ wchar, locale, dynamic library"
        depends on BR2_PACKAGE_XORG7
        depends on !(BR2_ENABLE_LOCALE && BR2_USE_WCHAR) \
-               || BR2_STATIC_LIBS || BR2_TOOLCHAIN_USES_MUSL
+               || BR2_STATIC_LIBS
index 1a077a2a475a838bc75b2af967862008d83ed432..a50b6b9b3e7829ba2f3f6db2e3ee387eeb439c02 100644 (file)
@@ -27,13 +27,12 @@ config BR2_PACKAGE_OPENVMTOOLS_PAM
        # linux-pam needs locale and wchar, but we already have this
        # dependency on the main symbol, above.
        depends on !BR2_STATIC_LIBS
-       depends on !BR2_TOOLCHAIN_USES_MUSL # linux-pam
        select BR2_PACKAGE_LINUX_PAM
        help
          Support for PAM in openvmtools
 
-comment "PAM support needs a glibc toolchain w/ dynamic library"
-       depends on BR2_STATIC_LIBS || BR2_TOOLCHAIN_USES_MUSL
+comment "PAM support needs a toolchain w/ dynamic library"
+       depends on BR2_STATIC_LIBS
 
 config BR2_PACKAGE_OPENVMTOOLS_RESOLUTIONKMS
        bool "resolutionkms support"
index 02865d00d64323019afe6fd142d3414558f9017e..92ba105ebf885e3f16da971184f397df2c06df15 100644 (file)
@@ -1,7 +1,6 @@
-comment "python-pam needs a uClibc or glibc toolchain w/ wchar, locale, dynamic library"
+comment "python-pam needs a toolchain w/ wchar, locale, dynamic library"
        depends on BR2_PACKAGE_PYTHON
-       depends on !BR2_ENABLE_LOCALE || !BR2_USE_WCHAR || BR2_STATIC_LIBS || \
-               BR2_TOOLCHAIN_USES_MUSL
+       depends on !BR2_ENABLE_LOCALE || !BR2_USE_WCHAR || BR2_STATIC_LIBS
 
 config BR2_PACKAGE_PYTHON_PAM
        bool "python-pam"
@@ -10,7 +9,6 @@ config BR2_PACKAGE_PYTHON_PAM
        depends on BR2_USE_WCHAR # linux-pam
        depends on BR2_USE_MMU # linux-pam
        depends on !BR2_STATIC_LIBS # linux-pam
-       depends on !BR2_TOOLCHAIN_USES_MUSL # linux-pam
        select BR2_PACKAGE_LINUX_PAM
        help
          PAM (Pluggable Authentication Module) bindings for Python.
index 1335c85739401f4cc76ed8e723a847fe0f7bb101..5647d7edefdbe29a315d8f133e8aacbcfe3208bb 100644 (file)
@@ -17,13 +17,12 @@ config BR2_PACKAGE_RSH_REDONE_RLOGIND
        bool "rlogind"
        depends on !BR2_STATIC_LIBS
        depends on BR2_ENABLE_LOCALE && BR2_USE_WCHAR
-       depends on !BR2_TOOLCHAIN_USES_MUSL # linux-pam
        depends on BR2_USE_MMU # linux-pam
        select BR2_PACKAGE_LINUX_PAM
 
-comment "rlogind needs a uClibc or glibc toolchain w/ wchar, locale, dynamic library"
+comment "rlogind needs a toolchain w/ wchar, locale, dynamic library"
        depends on !(BR2_ENABLE_LOCALE && BR2_USE_WCHAR) \
-               || BR2_STATIC_LIBS || BR2_TOOLCHAIN_USES_MUSL
+               || BR2_STATIC_LIBS
 
 config BR2_PACKAGE_RSH_REDONE_RSH
        bool "rsh"
@@ -32,12 +31,11 @@ config BR2_PACKAGE_RSH_REDONE_RSHD
        bool "rshd"
        depends on BR2_ENABLE_LOCALE && BR2_USE_WCHAR
        depends on !BR2_STATIC_LIBS
-       depends on !BR2_TOOLCHAIN_USES_MUSL # linux-pam
        depends on BR2_USE_MMU # linux-pam
        select BR2_PACKAGE_LINUX_PAM
 
-comment "rshd needs a uClibc or glibc toolchain w/ wchar, locale, dynamic library"
+comment "rshd needs a toolchain w/ wchar, locale, dynamic library"
        depends on !(BR2_ENABLE_LOCALE && BR2_USE_WCHAR) \
-               || BR2_STATIC_LIBS || BR2_TOOLCHAIN_USES_MUSL
+               || BR2_STATIC_LIBS
 
 endif
index 996f0cd7fa992f9475130a8875afcdbeb7dc988c..aa3c1a5f76b4454e086dee1ca973b065c947056b 100644 (file)
@@ -84,15 +84,14 @@ config BR2_PACKAGE_UTIL_LINUX_CHFN_CHSH
        bool "chfn/chsh"
        depends on (BR2_ENABLE_LOCALE && BR2_USE_WCHAR) # linux-pam
        depends on !BR2_STATIC_LIBS
-       depends on !BR2_TOOLCHAIN_USES_MUSL # linux-pam
        depends on BR2_USE_MMU # linux-pam
        select BR2_PACKAGE_LINUX_PAM
        help
          Change login shell, real user name and information
 
-comment "chfn/chsh needs a uClibc or glibc toolchain w/ wchar, locale, dynamic library"
+comment "chfn/chsh needs a toolchain w/ wchar, locale, dynamic library"
        depends on !(BR2_ENABLE_LOCALE && BR2_USE_WCHAR) \
-               || BR2_STATIC_LIBS || BR2_TOOLCHAIN_USES_MUSL
+               || BR2_STATIC_LIBS
 
 config BR2_PACKAGE_UTIL_LINUX_CHMEM
        bool "chmem"