Commit Graph

3509 Commits

Author SHA1 Message Date
f5ed484920 swclock: missing includes from IWYU 2023-01-29 11:32:22 -06:00
00f90f2b0e supervise-daemon: missing includes from IWYU 2023-01-29 11:32:22 -06:00
b405681926 start-stop-daemon: missing includes from IWYU 2023-01-29 11:32:22 -06:00
d5700d036a shell_var: missing includes from IWYU 2023-01-29 11:32:22 -06:00
616f756ca8 shared: missing includes from IWYU 2023-01-29 11:32:22 -06:00
17cfb41d81 service: missing includes from IWYU 2023-01-29 11:32:22 -06:00
1bc87b7a7c seedrng: missing includes from IWYU 2023-01-29 11:32:22 -06:00
f3be11a00d rc-update: missing includes from IWYU 2023-01-29 11:32:22 -06:00
406ab2a4ca rc-status: missing includes from IWYU 2023-01-29 11:32:22 -06:00
7878a53542 rc-service: missing includes from IWYU 2023-01-29 11:32:22 -06:00
084e6b5e20 rc-depend: missing includes from IWYU 2023-01-29 11:32:22 -06:00
a7bd13145b rc-abort: missing includes from IWYU 2023-01-29 11:32:22 -06:00
28ecb38515 openrc-shutdown: missing includes from IWYU 2023-01-29 11:32:22 -06:00
91737be1ab openrc-run: missing includes from IWYU 2023-01-29 11:32:22 -06:00
fb6ffc5713 openrc: missing includes from IWYU 2023-01-29 11:32:22 -06:00
01acbe3c27 openrc-init: missing includes from IWYU 2023-01-29 11:32:22 -06:00
aa5c3ccd0b mountinfo: missing includes from IWYU 2023-01-29 11:32:22 -06:00
d795ea183f mark_service: missing includes from IWYU 2023-01-29 11:32:22 -06:00
5af3944440 librc: missing includes from IWYU 2023-01-29 11:32:22 -06:00
01bcdb43b6 libeinfo: missing includes from IWYU 2023-01-29 11:32:22 -06:00
bcd1975fe7 kill_all: missing includes from IWYU 2023-01-29 11:32:22 -06:00
57e194df4f is_older_than: missing includes from IWYU 2023-01-29 11:32:22 -06:00
dacd0ab189 is_newer_than: missing includes from IWYU 2023-01-29 11:32:22 -06:00
7cfe93d032 fstabinfo: missing includes from IWYU 2023-01-29 11:32:22 -06:00
893df75e30 einfo: missing includes from IWYU 2023-01-29 11:32:22 -06:00
c80d6bb2ed checkpath: missing includes from IWYU 2023-01-29 11:32:22 -06:00
bfe38c98a8 src: shared: schedules: add missing includes to header
Needed for clang-tidy prep work, as it requires headers to work standalone
(which is useful anyway).
2023-01-28 22:14:30 -06:00
e8a76ad6e6 src: shared: plugin: add missing includes to header
Needed for clang-tidy prep work, as it requires headers to work standalone
(which is useful anyway).
2023-01-28 22:14:30 -06:00
7d63049adb src: shared: misc: add missing includes to header
Needed for clang-tidy prep work, as it requires headers to work standalone
(which is useful anyway).
2023-01-28 22:14:30 -06:00
dc0b3157a9 src: shared: helpers: add missing includes to header
Needed for clang-tidy prep work, as it requires headers to work standalone
(which is useful anyway).
2023-01-28 22:14:30 -06:00
2f6b5b7ef4 openrc: rc-logger: add missing includes to header
Needed for clang-tidy prep work, as it requires headers to work standalone
(which is useful anyway).
2023-01-28 22:14:30 -06:00
NRK
eb3635dd1f swclock: fix codeql warning and upgrade to futimens
this was reported by codeql's scan as a TOCTOU bug. while that's true in
theory, i don't believe it would've had any practical effect.

a better justification for this change might be the fact that it
upgrades from `utime` (which is depreciated by POSIX [0]) to `futimens`.

[0]: https://www.man7.org/linux/man-pages/man3/utime.3p.html#FUTURE_DIRECTIONS
2023-01-28 16:19:33 -05:00
NRK
459783bbad openrc: avoid unnecessary malloc inside sig-handler
malloc (called by xasprintf) is not async-signal-safe. beside, the
string here is constant, so there's no need to malloc it all.

eerrorx isn't async-signal-safe either (due to calling fprintf and exit)
but consequence of them are _typically_ not as grave as calling malloc
while it's internal state is inconsistent.

