]> git.ipfire.org Git - thirdparty/shadow.git/log
thirdparty/shadow.git
2 years agoDon't warn when failed to open /etc/nsswitch.conf
Serge Hallyn [Mon, 7 Nov 2022 15:54:50 +0000 (09:54 -0600)] 
Don't warn when failed to open /etc/nsswitch.conf

Maybe we should have a debug mode where it's still printed, but
we don't, so let's be quieter.

Closes #557

2 years agouseradd: Fix buffer overflow when using a prefix
David Michael [Sun, 23 Oct 2022 22:51:33 +0000 (18:51 -0400)] 
useradd: Fix buffer overflow when using a prefix

The buffer length did not count the string's trailing null byte.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
2 years agoadduser-old.c: Remove program 495/head
Alejandro Colomar [Fri, 7 Oct 2022 23:58:07 +0000 (01:58 +0200)] 
adduser-old.c: Remove program

This program has 10 calls to gets(3) according to grep(1).  That
makes it a very unsafe program which should not be used at all.
Let's kill the program already.

See what gets(3) has to say:

SYNOPSIS
       #include <stdio.h>

       [[deprecated]] char *gets(char *s);

DESCRIPTION
       Never use this function.

       ...

BUGS
       Never use gets().  Because it is impossible to tell with‐
       out knowing the  data  in  advance  how  many  characters
       gets()  will  read,  and  because gets() will continue to
       store characters past the end of the buffer,  it  is  ex‐
       tremely dangerous to use.  It has been used to break com‐
       puter security.  Use fgets() instead.

       For more information, see CWE‐242 (aka "Use of Inherently
       Dangerous Function") at http://cwe.mitre.org/data/defini‐
       tions/242.html

Acked-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agoRaise limit for passwd and shadow entry length
Iker Pedrosa [Fri, 7 Oct 2022 10:36:59 +0000 (12:36 +0200)] 
Raise limit for passwd and shadow entry length

Moreover, include checks to prevent writing entries longer than the
length limit.

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

Signed-off-by: Tomáš Mráz <tm@t8m.info>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agolastlog: check for localtime() return value
Iker Pedrosa [Thu, 6 Oct 2022 08:05:44 +0000 (10:05 +0200)] 
lastlog: check for localtime() return value

Signed-off-by: Tomáš Mráz <tm@t8m.info>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agoman: add missing space in useradd.8.xml
Iker Pedrosa [Fri, 7 Oct 2022 10:17:41 +0000 (12:17 +0200)] 
man: add missing space in useradd.8.xml

Resolves: https://github.com/shadow-maint/shadow/issues/580

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agofix `usermod -rG x y` while user `y` is not in group `x` will cause user `y` add...
xyz [Sat, 27 Aug 2022 02:23:13 +0000 (19:23 -0700)] 
fix `usermod -rG x y` while user `y` is not in group `x` will cause user `y` add into group `x`

2 years agolibmisc: minimum id check for system accounts
Iker Pedrosa [Thu, 6 Oct 2022 09:21:18 +0000 (11:21 +0200)] 
libmisc: minimum id check for system accounts

The minimum id allocation for system accounts shouldn't be 0 as this is
reserved for root.

Signed-off-by: Tomáš Mráz <tm@t8m.info>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agousermod: report error if homedir does not exist
Iker Pedrosa [Wed, 5 Oct 2022 13:20:43 +0000 (15:20 +0200)] 
usermod: report error if homedir does not exist

Report error if usermod asked for moving homedir and it does not exist.

Signed-off-by: Tomáš Mráz <tm@t8m.info>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2 years agochage: Fix regression in print_date
Xiami [Wed, 5 Oct 2022 10:11:28 +0000 (18:11 +0800)] 
chage: Fix regression in print_date

Introduced by c6c8130db4319613a91dd07bbb845f6c33c5f79f

After removing snprintf, the format string should get unescaped once.

Fixes #564

Reporter and patch author: DerMouse (github.com/DerMouse)

2 years agoUse libc MAX() and MIN()
Alejandro Colomar [Wed, 28 Sep 2022 21:19:37 +0000 (23:19 +0200)] 
Use libc MAX() and MIN()

glibc, musl, FreeBSD, and OpenBSD define the MAX() and MIN()
macros in <sys/param.h> with the same definition that we use.
Let's not redefine it here and use the system one, as it's
effectively the same as we define (modulo whitespace).

See:

shadow (previously):

alx@asus5775:~/src/shadow/shadow$ grepc -ktm MAX
./lib/defines.h:318:#define MAX(x,y) (((x) > (y)) ? (x) : (y))

glibc:

alx@asus5775:~/src/gnu/glibc$ grepc -ktm -x 'sys/param.h$' MAX
./misc/sys/param.h:103:#define MAX(a,b) (((a)>(b))?(a):(b))

musl:

alx@asus5775:~/src/musl/musl$ grepc -ktm -x 'sys/param.h$' MAX
./include/sys/param.h:19:#define MAX(a,b) (((a)>(b))?(a):(b))

OpenBSD:

alx@asus5775:~/src/bsd/openbsd/src$ grepc -ktm -x 'sys/param.h$' MAX
./sys/sys/param.h:193:#define MAX(a,b) (((a)>(b))?(a):(b))

FreeBSD:

alx@asus5775:~/src/bsd/freebsd/freebsd-src$ grepc -ktm -x 'sys/param.h$' MAX
./sys/sys/param.h:333:#define MAX(a,b) (((a)>(b))?(a):(b))

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agoDon't test for NULL before calling free(3)
Alex Colomar [Wed, 28 Sep 2022 20:03:52 +0000 (22:03 +0200)] 
Don't test for NULL before calling free(3)

free(3) accepts NULL, since the oldest ISO C.  I guess the
paranoid code was taking care of prehistoric implementations of
free(3).  I've never known of an implementation that doesn't
conform to this, so let's simplify this.

Remove xfree(3), which was effectively an equivalent of free(3).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 years agoupdated Dutch translation
Frans Spiesschaert [Tue, 27 Sep 2022 15:11:02 +0000 (17:11 +0200)] 
updated Dutch translation

2 years agolib: use memzero where applicable
Christian Göttsche [Sat, 17 Sep 2022 16:03:46 +0000 (18:03 +0200)] 
lib: use memzero where applicable

Use memzero when operating in a buffer of known size to clear all bytes
and avoid leaking the size of the stored data.

2 years agolib: use strzero where applicable
Christian Göttsche [Sat, 17 Sep 2022 15:56:49 +0000 (17:56 +0200)] 
lib: use strzero where applicable

Replace `memzero (s, strlen(s))` with just the internal wrapper
`strzero (s)` where the underlying allocated size is not known.

2 years agolib/commonio: make lock failures more detailed
Luca BRUNO [Mon, 29 Aug 2022 12:35:07 +0000 (12:35 +0000)] 
lib/commonio: make lock failures more detailed

This tweaks the database locking logic so that failures in the
link-checking paths are more detailed.
The rationale for this is that I've experienced a non-deterministic
bug which seems to be coming from this logic, and I'd like to get
more details about the actual failing condition.

2 years agocopy_tree: carefully treat permissions
Samanta Navarro [Sat, 10 Sep 2022 11:58:15 +0000 (11:58 +0000)] 
copy_tree: carefully treat permissions

The setuid, setgid, and sticky bits are not copied during copy_tree.

Also start with very restrictive permissions before setting ownerships.

This prevents situations in which users in a group with less permissions
than others could win a race in opening the file before permissions are
removed again.

Proof of concept:

$ echo $HOME
/home/uwu
$ install -o uwu -g fandom -m 604 /dev/null /home/uwu/owo
$ ls -l /home/uwu/owo
-rw----r-- 1 uwu fandom 0 Sep  4 00:00 /home/uwu/owo

If /tmp is on another filesystem, then "usermod -md /tmp/uwu uwu" leads
to this temporary situation:

$ ls -l /tmp/uwu/owo
-rw----r-- 1 root root  0 Sep  4 00:00 /tmp/uwu/owo

This means that between openat and chownat_if_needed a user of group
fandom could open /tmp/uwu/owo and read the content when it is finally
written into the file.

2 years agoci(lint): add shell linter - Differential ShellCheck
Jan Macku [Mon, 12 Sep 2022 08:15:43 +0000 (10:15 +0200)] 
ci(lint): add shell linter - Differential ShellCheck

It performs differential ShellCheck scans and report results directly in pull request.

documentation: https://github.com/redhat-plumbers-in-action/differential-shellcheck

Signed-off-by: Jan Macku <jamacku@redhat.com>
2 years agocopy_tree: do not block on fifos
Samanta Navarro [Sun, 4 Sep 2022 11:58:03 +0000 (11:58 +0000)] 
copy_tree: do not block on fifos

Fixes regression introduced in faeab50e710131816b261de66141524898c2c487.

If a directory contains fifos, then openat blocks until the other side
of the fifo is connected as well.

This means that users can prevent "usermod -m" from completing if their
home directories contain at least one fifo.

2 years agocopy_tree: use fchmodat instead of chmod
Samanta Navarro [Sun, 4 Sep 2022 11:54:19 +0000 (11:54 +0000)] 
copy_tree: use fchmodat instead of chmod

Fixes regression introduced in faeab50e710131816b261de66141524898c2c487
for setups configured without acl support.

2 years agouseradd: check MLS enablement before setting serange Resolves: https://github.com...
genBTC [Tue, 23 Aug 2022 14:25:51 +0000 (10:25 -0400)] 
useradd: check MLS enablement before setting serange Resolves: https://github.com/shadow-maint/shadow/issues/552

2 years agoshadow: use relaxed usernames
Alexander Kanavin [Tue, 16 Aug 2022 11:46:22 +0000 (13:46 +0200)] 
shadow: use relaxed usernames

The groupadd from shadow does not allow upper case group names, the
same is true for the upstream shadow. But distributions like
Debian/Ubuntu/CentOS has their own way to cope with this problem,
this patch is picked up from Fedora [1] to relax the usernames
restrictions to allow the upper case group names, and the relaxation is
POSIX compliant because POSIX indicate that usernames are composed of
characters from the portable filename character set [A-Za-z0-9._-].

[1] https://src.fedoraproject.org/rpms/shadow-utils/blob/rawhide/f/shadow-4.8-goodname.patch

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
2 years agopo: Georgian translation
NorwayFun [Mon, 22 Aug 2022 00:38:43 +0000 (02:38 +0200)] 
po: Georgian translation

po: Georgian translation

2 years agopo: Georgian translation
NorwayFun [Mon, 22 Aug 2022 00:37:21 +0000 (02:37 +0200)] 
po: Georgian translation

po: Georgian translation

2 years agouseradd: Do not reset non-existent data in {last,fail}log
David Kalnischkies [Wed, 24 Aug 2022 11:21:01 +0000 (13:21 +0200)] 
useradd: Do not reset non-existent data in {last,fail}log

useradd does not create the files if they don't exist, but if they exist
it will reset user data even if the data did not exist before creating
a hole and an explicitly zero'd data point resulting (especially for
high UIDs) in a lot of zeros ending up in containers and tarballs.

