Commit Graph

1980 Commits

Author SHA1 Message Date
Christian Göttsche
65b5747e32 libpam: cast to unsigned char for character handling function
Character handling functions, like isspace(3), expect a value
representable as unsigned char or equal to EOF.  Otherwise the behavior
is undefined.

See https://wiki.sei.cmu.edu/confluence/display/c/STR37-C.+Arguments+to+character-handling+functions+must+be+representable+as+an+unsigned+char
2023-08-07 10:46:40 +00:00
Christian Göttsche
2770046cd8 conf: cast to unsigned char for character handling function
Character handling functions, like isspace(3), expect a value
representable as unsigned char or equal to EOF.  Otherwise the behavior
is undefined.

See https://wiki.sei.cmu.edu/confluence/display/c/STR37-C.+Arguments+to+character-handling+functions+must+be+representable+as+an+unsigned+char
2023-08-07 10:46:40 +00:00
Christian Göttsche
dc9427961a ci: add GCC 13 job with sanitzers 2023-08-07 12:26:41 +02:00
Christian Göttsche
b2bc6a660a pam_faillock: free handle in test 2023-08-07 12:26:41 +02:00
Christian Göttsche
4e8af9027d pam_start: free handlers on handler init failure
If the pam handlers fail to initialize halfway, clean them up
afterwards.  Since we set the handle to NULL callers can't clean them.
2023-08-07 12:26:41 +02:00
Christian Göttsche
cee08b7a6e tests: free return value of _pam_mkargv()
_pam_mkargv() states that callers should free the returned value since
otherwise the memory gets leaked.
2023-08-07 12:26:41 +02:00
Christian Göttsche
9facab2134 tests: free handles via pam_end()
Destroy the pam handles via pam_end() to release all associated
resources.  This allows to run the test-suite with sanitizers and
validates the resource cleanup in pam_end() and callees.
2023-08-07 12:24:28 +02:00
Steve Grubb
1648734a69 pam_selinux: fix formatting of audit messages
pam_selinux uses audit_log_user_message to write to the audit system.
It does not take an op argument, so you have to add one yourself. Otherwise
the pam_selinux part of the message is lost because it's not in key=value
format.
2023-08-04 21:45:45 +00:00
Steve Grubb
c85513220c pam_faillock: fix formatting of audit messages
pam_faillock uses audit_log_user_message to write to the audit system.
It does not take an op argument, so you have to add one yourself. Otherwise
the pam_faillock part of the message is lost because it's not in key=value
format.