Bug: https://github.com/OpenRC/openrc/issues/589
2023-01-28 13:08:00 -05:00
a28bdc7e5c openrc-shutdown: mark handler as noreturn, use _unused macro 2023-01-25 01:11:25 -05:00
bcae7d03b4 openrc: mark handle_bad_signal as noreturn
For -Wmissing-noreturn.
2023-01-25 00:51:13 -05:00
ccc2b71145 supervise-daemon: mark various functions as noreturn
For -Wmissing-noreturn.
2023-01-25 00:50:43 -05:00
78c0693c50 openrc-shutdown: mark stop_shutdown as noreturn, fix typo/indentation
For -Wmissing-noreturn.
2023-01-25 00:50:15 -05:00
ddf4a3a7a0 shared: move _noreturn definition into helpers.h 2023-01-25 00:49:47 -05:00
a6568c304f libeinfo: fix -Wunused-but-set-variable 2023-01-25 00:49:22 -05:00
d6a5264a9d librc: fix 'init' memory leak
From scan-build w/ clang-16.0.0_pre20230107:
```
../src/librc/librc.c:759:14: warning: Potential leak of memory pointed to by 'init' [unix.Malloc]
                                                return false;
                                                       ^~~~~
```
2023-01-25 00:48:26 -05:00
9f227e8b49 openrc-run: drop strlen dead store 2023-01-25 00:08:30 -05:00
3bb5450320 openrc-shutdown: fix need_warning dead store
It's already initialised to false at the start and it's clear when reading
what the flow is.

While at it, fix some indentation and adjust whitespace to make more readable.
2023-01-25 00:07:03 -05:00
a689fdb7be openrc-run: fix -Wunused-but-set-variable 2023-01-25 00:06:27 -05:00
fc4f15d6cd openrc: fix double-assignment to dir
This one is a bit odd, it didn't get fixed in e273b4e08e,
and goes all the way back to cb9da6a262.
2023-01-25 00:05:32 -05:00
19f329d2f4 openrc, openrc-run: Fix -Wstrict-prototypes
These become fine with C23 because () starts to mean (void) then, but for
previous language versions, it's deprecated, and it causes an annoying
warning when building with Clang by default.

Plus, GCC lacks specific flags to trigger what C23 *does* ban, so a lot
of people are going around building with -Wstrict-prototypes, so let's
just fix this to be consistent with the rest of the codebase anyway
to fend off false positive reports.
2023-01-25 00:05:05 -05:00
0b86c06c3c update cirrus ci to latest FreeBSD images 2023-01-24 11:32:11 -06:00
fea9d9a7f0 add CoC based on the Contributor Covenant project 2023-01-21 22:01:15 -06:00
9dfd2b2737 start-stop-daemon, supervise-daemon: use closefrom()/close_range()
On systems with a very large RLIMIT_NOFILE, calling close() in a loop
from 3 to getdtablesize() effects an enormous number of system calls.
There are better alternatives. Both BSD and Linux have the closefrom()
system call that closes all file descriptors with indices not less than
a specified minimum. Have start-stop-daemon call closefrom() on systems
where it's implemented, falling back to the old loop elsewhere.

Likewise, calling fcntl(i, F_SETFD, FD_CLOEXEC) in a loop from 3 to
getdtablesize() raises a similar performance concern. Linux 5.11 and
onward has a close_range() system call with a CLOSE_RANGE_CLOEXEC flag
that sets the FD_CLOEXEC flag on all file descriptors in a specified
range. Have supervise-daemon utilize this feature on systems where it's
implemented, falling back to the old loop elsewhere.
2023-01-20 21:44:37 -06:00
de295bd0c6 start-stop-daemon: remove unnecessary carve-out for pipe FD
1364e6631c exempted the write end of the
synchronization pipe from the close() loop in the child process, but
this is unnecessary, as the pipe is opened with O_CLOEXEC, and the child
process calls execvp() soon after the close() loop, with the intervening
code not needing the pipe. Indeed, the pipe only needs to remain open in
the child process until after the call to setsid(), which occurs well
before the close() loop. So, eliminate the needless carve-out from the
close() loop, in preparation for introducing closefrom().
2023-01-20 21:44:37 -06:00
6f44445958 checkpath: add missing sticky/set*id mode bits to check
We incorrectly masked out the upper 3 bits when checking to see if the
permissions need updating leading us to run chmod when not needed.

Fixes #482.
2023-01-15 15:31:25 -05:00