]> git.ipfire.org Git - thirdparty/shadow.git/log
thirdparty/shadow.git
3 years agoREADME: update content and format 447/head
Iker Pedrosa [Fri, 19 Nov 2021 11:22:05 +0000 (12:22 +0100)] 
README: update content and format

* Change to markdown format
* Include an introduction
* Remove the commit mailing list from the contacts
* Add the IRC channel to the contacts
* Move 'S/Key' section to doc/README.skey
* Move authors and maintainers to AUTHORS.md

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agoMerge pull request #435 from freedge/groupdelcore
Serge Hallyn [Thu, 18 Nov 2021 16:30:46 +0000 (10:30 -0600)] 
Merge pull request #435 from freedge/groupdelcore

groupdel: fix SIGSEGV when passwd does not exist

3 years agoMerge pull request #436 from ikerexxe/getsubids
Serge Hallyn [Thu, 18 Nov 2021 13:32:10 +0000 (07:32 -0600)] 
Merge pull request #436 from ikerexxe/getsubids

getsubids: system binary for user's sub*ids

3 years agoREADME: add myself to the contributors list 436/head
Iker Pedrosa [Wed, 10 Nov 2021 09:04:12 +0000 (10:04 +0100)] 
README: add myself to the contributors list

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agogetsubids: system binary for user's sub*ids
Iker Pedrosa [Wed, 10 Nov 2021 08:54:59 +0000 (09:54 +0100)] 
getsubids: system binary for user's sub*ids

Rename list_subid_ranges to getsubids to provide a system binary to
check the sub*ids of a user. The intention is to provide this binary
with any distribution that includes the subid feature, so that system
administrators can check the subid ranges of a given user.

Finally, add a man page to explain the behaviour of getsubids.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1980780

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agoMerge pull request #437 from ikerexxe/newgrp_segfault
Serge Hallyn [Wed, 17 Nov 2021 14:18:13 +0000 (08:18 -0600)] 
Merge pull request #437 from ikerexxe/newgrp_segfault

newgrp: fix segmentation fault

3 years agoMerge pull request #439 from ikerexxe/useradd_skel_fix
Serge Hallyn [Wed, 17 Nov 2021 14:17:34 +0000 (08:17 -0600)] 
Merge pull request #439 from ikerexxe/useradd_skel_fix

useradd: change SELinux labels for home files

3 years agoMerge pull request #442 from rbalint/fix-no-passwd-help
Serge Hallyn [Wed, 17 Nov 2021 14:15:04 +0000 (08:15 -0600)] 
Merge pull request #442 from rbalint/fix-no-passwd-help

Fix typo in passwd --help's Norvegian translation

3 years agoMerge pull request #445 from ikerexxe/pwck_segfault
Serge Hallyn [Wed, 17 Nov 2021 14:14:22 +0000 (08:14 -0600)] 
Merge pull request #445 from ikerexxe/pwck_segfault

pwck: fix segfault when calling fprintf()

3 years agopwck: fix segfault when calling fprintf() 445/head
Iker Pedrosa [Mon, 15 Nov 2021 11:40:15 +0000 (12:40 +0100)] 
pwck: fix segfault when calling fprintf()

As shadow_logfd variable is not set at the beginning of the program if
something fails and fprintf() is called a segmentation fault happens.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2021339

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agoFix typo in passwd --help's Norvegian translation 442/head
Balint Reczey [Sun, 14 Nov 2021 11:50:53 +0000 (12:50 +0100)] 
Fix typo in passwd --help's Norvegian translation

Thanks to Tollef Fog Heen for the bug report at https://bugs.debian.org/949862

3 years agouseradd: change SELinux labels for home files 439/head
Iker Pedrosa [Fri, 12 Nov 2021 14:23:30 +0000 (15:23 +0100)] 
useradd: change SELinux labels for home files

Change SELinux labels for files copied from the skeleton directory to
the home directory.

This could cause gnome's graphical user adding to fail without copying
the full skeleton files.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2022658

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agonewgrp: fix segmentation fault 437/head
Iker Pedrosa [Wed, 10 Nov 2021 11:02:04 +0000 (12:02 +0100)] 
newgrp: fix segmentation fault

Fix segmentation fault in newgrp when xgetspnam() returns a NULL value
that is immediately freed.

The error was committed in
https://github.com/shadow-maint/shadow/commit/e65cc6aebcb4132fa413f00a905216a5b35b3d57

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2019553

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agogroupdel: fix SIGSEGV when passwd does not exist 435/head
François Rigault [Mon, 1 Nov 2021 12:54:25 +0000 (13:54 +0100)] 
groupdel: fix SIGSEGV when passwd does not exist

When using groupdel with a prefix, groupdel will attempt to read a
passwd file to look for any user in the group. When the file does not
exist it cores with segmentation fault.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1986111

3 years agoMerge pull request #423 from lrh2000/su-fix-sigkill
Serge Hallyn [Sun, 31 Oct 2021 17:36:03 +0000 (12:36 -0500)] 
Merge pull request #423 from lrh2000/su-fix-sigkill

su: Fix never alarmed SIGKILL when session terminates

3 years agoMerge pull request #432 from galaxy4public/tcb-missing-chmod
Serge Hallyn [Sat, 30 Oct 2021 16:02:12 +0000 (11:02 -0500)] 
Merge pull request #432 from galaxy4public/tcb-missing-chmod

Add missing chmod() for shadowtcb_move()

3 years agoMerge pull request #433 from stoeckmann/hushed
Serge Hallyn [Sat, 30 Oct 2021 14:34:55 +0000 (09:34 -0500)] 
Merge pull request #433 from stoeckmann/hushed

Handle malformed lines in hushlogins file.