Also, we can't use uid in that event because the kernel already adds that
field. What we normally do is use 'suid' (meaning sender uid) as the
field name.
2023-08-04 21:45:45 +00:00
Thorsten Kukuk
741acf4ff7 pam_access: make non-resolveable hostname a debug output (#590)
* modules/pam_access/pam_access.c (network_netmask_match): Don't print
an error if a string is not resolveable, only a debug message in debug
mode. We even don't know if that entry is for remote logins or not.
2023-08-04 13:46:16 +00:00
Thorsten Kukuk
4ba3105511 pam_access: document IPv6 link-local addresses (#582)
* modules/pam_access/access.conf.5.xml: Add example and note for IPv6
  link-local addresses
* modules/pam_access/access.conf: Add example for IPv6 link-local
  addresses
2023-08-03 17:42:57 +02:00
Julian Kranz
6caedeff52 pam_unix: improve fallback values for "rounds" for yescrypt and blowfish
This change improves the fallback values for the "rounds" parameter for
yescrypt and blowfish by using the smallest reasonable value if the
user sets a too low value and by using the highest reasonable value
if the user sets a too high value.  This better realizes user intent
and is consistent with the approach taken for SHA256.
2023-07-17 07:53:24 +00:00
Iker Pedrosa
45c2c496dc pam_userdb: enable GDBM support
* configure.ac: add `gdbm` option to `enable-db`
* modules/pam_userdb/pam_userdb.c: conditionally provide database access
  depending on the database technology

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2023-07-17 09:53:24 +02:00
Dmitry V. Levin
1fbf123d98 .github: add gcc-13 and clang-15 jobs
* .github/workflows/ci.yml (gcc13-x86_64, clang15-x86_64): New jobs.
(gcc12-x86_64-vendordir): Rename to gcc13-x86_64-vendordir,
replace gcc-12 with gcc-13.
(gcc12-x86_64-openssl): Rename to gcc13-x86_64-openssl,
replace gcc-12 with gcc-13.
(clang14-x86_64-vendordir): Rename to clang15-x86_64-vendordir,
replace clang-14 with clang-15.
(clang14-x86_64-openssl): Rename to clang15-x86_64-openssl,
replace clang-14 with clang-15.
2023-06-07 18:45:22 +00:00
Bernhard Rosenkränzer
b82acc21f1 Fix build if crypt_r isn't available
retval was being defined only in #ifdef HAVE_CRYPT_R, but used
unconditionally.

Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
Fixes: bcba17939e ("modules: make use of secure memory erasure")
2023-06-07 20:45:22 +02:00
Ondrej Sulek
60b8366254 po: update translations using Weblate (Slovak)
Currently translated at 100.0% (101 of 101 strings).

Translate-URL: https://translate.fedoraproject.org/projects/linux-pam/master/sk/
2023-06-06 08:00:00 +00:00
Tobias Stoeckmann
1a734af22a pam_shells: Plug econf memory leak
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2023-05-18 17:55:21 +02:00
Jonathan Krebs
52e49e17ac pam_shells: return PAM_USER_UNKNOWN if getpwnam fails
Until before, in this case PAM_AUTH_ERR was returned. This leads to unknown
users being logged with the unknown username.
Now it resembles the behaviour of other modules like pam_unix in this case.
2023-05-17 20:18:03 +00:00
Pino Toscano
e75e15c7ee pam_xauth: switch away from PATH_MAX
Allocate the path buffer in check_acl() dynamically using asprintf(),
so there is no need to use a PATH_MAX-fixed size buffer. The fallback
PATH_MAX definition is no more needed, thus is dropped.

Make sure that paths too long still result in PAM_SESSION_ERR.
2023-05-17 22:18:03 +02:00
Pino Toscano
2d121ac128 pam_mkhomedir: simplify handling of newsource/newdest
To support OSes without PATH_MAX (which is optional in POSIX), there are
two code paths for the 'newsource' and 'newdest' variables: one using
a PATH_MAX-sized stack buffer, and one using heap allocation. The second
is even more complicated than needed, doing manual calculations and
allocations.

To simplify the code a bit more, easing its maintenance, unify the two
using asprintf() to allocate 'newsource' and 'newdest': the extra
allocation needed should not be an issue, since this code runs in a
separate helper executable.

As additional change for this simplification, remove the reset to the
two variables to NULL right after their free(), which is not needed
since their scopes end.
2023-05-12 04:49:01 +00:00
Pino Toscano
bcd540496d pam_limits: build again on non-Linux OSes
Even if this module is supported officially on Linux, make sure it can
still build fine on non-Linux OSes, to ease its testing/fixing a bit:
- build parse_kernel_limits() and stuff needed for it only on Linux,
  as it is called already only on Linux
- limit the code needed to apply the 'nonewprivs' options to Linux only,
  as it uses a Linux-specific way to set it; add a syslog message for
  other OSes
2023-05-12 04:06:53 +00:00
Violet Purcell
5374f677e4 examples/tty_conv: fix build on musl
termio.h is the old System V version of the interface header, and is
only provided in glibc and dietlibc as far as I can tell.
This fixes it to use the POSIX termios.h instead.
2023-05-12 02:09:07 +00:00
김인수
c46bc41487 po: update translations using Weblate (Korean)
Currently translated at 100.0% (101 of 101 strings).

Translate-URL: https://translate.fedoraproject.org/projects/linux-pam/master/ko/
2023-05-11 05:16:06 +00:00
Dankaházi (ifj.) István
96ee4006b8 po: update translations using Weblate (Hungarian)
Currently translated at 76.2% (77 of 101 strings).

Translate-URL: https://translate.fedoraproject.org/projects/linux-pam/master/hu/
2023-05-11 05:16:06 +00:00
Pino Toscano
5fa961fd3b configure.ac: add --enable-examples option
Allow the user to not build the examples through --disable-examples
(enabled by default); this can be useful:
- when cross-compiling, as the examples are not useful
- in distribution builds, not building stuff that is not used in any
  way
2023-05-11 05:16:06 +00:00
Pino Toscano
b030a05e14 pam_nologin: explicitly fail when nologin path is a directory
On some systems (e.g. GNU/Hurd), read() succeeds on the fd of a
directory; since the module assumes that read() fails (and thus
pam_modutil_read() as well), manually fail in case the open fd refers
to a directory.
2023-05-11 05:16:06 +00:00
Pino Toscano
cbe0839c89 pam_timestamp: do not assume PATH_MAX is defined
PATH_MAX is optional in POSIX, and not defined on GNU/Hurd; hence,
in case it is not defined, define BUFLEN directly to LINE_MAX.
2023-05-11 07:16:06 +02:00
Pino Toscano
4aec21a15e pam_pwhistory: switch away from PATH_MAX
Allocate the buffers dynamically using asprintf(), so there is no need
to use PATH_MAX-fixed size buffers.
2023-05-11 07:15:51 +02:00
Pino Toscano
76acc70921 tests: define PATH_MAX if not available
PATH_MAX is optional in POSIX, and not defined on GNU/Hurd; since these
sources are tests, it is fine to hardcoded a fallback value that allows
the tests to build and run.
2023-05-11 07:12:49 +02:00
Christian Göttsche
bf07335a19 modules: update Linux detection
GCC and Clang only define the macro `linux` when using the GNU dialect
of C (e.g. -std=gnu11 instead of -std=c11).  Since `linux` is also not
in a reserved namespace it might be target of collisions.
Use the canonical macro `__linux__` instead (already used in
pam_limits.c).
2023-05-07 21:10:23 +02:00
Dmitry V. Levin
11583a190b 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 project version, line numbers,
and timestamps.
2023-04-29 11:11:00 +00:00
Dmitry V. Levin
90430edb47 Prepare for 1.5.3 release
* configure.ac (AC_INIT): Raise version to 1.5.3.
* NEWS: Update.
2023-04-29 11:11:00 +00:00
Remus-Gabriel Chelu
4dc0c0fb25 po: update translations using Weblate (Romanian)
Currently translated at 100.0% (101 of 101 strings).

Translate-URL: https://translate.fedoraproject.org/projects/linux-pam/master/ro/
2023-04-23 04:20:48 +00:00
김인수
65fc7b7a05 po: update translations using Weblate (Korean)
Currently translated at 100.0% (101 of 101 strings).

Translate-URL: https://translate.fedoraproject.org/projects/linux-pam/master/ko/
2023-04-23 04:20:47 +00:00
Dmitry V. Levin
057812f2dd pam_succeed_if: do not use the result of keyword substitution for keyword match
* modules/pam_succeed_if/pam_succeed_if.c (evaluate): Do not use the
result of keyword substitution for keyword match.

Resolves: https://github.com/linux-pam/linux-pam/issues/560
2023-04-20 13:10:06 +00:00
Dmitry V. Levin
2a4b23d3ee ci: add --enable-openssl jobs to the ci matrix
Link: https://github.com/linux-pam/linux-pam/pull/550#issuecomment-1490362439
2023-04-20 13:10:06 +00:00
Stefan Schubert
a7e4f035fe build: fix --enable-openssl
* Make.xml.rules.in: Avoid conflicting profile.condition settings.
* configure.ac: Likewise.

Resolves: https://github.com/linux-pam/linux-pam/issues/553
2023-04-20 13:10:06 +00:00
Iker Pedrosa
4bfb0ce61f pam_timestamp: Only build hmacfile when no openssl
* modules/pam_timestamp/Makefile.am: Only build hmacfile target when
openssl isn't enabled.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2023-04-20 13:10:06 +00:00
Luca Boccassi
52c04fea33 man: clarify PAM_DATA_SILENT in pam_set_data.3
pam_end.3 has additional and important information about PAM_DATA_SILENT,
copy it to pam_set_data.3 since that describes the cleanup callback where
it will be set.
2023-04-20 14:10:06 +01:00
Mark Huang
0816a6524b fix a grammar mistake 2023-04-20 14:16:30 +02:00
Thorsten Kukuk
4ce0965653 configure: Disable NIS if header files are missing
configure.ac: Disable NIS if RPC or YP header files are missing
modules/pam_unix/support.c: Use HAVE_NIS to check for header file presence
modules/pam_unix/pam_unix_passwd.c: Use HAVE_NIS, too
2023-04-06 16:05:04 +02:00
Thorsten Kukuk
9c0965b188 doc: Include custom-html.xsl.in and custom-man.xsl.in
doc/Makefile.am: Replace custom-html.xsl and custom-man.xsl with
                 custom-html.xsl.in and custom-man.xsl.in EXTRA_DIST
2023-04-04 19:32:08 +02:00
Dmitry V. Levin
b6011a23d5 treewide: fix unnecessary $ on arithmetic variables
This should fix shellcheck warning SC2004.
2023-03-31 08:00:00 +00:00
Dmitry V. Levin
b7ba550110 pgp.keys.asc: update
* pgp.keys.asc: Replace with the key used to sign v1.5.2.

Resolves: https://github.com/linux-pam/linux-pam/issues/544
2023-03-30 20:00:00 +00:00
Iker Pedrosa
8db48b022b pam_timestamp: fix build failure
bcba17939e started using pam_overwrite_n()
without providing the definition to this function, which causes a build
failure.

modules/pam_timestamp/hmac_openssl_wrapper.c: include pam_inline.h

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2023-03-30 12:53:41 +02:00
A S Alam
fce804e695 po: update translations using Weblate (Punjabi)
Currently translated at 100.0% (101 of 101 strings).

Translate-URL: https://translate.fedoraproject.org/projects/linux-pam/master/pa/
2023-03-14 07:44:41 +00:00
Thorsten Kukuk
34b062d311 manual pages: document usage of $DISPLAY and PAM_TTY
man/pam_item_types_std.inc.xml: In the past, PAM_TTY was used for tty
devices and $DISPLAY variables for X-based applications. With the
introduction of PAM_DISPLAY PAM_TTY should only be used for devices.
2023-03-14 08:44:41 +01:00
Christian Göttsche
f26d873435 libpam: simplify string copying using strdup 2023-03-04 12:03:28 +01:00
Christian Göttsche
bcba17939e modules: make use of secure memory erasure
Use empty initialization of structs to minimize the memset() usage, to
reduce the amount of calls which are not sensitive.

Non trivial changes:

- pam_env:
  * erase environment variables where possible

- pam_exec:
  * erase responce on error
  * erase auth token

- pam_pwhistory:
  * erase buffers containing old passwords

- pam_selinux: skip overwriting data structure consisting of only
  pointers to insensitive data, which also gets free'd afterwards (so
  it currently does not protect against double-free or use-after-free on
  the member pointers)

- pam_unix: erase cipher data in more places

- pam_userdb: erase password hashes
2023-02-28 15:13:15 +01:00
Christian Göttsche
87ff7a12a5 libpamc: make use of secure memory erasure 2023-02-28 15:13:15 +01:00