Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

savecore: add missing call to cap_openlog when in capabilities mode #1546

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion sbin/savecore/savecore.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@
#define STATUS_GOOD 1
#define STATUS_UNKNOWN 2

#define LOG_OPTIONS LOG_PERROR
#define LOG_FACILITY LOG_DAEMON

static cap_channel_t *capsyslog;
static fileargs_t *capfa;
static bool checkfor, compress, uncompress, clear, force, keep; /* flags */
Expand Down Expand Up @@ -1409,6 +1412,7 @@ init_caps(int argc, char **argv)
exit(EXIT_FAILURE);
}
cap_close(capcas);
cap_openlog(capsyslog, "savecore", LOG_OPTIONS, LOG_FACILITY);
}

static void
Expand Down Expand Up @@ -1436,7 +1440,7 @@ main(int argc, char **argv)
savedir = ".";
comp_desired = KERNELDUMP_COMP_NONE;

openlog("savecore", LOG_PERROR, LOG_DAEMON);
openlog("savecore", LOG_OPTIONS, LOG_FACILITY);
signal(SIGINFO, infohandler);

argc = xo_parse_args(argc, argv);
Expand Down
2 changes: 1 addition & 1 deletion sbin/savecore/tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ATF_TESTS_SH= livedump_test
ATF_TESTS_SH= livedump_test log_test

.include <bsd.test.mk>
25 changes: 25 additions & 0 deletions sbin/savecore/tests/log_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2025 Stéphane Rochoy <[email protected]>
#

atf_test_case log_perror
log_perror_head()
{
atf_set "descr" "Test LOG_PERROR behavior"
}
log_perror_body()
{
atf_check -s exit:1 \
-o ignore \
-e save:savecore.err \
savecore -vC /dev/missing
grep -qE 'savecore [0-9]+ - - /dev/missing: No such file or directory' savecore.err \
|| atf_fail "missing/invalid error output"
}

atf_init_test_cases()
{
atf_add_test_case log_perror
}
Loading