3 years agoHandle malformed lines in hushlogins file. 433/head
Tobias Stoeckmann [Fri, 29 Oct 2021 17:44:46 +0000 (19:44 +0200)] 
Handle malformed lines in hushlogins file.

If a line in hushlogins file, e.g. /etc/hushlogins, starts with
'\0', then current code performs an out of boundary write.
If the line lacks a newline at the end, then another character is
overridden.

With strcspn both cases are solved.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 years agoAdd missing chmod() 432/head
(GalaxyMaster) [Thu, 28 Oct 2021 00:16:59 +0000 (11:16 +1100)] 
Add missing chmod()

During shadowtcb_move() the directory is temporarily changed to be
owned by root:root with permissions 0700.  After the change is done,
the ownership and permissions were supposed to be restored.  The
call for chown() was there, but the chmod() call was missing.  This
resulted in the broken TCB functionality.  The added chmod() fixes
the issue.

3 years agoMerge pull request #430 from galaxy4public/libsubid-static
Serge Hallyn [Wed, 27 Oct 2021 13:31:23 +0000 (08:31 -0500)] 
Merge pull request #430 from galaxy4public/libsubid-static

Fixes the linking issues when libsubid is static and linked to

3 years agoFixes the linking issues when libsubid is static and linked to 430/head
(GalaxyMaster) [Wed, 27 Oct 2021 09:14:42 +0000 (20:14 +1100)] 
Fixes the linking issues when libsubid is static and linked to
binaries that also define the Prog and shadow_logfd variables.

3 years agoMerge pull request #422 from ikerexxe/home_selinux_user
Serge Hallyn [Wed, 27 Oct 2021 01:08:21 +0000 (20:08 -0500)] 
Merge pull request #422 from ikerexxe/home_selinux_user

Create the home and mail directories with SELinux user label

3 years agoAdd Christian Brauner to SECURITY.md
Serge Hallyn [Mon, 25 Oct 2021 19:26:37 +0000 (14:26 -0500)] 
Add Christian Brauner to SECURITY.md

Signed-off-by: Serge Hallyn <serge@hallyn.com>
3 years agosemanage: close the selabel handle 422/head
Iker Pedrosa [Fri, 8 Oct 2021 11:13:13 +0000 (13:13 +0200)] 
semanage: close the selabel handle

Close the selabel handle to update the file_context. This means that the
file_context will be remmaped and used by selabel_lookup() to return
the appropriate context to label the home folder.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1993081

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agouseradd: create directories after the SELinux user
Iker Pedrosa [Fri, 8 Oct 2021 11:09:59 +0000 (13:09 +0200)] 
useradd: create directories after the SELinux user

Create the home and mail folders after the SELinux user has been set for
the added user. This will allow the folders to be created with the
SELinux user label.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agosu: Fix never alarmed SIGKILL when session terminates 423/head
Ruihan Li [Sat, 9 Oct 2021 11:54:36 +0000 (19:54 +0800)] 
su: Fix never alarmed SIGKILL when session terminates

The buggy code was introduced nearly 5 years ago at the
commit 08fd4b69e84364677a10e519ccb25b71710ee686. The
desired behavior is that SIGKILL will be sent to the
child if it does not exit within 2 seconds after it
receives SIGTERM. However, SIGALRM is masked while
waiting for the child so it cannot wake the program
up after 2 seconds to send SIGKILL.

An example shows the buggy behavior, which exists in
Ubuntu 18.04 LTS (with login 1:4.5-1ubuntu2).
```bash
user1@localhost:~$ su user2 -c '
_term() {
  echo SIGTERM received
}
trap _term TERM

while true; do
  sleep 1
  echo still alive
done'
Password:
still alive

Session terminated, terminating shell...Terminated
SIGTERM received
still alive
still alive
still alive
still alive
```
(SIGTERM is sent in another user1's terminal by
executing `killall su`.)

Here is the desired behavior, which shows what the
commit fixes.
```bash
user1@localhost:~$ su user2 -c '
_term() {
  echo SIGTERM received
}
trap _term TERM

while true; do
  sleep 1
  echo still alive
done'
Password:
still alive

Session terminated, terminating shell...Terminated
SIGTERM received
still alive
still alive
 ...killed.
user1@localhost:~$ echo $?
255
```

3 years agoCreate SECURITY.md
Serge Hallyn [Sat, 23 Oct 2021 14:34:48 +0000 (09:34 -0500)] 
Create SECURITY.md

Barebones to unblock current reporters.

3 years agoMerge pull request #426 from hallyn/2021-10-15/man
Serge Hallyn [Wed, 20 Oct 2021 20:16:06 +0000 (15:16 -0500)] 
Merge pull request #426 from hallyn/2021-10-15/man

3 years agomanpages: fix 'File Formats and Conversions" 426/head
Serge Hallyn [Fri, 15 Oct 2021 21:28:12 +0000 (16:28 -0500)] 
manpages: fix 'File Formats and Conversions"

Closes #416

Signed-off-by: Serge Hallyn <serge@hallyn.com>
3 years agoinitial github actions attempt
Serge Hallyn [Sun, 10 Oct 2021 20:10:57 +0000 (15:10 -0500)] 
initial github actions attempt

Closes #415

3 years agoAdded a new configurable LOG_INIT to useradd
Andy Zaugg [Tue, 21 Sep 2021 03:42:21 +0000 (20:42 -0700)] 
Added a new configurable LOG_INIT to useradd

In some circumstances I want the default behaviour of useradd to
not add user entries to the lastlog and faillog databases. Allowing
this options behaviour to be controlled by the config file
/etc/default/useradd.

3 years agoAdded documentation around CREATE_MAIL_SPOOL
Andy Zaugg [Tue, 21 Sep 2021 03:41:50 +0000 (20:41 -0700)] 
Added documentation around CREATE_MAIL_SPOOL

