Commit Graph

2318 Commits

Author SHA1 Message Date
Dmitry V. Levin
45e46fc159 configure.ac: do not use AM_PROG_CC_C_O
According to the GNU Automake manual, this macro is obsolescent,
and its explicit use should no longer be required.

* configure.ac (AM_PROG_CC_C_O): Remove.
2024-08-14 08:00:00 +00:00
Dmitry V. Levin
fed0b59e8a configure.ac: do not use AC_PROG_LN_S
Given that LN_S defined by AC_PROG_LN_S is not used,
there is no point in using this macro.

* configure.ac (AC_PROG_LN_S): Remove.
2024-08-14 08:00:00 +00:00
Dmitry V. Levin
5a2cf804f2 configure.ac: do not use AC_PROG_MAKE_SET
Given that SET_MAKE defined by AC_PROG_MAKE_SET has never been
used directly, and AM_INIT_AUTOMAKE that needs this also calls
AC_PROG_MAKE_SET itself, there is no point in using this macro.

* configure.ac (AC_PROG_MAKE_SET): Remove.
2024-08-14 08:00:00 +00:00
Dmitry V. Levin
6ed459ed94 configure.ac: do not use AC_PROG_GCC_TRADITIONAL
According to the GNU Autoconf manual, this macro is obsolescent,
since current versions of the GNU C compiler fix the header files
automatically when installed.

* configure.ac (AC_PROG_GCC_TRADITIONAL): Remove.
2024-08-14 08:00:00 +00:00
Dmitry V. Levin
d452d787f1 configure.ac: do not use AC_FUNC_MEMCMP
According to the GNU Autoconf manual, this macro is obsolescent,
as current systems have a working 'memcmp'.

* configure.ac (AC_FUNC_MEMCMP): Remove.
2024-08-14 08:00:00 +00:00
Dmitry V. Levin
b21124a5cd configure.ac: do not use AC_C_CONST
According to the GNU Autoconf manual, this macro is obsolescent,
as current C compilers support 'const'.

* configure.ac (AC_C_CONST): Remove.
2024-08-14 08:00:00 +00:00
Dmitry V. Levin
5f42225b3c configure.ac: do not use AC_TYPE_GETGROUPS
Given that GETGROUPS_T defined by AC_TYPE_GETGROUPS has never been
checked, there is no point in using this macro.

* configure.ac (AC_TYPE_GETGROUPS): Remove.
2024-08-14 08:00:00 +00:00
Dmitry V. Levin
6b0ead2c63 configure.ac: do not use AC_STRUCT_TM
Given that TM_IN_SYS_TIME that might be defined by AC_STRUCT_TM
has never been checked, there is no point in using this obsolescent
macro.

* configure.ac (AC_STRUCT_TM): Remove.
2024-08-14 08:00:00 +00:00
Dmitry V. Levin
3fc6e8e548 configure.ac: do not use AC_HEADER_SYS_WAIT
Given that <sys/wait.h> is included unconditionally,
there is no point in using AC_HEADER_SYS_WAIT.

* configure.ac (AC_HEADER_SYS_WAIT): Remove.
2024-08-14 08:00:00 +00:00
Dmitry V. Levin
bb9eb07d02 configure.ac: do not use AC_HEADER_DIRENT
Given that <dirent.h> is included unconditionally,
there is no point in using AC_HEADER_DIRENT.

* configure.ac (AC_HEADER_DIRENT): Remove.
2024-08-14 08:00:00 +00:00
Dmitry V. Levin
7ff048524c configure.ac: do not check for lastlog.h, utmp.h, and utmpx.h
Given that utmp.h is included unconditionally in other modules,
and neither utmpx.h nor lastlog.h is used nowadays, remove obsolete
checks.

* configure.ac (AC_CHECK_HEADERS): Remove lastlog.h, utmp.h, and utmpx.h.
* modules/pam_lastlog/pam_lastlog.c: Include <utmp.h> unconditionally.
2024-08-13 08:00:00 +00:00
Matthew Luckam
83c344ee5a pam_access: support UID and GID in access.conf
Extend access.conf(5) syntax to support UID and GID in addition to
user and group names.