2 years agoRevert "Drop unused function subid_init()"
Serge Hallyn [Sun, 21 Aug 2022 18:14:37 +0000 (13:14 -0500)] 
Revert "Drop unused function subid_init()"

As rbalint points out, this was an exported fn.  It also is
the only way for a libsubid user to do what it does, so let's
not drop it.

This reverts commit 477c8e6f42df1e17e45584e74988eb46a11e6caa.

2 years agouseradd.8.xml: fix default group id from 100 to 1000 according to bbf4b79
Tim Biermann [Fri, 19 Aug 2022 20:31:01 +0000 (22:31 +0200)] 
useradd.8.xml: fix default group id from 100 to 1000 according to bbf4b79

2 years agoRelease 4.12.2 with CVE fix 4.12.2
Serge Hallyn [Thu, 18 Aug 2022 21:54:21 +0000 (16:54 -0500)] 
Release 4.12.2 with CVE fix

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2 years agoAvoid races in copy_tree()
Christian Göttsche [Fri, 5 Aug 2022 15:57:32 +0000 (17:57 +0200)] 
Avoid races in copy_tree()

Use *at() functions to pin the directory operating in to avoid being
redirected by unprivileged users replacing parts of paths by symlinks to
privileged files.

Introduce a path_info struct with the full path and dirfd and name
information for *at() functions, since the full path is needed for link
resolution, SELinux label lookup and ACL attributes.