Adding documentation aroud the parameter CREATE_MAIL_SPOOL in the
/etc/default/useradd file

3 years agoMerge pull request #412 from ljmf00/fix-trailing-whitespaces
Serge Hallyn [Mon, 27 Sep 2021 15:12:24 +0000 (10:12 -0500)] 
Merge pull request #412 from ljmf00/fix-trailing-whitespaces

treewide: remove trailing whitespaces

3 years agoMerge pull request #417 from jubalh/doublefree
Serge Hallyn [Mon, 27 Sep 2021 15:10:22 +0000 (10:10 -0500)] 
Merge pull request #417 from jubalh/doublefree

Only free sgent if it was initialized

3 years agoMerge pull request #420 from AZaugg/issue419
Serge Hallyn [Mon, 27 Sep 2021 13:48:24 +0000 (08:48 -0500)] 
Merge pull request #420 from AZaugg/issue419

Fix parentheses in configure.ac

3 years agoFix parentheses in configure.ac 420/head
Andy Zaugg [Wed, 22 Sep 2021 04:51:10 +0000 (21:51 -0700)] 
Fix parentheses in configure.ac

Resolving issue https://github.com/shadow-maint/shadow/issues/419

3 years agoOnly free sgent if it was initialized 417/head
Michael Vetter [Mon, 20 Sep 2021 09:04:50 +0000 (11:04 +0200)] 
Only free sgent if it was initialized

`sgent` is only initialized in `get_group()` if `is_shadowgrp` is true.
So we should also only attempt to free it if this is actually the case.

Can otherwise lead to:
```
free() double free detected in tcache 2 (gpasswd)
```

3 years agoMerge pull request #414 from Frans-Spiesschaert/new_dutch_po_branch
Serge Hallyn [Tue, 14 Sep 2021 15:01:17 +0000 (10:01 -0500)] 
Merge pull request #414 from Frans-Spiesschaert/new_dutch_po_branch

updated Dutch translation

3 years agoupdated Dutch translation 414/head
Frans Spiesschaert [Mon, 13 Sep 2021 19:05:45 +0000 (21:05 +0200)] 
updated Dutch translation

3 years agotreewide: remove trailing whitespaces 412/head
Luís Ferreira [Mon, 13 Sep 2021 16:23:17 +0000 (17:23 +0100)] 
treewide: remove trailing whitespaces

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
3 years agoMerge pull request #405 from a1346054/master
Serge Hallyn [Mon, 13 Sep 2021 15:57:38 +0000 (10:57 -0500)] 
Merge pull request #405 from a1346054/master

Minor cleanups

3 years agoMerge pull request #411 from ljmf00/ignore-check-subid
Serge Hallyn [Mon, 13 Sep 2021 15:37:59 +0000 (10:37 -0500)] 
Merge pull request #411 from ljmf00/ignore-check-subid

git: ignore generated check_subid_range

3 years agogit: ignore generated check_subid_range 411/head
Luís Ferreira [Mon, 13 Sep 2021 15:17:49 +0000 (16:17 +0100)] 
git: ignore generated check_subid_range

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
3 years agofix spelling 405/head
a1346054 [Mon, 13 Sep 2021 15:11:40 +0000 (15:11 +0000)] 
fix spelling

3 years agoMerge pull request #410 from paulmenzel/use-https-urls-in-readme
Serge Hallyn [Sun, 12 Sep 2021 15:50:09 +0000 (10:50 -0500)] 
Merge pull request #410 from paulmenzel/use-https-urls-in-readme

Use HTTPS URLs in README, where possible

3 years agoREADME: Use HTTPS URLs where possible 410/head
Paul Menzel [Sun, 12 Sep 2021 10:06:02 +0000 (12:06 +0200)] 
README: Use HTTPS URLs where possible

The GitHub and Debian permanently moved to HTTPS URLs and redirect
there. The Gentoo URL does not redirect to HTTPS, but still use it to
address certain kinds of attacks. Lastly, the NetBSD URL is only
available using HTTP.

3 years agofix some shellcheck-identified issues in scripts
a1346054 [Wed, 18 Aug 2021 18:21:06 +0000 (18:21 +0000)] 
fix some shellcheck-identified issues in scripts

3 years agouse a geographically close URL
a1346054 [Wed, 18 Aug 2021 18:07:50 +0000 (18:07 +0000)] 
use a geographically close URL

3 years agofix spelling and unify whitespace
a1346054 [Wed, 18 Aug 2021 18:06:02 +0000 (18:06 +0000)] 
fix spelling and unify whitespace

3 years agoRevert "useradd.c:fix memleaks of grp"
Serge Hallyn [Sun, 15 Aug 2021 00:37:24 +0000 (19:37 -0500)] 
Revert "useradd.c:fix memleaks of grp"

In some cases, the value which was being freed is not actually
safe to free.

Closes #394

This reverts commit c44b71cec25d60efc51aec9de3abce1f6efbfcf5.

3 years agoMerge pull request #400 from floppym/sha-rounds
Serge Hallyn [Sun, 15 Aug 2021 00:29:54 +0000 (19:29 -0500)] 
Merge pull request #400 from floppym/sha-rounds

libmisc: fix default value in SHA_get_salt_rounds()

3 years agoMerge pull request #401 from hallyn/2021-08-14/dropxml2po
Serge Hallyn [Sun, 15 Aug 2021 00:28:18 +0000 (19:28 -0500)] 
Merge pull request #401 from hallyn/2021-08-14/dropxml2po

man/po/Makefile.in: switch from xml2po to itstool

