From: Steffen Nurpmeso <steffen@sdaoden.eu>
To: John Cowan <cowan@ccil.org>
Cc: The Eunuchs Hysterical Society <tuhs@tuhs.org>
Subject: Re: [TUHS] Binary log files
Date: Mon, 05 Jul 2021 15:41:59 +0200 [thread overview]
Message-ID: <20210705134159.jR0uH%steffen@sdaoden.eu> (raw)
In-Reply-To: <CAD2gp_SXHQSauT_VibXPvP6PWrFULiMFYkvfs5=YxjHYbHGPwg@mail.gmail.com>
John Cowan wrote in
<CAD2gp_SXHQSauT_VibXPvP6PWrFULiMFYkvfs5=YxjHYbHGPwg@mail.gmail.com>:
|As long ago as the 7th Edition, several binary log files were maintained:
|the file generated by acct(2) (one record per process) and the utmp and
|wtmp files (one record per login). Both of these are defined by structs in
|.h files, so they are definitely not portable (int sizes, endianism, etc.)
And how did you handle it?
On a very current GNU/Linux system these files grow indefinetely,
and sometimes you find several megabytes that track years of data,
and yourself writing (nonetheless quickshot) truncation code like
#?0|kent:~# less bin/truncate-wutmp.sh
#!/bin/sh -
#@ /root/bin/truncate-wutmp.sh
trap 'rm -f /tmp/.doit-${$}.*' EXIT
cat >/tmp/.doit-${$}.c <<'_EOT'
#include <utmp.h>
#include <stdio.h>
int main(){
printf("%lu\n", sizeof(struct utmp));
return 0;
}
_EOT
cc -o /tmp/.doit-${$}.exe /tmp/.doit-${$}.c || exit 1
i=$(/tmp/.doit-${$}.exe)
echo "struct utmp is ${i} bytes"
cd /var/log
s=$(stat -c '%s' wtmp)
[ ${?} -eq 0 ] || exit 2
echo "wtmp size is ${s} bytes"
ix=$((s / i))
echo "... that makes ${ix} utmp entries"
[ ${ix} -gt 42 ] || exit 3
ix=$((ix - 42))
dd if=wtmp of=wtmp.new bs=${i} skip=${ix} || exit 4
mv wmtp.new wtmp
chmod 0644 wtmp
# s-sh-mode
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)
next prev parent reply other threads:[~2021-07-05 13:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-05 2:53 John Cowan
2021-07-05 13:41 ` Steffen Nurpmeso [this message]
2021-07-05 15:12 ` John Cowan
2021-07-05 19:25 ` Steffen Nurpmeso
2021-07-05 20:26 Norman Wilson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210705134159.jR0uH%steffen@sdaoden.eu \
--to=steffen@sdaoden.eu \
--cc=cowan@ccil.org \
--cc=tuhs@tuhs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).