Alejandro Colomar
dfc93b35cc
Assume mkdir(2) exists
...
It is required by POSIX.1-2001.
Link: <https://github.com/shadow-maint/shadow/pull/600 >
Cc: Christian Göttsche <cgzones@googlemail.com >
Cc: Iker Pedrosa <ipedrosa@redhat.com >
Cc: Mike Frysinger <vapier@gentoo.org >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
61299d69ad
Assume B[0-9]* macros are defined
...
All of the macros we're using are required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
f51c6838ac
Assume SIGTTOU is defined
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
307502d8b5
Assume SIGTSTP is defined
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
74c8015730
Assume RLIMIT_STACK is defined
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
c916715a6c
Assume RLIMIT_NOFILE is defined
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
5ebf28c999
Assume RLIMIT_FSIZE is defined
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
91adf3b8bb
Assume RLIMIT_DATA is defined
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
891d8dbedd
Assume RLIMIT_CPU is defined
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
7a4906fc75
Assume RLIMIT_AS is defined
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
e1a39e1dfc
Assume RLIMIT_CORE is defined
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
cbc363f671
Assume getgrgid_r(3) exists
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
88eb38f4ab
Assume getgrnam_r(3) exists
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
e5e5df1966
Assume getpwuid_r(3) exists
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
e788001977
Assume getpwnam_r(3) exists
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
a082a3975f
Assume fsync(2) exists
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
e71c23586a
Assume fchown(2) exists
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
9c86e07067
Assume fchmod(2) exists
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
55c62b663f
Assume l64a(3) exists
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
48391fb862
Assume <netdb.h> exists
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
b76d9b540a
Remove preprocessor conditionals that are always true
...
Since the last commit, LIMITS is always defined. Remove the dummy
macro, and all conditionals on it.
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
9d695340b4
Assume <sys/resource.h> exists
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
cdaa04e460
Remove uses of ulimit(3)
...
The function is obsolete. It is recommended to use getrlimit(2) instead
(see the manual page for ulimit(3) or the POSIX manual for it). Since
getrlimit(2) is required by POSIX.1-2001, we can rely on it.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
0527fa677b
Add indentation to heavy use of preprocessor conditionals
...
This clarifies which code is under which conditions,
for further clenaup.
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
7b1fc83e9b
Remove unused check for <utime.h>
...
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
eecd021c04
Remove unused check for <syslog.h>
...
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
5777e583cd
Assume <termios.h> exists
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
b47aa1e9aa
Assume <utmpx.h> exists
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
85d2688d62
Remove unused check for <sys/time.h>
...
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
578f286215
Assume <unistd.h> exists
...
It is required by POSIX.1-2001.
Cc: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
28e565aa83
Remove unused check for <fcntl.h>
...
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-15 16:22:05 -06:00
Alejandro Colomar
d7baafb2eb
Assume strstr(3) exists
...
ISO C99 requires strstr(3).
Link: <https://github.com/shadow-maint/shadow/pull/600 >
Cc: Christian Göttsche <cgzones@googlemail.com >
Cc: Iker Pedrosa <ipedrosa@redhat.com >
Cc: Mike Frysinger <vapier@gentoo.org >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-12 09:16:43 +01:00
Alejandro Colomar
0793782d31
Assume snprintf(3) exists
...
ISO C99 requires snprintf(3).
Link: <https://github.com/shadow-maint/shadow/pull/600 >
Cc: Christian Göttsche <cgzones@googlemail.com >
Cc: Iker Pedrosa <ipedrosa@redhat.com >
Cc: Mike Frysinger <vapier@gentoo.org >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-12 09:16:43 +01:00
Alejandro Colomar
7d3213741e
Assume rename(2) exists
...
ISO C99 requires rename(2).
Link: <https://github.com/shadow-maint/shadow/pull/600 >
Cc: Christian Göttsche <cgzones@googlemail.com >
Cc: Iker Pedrosa <ipedrosa@redhat.com >
Cc: Mike Frysinger <vapier@gentoo.org >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-12 09:16:43 +01:00
Alejandro Colomar
9d8c3df93c
Assume NULL exists
...
ISO C99 requires NULL.
Link: <https://github.com/shadow-maint/shadow/pull/600 >
Cc: Christian Göttsche <cgzones@googlemail.com >
Cc: Iker Pedrosa <ipedrosa@redhat.com >
Cc: Mike Frysinger <vapier@gentoo.org >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-12 09:16:43 +01:00
Alejandro Colomar
3a32f5278d
Assume strerror(3) exists
...
ISO C99 requires strerror(3).
Link: <https://github.com/shadow-maint/shadow/pull/600 >
Cc: Christian Göttsche <cgzones@googlemail.com >
Cc: Iker Pedrosa <ipedrosa@redhat.com >
Cc: Mike Frysinger <vapier@gentoo.org >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-12 09:16:43 +01:00
Alejandro Colomar
5e8df2b2b5
Assume fputs(3) exists
...
ISO C99 requires fputs(3).
Link: <https://github.com/shadow-maint/shadow/pull/600 >
Cc: Christian Göttsche <cgzones@googlemail.com >
Cc: Iker Pedrosa <ipedrosa@redhat.com >
Cc: Mike Frysinger <vapier@gentoo.org >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-12 09:16:43 +01:00
Alejandro Colomar
c26b682381
Assume <locale.h> exists
...
ISO C99 requires <locale.h>.
Other files in the project already include <locale.h> unconditionally,
so it's reasonable to assume that it is always available.
Link: <https://github.com/shadow-maint/shadow/pull/600 >
Cc: Christian Göttsche <cgzones@googlemail.com >
Cc: Iker Pedrosa <ipedrosa@redhat.com >
Cc: Mike Frysinger <vapier@gentoo.org >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-12 09:16:43 +01:00
Alejandro Colomar
d34c834ea8
Remove unused check for <limits.h>
...
Link: <https://github.com/shadow-maint/shadow/pull/600 >
Cc: Christian Göttsche <cgzones@googlemail.com >
Cc: Iker Pedrosa <ipedrosa@redhat.com >
Cc: Mike Frysinger <vapier@gentoo.org >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-12 09:16:43 +01:00
Alejandro Colomar
1eaa30756e
Assume <errno.h> exists
...
ISO C99 requires <errno.h>.
Many files in the project already include <errno.h> unconditionally,
so it's reasonable to assume that it is always available.
Link: <https://github.com/shadow-maint/shadow/pull/600 >
Cc: Christian Göttsche <cgzones@googlemail.com >
Cc: Iker Pedrosa <ipedrosa@redhat.com >
Cc: Mike Frysinger <vapier@gentoo.org >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-12 09:16:43 +01:00
Alejandro Colomar
c4d9dcacc9
Assume <stdbool.h> exists
...
ISO C99 requires <stdbool.h>.
Many files in the project already include <stdbool.h> unconditionally,
so it's reasonable to assume that it is always available.
Link: <https://github.com/shadow-maint/shadow/pull/600 >
Cc: Christian Göttsche <cgzones@googlemail.com >
Cc: Iker Pedrosa <ipedrosa@redhat.com >
Cc: Mike Frysinger <vapier@gentoo.org >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-12 09:16:43 +01:00
Alejandro Colomar
ab91ec10b4
Hide [[gnu::malloc(deallocator)]] in a macro
...
Clang doesn't implement this attribute and reports an error. Work
around it by hiding it in a macro that will be empty in clang.
Reported-by: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-05 10:47:19 +01:00
Alejandro Colomar
554f86bafa
Replace the deprecated getpass(3) by our agetpass()
...
getpass(3) is broken in all implementations; in some, more than
others, but somewhat broken in all of them. Check the immediate
previous commit, which added the functions, for more details.
Check also the Linux man-pages commit that marked it as
deprecated, for more details:
7ca189099d73bde954eed2d7fc21732bcc8ddc6b.
Link: <https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit?id=7ca189099d73bde954eed2d7fc21732bcc8ddc6b >
Reported-by: Christian Göttsche <cgzones@googlemail.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2022-12-05 10:47:19 +01:00
Alejandro Colomar
0336454503
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 >
2022-10-17 09:06:08 -05:00
Alejandro Colomar
3dc1754e50
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 >
2022-09-30 16:13:36 -05:00