Co-authored-by: blueskycs2c <lili.ding@cs2c.com>
Signed-off-by: Dmitry V. Levin <ldv@strace.io>
Resolves: https://github.com/linux-pam/linux-pam/issues/114
Resolves: https://github.com/linux-pam/linux-pam/pull/186
Resolves: https://github.com/linux-pam/linux-pam/pull/601
2024-08-13 08:00:00 +00:00
Dmitry V. Levin
10071e284e pam_inline.h: introduce zero_extend_signed_to_ull() and sign_extend_unsigned_to_ll()
Import these handy macros from strace project.
2024-08-13 08:00:00 +00:00
Stanislav Brabec
8ae228fa76 libpam_misc: Use ECHOCTL in the terminal input
Use the canonical terminal mode (line mode) and set ECHOCTL to prevent
cursor escape from the login prompt using arrows or escape sequences.

ICANON is the default in most cases anyway. ECHOCTL is default on tty, but
for example not on pty, allowing cursor to escape.

Stanislav Brabec <sbrabec@suse.com>
2024-08-07 08:00:00 +00:00
Firas Khalil Khana
02f451baac configure.ac: fix typo in the help message for --enable-lastlog 2024-08-07 08:00:00 +00:00
Dmitry V. Levin
c8dbebd410 pam_faillock: silence compilation warning
Since audit_log_acct_message() was decorated with warn_unused_result
attribute, compilation of faillock helper produces the following
diagnostics:

    main.c: In function 'do_user':
    main.c:250:25: warning: ignoring return value of 'audit_log_acct_message' declared with attribute 'warn_unused_result' [-Wunused-result]

Given that this helper has never been picky about audit, e.g.
audit_open() errors do not affect its exit status, just silence this
new warning.

* modules/pam_faillock/main.c [HAVE_LIBAUDIT] (do_user): Silence
compilation warning.
2024-07-28 08:00:00 +00:00
Stefan Schubert
fa3295e079 pam_econf_readconfig: add econf_readConfigWithCallback support
Check for econf_readConfigWithCallback() and use it if available.

Co-authored-by: Dmitry V. Levin <ldv@strace.io>
2024-07-02 08:00:00 +00:00
Stefan Schubert
bc46189844 libpam_internal: introduce pam_econf_readconfig
Use this new function instead of econf_readDirs() and
econf_readDirsWithCallback().

Co-authored-by: Dmitry V. Levin <ldv@strace.io>
2024-07-02 08:00:00 +00:00
Egor Ignatov
efa6e33b1d
pam_set_item: disallow setting service to NULL
This also prevents a possible segfault when pam_set_item tries to
convert an empty service_name to lower case.
2024-05-30 14:30:46 +03:00
Christian Göttsche
8562cb1b95 pam_xauth: improve error logging on selabel lookup
Log in case the database could not be initialized.

Include the errno on lookup failure.
2024-05-24 17:39:21 +02:00
Christian Göttsche
5d548fec5a pam_namespace: log getfscreatecon(3) failure
Log in case the current fscreate context could not be retrieved.
2024-05-24 17:38:31 +02:00
Iker Pedrosa
bd2f695b3d pam_namespace: free SELinux context on error path
* modules/pam_namespace/pam_namespace.c (create_polydir) [WITH_SELINUX]:
Free SELinux context in case of an error.

```
Error: RESOURCE_LEAK (CWE-772):
Linux-PAM-1.6.0/modules/pam_namespace/pam_namespace.c:1433: alloc_arg: "getfscreatecon_raw" allocates memory that is stored into "oldcon_raw".
Linux-PAM-1.6.0/modules/pam_namespace/pam_namespace.c:1462: leaked_storage: Variable "oldcon_raw" going out of scope leaks the storage it points to.
1460|               pam_syslog(idata->pamh, LOG_ERR,
1461|                          "Error creating directory %s: %m", dir);
1462|->             return PAM_SESSION_ERR;
1463|       }
1464|
```

Resolves: https://issues.redhat.com/browse/RHEL-36475
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2024-05-23 10:25:09 +00:00
Iker Pedrosa
667204d7e3 pam_namespace: free SELinux context
* modules/pam_namespace/pam_namespace.c [WITH_SELINUX] (form_context):
Free SELinux context before returning.

```
Error: RESOURCE_LEAK (CWE-772):
Linux-PAM-1.6.0/modules/pam_namespace/pam_namespace.c:928: alloc_arg: "getexeccon" allocates memory that is stored into "scon".
Linux-PAM-1.6.0/modules/pam_namespace/pam_namespace.c:1004: leaked_storage: Variable "scon" going out of scope leaks the storage it points to.
1002|           }
1003|           /* Should never get here */
1004|->         return PAM_SUCCESS;
1005|   }
1006|   #endif
```

