summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristoph Biedl <ngircd.anoy@manchmal.in-ulm.de>2015-08-25 18:12:05 +0200
committerAlexander Barton <alex@barton.de>2015-08-26 10:05:36 +0200
commitccc899c7f4751ba72dcd7330c55614cf986f0fa3 (patch)
tree6665bbd00e134ce6eb2bad588c8afd4a6a99de83
parent2a52befa56eec493d4179c1568c7e6cd26d9ae23 (diff)
downloadngircd-ccc899c7f4751ba72dcd7330c55614cf986f0fa3.tar.gz
ngircd-ccc899c7f4751ba72dcd7330c55614cf986f0fa3.zip
Reproducible builds
At the moment ngircd fails the tests for reproducible builds in Debian
since it uses the __DATE__ and __TIME__ macros for the INFO command.

Instead of patching this out I decided to implement an optional
constant BIRTHTIME that allows you to set a time stamp for the "Birth
Date" information, in seconds since the epoch, like in

    export CFLAGS += -DBIRTHTIME=$(shell date +%s --date="2015/08/15 23:42:22")

In the future, Debian will provide a SOURCE_DATE_EPOCH environment
variable, dealing with the situation until then will be my job.

The time format was taken from the NGIRCd_StartStr formatting in
ngircd.c so the "Birth Date" and "On-line since" lines in the INFO
output look similar:

    :irc.example.net 371 nick :ngIRCd 22.1-IDENT+IPv6+IRCPLUS+PAM+SSL+SYSLOG+ZLIB-x86_64/pc/linux-gnu
    :irc.example.net 371 nick :Birth Date: Tue Aug 25 2015 at 18:11:11 (CEST)
    :irc.example.net 371 nick :On-line since Tue Aug 25 2015 at 18:11:33 (CEST)
    :irc.example.net 374 nick :End of INFO list

The format of the time stamped is changed, but as far as I can tell, there's no
rule that is violated by that.

Bonus level: Reformat the messages so the time stamps are aligned.
-rw-r--r--src/ngircd/irc-info.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c
index 1bbaf57b..1788bf60 100644
--- a/src/ngircd/irc-info.c
+++ b/src/ngircd/irc-info.c
@@ -558,7 +558,15 @@ IRC_INFO(CLIENT * Client, REQUEST * Req)
 				NGIRCd_Version))
 		return DISCONNECTED;
 
-#if defined(__DATE__) && defined(__TIME__)
+#if defined(BIRTHDATE)
+	char t_str[60];
+	time_t t = BIRTHDATE;
+	(void)strftime(t_str, sizeof(t_str), "%a %b %d %Y at %H:%M:%S (%Z)",
+			localtime(&t));
+	snprintf(msg, sizeof(msg), "Birth Date: %s", t_str);
+	if (!IRC_WriteStrClient(Client, RPL_INFO_MSG, Client_ID(prefix), msg))
+		return DISCONNECTED;
+#elif defined(__DATE__) && defined(__TIME__)
 	snprintf(msg, sizeof(msg), "Birth Date: %s at %s", __DATE__, __TIME__);
 	if (!IRC_WriteStrClient(Client, RPL_INFO_MSG, Client_ID(prefix), msg))
 		return DISCONNECTED;