annotate 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 |
08114f7dcc23 |
children |
dcb315792513 |
rev |
line source |
meillo@0
|
1 #include <stdio.h>
|
meillo@0
|
2 #include <stdlib.h>
|
meillo@0
|
3 #include <sys/time.h>
|
meillo@0
|
4 #include <string.h>
|
meillo@0
|
5 #include "global.h"
|
meillo@0
|
6 #include "md5.h"
|
meillo@0
|
7 #include "hmac_md5.h"
|
meillo@0
|
8
|
meillo@10
|
9 static void
|
meillo@10
|
10 pad0_copy(char *d, char *s, int sz)
|
meillo@0
|
11 {
|
meillo@10
|
12 int i = 0;
|
meillo@10
|
13 while (*s && (i < sz)) {
|
meillo@10
|
14 *(d++) = *(s++);
|
meillo@10
|
15 i++;
|
meillo@10
|
16 }
|
meillo@10
|
17 while (i <= sz) {
|
meillo@10
|
18 *(d++) = 0;
|
meillo@10
|
19 i++;
|
meillo@10
|
20 }
|
meillo@0
|
21 }
|
meillo@0
|
22
|
meillo@10
|
23 int
|
meillo@10
|
24 main()
|
meillo@0
|
25 {
|
meillo@10
|
26 int i;
|
meillo@10
|
27 // unsigned char digest[16];
|
meillo@10
|
28 char digest[16];
|
meillo@10
|
29 char *msgid = "<1896.697170952@postoffice.reston.mci.net>";
|
meillo@10
|
30 char secret[65];
|
meillo@0
|
31
|
meillo@10
|
32 hmac_md5("<48157.953508124@mail.class-c.net>", 34, "no!SpamAtAll", 12, digest);
|
meillo@10
|
33 for (i = 0; i < 16; i++)
|
meillo@10
|
34 printf("%x", (unsigned int) digest[i]);
|
meillo@10
|
35 printf("\n");
|
meillo@0
|
36
|
meillo@10
|
37 hmac_md5(msgid, strlen(msgid), "tanstaaftanstaaf", 16, digest);
|
meillo@10
|
38 for (i = 0; i < 16; i++)
|
meillo@10
|
39 printf("%x", (unsigned int) digest[i]);
|
meillo@10
|
40 printf("\n");
|
meillo@0
|
41
|
meillo@10
|
42 pad0_copy(secret, "tanstaaftanstaaf", 64);
|
meillo@10
|
43 hmac_md5(msgid, strlen(msgid), secret, 64, digest);
|
meillo@10
|
44 for (i = 0; i < 16; i++)
|
meillo@10
|
45 printf("%x", (unsigned int) digest[i]);
|
meillo@10
|
46 printf("\n");
|
meillo@0
|
47
|
meillo@10
|
48 exit(0);
|
meillo@0
|
49 }
|