Resolves: https://issues.redhat.com/browse/RHEL-36475
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2024-05-23 10:25:09 +00:00
Iker Pedrosa
1ca5bfed50 pam_timestamp: close the timestamp file on error path
* modules/pam_timestamp/pam_timestamp.c (pam_sm_authenticate)
[WITH_OPENSSL]: Close the timestamp file if hmac_size returned
an error.

```
Error: RESOURCE_LEAK (CWE-772):
Linux-PAM-1.6.0/modules/pam_timestamp/pam_timestamp.c:450: open_fn: Returning handle opened by "open". [Note: The source code implementation of the function has been overridden by a user model.]
Linux-PAM-1.6.0/modules/pam_timestamp/pam_timestamp.c:450: var_assign: Assigning: "fd" = handle returned from "open(path, 131072)".
Linux-PAM-1.6.0/modules/pam_timestamp/pam_timestamp.c:460: noescape: Resource "fd" is not freed or pointed-to in "fstat".
Linux-PAM-1.6.0/modules/pam_timestamp/pam_timestamp.c:484: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
482|   #ifdef WITH_OPENSSL
483|                   if (hmac_size(pamh, debug, &maclen)) {
484|->                         return PAM_AUTH_ERR;
485|                   }
486|   #else
```

Resolves: https://issues.redhat.com/browse/RHEL-36475
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2024-05-23 10:25:09 +00:00
Iker Pedrosa
d00f6cb366 pam_rootok: close the audit socket on error path
* modules/pam_rootok/pam_rootok.c (log_callback): Close the audit socket
if vasprintf returned an error.

```
Error: RESOURCE_LEAK (CWE-772):
Linux-PAM-1.6.0/modules/pam_rootok/pam_rootok.c:59: open_fn: Returning handle opened by "audit_open".
Linux-PAM-1.6.0/modules/pam_rootok/pam_rootok.c:59: var_assign: Assigning: "audit_fd" = handle returned from "audit_open()".
Linux-PAM-1.6.0/modules/pam_rootok/pam_rootok.c:69: leaked_handle: Handle variable "audit_fd" going out of scope leaks the handle.
67|           va_end(ap);
68|           if (ret < 0) {
69|->                 return 0;
70|           }
71|           audit_log_user_avc_message(audit_fd, AUDIT_USER_AVC, buf, NULL, NULL,
```

Resolves: https://issues.redhat.com/browse/RHEL-36475
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2024-05-23 10:25:09 +00:00
Iker Pedrosa
5eccaf9b34 pam_faillock: close the audit socket after use
* modules/pam_faillock/pam_faillock.c (check_tally): Close the audit
socket when it will no longer be used.

```
Error: RESOURCE_LEAK (CWE-772):
Linux-PAM-1.6.0/modules/pam_faillock/pam_faillock.c:247: open_fn: Returning handle opened by "audit_open".
Linux-PAM-1.6.0/modules/pam_faillock/pam_faillock.c:247: var_assign: Assigning: "audit_fd" = handle returned from "audit_open()".
Linux-PAM-1.6.0/modules/pam_faillock/pam_faillock.c:256: noescape: Resource "audit_fd" is not freed or pointed-to in "audit_log_user_message".
Linux-PAM-1.6.0/modules/pam_faillock/pam_faillock.c:258: leaked_handle: Handle variable "audit_fd" going out of scope leaks the handle.
256|                                   audit_log_user_message(audit_fd, AUDIT_RESP_ACCT_UNLOCK_TIMED, buf,
257|                                           rhost, NULL, tty, 1);
258|->                         }
259|   #endif
260|                           opts->flags |= FAILLOCK_FLAG_UNLOCKED;
```

Resolves: https://issues.redhat.com/browse/RHEL-36475
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2024-05-23 10:24:02 +00:00
Dmitry V. Levin
75292685a6 pam_env: fix error handling in econf_read_file
* modules/pam_env/pam_env.c [USE_ECONF] (econf_read_file): Make sure
the returned array of strings is properly initialized
when econf_getStringValue() fails to return a value.
2024-05-19 15:00:00 +00:00
Dmitry V. Levin
aabd5314a6 pam_env: fix NULL dereference on error path in econf_read_file
* modules/pam_env/pam_env.c [USE_ECONF] (econf_read_file): Handle NULL
value returned by econf_getStringValue().