2 years agoAddress minor compiler warnings
Christian Göttsche [Fri, 5 Aug 2022 15:57:29 +0000 (17:57 +0200)] 
Address minor compiler warnings

    copydir.c:666:44: warning: unsigned conversion from 'int' to '__mode_t' {aka 'unsigned int'} changes value from '-4096' to '4294963200' [-Wsign-conversion]
      666 |         if (   (mknod (dst, statp->st_mode & ~07777, statp->st_rdev) != 0)
          |                                            ^

    copydir.c:116:1: warning: missing initializer for field 'quote' of 'struct error_context' [-Wmissing-field-initializers]
      116 | };
          | ^
    In file included from copydir.c:27:
    /usr/include/attr/error_context.h:30:23: note: 'quote' declared here
       30 |         const char *(*quote) (struct error_context *, const char *);
          |                       ^~~~~

2 years agoMore robust file content copy in copy_tree()
Christian Göttsche [Fri, 5 Aug 2022 15:57:27 +0000 (17:57 +0200)] 
More robust file content copy in copy_tree()

Bail out on read(2) failure, continue on EINTR, support short writes and
increase chunk size.

2 years agoFail if regular file pre-exists in copy_tree()
Christian Göttsche [Fri, 5 Aug 2022 15:57:26 +0000 (17:57 +0200)] 
Fail if regular file pre-exists in copy_tree()

