From 3534af1fbfdc57f0cc02962a71dddfde87fad2f8 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Tue, 11 Aug 2020 16:38:34 -0700 Subject: Drop patches to implement "nullok_secure" option for pam_unix. Closes: #674857, #936071. --- debian/changelog | 2 + .../054_pam_security_abstract_securetty_handling | 199 ------------------ debian/patches-applied/055_pam_unix_nullok_secure | 223 --------------------- debian/patches-applied/series | 2 - 4 files changed, 2 insertions(+), 424 deletions(-) delete mode 100644 debian/patches-applied/054_pam_security_abstract_securetty_handling delete mode 100644 debian/patches-applied/055_pam_unix_nullok_secure (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 314502cc..ebfde748 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ pam (1.4.0-1) UNRELEASED; urgency=medium * New upstream release. Closes: #948188. - Stop using obsoleted selinux headers. Closes: #956355. + * Drop patches to implement "nullok_secure" option for pam_unix. + Closes: #674857, #936071, LP: #1860826. -- Steve Langasek Tue, 11 Aug 2020 14:58:13 -0700 diff --git a/debian/patches-applied/054_pam_security_abstract_securetty_handling b/debian/patches-applied/054_pam_security_abstract_securetty_handling deleted file mode 100644 index 96222710..00000000 --- a/debian/patches-applied/054_pam_security_abstract_securetty_handling +++ /dev/null @@ -1,199 +0,0 @@ -Description: extract the securetty logic for use with the "nullok_secure" option - introduced in the "055_pam_unix_nullok_secure" patch. - -Index: pam/modules/pam_securetty/pam_securetty.c -=================================================================== ---- pam.orig/modules/pam_securetty/pam_securetty.c -+++ pam/modules/pam_securetty/pam_securetty.c -@@ -1,7 +1,5 @@ - /* pam_securetty module */ - --#define SECURETTY_FILE "/etc/securetty" --#define TTY_PREFIX "/dev/" - #define CMDLINE_FILE "/proc/cmdline" - #define CONSOLEACTIVE_FILE "/sys/class/tty/console/active" - -@@ -40,6 +38,9 @@ - #include - #include - -+extern int _pammodutil_tty_secure(const pam_handle_t *pamh, -+ const char *uttyname); -+ - #define PAM_DEBUG_ARG 0x0001 - #define PAM_NOCONSOLE_ARG 0x0002 - -@@ -73,11 +74,7 @@ - const char *username; - const char *uttyname; - const void *void_uttyname; -- char ttyfileline[256]; -- char ptname[256]; -- struct stat ttyfileinfo; - struct passwd *user_pwd; -- FILE *ttyfile; - - /* log a trail for debugging */ - if (ctrl & PAM_DEBUG_ARG) { -@@ -105,50 +102,7 @@ - return PAM_SERVICE_ERR; - } - -- /* The PAM_TTY item may be prefixed with "/dev/" - skip that */ -- if (strncmp(TTY_PREFIX, uttyname, sizeof(TTY_PREFIX)-1) == 0) { -- uttyname += sizeof(TTY_PREFIX)-1; -- } -- -- if (stat(SECURETTY_FILE, &ttyfileinfo)) { -- pam_syslog(pamh, LOG_NOTICE, "Couldn't open %s: %m", SECURETTY_FILE); -- return PAM_SUCCESS; /* for compatibility with old securetty handling, -- this needs to succeed. But we still log the -- error. */ -- } -- -- if ((ttyfileinfo.st_mode & S_IWOTH) || !S_ISREG(ttyfileinfo.st_mode)) { -- /* If the file is world writable or is not a -- normal file, return error */ -- pam_syslog(pamh, LOG_ERR, -- "%s is either world writable or not a normal file", -- SECURETTY_FILE); -- return PAM_AUTH_ERR; -- } -- -- ttyfile = fopen(SECURETTY_FILE,"r"); -- if (ttyfile == NULL) { /* Check that we opened it successfully */ -- pam_syslog(pamh, LOG_ERR, "Error opening %s: %m", SECURETTY_FILE); -- return PAM_SERVICE_ERR; -- } -- -- if (isdigit(uttyname[0])) { -- snprintf(ptname, sizeof(ptname), "pts/%s", uttyname); -- } else { -- ptname[0] = '\0'; -- } -- -- retval = 1; -- -- while ((fgets(ttyfileline, sizeof(ttyfileline)-1, ttyfile) != NULL) -- && retval) { -- if (ttyfileline[strlen(ttyfileline) - 1] == '\n') -- ttyfileline[strlen(ttyfileline) - 1] = '\0'; -- -- retval = ( strcmp(ttyfileline, uttyname) -- && (!ptname[0] || strcmp(ptname, uttyname)) ); -- } -- fclose(ttyfile); -+ retval = _pammodutil_tty_secure(pamh, uttyname); - - if (retval && !(ctrl & PAM_NOCONSOLE_ARG)) { - FILE *cmdlinefile; -Index: pam/modules/pam_securetty/tty_secure.c -=================================================================== ---- /dev/null -+++ pam/modules/pam_securetty/tty_secure.c -@@ -0,0 +1,90 @@ -+/* -+ * A function to determine if a particular line is in /etc/securetty -+ */ -+ -+ -+#define SECURETTY_FILE "/etc/securetty" -+#define TTY_PREFIX "/dev/" -+ -+/* This function taken out of pam_securetty by Sam Hartman -+ * */ -+/* -+ * by Elliot Lee , Red Hat Software. -+ * July 25, 1996. -+ * Slight modifications AGM. 1996/12/3 -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+extern int _pammodutil_tty_secure(const pam_handle_t *pamh, -+ const char *uttyname); -+ -+int _pammodutil_tty_secure(const pam_handle_t *pamh, const char *uttyname) -+{ -+ int retval = PAM_AUTH_ERR; -+ char ttyfileline[256]; -+ char ptname[256]; -+ struct stat ttyfileinfo; -+ FILE *ttyfile; -+ /* The PAM_TTY item may be prefixed with "/dev/" - skip that */ -+ if (strncmp(TTY_PREFIX, uttyname, sizeof(TTY_PREFIX)-1) == 0) -+ uttyname += sizeof(TTY_PREFIX)-1; -+ -+ if (stat(SECURETTY_FILE, &ttyfileinfo)) { -+ pam_syslog(pamh, LOG_NOTICE, "Couldn't open %s: %m", -+ SECURETTY_FILE); -+ return PAM_SUCCESS; /* for compatibility with old securetty handling, -+ this needs to succeed. But we still log the -+ error. */ -+ } -+ -+ if ((ttyfileinfo.st_mode & S_IWOTH) || !S_ISREG(ttyfileinfo.st_mode)) { -+ /* If the file is world writable or is not a -+ normal file, return error */ -+ pam_syslog(pamh, LOG_ERR, -+ "%s is either world writable or not a normal file", -+ SECURETTY_FILE); -+ return PAM_AUTH_ERR; -+ } -+ -+ ttyfile = fopen(SECURETTY_FILE,"r"); -+ if(ttyfile == NULL) { /* Check that we opened it successfully */ -+ pam_syslog(pamh, LOG_ERR, "Error opening %s: %m", SECURETTY_FILE); -+ return PAM_SERVICE_ERR; -+ } -+ -+ if (isdigit(uttyname[0])) { -+ snprintf(ptname, sizeof(ptname), "pts/%s", uttyname); -+ } else { -+ ptname[0] = '\0'; -+ } -+ -+ retval = 1; -+ -+ while ((fgets(ttyfileline,sizeof(ttyfileline)-1, ttyfile) != NULL) -+ && retval) { -+ if(ttyfileline[strlen(ttyfileline) - 1] == '\n') -+ ttyfileline[strlen(ttyfileline) - 1] = '\0'; -+ retval = ( strcmp(ttyfileline,uttyname) -+ && (!ptname[0] || strcmp(ptname, uttyname)) ); -+ } -+ fclose(ttyfile); -+ -+ if(retval) { -+ retval = PAM_AUTH_ERR; -+ } -+ -+ return retval; -+} -Index: pam/modules/pam_securetty/Makefile.am -=================================================================== ---- pam.orig/modules/pam_securetty/Makefile.am -+++ pam/modules/pam_securetty/Makefile.am -@@ -24,6 +24,10 @@ - securelib_LTLIBRARIES = pam_securetty.la - pam_securetty_la_LIBADD = $(top_builddir)/libpam/libpam.la - -+pam_securetty_la_SOURCES = \ -+ pam_securetty.c \ -+ tty_secure.c -+ - if ENABLE_REGENERATE_MAN - noinst_DATA = README - README: pam_securetty.8.xml diff --git a/debian/patches-applied/055_pam_unix_nullok_secure b/debian/patches-applied/055_pam_unix_nullok_secure deleted file mode 100644 index 8a8cfdd7..00000000 --- a/debian/patches-applied/055_pam_unix_nullok_secure +++ /dev/null @@ -1,223 +0,0 @@ -Debian patch to add a new 'nullok_secure' option to pam_unix, which -accepts users with null passwords only when the applicant is connected -from a tty listed in /etc/securetty. - -Authors: Sam Hartman , - Steve Langasek - -Upstream status: not yet submitted - -Index: pam/modules/pam_unix/support.c -=================================================================== ---- pam.orig/modules/pam_unix/support.c -+++ pam/modules/pam_unix/support.c -@@ -183,13 +183,22 @@ - /* now parse the arguments to this module */ - - for (; argc-- > 0; ++argv) { -+ int sl; - - D(("pam_unix arg: %s", *argv)); - - for (j = 0; j < UNIX_CTRLS_; ++j) { -- if (unix_args[j].token -- && !strncmp(*argv, unix_args[j].token, strlen(unix_args[j].token))) { -- break; -+ if (unix_args[j].token) { -+ sl = strlen(unix_args[j].token); -+ if (unix_args[j].token[sl-1] == '=') { -+ /* exclude argument from comparison */ -+ if (!strncmp(*argv, unix_args[j].token, sl)) -+ break; -+ } else { -+ /* compare full strings */ -+ if (!strcmp(*argv, unix_args[j].token)) -+ break; -+ } - } - } - -@@ -558,6 +567,7 @@ - /* fork */ - child = fork(); - if (child == 0) { -+ int nullok = off(UNIX__NONULL, ctrl); - static char *envp[] = { NULL }; - const char *args[] = { NULL, NULL, NULL, NULL }; - -@@ -587,7 +597,17 @@ - /* exec binary helper */ - args[0] = CHKPWD_HELPER; - args[1] = user; -- if (off(UNIX__NONULL, ctrl)) { /* this means we've succeeded */ -+ if (on(UNIX_NULLOK_SECURE, ctrl)) { -+ const void *uttyname; -+ retval = pam_get_item(pamh, PAM_TTY, &uttyname); -+ if (retval != PAM_SUCCESS || uttyname == NULL -+ || _pammodutil_tty_secure(pamh, (const char *)uttyname) != PAM_SUCCESS) -+ { -+ nullok = 0; -+ } -+ } -+ -+ if (nullok) { - args[2]="nullok"; - } else { - args[2]="nonull"; -@@ -672,6 +692,17 @@ - if (on(UNIX__NONULL, ctrl)) - return 0; /* will fail but don't let on yet */ - -+ if (on(UNIX_NULLOK_SECURE, ctrl)) { -+ int retval2; -+ const void *uttyname; -+ retval2 = pam_get_item(pamh, PAM_TTY, &uttyname); -+ if (retval2 != PAM_SUCCESS || uttyname == NULL) -+ return 0; -+ -+ if (_pammodutil_tty_secure(pamh, (const char *)uttyname) != PAM_SUCCESS) -+ return 0; -+ } -+ - /* UNIX passwords area */ - - retval = get_pwd_hash(pamh, name, &pwd, &salt); -@@ -758,7 +789,8 @@ - } - } - } else { -- retval = verify_pwd_hash(p, salt, off(UNIX__NONULL, ctrl)); -+ retval = verify_pwd_hash(p, salt, -+ _unix_blankpasswd(pamh, ctrl, name)); - } - - if (retval == PAM_SUCCESS) { -Index: pam/modules/pam_unix/support.h -=================================================================== ---- pam.orig/modules/pam_unix/support.h -+++ pam/modules/pam_unix/support.h -@@ -99,8 +99,10 @@ - #define UNIX_NO_PASS_EXPIRY 29 /* Don't check for password expiration if not used for authentication */ - #define UNIX_DES 30 /* DES, default */ - #define UNIX_OBSCURE_CHECKS 31 /* enable obscure checks on passwords */ -+#define UNIX_NULLOK_SECURE 32 /* NULL passwords allowed only on secure ttys */ -+ - /* -------------- */ --#define UNIX_CTRLS_ 32 /* number of ctrl arguments defined */ -+#define UNIX_CTRLS_ 33 /* number of ctrl arguments defined */ - - #define UNIX_DES_CRYPT(ctrl) (off(UNIX_MD5_PASS,ctrl)&&off(UNIX_BIGCRYPT,ctrl)&&off(UNIX_SHA256_PASS,ctrl)&&off(UNIX_SHA512_PASS,ctrl)&&off(UNIX_BLOWFISH_PASS,ctrl)) - -@@ -118,7 +120,7 @@ - /* UNIX_AUTHTOK_TYPE */ {"authtok_type=", _ALL_ON_, 0x40, 0}, - /* UNIX__PRELIM */ {NULL, _ALL_ON_^(0x180), 0x80, 0}, - /* UNIX__UPDATE */ {NULL, _ALL_ON_^(0x180), 0x100, 0}, --/* UNIX__NONULL */ {NULL, _ALL_ON_, 0x200, 0}, -+/* UNIX__NONULL */ {NULL, _ALL_ON_^(0x10000000), 0x200, 0}, - /* UNIX__QUIET */ {NULL, _ALL_ON_, 0x400, 0}, - /* UNIX_USE_AUTHTOK */ {"use_authtok", _ALL_ON_, 0x800, 0}, - /* UNIX_SHADOW */ {"shadow", _ALL_ON_, 0x1000, 0}, -@@ -141,6 +143,7 @@ - /* UNIX_NO_PASS_EXPIRY */ {"no_pass_expiry", _ALL_ON_, 0x10000000, 0}, - /* UNIX_DES */ {"des", _ALL_ON_^(0x2C22000), 0, 1}, - /* UNIX_OBSCURE_CHECKS */ {"obscure", _ALL_ON_, 0x20000000, 0}, -+/* UNIX_NULLOK_SECURE */ {"nullok_secure", _ALL_ON_^(0x200), 0x40000000, 0}, - }; - - #define UNIX_DEFAULTS (unix_args[UNIX__NONULL].flag) -@@ -174,6 +177,9 @@ - ,const char *data_name - ,const void **pass); - -+extern int _pammodutil_tty_secure(const pam_handle_t *pamh, -+ const char *uttyname); -+ - extern int _unix_run_verify_binary(pam_handle_t *pamh, - unsigned int ctrl, const char *user, int *daysleft); - #endif /* _PAM_UNIX_SUPPORT_H */ -Index: pam/modules/pam_unix/Makefile.am -=================================================================== ---- pam.orig/modules/pam_unix/Makefile.am -+++ pam/modules/pam_unix/Makefile.am -@@ -30,7 +30,8 @@ - pam_unix_la_LDFLAGS += -Wl,--version-script=$(srcdir)/../modules.map - endif - pam_unix_la_LIBADD = $(top_builddir)/libpam/libpam.la \ -- @LIBCRYPT@ @LIBSELINUX@ @TIRPC_LIBS@ @NSL_LIBS@ -+ @LIBCRYPT@ @LIBSELINUX@ @TIRPC_LIBS@ @NSL_LIBS@ \ -+ ../pam_securetty/tty_secure.lo - - securelib_LTLIBRARIES = pam_unix.la - -Index: pam/modules/pam_unix/README -=================================================================== ---- pam.orig/modules/pam_unix/README -+++ pam/modules/pam_unix/README -@@ -67,7 +67,16 @@ - - The default action of this module is to not permit the user access to a - service if their official password is blank. The nullok argument overrides -- this default. -+ this default and allows any user with a blank password to access the -+ service. -+ -+nullok_secure -+ -+ The default action of this module is to not permit the user access to a -+ service if their official password is blank. The nullok_secure argument -+ overrides this default and allows any user with a blank password to access -+ the service as long as the value of PAM_TTY is set to one of the values -+ found in /etc/securetty. - - try_first_pass - -Index: pam/modules/pam_unix/pam_unix.8 -=================================================================== ---- pam.orig/modules/pam_unix/pam_unix.8 -+++ pam/modules/pam_unix/pam_unix.8 -@@ -92,7 +92,14 @@ - .RS 4 - The default action of this module is to not permit the user access to a service if their official password is blank\&. The - \fBnullok\fR --argument overrides this default\&. -+argument overrides this default and allows any user with a blank password to access the service\&. -+.RE -+.PP -+\fBnullok_secure\fR -+.RS 4 -+The default action of this module is to not permit the user access to a service if their official password is blank\&. The -+\fBnullok_secure\fR -+argument overrides this default and allows any user with a blank password to access the service as long as the value of PAM_TTY is set to one of the values found in /etc/securetty\&. - .RE - .PP - \fBtry_first_pass\fR -Index: pam/modules/pam_unix/pam_unix.8.xml -=================================================================== ---- pam.orig/modules/pam_unix/pam_unix.8.xml -+++ pam/modules/pam_unix/pam_unix.8.xml -@@ -159,7 +159,24 @@ - - The default action of this module is to not permit the - user access to a service if their official password is blank. -- The argument overrides this default. -+ The argument overrides this default -+ and allows any user with a blank password to access the -+ service. -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ The default action of this module is to not permit the -+ user access to a service if their official password is blank. -+ The argument overrides this -+ default and allows any user with a blank password to access -+ the service as long as the value of PAM_TTY is set to one of -+ the values found in /etc/securetty. - - - diff --git a/debian/patches-applied/series b/debian/patches-applied/series index d5318db2..4e56e9ce 100644 --- a/debian/patches-applied/series +++ b/debian/patches-applied/series @@ -14,8 +14,6 @@ do_not_check_nis_accidentally hurd_no_setfsuid 040_pam_limits_log_failure 045_pam_dispatch_jump_is_ignore -054_pam_security_abstract_securetty_handling -055_pam_unix_nullok_secure cve-2010-4708.patch PAM-manpage-section update-motd -- cgit v1.2.3