From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1et7fh-0004mD-RE for guix-patches@gnu.org; Tue, 06 Mar 2018 03:10:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1et7fe-0000SV-LC for guix-patches@gnu.org; Tue, 06 Mar 2018 03:10:05 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:38903) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1et7fe-0000SO-Hk for guix-patches@gnu.org; Tue, 06 Mar 2018 03:10:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1et7fe-0005rZ-CB for guix-patches@gnu.org; Tue, 06 Mar 2018 03:10:02 -0500 Subject: [bug#30498] [WIP v2 shepherd] shepherd: If /dev/kmsg is writable, use it for logging. Resent-Message-ID: Date: Tue, 6 Mar 2018 09:09:05 +0100 From: Danny Milosavljevic Message-ID: <20180306090905.77f528a9@scratchpost.org> In-Reply-To: <87371ea2jj.fsf@gnu.org> References: <20180217122035.1443-1-dannym@scratchpost.org> <20180217164835.1178-1-dannym@scratchpost.org> <87muzvtyo3.fsf@gnu.org> <20180226233214.6fe40fa3@scratchpost.org> <87inai6b7w.fsf@gnu.org> <87bmg46d10.fsf@gnu.org> <20180303233715.7ec8a08c@scratchpost.org> <87371ea2jj.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/Wk_unt5IA62ejG146VS/FoR"; protocol="application/pgp-signature" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 30498@debbugs.gnu.org --Sig_/Wk_unt5IA62ejG146VS/FoR Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, On Mon, 05 Mar 2018 17:51:44 +0100 ludo@gnu.org (Ludovic Court=C3=A8s) wrote: > I tested it in a GuixSD VM and it works as advertised! \o/ Yay! > There=E2=80=99s one thing we need to improve though: syslogd reads /proc/= kmsg > and prefixes everything that comes from there with =E2=80=9Cvmunix=E2=80= =9D (as if it > came from the kernel). =20 Also, apparently syslogd uses the timestamp of "when it read the messages out of /dev/kmsg" as syslog entry timestamp *although* /dev/kmsg contains i= ts own timestamps (as offsets-from-bootup). Hrmmm... >That=E2=80=99s inconvenient because it makes it > impossible to have syslogd rules to filter shepherd messages. I've added a shepherd "prefix" in the shepherd messages, so it should end up as "vmunix: shepherd[1]: ..." (or so). The somewhat heavyhanded way to fix it would be to replace strcpy (line, "vmunix: "); by strcpy (line, ""); in inetutils-1.9.4/src/syslogd.c . Or use another syslogd :) According to the Linux kernel documentation the /dev/kmsg ring buffer is specifically allowed to be used by user processes (although they must not impersonate the kernel - if they try, the specified priority is ignored), so we're in the clear there. > So I think we need to do instead use a =E2=80=98syslog=E2=80=99-style int= erface and, > similar to what =E2=80=98syslog=E2=80=99 does in glibc, write to /dev/log= unless it=E2=80=99s > unavailable, in which case we fall back to /dev/kmsg. Yes, in the long run, we should do that. I think for this shepherd release it would be fine to use only /dev/kmsg - it's still an improvement - and the risk that we introduced a new bug by this is basically nonexistent. Later on, we should use /dev/log and fall back to /dev/kmsg and then again use /dev/log as it gets available etc. I'm not sure how to do the synchronisation (from shepherd's point of view, syslogd asynchronously reads from /dev/kmsg and puts the messages into its output files - so if we write to /dev/kmsg, then to /dev/log, then to /dev/kmsg, then to /dev/log, is the message order guaranteed?) >I=E2=80=99ll see if I can give it a try. Thanks :) --Sig_/Wk_unt5IA62ejG146VS/FoR Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqeTKEACgkQ5xo1VCww uqUBXQgAmNwQh/An5wPAfhFKO4FwnRpdlRcIAP2HbFwQsr/VLOp639tREQM/bSYg T+IoTLPkFy0a/8jCI/xpOfK7HjPGtRRNQ7Dvj+i//yfukGCkuDOvoNH4+rEPKObL Av4AOfBenL8GUAuiKMkn4EXkz4FFdmdXSApLGtvvceK094B1xsvTdlyIzXKDwS5J NzZjii5GZ9y6G8dtwQoVnB80ukcAEHrozGMof8wLGhvqg4LR5rm7F/uK/XuFkezy hXegQ0hDZ4p37/dS+u7zvZ+O115OsK6leAJ+vBgoWzLv5hOENmuyD1jkNvnalGIR lhluoxEwpxQYl3EToaiFsJOIc3uQmg== =6BVe -----END PGP SIGNATURE----- --Sig_/Wk_unt5IA62ejG146VS/FoR--