Similar to the default behavior of mkdir(2), symlink(2), link(2) and
mknod(2).

2 years agoRequire symlink support
Christian Göttsche [Fri, 5 Aug 2022 15:57:24 +0000 (17:57 +0200)] 
Require symlink support

Require lstat(2), lchown(2), S_IFLNK and S_ISLNK from POSIX.1-2001.

Already unconditionally used in lib/tcbfuncs.c and lib/run_part.c.

2 years agoAvoid races in remove_tree()
Christian Göttsche [Fri, 5 Aug 2022 15:57:22 +0000 (17:57 +0200)] 
Avoid races in remove_tree()

Use *at() functions to pin the directory operating in to avoid being
redirected by unprivileged users replacing parts of paths by symlinks to
privileged files.

2 years agoAvoid races in chown_tree()
Christian Göttsche [Fri, 5 Aug 2022 15:57:19 +0000 (17:57 +0200)] 
Avoid races in chown_tree()

Use *at() functions to pin the directory operating in to avoid being
redirected by unprivileged users replacing parts of paths by symlinks to
privileged files.

2 years agoRelease 4.12 4.12.1
Serge Hallyn [Mon, 15 Aug 2022 17:16:41 +0000 (12:16 -0500)] 
Release 4.12

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2 years agouk has no limits.5 translation
Serge Hallyn [Fri, 12 Aug 2022 18:11:56 +0000 (13:11 -0500)] 
uk has no limits.5 translation

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2 years agoAdd uk to list of man subdirs
Serge Hallyn [Fri, 12 Aug 2022 17:29:50 +0000 (12:29 -0500)] 
Add uk to list of man subdirs

Closes #547

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2 years agoRelease 4.12 4.12
Serge Hallyn [Thu, 11 Aug 2022 16:04:18 +0000 (11:04 -0500)] 
Release 4.12

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2 years agoUpdate changelog
Serge Hallyn [Mon, 8 Aug 2022 23:56:41 +0000 (18:56 -0500)] 
Update changelog

Signed-off-by: Serge Hallyn <serge@hallyn.com>
3 years agolibmisc/root_flag: add tips for --root flag only support abspath
Celeste Liu [Wed, 27 Jul 2022 15:06:36 +0000 (23:06 +0800)] 
libmisc/root_flag: add tips for --root flag only support abspath

- Add tips in error message.
- Add tips in man.
- Add zh_CN and zh_TW for tips.

Signed-off-by: Celeste Liu <coelacanthus@outlook.com>
3 years agoUse function format attribute where applicable
Christian Göttsche [Fri, 5 Aug 2022 15:40:42 +0000 (17:40 +0200)] 
Use function format attribute where applicable

Allow the compiler to verify the format string against the supplied
arguments.

    chage.c:239:51: warning: format not a string literal, format string not checked [-Wformat-nonliteral]
      239 |                 (void) strftime (buf, sizeof buf, format, tp);
          |                                                   ^~~~~~

3 years agoDrop unused function subid_init()
Christian Göttsche [Fri, 5 Aug 2022 15:40:39 +0000 (17:40 +0200)] 
Drop unused function subid_init()

3 years agoDrop obsolete prototype for log_dolog()
Christian Göttsche [Fri, 5 Aug 2022 15:40:37 +0000 (17:40 +0200)] 
Drop obsolete prototype for log_dolog()

log_dolog() is neither implemented nor used.

3 years agoDrop superfluous const from return type
Christian Göttsche [Fri, 5 Aug 2022 15:40:36 +0000 (17:40 +0200)] 
Drop superfluous const from return type

    salt.c:102:22: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
      102 | static /*@observer@*/const unsigned long SHA_get_salt_rounds (/*@null@*/int *prefered_rounds);
          |                      ^~~~~
    salt.c:110:22: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
      110 | static /*@observer@*/const unsigned long YESCRYPT_get_salt_cost (/*@null@*/int *prefered_cost);
          |                      ^~~~~

    subordinateio.c:160:8: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
      160 | static const bool range_exists(struct commonio_db *db, const char *owner)
          |        ^~~~~

