Mercurial > masqmail-0.2
view src/md5/hmactest.c @ 72:ad034b57f3b2
fixed Debian bug 536060 (log files are closed after SIGHUP receival)
Explanation:
When run in daemon mode, first the log files are opened. They get
assigned to the file descriptors 3 and 4 usually. Then std{in,out,err}
are closed. When SIGHUP comes in, all open files are closes and
masqmail reexecutes itself. The new masqmail instance opens the log
files at fd 0 and 1 now, but std{in,out,err} are closed afterwards,
thus the log files are closed.
The fix is to close the log files before std{in,out,err} are closed,
in case the log files have higher fds. After std{in,out,err} were
closed, the log files get opened again, now.
See also: http://bugs.debian.org/536060
author | meillo@marmaro.de |
---|---|
date | Wed, 16 Jun 2010 10:32:20 +0200 |
parents | 26e34ae9a3e3 |
children | 52c82d755215 |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <string.h> #include "global.h" #include "md5.h" #include "hmac_md5.h" static void pad0_copy(char *d, char *s, int sz) { int i = 0; while (*s && (i < sz)) { *(d++) = *(s++); i++; } while (i <= sz) { *(d++) = 0; i++; } } int main() { int i; // unsigned char digest[16]; char digest[16]; char *msgid = "<1896.697170952@postoffice.reston.mci.net>"; char secret[65]; hmac_md5("<48157.953508124@mail.class-c.net>", 34, "no!SpamAtAll", 12, digest); for (i = 0; i < 16; i++) printf("%x", (unsigned int) digest[i]); printf("\n"); hmac_md5(msgid, strlen(msgid), "tanstaaftanstaaf", 16, digest); for (i = 0; i < 16; i++) printf("%x", (unsigned int) digest[i]); printf("\n"); pad0_copy(secret, "tanstaaftanstaaf", 64); hmac_md5(msgid, strlen(msgid), secret, 64, digest); for (i = 0; i < 16; i++) printf("%x", (unsigned int) digest[i]); printf("\n"); exit(0); }