Compare commits

..

10 Commits

Author SHA1 Message Date
Joachim Wiberg
b6d1ae2667 Bump version and update ChangeLog for v2.5.0 release
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-30 20:08:56 +02:00
Joachim Wiberg
f926039511 Update copyright years
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-30 20:06:33 +02:00
Joachim Wiberg
ae15ee11a7 lib: minor, ensure we have TIMESPEC_TO_TIMEVAL()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-30 20:02:51 +02:00
Joachim Wiberg
c6de7dfa69 Inform Coverity Scan we use relative time for alarm()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-22 09:31:38 +02:00
Joachim Wiberg
0cde7cbcc5 .github: bump version of actions for Node.js upgrade
This also refactors the release job to use ncipollo/release-action@v1
instead of the deprecated actions/create-release@v1

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-22 09:18:07 +02:00
Joachim Wiberg
8768f9246b Clang workaround for valgrind checks
https://www.reddit.com/r/C_Programming/comments/wau4t5/weird_error_when_trying_to_run_valgrind_possibly

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-22 09:13:13 +02:00
Joachim Wiberg
5c33df4ca0 Update ChangeLog and bump version for upcoming v2.5.0 release
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-22 08:59:35 +02:00
Joachim Wiberg
218a032557 Fix #61: add support for -c and -cc to disable log compression
This patch imports the FreeBSD meaning to the `-c` command line option.
It disables "last message repeated" style log compression for repeated
log messages.  A single `-c` disables compression for pipes, another
`-c` (-cc works) also disables compression for all other log targets.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-22 08:48:32 +02:00
Joachim Wiberg
b3d0a9b638 Revert "syslog.conf: disable debug messages by default from /var/log/syslog"
This reverts commit 4fd55cd1ac because it
has caused more problems than it was intended to fix.  If users get too
much debug log messages they can add this themselves, but if they don't
get their log messages they will believe there's something wrong with
their application generating the logs.

The file /var/log/syslog is supposed to log everything, except auth*.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-22 08:33:23 +02:00
Joachim Wiberg
7ec64e5f9c Fix #62: early log messages lost when running in systemd
This is a follow-up to d7576c7 which initially added support for running
in systemd based systems.  Since the unit file sources the syslog.socket
we have /run/systemd/journal/syslog open already on descriptor 3.  All
we need to do is verify that's the mode syslogd runs in.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-22 08:27:57 +02:00
19 changed files with 91 additions and 71 deletions

View File

@ -28,7 +28,7 @@ jobs:
run: | run: |
sudo apt-get -y update sudo apt-get -y update
sudo apt-get -y install tree tshark valgrind sudo apt-get -y install tree tshark valgrind
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Configure - name: Configure
run: | run: |
set -x set -x

View File

@ -15,8 +15,8 @@ jobs:
coverity: coverity:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/cache@v2 - uses: actions/cache@v3
id: coverity-toolchain-cache id: coverity-toolchain-cache
with: with:
path: cov-analysis-linux64 path: cov-analysis-linux64
@ -53,7 +53,7 @@ jobs:
--form description="${PROJECT_NAME} $(git rev-parse HEAD)" \ --form description="${PROJECT_NAME} $(git rev-parse HEAD)" \
https://scan.coverity.com/builds?project=${COVERITY_PROJ} https://scan.coverity.com/builds?project=${COVERITY_PROJ}
- name: Upload build.log - name: Upload build.log
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
with: with:
name: coverity-build.log name: coverity-build.log
path: cov-int/build-log.txt path: cov-int/build-log.txt

View File