3 years agoMerge pull request #403 from hallyn/2021-08-14/fixnosubuidbuild
Serge Hallyn [Sun, 15 Aug 2021 00:28:07 +0000 (19:28 -0500)] 
Merge pull request #403 from hallyn/2021-08-14/fixnosubuidbuild

useradd.c: Fix undeclared subuid_count when not using subids

3 years agouseradd.c: Fix undeclared subuid_count when not using subids 403/head
Serge Hallyn [Sun, 15 Aug 2021 00:25:51 +0000 (19:25 -0500)] 
useradd.c: Fix undeclared subuid_count when not using subids

subuid_count won't get used by usr_update(), but since we're passing it
as an argument we have to make sure it's always defined.  So just define
it as pre-set to 0.

Closes #402

Signed-off-by: Serge Hallyn <serge@hallyn.com>
3 years agoman/po/Makefile.in: switch from xml2po to itstool 401/head
Serge Hallyn [Sat, 14 Aug 2021 19:24:03 +0000 (14:24 -0500)] 
man/po/Makefile.in: switch from xml2po to itstool

xml2po is deprecated.  We've previously replaced xml2po with
itstool in man/generate_translations.mak, but there was still
an instance of it that only is exercised for 'make dist'.
Update that one.  Now 'make dist' succeeds on a ubuntu focal
or newer host where xml2po is not available.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
3 years agolibmisc: fix default value in SHA_get_salt_rounds() 400/head
Mike Gilbert [Sat, 14 Aug 2021 17:24:34 +0000 (13:24 -0400)] 
libmisc: fix default value in SHA_get_salt_rounds()

If SHA_CRYPT_MIN_ROUNDS and SHA_CRYPT_MAX_ROUNDS are both unspecified,
use SHA_ROUNDS_DEFAULT.

Previously, the code fell through, calling shadow_random(-1, -1). This
ultimately set rounds = (unsigned long) -1, which ends up being a very
large number! This then got capped to SHA_ROUNDS_MAX later in the
function.

The new behavior matches BCRYPT_get_salt_rounds().

Bug: https://bugs.gentoo.org/808195
Fixes: https://github.com/shadow-maint/shadow/issues/393
3 years agoMerge pull request #399 from ikerexxe/useradd_empty_subid_range
Serge Hallyn [Sat, 14 Aug 2021 14:23:26 +0000 (09:23 -0500)] 
Merge pull request #399 from ikerexxe/useradd_empty_subid_range

useradd: avoid generating an empty subid range

3 years agouseradd: avoid generating an empty subid range 399/head
Iker Pedrosa [Tue, 10 Aug 2021 07:07:03 +0000 (09:07 +0200)] 
useradd: avoid generating an empty subid range

useradd generates an empty subid range when adding a new user. This is
caused because there are two variables, one local and the other one
global, that have a very similar name and they are used indistinctly in
the code. The local variable loads the SUB_*ID_COUNT configuration from
the login.defs file, while the global variable, which holds a value of
0, is used to generate the subid range. Causing the empty subid range
problem.

I've merged the two variables in the local one and removed the global
variable. I prefer to do it this way to reduce the scope of it but I'm
open to doing it the other way round.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1990653

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 years agoMerge pull request #397 from ikerexxe/revert_local_groups_check
Serge Hallyn [Wed, 4 Aug 2021 15:41:56 +0000 (10:41 -0500)] 
Merge pull request #397 from ikerexxe/revert_local_groups_check

usermod: allow all group types with -G option

4 years agoMerge pull request #398 from Dzejrou/master
Serge Hallyn [Wed, 4 Aug 2021 15:38:30 +0000 (10:38 -0500)] 
Merge pull request #398 from Dzejrou/master

passwd: handle NULL pw_passwd when printing password status

4 years agoMerge pull request #396 from floppym/libcrack
Serge Hallyn [Wed, 4 Aug 2021 15:37:08 +0000 (10:37 -0500)] 
Merge pull request #396 from floppym/libcrack

libsubid: fix build with libcrack

4 years agoMerge pull request #395 from ikerexxe/downstream_4_9
Serge Hallyn [Wed, 4 Aug 2021 15:36:44 +0000 (10:36 -0500)] 
Merge pull request #395 from ikerexxe/downstream_4_9

Makefile: include libeconf dependency in new*idmap

4 years agopasswd: handle NULL pw_passwd when printing password status 398/head
Jaroslav Jindrak [Tue, 3 Aug 2021 18:03:46 +0000 (20:03 +0200)] 
passwd: handle NULL pw_passwd when printing password status

When the -S and -a options are used for passwd to list the status
of all passwords, there is a chance the pw_passwd field of struct
passwd will be NULL. This can be due to 'files compat' being set
for passwd in /etc/nsswitch.conf and the usage of some features
not available in the 'files' mode (e.g. a plus sign at the start
of a line).

Example:

germ161:~ # grep passwd /etc/nsswitch.conf
passwd: files compat
germ161:~ # rpm -qa shadow
shadow-4.2.1-34.20.x86_64
germ161:~ # grep passwd /etc/nsswitch.conf
passwd: files compat
germ161:~ # grep + /etc/passwd
+@nisgroup
germ161:~ # passwd -S -a > /dev/null
Segmentation fault (core dumped)

With this commit:

germ161:~ # passwd -S -a > /dev/null
passwd: malformed password data obtained for user +@nisgroup

4 years agousermod: allow all group types with -G option 397/head
Iker Pedrosa [Tue, 3 Aug 2021 06:57:20 +0000 (08:57 +0200)] 
usermod: allow all group types with -G option

The only way of removing a group from the supplementary list is to use
-G option, and list all groups that the user is a member of except for
the one that wants to be removed. The problem lies when there's a user
that contains both local and remote groups, and the group to be removed
is a local one. As we need to include the remote group with -G option
the command will fail.