3 years agoAdd include for uid_t
Christian Göttsche [Fri, 5 Aug 2022 15:40:34 +0000 (17:40 +0200)] 
Add include for uid_t

Allow IDEs to parse the header file on its own.

3 years agoDrop unnecessary prototype
Christian Göttsche [Fri, 5 Aug 2022 15:40:33 +0000 (17:40 +0200)] 
Drop unnecessary prototype

The function is defined directly after.

3 years agoDeclare read-only data const
Christian Göttsche [Fri, 5 Aug 2022 15:40:31 +0000 (17:40 +0200)] 
Declare read-only data const

3 years agoDrop register keyword
Christian Göttsche [Fri, 5 Aug 2022 15:40:29 +0000 (17:40 +0200)] 
Drop register keyword

Compilers are free to ignore the indented hint and modern optimizations
should create good code by themself.

(As such it is for example deprecated in C++17.)

3 years agoReturn void pointer from xmalloc
Christian Göttsche [Fri, 5 Aug 2022 15:40:28 +0000 (17:40 +0200)] 
Return void pointer from xmalloc

xmalloc is a wrapper around malloc(3), which bails out on OOM failures.
As such it returns raw memory and is used to allocated all kind of
types.

3 years agoDeclare read-only parameters const
Christian Göttsche [Fri, 5 Aug 2022 15:40:26 +0000 (17:40 +0200)] 
Declare read-only parameters const

Signal callers arguments are not going to be modified and allow passing
const pointers.

3 years agopo: update translations
Christian Göttsche [Fri, 5 Aug 2022 15:40:24 +0000 (17:40 +0200)] 
po: update translations

Add language identifiers and fix line break.

3 years agoconfigure.ac: bump gettext version
Christian Göttsche [Fri, 5 Aug 2022 15:40:21 +0000 (17:40 +0200)] 
configure.ac: bump gettext version

