retitle 367320 prelink: Add timestamps to logged messages
tags 367320 patch
stop
I have written a patch that adds timestamps to the output of prelink
through a "-T" command-line option. The patch is attached as
prelink-timestamp.patch and has been sent upstream.
Because the addition of the "-T" flag is required for timestamp-enabled
output, the daily cron job in the Debian packaging has to be modified to
enable the -T flag for all runs. See attached
prelink-timestamp-debian.patch.
I also decided it's not necessary to log starting and stopping messages
because the prelink logfile is replaced on each run. I have retitled the
bug accordingly.
-Ted
diff -ruN prelink-0.0.20060712/doc/prelink.8 prelink-0.0.20060712-new/doc/prelink.8
--- prelink-0.0.20060712/doc/prelink.8 2004-11-23 20:37:41.0 +1000
+++ prelink-0.0.20060712-new/doc/prelink.8 2006-09-02 19:45:16.0 +1000
@@ -141,6 +141,9 @@
When processing command line directory arguments, limit directory tree walk
to a single filesystem.
.TP
+.B \-T \-\-timestamp\-output
+Prefix output with timestamps.
+.TP
.B \-u \-\-undo
Revert binaries and libraries to their original content before they were
prelinked.
diff -ruN prelink-0.0.20060712/src/main.c prelink-0.0.20060712-new/src/main.c
--- prelink-0.0.20060712/src/main.c 2005-06-11 01:09:06.0 +1000
+++ prelink-0.0.20060712-new/src/main.c 2006-09-02 19:42:51.0 +1000
@@ -25,6 +25,7 @@
#include
#include
#include
+#include
#include "prelink.h"
@@ -50,6 +51,7 @@
enum verify_method_t verify_method;
int quick;
int compute_checksum;
+int timestamp_output;
long long seed;
GElf_Addr mmap_reg_start = ~(GElf_Addr) 0;
GElf_Addr mmap_reg_end = ~(GElf_Addr) 0;
@@ -97,6 +99,7 @@
{"undo", 'u', 0, 0, "Undo prelink" },
{"verbose", 'v', 0, 0, "Produce verbose output" },
{"verify", 'y', 0, 0, "Verify file consistency by undoing and redoing prelink and printing original to standard output" },
+ {"timestamp-output", 'T', 0, 0, "Prefix output with timestamps" },
{"md5", OPT_MD5, 0, 0, "For verify print MD5 sum of original to standard output instead of content" },
{"sha", OPT_SHA, 0, 0, "For verify print SHA sum of original to standard output instead of content" },
{"dynamic-linker", OPT_DYNAMIC_LINKER, "DYNAMIC_LINKER",
@@ -140,6 +143,9 @@
case 'v':
++verbose;
break;
+case 'T':
+ timestamp_output = 1;
+ break;
case 'R':
random_base |= 1;
break;
@@ -230,6 +236,20 @@
static struct argp argp = { options, parse_opt, "[FILES]", argp_doc };
+void print_error_prefix(void)
+{
+ time_t t;
+ char buf[20];
+ size_t len;
+
+ if (timestamp_output) {
+t = time(NULL);
+if (strftime(buf, 20, "%Y-%m-%d %H:%M:%S", localtime(&t)))
+ fprintf(stderr, "%s ", buf);
+ }
+ fprintf(stderr, "prelink: ");
+}
+
int
main (int argc, char *argv[])
{
@@ -237,6 +257,8 @@
setlocale (LC_ALL, "");
+ error_print_progname = print_error_prefix;
+
/* Set the default for exec_shield. */
if (! access ("/proc/sys/kernel/exec-shield", F_OK))
exec_shield = 1;
diff -ruN prelink-0.0.20060712/debian/prelink.cron.daily prelink-0.0.20060712-new/debian/prelink.cron.daily
--- prelink-0.0.20060712/debian/prelink.cron.daily 2006-09-02 17:49:58.0 +1000
+++ prelink-0.0.20060712-new/debian/prelink.cron.daily 2006-09-02 19:56:57.0 +1000
@@ -10,6 +10,8 @@
exit 0
fi
+PRELINK_OPTS="$PRELINK_OPTS -T"
+
if [ "$PRELINKING" = no ]; then
if [ -f /etc/prelink.cache ]; then
echo /usr/sbin/prelink -ua > /var/log/prelink.log
signature.asc
Description: OpenPGP digital signature