@ -7,38 +7,11 @@ on:
jobs: jobs:
release: release:
name: Create GitHub release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release_id: ${{ steps.create_release.outputs.id }}
steps:
- uses: actions/checkout@v2
- name: Extract ChangeLog entry ...
# Hack to extract latest entry for body_path below
run: |
awk '/-----*/{if (x == 1) exit; x=1;next}x' ChangeLog.md \
|head -n -1 > release.md
cat release.md
- name: Create release ...
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: sysklogd ${{ github.ref }}
body_path: release.md
draft: false
prerelease: false
tarball:
name: Build and upload release tarball name: Build and upload release tarball
needs: release
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Installing dependencies ... - name: Installing dependencies ...
run: | run: |
sudo apt-get -y update sudo apt-get -y update
@ -49,14 +22,16 @@ jobs:
./configure --prefix=/tmp --with-systemd=/tmp/lib/systemd/system ./configure --prefix=/tmp --with-systemd=/tmp/lib/systemd/system
- name: Build release ... - name: Build release ...
run: | run: |
make release || (cat sysklogd-2.3.0/_build/sub/test/start.log; cat sysklogd-2.3.0/_build/sub/test/remote.log; false) make release
ls -lF ../
mkdir -p artifacts/ mkdir -p artifacts/
mv ../*.tar.* artifacts/ mv ../*.tar.* artifacts/
- name: Upload release artifacts ... - name: Extract ChangeLog entry ...
uses: skx/github-action-publish-binaries@release-0.15 run: |
env: awk '/-----*/{if (x == 1) exit; x=1;next}x' ChangeLog.md \
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |head -n -1 > release.md
cat release.md
- uses: ncipollo/release-action@v1
with: with:
releaseId: ${{ needs.release.outputs.release_id }} name: sysklogd ${{ github.ref_name }}
args: artifacts/* bodyFile: "release.md"
artifacts: "artifacts/*"

View File

@ -4,6 +4,24 @@ Change Log
All relevant changes to the project are documented in this file. All relevant changes to the project are documented in this file.
[v2.5.0][] - 2023-04-30
-----------------------
### Changes
- Issue #59: initial port to NuttX, contributed by Xiaomi
- Issue #61: add support for `-c` and `-cc` to disable log compression.
A single `-c` disables compression for pipes, another `-c` (or `-cc`)
disables compression for all other log targets
- The default `syslog.conf` now logs debug messages again (disabled in
v2.4.0) due to problems (confusion) reported in the field
- Dropped not recommended `KillMode=process` from systemd unit file
### Fixes
- Issue #60: document how to set side-wide permissions on log files
- Issue #62: early log messages lost when running under systemd, found
by Wind River Systems, including initial fix
[v2.4.4][] - 2022-08-14 [v2.4.4][] - 2022-08-14
----------------------- -----------------------
@ -525,7 +543,9 @@ and a replacement for `syslog.h` to enable new features in RFC5424.
- Several bugfixes and improvements, please refer to the .c files - Several bugfixes and improvements, please refer to the .c files
[UNRELEASED]: https://github.com/troglobit/sysklogd/compare/v2.4.3...HEAD [UNRELEASED]: https://github.com/troglobit/sysklogd/compare/v2.5.0...HEAD
[v2.5.0]: https://github.com/troglobit/sysklogd/compare/v2.4.4...v2.5.0
[v2.4.4]: https://github.com/troglobit/sysklogd/compare/v2.4.3...v2.4.4
[v2.4.3]: https://github.com/troglobit/sysklogd/compare/v2.4.2...v2.4.3 [v2.4.3]: https://github.com/troglobit/sysklogd/compare/v2.4.2...v2.4.3
[v2.4.2]: https://github.com/troglobit/sysklogd/compare/v2.4.1...v2.4.2 [v2.4.2]: https://github.com/troglobit/sysklogd/compare/v2.4.1...v2.4.2
[v2.4.1]: https://github.com/troglobit/sysklogd/compare/v2.4.0...v2.4.1 [v2.4.1]: https://github.com/troglobit/sysklogd/compare/v2.4.0...v2.4.1

View File

@ -1,4 +1,4 @@
# Copyright (c) 2018-2021 Joachim Wiberg <troglobit@gmail.com> # Copyright (c) 2018-2023 Joachim Wiberg <troglobit@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without

View File

@ -1,4 +1,4 @@
# Copyright (c) 2018-2021 Joachim Wiberg <troglobit@gmail.com> # Copyright (c) 2018-2023 Joachim Wiberg <troglobit@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -25,7 +25,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE. # SUCH DAMAGE.
AC_INIT([sysklogd], [2.4.4], [https://github.com/troglobit/sysklogd/issues],, AC_INIT([sysklogd], [2.5.0], [https://github.com/troglobit/sysklogd/issues],,
[https://github.com/troglobit/sysklogd]) [https://github.com/troglobit/sysklogd])
AC_CONFIG_AUX_DIR(aux) AC_CONFIG_AUX_DIR(aux)
AM_INIT_AUTOMAKE([1.11 foreign subdir-objects]) AM_INIT_AUTOMAKE([1.11 foreign subdir-objects])

View File

@ -1,6 +1,6 @@
/* Replacement in case utimensat(2) is missing /* Replacement in case utimensat(2) is missing
* *
* Copyright (C) 2017-2021 Joachim Wiberg <troglobit@gmail.com> * Copyright (C) 2017-2023 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@ -21,12 +21,20 @@
#endif #endif
#include <sys/time.h> /* lutimes(), utimes(), utimensat() */ #include <sys/time.h> /* lutimes(), utimes(), utimensat() */
#ifndef TIMESPEC_TO_TIMEVAL
#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
(tv)->tv_sec = (ts)->tv_sec; \
(tv)->tv_usec = (ts)->tv_nsec / 1000; \
}
#endif
int int
__utimensat(int dirfd, const char *pathname, const struct timespec ts[2], int flags) __utimensat(int dirfd, const char *pathname, const struct timespec ts[2], int flags)
{ {
int ret = -1; int ret = -1;
struct timeval tv[2]; struct timeval tv[2];
(void)flags;
if (dirfd != 0) { if (dirfd != 0) {
errno = ENOTSUP; errno = ENOTSUP;
return -1; return -1;

View File

@ -1,4 +1,4 @@
# Copyright (c) 2018-2021 Joachim Wiberg <troglobit@gmail.com> # Copyright (c) 2018-2023 Joachim Wiberg <troglobit@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
.\" -*- nroff -*- .\" -*- nroff -*-
.\" Copyright (c) 2018-2022 Joachim Wiberg <troglobit@gmail.com> .\" Copyright (c) 2018-2023 Joachim Wiberg <troglobit@gmail.com>
.\" All rights reserved. .\" All rights reserved.
.\" .\"
.\" Redistribution and use in source and binary forms, with or without .\" Redistribution and use in source and binary forms, with or without
@ -25,7 +25,7 @@
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.Dd August 1, 2022 .Dd April 30, 2023
.Dt LOGGER 1 .Dt LOGGER 1
.Os sysklogd .Os sysklogd
.Sh NAME .Sh NAME

View File

@ -38,7 +38,7 @@
.Nd log systems messages .Nd log systems messages
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl ?468AdFHKknsTtv .Op Fl ?468AcdFHKknsTtv
.Op Fl a Ar addr[/len][:port] .Op Fl a Ar addr[/len][:port]
.Op Fl a Ar name[:port] .Op Fl a Ar name[:port]
.Op Fl b Ar addr[:port] .Op Fl b Ar addr[:port]
@ -245,6 +245,12 @@ relies on this file being removed at system reboot. The default
location depends on the system and how location depends on the system and how
.Nm .Nm
was configured. was configured.
.It Fl c
Disable the compression of repeated instances of the same line into a
single line of the form
.Dq Li "last message repeated N times"
when the output is a pipe to another program. If specified twice,
disable this compression in all cases.
.It Fl d .It Fl d
Put Put
.Nm .Nm

View File

@ -1,4 +1,4 @@
# Copyright (c) 2018-2021 Joachim Wiberg <troglobit@gmail.com> # Copyright (c) 2018-2023 Joachim Wiberg <troglobit@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -33,7 +33,7 @@ if ENABLE_LOGGER
bin_PROGRAMS += logger bin_PROGRAMS += logger
endif endif
AM_CFLAGS = -W -Wall -Wextra -std=c99 AM_CFLAGS = -W -Wall -Wextra -std=c99 -gdwarf-4
AM_CFLAGS += -Wno-unused-result -Wno-unused-parameter -fno-strict-aliasing AM_CFLAGS += -Wno-unused-result -Wno-unused-parameter -fno-strict-aliasing
AM_CPPFLAGS = -DSYSCONFDIR=\"@sysconfdir@\" -DRUNSTATEDIR=\"@runstatedir@\" AM_CPPFLAGS = -DSYSCONFDIR=\"@sysconfdir@\" -DRUNSTATEDIR=\"@runstatedir@\"
AM_CPPFLAGS += -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_GNU_SOURCE AM_CPPFLAGS += -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_GNU_SOURCE

View File

@ -1,7 +1,7 @@
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
* Copyright (c) 2018-2021 Joachim Wiberg <troglobit@gmail.com> * Copyright (c) 2018-2023 Joachim Wiberg <troglobit@gmail.com>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
* Copyright (C) 2017-2021 Joachim Wiberg <troglobit@gmail.com> * Copyright (C) 2017-2023 Joachim Wiberg <troglobit@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions

View File

@ -1,7 +1,7 @@
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
* Copyright (C) 2017-2021 Joachim Wiberg <troglobit@gmail.com> * Copyright (C) 2017-2023 Joachim Wiberg <troglobit@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions

View File

@ -144,6 +144,7 @@ static int MarkInterval = 20 * 60; /* interval between marks in seconds */
static int family = PF_UNSPEC; /* protocol family (IPv4, IPv6 or both) */ static int family = PF_UNSPEC; /* protocol family (IPv4, IPv6 or both) */
static int mask_C1 = 1; /* mask characters from 0x80 - 0x9F */ static int mask_C1 = 1; /* mask characters from 0x80 - 0x9F */
static int send_to_all; /* send message to all IPv4/IPv6 addresses */ static int send_to_all; /* send message to all IPv4/IPv6 addresses */
static int no_compress; /* don't compress messages (1=pipes, 2=all) */
static int secure_opt; /* sink for others, log to remote, or only unix domain socks */ static int secure_opt; /* sink for others, log to remote, or only unix domain socks */
static int secure_mode; /* same as above but from syslog.conf, only if cmdline unset */ static int secure_mode; /* same as above but from syslog.conf, only if cmdline unset */
@ -193,6 +194,7 @@ void untty(void);
static void parsemsg(const char *from, char *msg); static void parsemsg(const char *from, char *msg);
static int opensys(const char *file); static int opensys(const char *file);
static void printsys(char *msg); static void printsys(char *msg);
static void unix_cb(int sd, void *arg);
static void logmsg(struct buf_msg *buffer); static void logmsg(struct buf_msg *buffer);
static void logrotate(struct filed *f); static void logrotate(struct filed *f);
static void rotate_file(struct filed *f, struct stat *stp_or_null); static void rotate_file(struct filed *f, struct stat *stp_or_null);
@ -395,7 +397,7 @@ int main(int argc, char *argv[])
char *ptr; char *ptr;
int ch; int ch;
while ((ch = getopt(argc, argv, "468Aa:b:C:dHFf:Kkm:nP:p:r:sTtv?")) != EOF) { while ((ch = getopt(argc, argv, "468Aa:b:C:cdHFf:Kkm:nP:p:r:sTtv?")) != EOF) {
switch ((char)ch) { switch ((char)ch) {
case '4': case '4':
family = PF_INET; family = PF_INET;
@ -433,6 +435,10 @@ int main(int argc, char *argv[])
CacheFile = optarg; CacheFile = optarg;
break; break;
case 'c':
no_compress++;
break;
case 'd': /* debug */ case 'd': /* debug */
Debug = 1; Debug = 1;
Foreground = 1; Foreground = 1;
@ -521,12 +527,20 @@ int main(int argc, char *argv[])
.pe_serv = "syslog", .pe_serv = "syslog",
}); });
/* Default to _PATH_LOG for the UNIX domain socket */ /* Figure out where to read system log messages from */
if (!pflag) if (!pflag) {
addpeer(&(struct peer) { /* Do we run under systemd-journald (Requires=syslog.socket)? */
.pe_name = _PATH_LOG, if (fcntl(3, F_GETFD) != -1) {
.pe_mode = 0666, if (socket_register(3, NULL, unix_cb, NULL) == -1)
}); err(1, "failed registering syslog.socket (3)");
} else {
/* Default to _PATH_LOG for the UNIX domain socket */
addpeer(&(struct peer) {
.pe_name = _PATH_LOG,
.pe_mode = 0666,
});
}
}
if (!Foreground && !Debug) { if (!Foreground && !Debug) {
ppid = waitdaemon(30); ppid = waitdaemon(30);
@ -1671,7 +1685,8 @@ static void logmsg(struct buf_msg *buffer)
/* /*
* suppress duplicate lines to this file * suppress duplicate lines to this file
*/ */
if ((buffer->flags & MARK) == 0 && savedlen == f->f_prevlen && if (no_compress - (f->f_type != F_PIPE) < 1 &&
(buffer->flags & MARK) == 0 && savedlen == f->f_prevlen &&
!strcmp(saved, f->f_prevline)) { !strcmp(saved, f->f_prevline)) {
f->f_lasttime = buffer->timestamp; f->f_lasttime = buffer->timestamp;
f->f_prevcount++; f->f_prevcount++;

View File

@ -1,7 +1,7 @@
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
* Copyright (C) 2017-2021 Joachim Wiberg <troglobit@gmail.com> * Copyright (C) 2017-2023 Joachim Wiberg <troglobit@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -106,7 +106,7 @@ static int __timer_start(void)
if (sec <= 0) if (sec <= 0)
sec = 1; sec = 1;
return alarm(sec); return alarm((unsigned int)sec);
} }
/* /*

View File

@ -1,7 +1,7 @@
/*- /*-
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
* *
* Copyright (C) 2017-2021 Joachim Wiberg <troglobit@gmail.com> * Copyright (C) 2017-2023 Joachim Wiberg <troglobit@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions

View File

@ -7,11 +7,7 @@
# First some standard log files. Log by facility. # First some standard log files. Log by facility.
# #
auth,authpriv.* /var/log/auth.log auth,authpriv.* /var/log/auth.log
*.*;auth,authpriv.none -/var/log/syslog
# Everything except debug and security tokens, re-enable debug by
# dropping '*.!=debug;', or enable /var/log/debug below
*.*;*.!=debug;\
auth,authpriv.none -/var/log/syslog
#cron.* /var/log/cron.log #cron.* /var/log/cron.log
#daemon.* -/var/log/daemon.log #daemon.* -/var/log/daemon.log

View File

@ -6,7 +6,7 @@ Requires=syslog.socket
[Service] [Service]
EnvironmentFile=-@SYSCONFDIR@/default/syslogd EnvironmentFile=-@SYSCONFDIR@/default/syslogd
ExecStart=@SBINDIR@/syslogd -F -p /run/systemd/journal/syslog $SYSLOGD_OPTS ExecStart=@SBINDIR@/syslogd -F $SYSLOGD_OPTS
StandardOutput=null StandardOutput=null
Restart=on-failure Restart=on-failure