Version 1.19.1 was released in June 2014.

    configure.ac:697: warning: AM_PROG_MKDIR_P: this macro is deprecated, and will soon be removed.
    configure.ac:697: You should use the Autoconf-provided 'AC_PROG_MKDIR_P' macro instead,
    configure.ac:697: and use '$(MKDIR_P)' instead of '$(mkdir_p)'in your Makefile.am files.
    ./lib/autoconf/general.m4:2434: AC_DIAGNOSE is expanded from...
    aclocal.m4:780: AM_PROG_MKDIR_P is expanded from...
    m4/po.m4:23: AM_PO_SUBDIRS is expanded from...
    m4/gettext.m4:57: AM_GNU_GETTEXT is expanded from...
    configure.ac:697: the top level
    configure.ac:697: warning: The macro `AC_TRY_LINK' is obsolete.
    configure.ac:697: You should run autoupdate.
    ./lib/autoconf/general.m4:2920: AC_TRY_LINK is expanded from...
    lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    ./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from...
    ./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from...
    m4/gettext.m4:365: gt_INTL_MACOSX is expanded from...
    m4/gettext.m4:57: AM_GNU_GETTEXT is expanded from...
    configure.ac:697: the top level
    configure.ac:697: warning: The macro `AC_TRY_LINK' is obsolete.
    configure.ac:697: You should run autoupdate.
    ./lib/autoconf/general.m4:2920: AC_TRY_LINK is expanded from...
    lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    ./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from...
    ./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from...
    m4/gettext.m4:57: AM_GNU_GETTEXT is expanded from...
    configure.ac:697: the top level
    configure.ac:697: warning: The macro `AC_TRY_LINK' is obsolete.
    configure.ac:697: You should run autoupdate.
    ./lib/autoconf/general.m4:2920: AC_TRY_LINK is expanded from...
    lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    ./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from...
    ./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from...
    m4/iconv.m4:20: AM_ICONV_LINK is expanded from...
    m4/gettext.m4:57: AM_GNU_GETTEXT is expanded from...
    configure.ac:697: the top level

3 years agoconfigure.ac: replace deprecated aliases
Christian Göttsche [Fri, 5 Aug 2022 15:40:12 +0000 (17:40 +0200)] 
configure.ac: replace deprecated aliases

See https://www.gnu.org/software/libtool/manual/html_node/LT_005fINIT.html

    configure.ac:25: warning: The macro `AM_ENABLE_STATIC' is obsolete.
    configure.ac:25: You should run autoupdate.
    m4/ltoptions.m4:259: AM_ENABLE_STATIC is expanded from...
    configure.ac:25: the top level
    configure.ac:26: warning: The macro `AM_ENABLE_SHARED' is obsolete.
    configure.ac:26: You should run autoupdate.
    m4/ltoptions.m4:205: AM_ENABLE_SHARED is expanded from...
    configure.ac:26: the top level

3 years agoFix E_NAME_IN_USE documentation.
Jeremy Whiting [Wed, 27 Jul 2022 18:02:12 +0000 (12:02 -0600)] 
Fix E_NAME_IN_USE documentation.

Since code gives this error if username or group name is already
used the documentation should reflect that.

3 years agoFix CI by testing Ubuntu 22.04 instead of 21.10.
Jeremy Whiting [Sat, 6 Aug 2022 15:48:53 +0000 (09:48 -0600)] 
Fix CI by testing Ubuntu 22.04 instead of 21.10.

Since Ubuntu 21.10 has gone out of support it no longer works for
testing with CI. Instead use 22.04 which is still supported.

3 years agotests: add a case for testing -F option of useradd
Masatake YAMATO [Wed, 20 Jul 2022 08:40:11 +0000 (17:40 +0900)] 
tests: add a case for testing -F option of useradd

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
3 years agouseradd: add -F option for updating /etc/sub[ig]id for system accounts
Masatake YAMATO [Wed, 20 Jul 2022 02:17:16 +0000 (11:17 +0900)] 
useradd: add -F option for updating /etc/sub[ig]id for system accounts

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
3 years agouseradd: make the option specstr passed to getopt_long extensible
Masatake YAMATO [Wed, 20 Jul 2022 01:43:02 +0000 (10:43 +0900)] 
useradd: make the option specstr passed to getopt_long extensible

It was hard to extend the option specification string passed to
getopt_long as the third argument.

The origian code had a branch with WITH_SELINUX ifdef condition. If
one wants to add one more option char with another ifdef condition
like ENABLE_SUBIDS to the spec, the one must enumerate the specs for
all combinations of the conditions:

*  WITH_SELINUX &&  ENABLE_SUBIDS
*  WITH_SELINUX && !ENABLE_SUBIDS
* !WITH_SELINUX &&  ENABLE_SUBIDS
* !WITH_SELINUX && !ENABLE_SUBIDS

With this change, you can append an option char to the spec.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
3 years agosubordinateio: also compare the owner ID
Iker Pedrosa [Wed, 13 Jul 2022 07:55:14 +0000 (09:55 +0200)] 
subordinateio: also compare the owner ID

IDs already populate /etc/subuid and /etc/subgid files so it's necessary
not only to check for the owner name but also for the owner ID of a
given range.

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

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agoman (useradd): add a note about -r option and /etc/subuid and subgid
Masatake YAMATO [Wed, 13 Jul 2022 16:58:33 +0000 (01:58 +0900)] 
man (useradd): add a note about -r option and /etc/subuid and subgid

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
3 years agoFix typo
Alexander Zhang [Wed, 6 Jul 2022 21:41:09 +0000 (14:41 -0700)] 
Fix typo

3 years agofix Changelog typo
Serge Hallyn [Tue, 5 Jul 2022 13:49:15 +0000 (08:49 -0500)] 
fix Changelog typo

Spotted by cgzones.

3 years agoUpdate changelog
Serge Hallyn [Mon, 4 Jul 2022 19:30:09 +0000 (14:30 -0500)] 
Update changelog

Signed-off-by: Serge Hallyn <serge@hallyn.com>
3 years agolibmisc: use /dev/urandom as a generic fallback for read_random_bytes()
Xi Ruoyao [Mon, 13 Jun 2022 08:44:14 +0000 (16:44 +0800)] 
libmisc: use /dev/urandom as a generic fallback for read_random_bytes()

On systems with Linux kernel < 3.17, getentropy() and getrandom() may
exist but return ENOSYS.  Use /dev/urandom as a fallback to avoid a hard
requirement on Linux kernel version.

Fixes #512.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
3 years agoCI: update actions version
Iker Pedrosa [Wed, 1 Jun 2022 11:22:22 +0000 (13:22 +0200)] 
CI: update actions version

CodeQL Action v1 is being deprecated and v2 needs to be used instead.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agoCI: enable CodeQL analyzer
Iker Pedrosa [Mon, 9 May 2022 14:06:38 +0000 (16:06 +0200)] 
CI: enable CodeQL analyzer

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agoCI: create Github workflow to install dependencies
Iker Pedrosa [Mon, 9 May 2022 14:17:57 +0000 (16:17 +0200)] 
CI: create Github workflow to install dependencies

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agoComplete Ukrainian translation
Yuri Chornoivan [Sat, 21 May 2022 17:49:25 +0000 (20:49 +0300)] 
Complete Ukrainian translation

3 years agoUpdate Ukrainian translation
Yuri Chornoivan [Fri, 20 May 2022 18:46:54 +0000 (21:46 +0300)] 
Update Ukrainian translation

3 years agoAdd Ukrainian translation for man pages
Yuri Chornoivan [Thu, 19 May 2022 19:01:55 +0000 (22:01 +0300)] 
Add Ukrainian translation for man pages

3 years agoInitialize local variables
Iker Pedrosa [Mon, 16 May 2022 15:24:58 +0000 (17:24 +0200)] 
Initialize local variables

CWE-457 by CodeQL.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agoAdd header guards
Iker Pedrosa [Tue, 10 May 2022 13:26:15 +0000 (15:26 +0200)] 
Add header guards

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agoRemove commented out code and FIXMEs
Iker Pedrosa [Tue, 10 May 2022 13:01:21 +0000 (15:01 +0200)] 
Remove commented out code and FIXMEs

In order to remove some of the FIXMEs it was necessary to change the
code and call getulong() instead of getlong().

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agoRemove redeclared variable
Iker Pedrosa [Tue, 10 May 2022 11:23:07 +0000 (13:23 +0200)] 
Remove redeclared variable

No need to redeclare a variable with the same name and type. Just keep
the one with the biggest scope.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agoUpdate Ukrainian translation
Yuri Chornoivan [Mon, 16 May 2022 16:38:39 +0000 (19:38 +0300)] 
Update Ukrainian translation

3 years agotests: replace egrep -> grep -E
Sam James [Sun, 15 May 2022 01:37:11 +0000 (01:37 +0000)] 
tests: replace egrep -> grep -E

"egrep" is an obsolete alias for grep -E and newer greps will warn on usage
of egrep, so let's just swap it out.

Signed-off-by: Sam James <sam@gentoo.org>
3 years agoconfigure: replace obsolete autoconf macros
Christian Göttsche [Mon, 9 May 2022 16:36:02 +0000 (18:36 +0200)] 
configure: replace obsolete autoconf macros

Replace
 AC_HELP_STRING by AS_HELP_STRING,
 AC_GNU_SOURCE by AC_USE_SYSTEM_EXTENSIONS,
 AC_TRY_COMPILE by AC_COMPILE_IFELSE and
 AM_PROG_LIBTOOL by LT_INIT.

See https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Obsolete-Macros.html

3 years agosrc: correct "badname" option
Iker Pedrosa [Wed, 4 May 2022 07:33:59 +0000 (09:33 +0200)] 
src: correct "badname" option

Change "badnames" to "badname" as this is the accepted option name.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agoman: correct "badname" option
Iker Pedrosa [Wed, 27 Apr 2022 14:59:03 +0000 (16:59 +0200)] 
man: correct "badname" option

Change "badnames" to "badname" as this is the accepted option name.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agopo: update translation files
Iker Pedrosa [Wed, 27 Apr 2022 14:53:39 +0000 (16:53 +0200)] 
po: update translation files

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agoSuggest badname if name has special characters
Iker Pedrosa [Tue, 26 Apr 2022 14:45:04 +0000 (16:45 +0200)] 
Suggest badname if name has special characters

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

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agopasswd: erase password copy on all error branches
Christian Göttsche [Mon, 25 Apr 2022 10:17:40 +0000 (12:17 +0200)] 
passwd: erase password copy on all error branches

3 years agousermod: fix alphabetical order in help message
Matheus Marques [Sun, 24 Apr 2022 19:16:58 +0000 (16:16 -0300)] 
usermod: fix alphabetical order in help message

3 years agoWork around git safe.directory enforcement
Serge Hallyn [Mon, 25 Apr 2022 15:42:41 +0000 (10:42 -0500)] 
Work around git safe.directory enforcement

Git wants to ensure that you do not read .git owned by other users.
But we fetch+build as 'build' user, and run tests as root user.  Those
tests calculate git topdir using git rev-parse --show-toplevel, which
git now fails.

Setting safe.directory, seems wrong.  Let's just use bash to figure
out the top dir.

3 years agochpasswd: add IS_CRYPT_METHOD
juyin [Sat, 2 Apr 2022 03:48:51 +0000 (11:48 +0800)] 
chpasswd: add IS_CRYPT_METHOD

Use macro IS_CRYPT_METHOD instead of ’strcmp(crypt_method, xx)==0’ to make the code more cleanup

3 years agorefactor get_salt function
juyin [Fri, 1 Apr 2022 01:26:29 +0000 (09:26 +0800)] 
refactor get_salt function

refactor get_salt function to make it easier to read.

3 years agochpasswd: fix function problem with -R parameter
juyin [Thu, 31 Mar 2022 08:48:52 +0000 (16:48 +0800)] 
chpasswd: fix function problem with -R parameter

Generating salt value depends on /dev/urandom. But after the
function process_root_flag changed the root directory, It does
not exist.

So, generate salt value before changeing the directory.

Fixes: #514
3 years agochpasswd: add get_salt for generating salt value
juyin [Thu, 31 Mar 2022 08:45:19 +0000 (16:45 +0800)] 
chpasswd: add get_salt for generating salt value

The function that generates the salt value is extracted separately, and it is more convenient to modify it later.

3 years agolibmisc: add check fopen return value in read_random_bytes()
juyin [Wed, 30 Mar 2022 11:21:32 +0000 (19:21 +0800)] 
libmisc: add check fopen return value in read_random_bytes()

Returns null when fopen fails. Then, using fread with a null pointer will cause a segfault.

Signed-off-by: Yan Zhu <zhuyan34@huawei.com>
3 years agoHandle ERANGE error correctly
Niko [Tue, 1 Mar 2022 13:43:07 +0000 (14:43 +0100)] 
Handle ERANGE error correctly

The reentrant functions getgrgid_r, getgrnam_r, getpwnam_r, etc. all return an error code instead of setting errno. Adapt the error check accordingly.

3 years agoAUTHORS: improve markdown output
Iker Pedrosa [Tue, 15 Mar 2022 08:29:04 +0000 (09:29 +0100)] 
AUTHORS: improve markdown output

The markdown output for the maintainers, authors and contributors list
was wrapped in a single line and it was difficult to read. I've created
an unordered list to get a better output. On top of that I've also added
myself as a maintainer.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agoChange to strncat
Steve Grubb [Fri, 18 Mar 2022 19:35:02 +0000 (15:35 -0400)] 
Change to strncat

ut_line is declared as a nonstring in bits/utmp.h. It might not be NUL
terminated. Limit how much it copies to the size of the array.

3 years agoFix code comment
ed neville [Sat, 12 Mar 2022 08:22:31 +0000 (08:22 +0000)] 
Fix code comment

Improving check around pw_dir which may be NULL

3 years agoCI: add fedora to build
Iker Pedrosa [Fri, 11 Mar 2022 14:38:13 +0000 (15:38 +0100)] 
CI: add fedora to build

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
3 years agoFix syntax error in usermod man source.
Adam Sampson [Mon, 7 Mar 2022 23:51:18 +0000 (23:51 +0000)] 
Fix syntax error in usermod man source.

Signed-off-by: Adam Sampson <ats@offog.org>
3 years agoImprove groupadd and useradd manpage
Markus Hiereth [Mon, 7 Mar 2022 00:48:22 +0000 (18:48 -0600)] 
Improve groupadd and useradd manpage

Signed-off-by: Serge Hallyn <serge@hallyn.com>
3 years agoupdate useradd homepage
Markus Hiereth [Mon, 7 Mar 2022 00:37:39 +0000 (18:37 -0600)] 
update useradd homepage

Signed-off-by: Serge Hallyn <serge@hallyn.com>
3 years agoManpage improvements for usermod
Markus Hiereth [Mon, 7 Mar 2022 00:12:13 +0000 (18:12 -0600)] 
Manpage improvements for usermod

Signed-off-by: Serge Hallyn <serge@hallyn.com>
3 years agoImprove groups and id manpages
Markus Hiereth [Sun, 6 Mar 2022 23:59:41 +0000 (17:59 -0600)] 
Improve groups and id manpages

Signed-off-by: Serge Hallyn <serge@hallyn.com>