From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22152 invoked from network); 5 Jul 2021 13:44:12 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 5 Jul 2021 13:44:12 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 2D8059CA59; Mon, 5 Jul 2021 23:44:08 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id E83509C9F1; Mon, 5 Jul 2021 23:43:44 +1000 (AEST) Received: by minnie.tuhs.org (Postfix, from userid 112) id EAABB9C9F1; Mon, 5 Jul 2021 23:42:04 +1000 (AEST) Received: from sdaoden.eu (sdaoden.eu [217.144.132.164]) by minnie.tuhs.org (Postfix) with ESMTPS id AF4299C9F0 for ; Mon, 5 Jul 2021 23:42:03 +1000 (AEST) Received: from kent.sdaoden.eu (kent.sdaoden.eu [10.5.0.2]) by sdaoden.eu (Postfix) with ESMTPS id 1C95D16059; Mon, 5 Jul 2021 15:42:01 +0200 (CEST) Received: by kent.sdaoden.eu (Postfix, from userid 1000) id 28D7411C11; Mon, 5 Jul 2021 15:41:59 +0200 (CEST) Date: Mon, 05 Jul 2021 15:41:59 +0200 Author: Steffen Nurpmeso From: Steffen Nurpmeso To: John Cowan Message-ID: <20210705134159.jR0uH%steffen@sdaoden.eu> In-Reply-To: References: Mail-Followup-To: John Cowan , The Eunuchs Hysterical Society User-Agent: s-nail v14.9.22-170-g4fc3932ea4 OpenPGP: id=EE19E1C1F2F7054F8D3954D8308964B51883A0DD; url=https://ftp.sdaoden.eu/steffen.asc; preference=signencrypt BlahBlahBlah: Any stupid boy can crush a beetle. But all the professors in the world can make no bugs. Subject: Re: [TUHS] Binary log files X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: The Eunuchs Hysterical Society Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" John Cowan wrote in : |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 #include 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)