This reverts commit 140510de9de4771feb3af1d859c09604043a4c9b. This way,
it would be possible to remove the remote groups from the supplementary
list.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1967641
Resolves: https://github.com/shadow-maint/shadow/issues/338

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 years agolibsubid: fix build with libcrack 396/head
Mike Gilbert [Mon, 2 Aug 2021 15:51:44 +0000 (11:51 -0400)] 
libsubid: fix build with libcrack

Fixes a link failure:

  ../libsubid/.libs/libsubid.so: undefined reference to `FascistCheck'

Bug: https://bugs.gentoo.org/806124
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
4 years agoMakefile: include libeconf dependency in new*idmap 395/head
Iker Pedrosa [Mon, 2 Aug 2021 13:54:20 +0000 (15:54 +0200)] 
Makefile: include libeconf dependency in new*idmap

new*idmap has a dependency with libeconf since commit
c464ec55709dc931ba2f24073b8b1a86d5209ab0. I'm just adding it to the
Makefile to be able to compile in distributions that include libeconf.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 years agoMerge pull request #392 from hallyn/2021-07-25/useradd-defaults
Christian Brauner [Mon, 26 Jul 2021 08:20:56 +0000 (10:20 +0200)] 
Merge pull request #392 from hallyn/2021-07-25/useradd-defaults

useradd: create /etc/default saving defaults.

4 years agouseradd: create /etc/default saving defaults. 392/head
Serge Hallyn [Sun, 25 Jul 2021 21:19:56 +0000 (16:19 -0500)] 
useradd: create /etc/default saving defaults.

Since bbf4b79, we stopped shipping /etc/default/useradd, and therefore
install of shadow does not auto-create /etc/default.  So when useradd
tries to save a new default, it needs to create the directory.

Closes #390.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
4 years agoMerge pull request #391 from hallyn/2021-07-25/static
Serge Hallyn [Sun, 25 Jul 2021 19:01:11 +0000 (14:01 -0500)] 
Merge pull request #391 from hallyn/2021-07-25/static

Respect --enable-static=no in libsubid

4 years agoRespect --enable-static=no in libsubid 391/head
Serge Hallyn [Sun, 25 Jul 2021 17:18:02 +0000 (17:18 +0000)] 
Respect --enable-static=no in libsubid

libsubid's Makefile.am was always setting enable-shared in its LDFLAGS.
Do that only if not building static.

Closes #387

Signed-off-by: Serge Hallyn <shallyn@cisco.com>
4 years agoMerge pull request #388 from hallyn/2021-07-23/outoftreebuild
Serge Hallyn [Fri, 23 Jul 2021 23:11:51 +0000 (18:11 -0500)] 
Merge pull request #388 from hallyn/2021-07-23/outoftreebuild

Fix out of tree builds with respect to libsubid includes

4 years agoFix out of tree builds with respect to libsubid includes 388/head
Serge Hallyn [Fri, 23 Jul 2021 22:51:13 +0000 (17:51 -0500)] 
Fix out of tree builds with respect to libsubid includes

There's a better way to do this, and I hope to clean that up,
but this fixes out of tree builds for me right now.

Closes #386

Signed-off-by: Serge Hallyn <serge@hallyn.com>
4 years agoMerge pull request #385 from xry111/ftbfs-fix
Serge Hallyn [Fri, 23 Jul 2021 09:53:34 +0000 (04:53 -0500)] 
Merge pull request #385 from xry111/ftbfs-fix

libsubid: link to PAM libraries

4 years agolibsubid: link to PAM libraries 385/head
Xi Ruoyao [Fri, 23 Jul 2021 06:38:08 +0000 (14:38 +0800)] 
libsubid: link to PAM libraries

libsubid.so links to libmisc.a, which contains several routines referring to
PAM functions.

4 years agoconfigure.ac: get ready to release 4.9 4.9 v4.9
Serge Hallyn [Thu, 22 Jul 2021 21:50:51 +0000 (16:50 -0500)] 
configure.ac: get ready to release 4.9

Signed-off-by: Serge Hallyn <serge@hallyn.com>
4 years agoupdate Changelog
Serge Hallyn [Thu, 22 Jul 2021 21:49:26 +0000 (16:49 -0500)] 
update Changelog

Signed-off-by: Serge Hallyn <serge@hallyn.com>
4 years agoMerge pull request #378 from besser82/topic/besser82/update_po
Serge Hallyn [Wed, 14 Jul 2021 14:35:31 +0000 (09:35 -0500)] 
Merge pull request #378 from besser82/topic/besser82/update_po

Update translation files.

4 years agoMerge pull request #383 from ikerexxe/wrong_free
Serge Hallyn [Wed, 14 Jul 2021 12:25:55 +0000 (07:25 -0500)] 
Merge pull request #383 from ikerexxe/wrong_free

libmisc: don't free members variable

4 years agoMerge pull request #382 from StevenYGui/master
Serge Hallyn [Wed, 14 Jul 2021 12:20:24 +0000 (07:20 -0500)] 
Merge pull request #382 from StevenYGui/master

fread returns element count, not element size

4 years agolibmisc: don't free members variable 383/head
Iker Pedrosa [Wed, 14 Jul 2021 09:59:38 +0000 (11:59 +0200)] 
libmisc: don't free members variable

In 9eb191edc4a625bb68e827b18638f5b5816cb30c I included a free() that
frees the members variable, which in turn causes the comma_to_list()
function to return an array of empty elements. The array variable holds
a list of pointers that point to offsets of the members variable. When
the function succeeds freeing members variable causes the elements of
the array variable to point to an empty string.

This is causing several regressions in our internal testing environment.
So, I'm reverting the change.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
4 years agofread returns element count, not element size 381/head 382/head
steven Y Gui [Wed, 14 Jul 2021 08:17:48 +0000 (16:17 +0800)] 
fread returns element count, not element size

4 years agopo/de.po: Update German translations. 378/head
Björn Esser [Sun, 4 Jul 2021 10:26:36 +0000 (12:26 +0200)] 
po/de.po: Update German translations.

Signed-off-by: Björn Esser <besser82@fedoraproject.org>
4 years agopo: Update translation files from updated template.
Björn Esser [Sun, 4 Jul 2021 10:23:51 +0000 (12:23 +0200)] 
po: Update translation files from updated template.

Signed-off-by: Björn Esser <besser82@fedoraproject.org>
4 years agopo: Update pot file.
Björn Esser [Wed, 16 Jun 2021 15:58:46 +0000 (17:58 +0200)] 
po: Update pot file.

Signed-off-by: Björn Esser <besser82@fedoraproject.org>
4 years agoMerge pull request #357 from besser82/topic/besser82/xcrypt_gensalt
Serge Hallyn [Mon, 5 Jul 2021 03:23:56 +0000 (22:23 -0500)] 
Merge pull request #357 from besser82/topic/besser82/xcrypt_gensalt

Use crypt_gensalt(), if available in libcrypt.

4 years agolibmisc/salt.c: Use crypt_gensalt(), if available in libcrypt. 357/head
Björn Esser [Tue, 15 Jun 2021 12:23:42 +0000 (14:23 +0200)] 
libmisc/salt.c: Use crypt_gensalt(), if available in libcrypt.

Most Linux distributions, including Fedora and RHEL 8, are shipping
with libxcrypt >= 4.0.

Since that version of libxcrypt the provided family of crypt_gensalt()
functions are able to use automatic entropy drawn from secure system
ressources, like arc4random(), getentropy() or getrandom().

Anyways, the settings generated by crypt_gensalt() are always
guaranteed to works with the crypt() function.

Using crypt_gensalt() is also needed to make proper use of newer
hashing methods, like yescrypt, provided by libxcrypt.

Signed-off-by: Björn Esser <besser82@fedoraproject.org>
4 years agolib/defines.h: Include <crypt.h> if present on the system.
Björn Esser [Thu, 24 Jun 2021 10:39:27 +0000 (12:39 +0200)] 
lib/defines.h: Include <crypt.h> if present on the system.

The functions crypt(3), crypt_gensalt(3), and their
feature test macros may be defined in there.

Signed-off-by: Björn Esser <besser82@fedoraproject.org>
4 years agolibmisc/salt.c: Use secure system ressources to obtain random bytes. 380/head
Björn Esser [Sun, 4 Jul 2021 10:10:11 +0000 (12:10 +0200)] 
libmisc/salt.c: Use secure system ressources to obtain random bytes.

In a previous commit we introduced /dev/urandom as a source to obtain
random bytes from.  This may not be available on all systems, or when
operating inside of a chroot.

Almost all systems provide functions to obtain random bytes from
secure system ressources.  Thus we should prefer to use these, and
fall back to /dev/urandom, if there is no such function present, as
a last resort.

Signed-off-by: Björn Esser <besser82@fedoraproject.org>
4 years agoMerge pull request #359 from ikerexxe/rest_resource_leak
Serge Hallyn [Thu, 24 Jun 2021 18:14:15 +0000 (13:14 -0500)] 
Merge pull request #359 from ikerexxe/rest_resource_leak

Fix covscan RESOURCE_LEAK

4 years agoFix covscan RESOURCE_LEAK 359/head
Iker Pedrosa [Mon, 14 Jun 2021 10:39:48 +0000 (12:39 +0200)] 
Fix covscan RESOURCE_LEAK

Error: RESOURCE_LEAK (CWE-772): [#def1]
shadow-4.8.1/lib/commonio.c:320: alloc_fn: Storage is returned from allocation function "fopen_set_perms".
shadow-4.8.1/lib/commonio.c:320: var_assign: Assigning: "bkfp" = storage returned from "fopen_set_perms(backup, "w", &sb)".
shadow-4.8.1/lib/commonio.c:329: noescape: Resource "bkfp" is not freed or pointed-to in "putc".
shadow-4.8.1/lib/commonio.c:334: noescape: Resource "bkfp" is not freed or pointed-to in "fflush".
shadow-4.8.1/lib/commonio.c:339: noescape: Resource "bkfp" is not freed or pointed-to in "fileno".
shadow-4.8.1/lib/commonio.c:342: leaked_storage: Variable "bkfp" going out of scope leaks the storage it points to.
  340|        || (fclose (bkfp) != 0)) {
  341|    /* FIXME: unlink the backup file? */
  342|->  return -1;
  343|    }
  344|

Error: RESOURCE_LEAK (CWE-772): [#def2]
shadow-4.8.1/libmisc/addgrps.c:69: alloc_fn: Storage is returned from allocation function "malloc".
shadow-4.8.1/libmisc/addgrps.c:69: var_assign: Assigning: "grouplist" = storage returned from "malloc(i * 4UL)".
shadow-4.8.1/libmisc/addgrps.c:73: noescape: Resource "grouplist" is not freed or pointed-to in "getgroups". [Note: The source code implementation of the function has been overridden by a builtin model.]
shadow-4.8.1/libmisc/addgrps.c:126: leaked_storage: Variable "grouplist" going out of scope leaks the storage it points to.
  124|    }
  125|
  126|->  return 0;
  127|   }
  128|   #else /* HAVE_SETGROUPS && !USE_PAM */

Error: RESOURCE_LEAK (CWE-772): [#def3]
shadow-4.8.1/libmisc/chowntty.c:62: alloc_fn: Storage is returned from allocation function "getgr_nam_gid".
shadow-4.8.1/libmisc/chowntty.c:62: var_assign: Assigning: "grent" = storage returned from "getgr_nam_gid(getdef_str("TTYGROUP"))".
shadow-4.8.1/libmisc/chowntty.c:98: leaked_storage: Variable "grent" going out of scope leaks the storage it points to.
   96|     */
   97|   #endif
   98|-> }
   99|

Error: RESOURCE_LEAK (CWE-772): [#def4]
shadow-4.8.1/libmisc/copydir.c:742: open_fn: Returning handle opened by "open". [Note: The source code implementation of the function has been overridden by a user model.]
shadow-4.8.1/libmisc/copydir.c:742: var_assign: Assigning: "ifd" = handle returned from "open(src, 0)".
shadow-4.8.1/libmisc/copydir.c:748: leaked_handle: Handle variable "ifd" going out of scope leaks the handle.
  746|   #ifdef WITH_SELINUX
  747|    if (set_selinux_file_context (dst, NULL) != 0) {
  748|->  return -1;
  749|    }
  750|   #endif /* WITH_SELINUX */

Error: RESOURCE_LEAK (CWE-772): [#def5]
shadow-4.8.1/libmisc/copydir.c:751: open_fn: Returning handle opened by "open". [Note: The source code implementation of the function has been overridden by a user model.]
shadow-4.8.1/libmisc/copydir.c:751: var_assign: Assigning: "ofd" = handle returned from "open(dst, 577, statp->st_mode & 0xfffU)".
shadow-4.8.1/libmisc/copydir.c:752: noescape: Resource "ofd" is not freed or pointed-to in "fchown_if_needed".
shadow-4.8.1/libmisc/copydir.c:775: leaked_handle: Handle variable "ofd" going out of scope leaks the handle.
  773|       ) {
  774|    (void) close (ifd);
  775|->  return -1;
  776|    }
  777|

Error: RESOURCE_LEAK (CWE-772): [#def7]
shadow-4.8.1/libmisc/idmapping.c:188: alloc_fn: Storage is returned from allocation function "xmalloc".
shadow-4.8.1/libmisc/idmapping.c:188: var_assign: Assigning: "buf" = storage returned from "xmalloc(bufsize)".
shadow-4.8.1/libmisc/idmapping.c:188: var_assign: Assigning: "pos" = "buf".
shadow-4.8.1/libmisc/idmapping.c:213: noescape: Resource "buf" is not freed or pointed-to in "write".
shadow-4.8.1/libmisc/idmapping.c:219: leaked_storage: Variable "pos" going out of scope leaks the storage it points to.
shadow-4.8.1/libmisc/idmapping.c:219: leaked_storage: Variable "buf" going out of scope leaks the storage it points to.
  217|    }
  218|    close(fd);
  219|-> }

Error: RESOURCE_LEAK (CWE-772): [#def8]
shadow-4.8.1/libmisc/list.c:211: alloc_fn: Storage is returned from allocation function "xstrdup".
shadow-4.8.1/libmisc/list.c:211: var_assign: Assigning: "members" = storage returned from "xstrdup(comma)".
shadow-4.8.1/libmisc/list.c:217: var_assign: Assigning: "cp" = "members".
shadow-4.8.1/libmisc/list.c:218: noescape: Resource "cp" is not freed or pointed-to in "strchr".
shadow-4.8.1/libmisc/list.c:244: leaked_storage: Variable "cp" going out of scope leaks the storage it points to.
shadow-4.8.1/libmisc/list.c:244: leaked_storage: Variable "members" going out of scope leaks the storage it points to.
  242|    if ('\0' == *members) {
  243|    *array = (char *) 0;
  244|->  return array;
  245|    }
  246|

Error: RESOURCE_LEAK (CWE-772): [#def11]
shadow-4.8.1/libmisc/myname.c:61: alloc_fn: Storage is returned from allocation function "xgetpwnam".
shadow-4.8.1/libmisc/myname.c:61: var_assign: Assigning: "pw" = storage returned from "xgetpwnam(cp)".
shadow-4.8.1/libmisc/myname.c:67: leaked_storage: Variable "pw" going out of scope leaks the storage it points to.
   65|    }
   66|
   67|->  return xgetpwuid (ruid);
   68|   }
   69|

Error: RESOURCE_LEAK (CWE-772): [#def12]
shadow-4.8.1/libmisc/user_busy.c:260: alloc_fn: Storage is returned from allocation function "opendir".
shadow-4.8.1/libmisc/user_busy.c:260: var_assign: Assigning: "task_dir" = storage returned from "opendir(task_path)".
shadow-4.8.1/libmisc/user_busy.c:262: noescape: Resource "task_dir" is not freed or pointed-to in "readdir".
shadow-4.8.1/libmisc/user_busy.c:278: leaked_storage: Variable "task_dir" going out of scope leaks the storage it points to.
  276|             _("%s: user %s is currently used by process %d\n"),
  277|             Prog, name, pid);
  278|->  return 1;
  279|    }
  280|    }

Error: RESOURCE_LEAK (CWE-772): [#def20]
shadow-4.8.1/src/newgrp.c:162: alloc_fn: Storage is returned from allocation function "xgetspnam".
shadow-4.8.1/src/newgrp.c:162: var_assign: Assigning: "spwd" = storage returned from "xgetspnam(pwd->pw_name)".
shadow-4.8.1/src/newgrp.c:234: leaked_storage: Variable "spwd" going out of scope leaks the storage it points to.
  232|    }
  233|
  234|->  return;
  235|
  236|   failure:

Error: RESOURCE_LEAK (CWE-772): [#def21]
shadow-4.8.1/src/passwd.c:530: alloc_fn: Storage is returned from allocation function "xstrdup".
shadow-4.8.1/src/passwd.c:530: var_assign: Assigning: "cp" = storage returned from "xstrdup(crypt_passwd)".
shadow-4.8.1/src/passwd.c:551: noescape: Resource "cp" is not freed or pointed-to in "strlen".
shadow-4.8.1/src/passwd.c:554: noescape: Resource "cp" is not freed or pointed-to in "strcat". [Note: The source code implementation of the function has been overridden by a builtin model.]
shadow-4.8.1/src/passwd.c:555: overwrite_var: Overwriting "cp" in "cp = newpw" leaks the storage that "cp" points to.
  553|    strcpy (newpw, "!");
  554|    strcat (newpw, cp);
  555|->  cp = newpw;
  556|    }
  557|    return cp;

4 years agoMerge pull request #377 from besser82/topic/besser82/salt_c_random
Serge Hallyn [Wed, 23 Jun 2021 19:54:25 +0000 (14:54 -0500)] 
Merge pull request #377 from besser82/topic/besser82/salt_c_random

libmisc/salt.c: Obtain random bytes from /dev/urandom.

4 years agolibmisc/salt.c: Obtain random bytes from /dev/urandom. 377/head
Björn Esser [Wed, 23 Jun 2021 14:06:47 +0000 (16:06 +0200)] 
libmisc/salt.c: Obtain random bytes from /dev/urandom.

Using the random() function to obtain pseudo-random bytes
for generating salt strings is considered to be dangerous.
See CWE-327.

We really should use a more reliable source for obtaining
pseudo-random bytes like /dev/urandom.

Fixes #376.

Signed-off-by: Björn Esser <besser82@fedoraproject.org>
4 years agolibmisc/salt.c: Add comments how the minmum buffer length is computed.
Björn Esser [Mon, 14 Jun 2021 21:28:28 +0000 (23:28 +0200)] 
libmisc/salt.c: Add comments how the minmum buffer length is computed.

In the previous commit we refactored the functions converting the
rounds number into a string for use with the crypt() function, to
not require any static buffer anymore.

Add some clarifying comments about how the minimum required buffer
length is computed inside of these functions.

Signed-off-by: Björn Esser <besser82@fedoraproject.org>
4 years agoMerge pull request #361 from besser82/topic/besser82/simplyfy_libmisc_salt
Serge Hallyn [Wed, 23 Jun 2021 14:18:05 +0000 (09:18 -0500)] 
Merge pull request #361 from besser82/topic/besser82/simplyfy_libmisc_salt

Sanitize code in libmisc/salt.c

4 years agoMerge pull request #362 from ikerexxe/buffer_size
Serge Hallyn [Wed, 23 Jun 2021 01:55:31 +0000 (20:55 -0500)] 
Merge pull request #362 from ikerexxe/buffer_size

Fix covscan BUFFER_SIZE

4 years agolibmisc/salt.c: Sanitize code. 361/head
Björn Esser [Mon, 14 Jun 2021 21:28:28 +0000 (23:28 +0200)] 
libmisc/salt.c: Sanitize code.

* Move all pre-processor defines to the top of the file.
* Unify the gensalt() function to be useable for all supported
  hash methods.
* Drop the gensalt_{b,yes}crypt() functions in favor of the
  previous change.
* Refactor the functions converting the rounds number into
  a string for use with the crypt() function, to not require
  any static buffer anymore.
* Clarify the comment about how crypt_make_salt() chooses the used
  hash method from the settings in the login.defs file.
* Use memset() to fill static buffers with zero before using them.
* Use a fixed amount of 16 random base64-chars for the
  sha{256,512}crypt hash methods, which is effectively still less
  than the recommendation from NIST (>= 128 bits), but the maximum
  those methods can effectively use (approx. 90 bits).
* Rename ROUNDS_{MIN,MAX} to SHA_ROUNDS_{MIN,MAX}.
* Bugfixes in the logic of setting rounds in BCRYPT_salt_rounds().
* Likewise for YESCRYPT_salt_cost().
* Fix formatting and white-space errors.

Signed-off-by: Björn Esser <besser82@fedoraproject.org>
4 years agoMerge pull request #360 from besser82/topic/besser82/bcrypt_prefix
Serge Hallyn [Tue, 22 Jun 2021 19:46:41 +0000 (14:46 -0500)] 
Merge pull request #360 from besser82/topic/besser82/bcrypt_prefix

bcrypt should use $2b$ as prefix for setting.

4 years agolibmisc/salt.c: bcrypt should use $2b$ as prefix for setting. 360/head
Björn Esser [Sat, 12 Jun 2021 11:54:14 +0000 (13:54 +0200)] 
libmisc/salt.c: bcrypt should use $2b$ as prefix for setting.

This prefix is the recommended one for new bcrypt hashes
for a long time.

Signed-off-by: Björn Esser <besser82@fedoraproject.org>
4 years agolibmisc/salt.c: Use int pointer for YESCRYPT_salt_cost(). 358/head
Björn Esser [Sat, 12 Jun 2021 17:05:07 +0000 (19:05 +0200)] 
libmisc/salt.c: Use int pointer for YESCRYPT_salt_cost().

The corresponding functions for the other hash methods all take
a pointer to an integer value as the only paramater, so this
particular function should do so as well.

Signed-off-by: Björn Esser <besser82@fedoraproject.org>
4 years agoMerge pull request #354 from ikerexxe/useradd_resource_leak
Serge Hallyn [Tue, 22 Jun 2021 14:22:09 +0000 (09:22 -0500)] 
Merge pull request #354 from ikerexxe/useradd_resource_leak

useradd.c: fix covscan RESOURCE_LEAK