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: |
sudo apt-get -y update
sudo apt-get -y install tree tshark valgrind
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Configure
run: |
set -x

View File

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

View File

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

View File

@ -4,6 +4,24 @@ Change Log
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
-----------------------
@ -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
[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.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

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.
#
# 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.
#
# 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
# 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])
AC_CONFIG_AUX_DIR(aux)
AM_INIT_AUTOMAKE([1.11 foreign subdir-objects])

View File

@ -1,6 +1,6 @@
/* 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
* purpose with or without fee is hereby granted, provided that the above
@ -21,12 +21,20 @@
#endif
#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
__utimensat(int dirfd, const char *pathname, const struct timespec ts[2], int flags)
{
int ret = -1;
struct timeval tv[2];
(void)flags;
if (dirfd != 0) {
errno = ENOTSUP;
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.
#
# Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
.\" -*- nroff -*-
.\" Copyright (c) 2018-2022 Joachim Wiberg <troglobit@gmail.com>
.\" Copyright (c) 2018-2023 Joachim Wiberg <troglobit@gmail.com>
.\" All rights reserved.
.\"
.\" 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
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.Dd August 1, 2022
.Dd April 30, 2023
.Dt LOGGER 1
.Os sysklogd
.Sh NAME

View File

@ -38,7 +38,7 @@
.Nd log systems messages
.Sh SYNOPSIS
.Nm
.Op Fl ?468AdFHKknsTtv
.Op Fl ?468AcdFHKknsTtv
.Op Fl a Ar addr[/len][:port]
.Op Fl a Ar name[: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
.Nm
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
Put
.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.
#
# Redistribution and use in source and binary forms, with or without
@ -33,7 +33,7 @@ if ENABLE_LOGGER
bin_PROGRAMS += logger
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_CPPFLAGS = -DSYSCONFDIR=\"@sysconfdir@\" -DRUNSTATEDIR=\"@runstatedir@\"
AM_CPPFLAGS += -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_GNU_SOURCE

View File

@ -1,7 +1,7 @@
/*-
* 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.
*
* Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
/*-
* 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
* modification, are permitted provided that the following conditions

View File

@ -1,7 +1,7 @@
/*-
* 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
* 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 mask_C1 = 1; /* mask characters from 0x80 - 0x9F */
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_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 int opensys(const char *file);
static void printsys(char *msg);
static void unix_cb(int sd, void *arg);
static void logmsg(struct buf_msg *buffer);
static void logrotate(struct filed *f);
static void rotate_file(struct filed *f, struct stat *stp_or_null);
@ -395,7 +397,7 @@ int main(int argc, char *argv[])
char *ptr;
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) {
case '4':
family = PF_INET;
@ -433,6 +435,10 @@ int main(int argc, char *argv[])
CacheFile = optarg;
break;
case 'c':
no_compress++;
break;
case 'd': /* debug */
Debug = 1;
Foreground = 1;
@ -521,12 +527,20 @@ int main(int argc, char *argv[])
.pe_serv = "syslog",
});
/* Default to _PATH_LOG for the UNIX domain socket */
if (!pflag)
addpeer(&(struct peer) {
.pe_name = _PATH_LOG,
.pe_mode = 0666,
});
/* Figure out where to read system log messages from */
if (!pflag) {
/* Do we run under systemd-journald (Requires=syslog.socket)? */
if (fcntl(3, F_GETFD) != -1) {
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) {
ppid = waitdaemon(30);
@ -1671,7 +1685,8 @@ static void logmsg(struct buf_msg *buffer)
/*
* 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)) {
f->f_lasttime = buffer->timestamp;
f->f_prevcount++;

View File

@ -1,7 +1,7 @@
/*-
* 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
* modification, are permitted provided that the following conditions
@ -106,7 +106,7 @@ static int __timer_start(void)
if (sec <= 0)
sec = 1;
return alarm(sec);
return alarm((unsigned int)sec);
}
/*

View File

@ -1,7 +1,7 @@
/*-
* 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
* modification, are permitted provided that the following conditions

View File

@ -7,11 +7,7 @@
# First some standard log files. Log by facility.
#
auth,authpriv.* /var/log/auth.log
# 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
*.*;auth,authpriv.none -/var/log/syslog
#cron.* /var/log/cron.log
#daemon.* -/var/log/daemon.log

View File

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