Resolves: https://github.com/linux-pam/linux-pam/issues/796
2024-05-19 15:00:00 +00:00
Dmitry V. Levin
0f6796ec4c Move all historic changelog files to a top-level ChangeLog.old directory
Move all historic changelog files away to avoid confusion.
2024-05-15 08:00:00 +00:00
Dmitry V. Levin
a7eb114974 build: do not distribute historic changelog files
Since 2011, ChangeLog file is generated from git log history.
ChangeLog-CVS is a historic changelog file that was maintained before
the project was migrated from cvs to git.
CHANGELOG is another historic changelog file that was replaced by
ChangeLog in 2005.
modules/pam_unix/CHANGELOG is the oldest of historic changelog files,
it is not maintained since 1999.

All these historic changelog files are no longer relevant, so they are
no longer included into release tarballs.
2024-05-15 08:00:00 +00:00
Göran Uddeborg
55a20554f9 libpam: make /etc/passwd checks 8 bit clean
libpam/pam_modutil_check_user.c: explicitly convert the character
read from /etc/passwd to type "char" to get the same signedness
as the one compared with. Otherwise the functionality will depend
on the (implementation defined) signedness of "char" on the
platform built for.
2024-05-13 15:45:32 +02:00
Tim Hutt
99888b2566 Fix CHANGELOG encoding
Dag-Erling Smørgrav's name was encoded using some encoding other than
UTF-8 (that line predates the UTF-8 consensus). This changes it to use
UTF-8, so that it renders properly and so that editors that guess the
file is UTF-8 do not get confused about it.
2024-04-25 09:05:28 +01:00
Christoph Anton Mitterer
cec36a8cd2 pam_umask: document details about the GECOS field
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
2024-04-15 08:00:00 +00:00
Christoph Anton Mitterer
ffe8178f7d pam_umask: minor improvements to wording
The previous sentence was strange to read.

Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
2024-04-15 08:00:00 +00:00
Christian Göttsche
42064cdf2b pam_unix: compare password hashes in constant time
Compare the hashes in constant time as a defense-in-depth mechanism,
since performance is not a priority.
2024-04-13 22:02:36 +02:00
Christian Göttsche
c11ccdfad1 libpam: add helper to compare strings in constant time
Add a helper function to compare two strings for equality, that performs
the same amount of operations based on the first argument, regardless of
the length of the second argument, or the position of the first
difference.
This can be used as defense-in-depth mitigation against timing attacks
of password comparisons.
2024-04-13 22:02:13 +02:00
Dmitry V. Levin
9438e084e2 Prepare for 1.6.1 release
* configure.ac (AC_INIT): Raise version to 1.6.1.
* po/Linux-PAM.pot (Project-Id-Version): Likewise.
* NEWS: Update.

