Commit Graph

2741 Commits

Author SHA1 Message Date
Christian Göttsche
4c641c1f2a Drop unnecessary prototype
The function is defined directly after.
2022-08-06 11:27:56 -05:00
Christian Göttsche
ae38d3a87f Declare read-only data const 2022-08-06 11:27:56 -05:00
Christian Göttsche
44917600b6 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.)
2022-08-06 11:27:56 -05:00
Christian Göttsche
c5090d91a1 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.
2022-08-06 11:27:56 -05:00
Christian Göttsche
e32b4a9a81 Declare read-only parameters const
Signal callers arguments are not going to be modified and allow passing
const pointers.
2022-08-06 11:27:56 -05:00
Christian Göttsche
0fe4128ee6 po: update translations
Add language identifiers and fix line break.
2022-08-06 11:27:56 -05:00
Christian Göttsche
af76c25f77 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
2022-08-06 11:27:56 -05:00
Christian Göttsche
caad9b987c 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
2022-08-06 11:27:56 -05:00
Jeremy Whiting
b5aba2624b Fix E_NAME_IN_USE documentation.
Since code gives this error if username or group name is already
used the documentation should reflect that.
2022-08-06 11:10:54 -05:00
Jeremy Whiting
f397e32638 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.
2022-08-06 10:54:26 -05:00
Masatake YAMATO
18b8095a8d tests: add a case for testing -F option of useradd
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2022-08-01 15:45:10 +02:00
Masatake YAMATO
3f7a72e967 useradd: add -F option for updating /etc/sub[ig]id for system accounts
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2022-08-01 15:45:10 +02:00
Masatake YAMATO
fb96d3f84d 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>
2022-08-01 15:45:10 +02:00
Iker Pedrosa
3ec32f9975 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>
2022-07-20 09:29:31 -05:00
Masatake YAMATO
62d99ee3fc man (useradd): add a note about -r option and /etc/subuid and subgid
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2022-07-15 09:42:21 +02:00
Alexander Zhang
ad4ab16559 Fix typo 2022-07-08 09:34:40 +02:00
Serge Hallyn
1bf5868e33 fix Changelog typo
Spotted by cgzones.
2022-07-05 08:49:15 -05:00
Serge Hallyn
f1a922f3b3 Update changelog
Signed-off-by: Serge Hallyn <serge@hallyn.com>
2022-07-04 14:30:09 -05:00
Xi Ruoyao
274e786be9 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>
2022-06-19 09:16:38 -05:00
Iker Pedrosa
6688f1c1eb 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>
2022-06-12 10:08:30 -05:00
Iker Pedrosa
1f84142915 CI: enable CodeQL analyzer
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2022-05-24 10:55:32 -05:00
Iker Pedrosa
f4d5705e4a CI: create Github workflow to install dependencies
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2022-05-24 10:55:32 -05:00
Yuri Chornoivan
f4cf8fe51c Complete Ukrainian translation 2022-05-24 07:52:36 -05:00
Yuri Chornoivan
a83533d97d Update Ukrainian translation 2022-05-24 07:52:36 -05:00
Yuri Chornoivan
b372b8a3be Add Ukrainian translation for man pages 2022-05-24 07:52:36 -05:00
Iker Pedrosa
3b89b71680 Initialize local variables
CWE-457 by CodeQL.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2022-05-24 07:49:11 -05:00
Iker Pedrosa
0c7ded471f Add header guards
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2022-05-24 07:49:11 -05:00
Iker Pedrosa
0b51cde162 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>
2022-05-24 07:49:11 -05:00
Iker Pedrosa
23baa40d9d 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>
2022-05-24 07:49:11 -05:00
Yuri Chornoivan
3e183c2f5a Update Ukrainian translation 2022-05-19 13:34:14 -05:00
Sam James
29309f5913 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>
2022-05-15 17:36:08 -05:00
Christian Göttsche
48ceff86de 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
2022-05-10 09:55:18 +02:00
Iker Pedrosa
45d6746219 src: correct "badname" option
Change "badnames" to "badname" as this is the accepted option name.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2022-05-06 10:13:51 -05:00
Iker Pedrosa
edf5ea7974 man: correct "badname" option
Change "badnames" to "badname" as this is the accepted option name.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2022-05-06 10:13:51 -05:00
Iker Pedrosa
b62d02f38f po: update translation files
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2022-05-06 10:13:51 -05:00
Iker Pedrosa
0593b330d8 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>
2022-05-06 10:13:51 -05:00
Christian Göttsche
58b6e97a9e passwd: erase password copy on all error branches 2022-04-30 13:19:14 -05:00
Matheus Marques
edca359022 usermod: fix alphabetical order in help message 2022-04-25 21:33:11 -05:00
Serge Hallyn
5a7ed86fba 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.
2022-04-25 10:52:29 -05:00
juyin
9cdb5251b6 chpasswd: add IS_CRYPT_METHOD
Use macro IS_CRYPT_METHOD instead of ’strcmp(crypt_method, xx)==0’ to make the code more cleanup
2022-04-03 21:07:09 -05:00
juyin
3c1e5fcf16 refactor get_salt function
refactor get_salt function to make it easier to read.
2022-04-03 21:07:09 -05:00
juyin
3732cf72d6 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
2022-04-03 21:07:09 -05:00
juyin
a026154c6f 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.
2022-04-03 21:07:09 -05:00
juyin
a43d0b95c4 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>
2022-04-03 21:07:09 -05:00
Niko
e9bf727253 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.
2022-03-18 20:24:10 -05:00
Iker Pedrosa
57cd14f194 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>
2022-03-18 16:10:51 -05:00
Steve Grubb
4f393a5f9f 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.
2022-03-18 16:02:01 -05:00
ed neville
b7bbf1beb8 Fix code comment
Improving check around pw_dir which may be NULL
2022-03-13 09:06:36 -05:00
Iker Pedrosa
d2da05aa1b CI: add fedora to build
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2022-03-11 12:40:47 -06:00
Adam Sampson
c9015a7e58 Fix syntax error in usermod man source.
Signed-off-by: Adam Sampson <ats@offog.org>
2022-03-07 19:39:49 -06:00