Resolves: https://github.com/linux-pam/linux-pam/issues/774
2024-04-09 08:00:00 +00:00
Dmitry V. Levin
d46fb554da po: update .pot and .po files
Regenerate po/Linux-PAM.pot and po/*.po using "make -C po update-po"
command.  This essentially updates the line numbers and timestamps.
2024-04-08 08:04:00 +00:00
Dmitry V. Levin
ff2d131534 configure.ac: do not check for headers that are included unconditionally
* configure.ac (AC_HEADER_STDC, AC_HEADER_TIME): Remove.
(AC_CHECK_HEADERS): Remove fcntl.h, limits.h, malloc.h, sys/file.h,
sys/ioctl.h, sys/time.h, syslog.h, net/if.h, termio.h, unistd.h,
sys/fsuid.h, and inittypes.h.
2024-04-07 08:00:00 +00:00
Dmitry V. Levin
7b87f9fe57 doc: fix pam_get_data manual regarding PAM_NO_MODULE_DATA return value
pam_get_data manual page used to claim that PAM_NO_MODULE_DATA is
returned not only when no module specific data is present but also
when there is a corresponding data entry with NULL value.

As this claim is in contradiction with the implementation and with the
pam manual page, fix pam_get_data manual page.

* doc/man/pam_get_data.3.xml (PAM_NO_MODULE_DATA): Sync with
the implementation and with the pam manual page.

Resolves: https://github.com/linux-pam/linux-pam/pull/780
2024-04-03 08:00:00 +00:00
Dmitry V. Levin
8c3b9402fe tests: check pam_get_data PAM_NO_MODULE_DATA return value semantics
* tests/tst-pam_get_data.c (main): Check that PAM_NO_MODULE_DATA is
returned by pam_get_data iff the corresponding data is not present.
2024-04-03 08:00:00 +00:00
Dmitry V. Levin
f6fe98be3d tests: cleanup tst-pam_get_data to use test_assert.h framework
* tests/tst-pam_get_data.c: Include "test_assert.h".
(main): Rewrite using ASSERT_EQ() and ASSERT_NE() macros.
2024-04-03 08:00:00 +00:00
Marco Trevisan (Treviño)
09aa326d42 tests: Add some pam_get_data tests
The function was not tested, so add some basic testing to it.
2024-04-03 08:00:00 +00:00
Aura Herrero Ruiz
88eccaedc6 doc: fix uses of non-neutral gender pronouns 2024-04-02 14:00:00 +00:00
Dmitry V. Levin
ce8aa213b0 pam_start.c: do not call bindtextdomain() unless nls is enabled
Call bindtextdomain() only when both the function is available and
the build is configured with --enable-nls.

* libpam/pam_start.c (_pam_start_internal): Guard bindtextdomain()
invocation with ENABLE_NLS.

Complements: v1.6.0~244 ("pam_start.c: call bindtextdomain() to expose Linux-PAM locales")
Resolves: https://github.com/linux-pam/linux-pam/pull/773
2024-03-31 08:00:00 +00:00
Thorsten Kukuk
78e3988dd3 pam_env: document when the module is executed
Document that pam_env.so is only called by pam_setcred() and
not by pam_authenticate() when added to the auth stack.

Resolves: https://github.com/linux-pam/linux-pam/issues/680
Signed-off-by: Thorsten Kukuk <kukuk@suse.com>
2024-03-31 08:00:00 +00:00
Alan01
140b407ed4 po: update da.po 2024-03-31 08:00:00 +00:00
Andika Triwidada
4376df5256 po: update translations using Weblate (Indonesian)
Currently translated at 87.1% (88 of 101 strings).

Translate-URL: https://translate.fedoraproject.org/projects/linux-pam/master/id/
2024-03-31 08:00:00 +00:00
Sergei Trofimovich
8d0c575336 pam_unix: allow empty passwords with non-empty hashes
Before the change pam_unix has different behaviours for a user with
empty password for these two `/etc/shadow` entries:

    nulloktest:$6$Yy4ty2jJ$bsVQWo8qlXC6UHq1/qTC3UR60ZJKmKApJ3Wj7DreAy8FxlVKtlDnplFQ7jMLVlDqordE7e4t49GvTb.aI59TP0:1::::::
    nulloktest::1::::::

The entry with a hash was rejected and the entry without was accepted.

The rejection happened because 9e74e90147 "pam_unix: avoid determining
if user exists" introduced the following rejection check (slightly
simplified):

        ...
        } else if (p[0] == '\0' && nullok) {
                if (hash[0] != '\0') {
                        retval = PAM_AUTH_ERR;
                }

We should not reject the user with a hash assuming it's non-empty.
The change does that by pushing empty password check into
`verify_pwd_hash()`.

`NixOS` generates such hashed entries for empty passwords as if they
were non-empty using the following perl code:

    sub hashPassword {
        my ($password) = @_;
        my $salt = "";
        my @chars = ('.', '/', 0..9, 'A'..'Z', 'a'..'z');
        $salt .= $chars[rand 64] for (1..8);
        return crypt($password, '$6$' . $salt . '$');
    }

Resolves: https://github.com/linux-pam/linux-pam/issues/758
Fixes: 9e74e90147 "pam_unix: avoid determining if user exists"
Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
2024-03-29 07:09:08 +00:00
Shaleen Bathla
db25d975c8 pam_limits: fix potential use-after-free of pl->conf_file
When limits.d is processed, pl->conf_file consequently points to
elements of filename_list array which are freed later even though
it can still be used in the logging.

Signed-off-by: Shaleen Bathla <shaleen.bathla@oracle.com>
Co-authored-by: Dmitry V. Levin <ldv@strace.io>
Fixes: f6b973b922 ("Add support for limits.d directory to pam_limits")
2024-03-04 09:01:16 +00:00