ipsec-tools: fix compilation against Linux 3.7, refresh patches
[openwrt/svn-archive/archive.git] / net / ipsec-tools / patches / 002-patch8-utmp.patch
1 --- a/src/racoon/isakmp_cfg.c
2 +++ b/src/racoon/isakmp_cfg.c
3 @@ -38,7 +38,7 @@
4 #include <sys/socket.h>
5 #include <sys/queue.h>
6
7 -#include <utmpx.h>
8 +#include <utmp.h>
9 #if defined(__APPLE__) && defined(__MACH__)
10 #include <util.h>
11 #endif
12 @@ -1661,7 +1661,8 @@ isakmp_cfg_accounting_system(port, raddr
13 int inout;
14 {
15 int error = 0;
16 - struct utmpx ut;
17 + struct utmp ut;
18 + char term[UT_LINESIZE];
19 char addr[NI_MAXHOST];
20
21 if (usr == NULL || usr[0]=='\0') {
22 @@ -1670,34 +1671,37 @@ isakmp_cfg_accounting_system(port, raddr
23 return -1;
24 }
25
26 - memset(&ut, 0, sizeof ut);
27 - gettimeofday((struct timeval *)&ut.ut_tv, NULL);
28 - snprintf(ut.ut_id, sizeof ut.ut_id, TERMSPEC, port);
29 + sprintf(term, TERMSPEC, port);
30
31 switch (inout) {
32 case ISAKMP_CFG_LOGIN:
33 - ut.ut_type = USER_PROCESS;
34 - strncpy(ut.ut_user, usr, sizeof ut.ut_user);
35 + strncpy(ut.ut_name, usr, UT_NAMESIZE);
36 + ut.ut_name[UT_NAMESIZE - 1] = '\0';
37 +
38 + strncpy(ut.ut_line, term, UT_LINESIZE);
39 + ut.ut_line[UT_LINESIZE - 1] = '\0';
40
41 GETNAMEINFO_NULL(raddr, addr);
42 - strncpy(ut.ut_host, addr, sizeof ut.ut_host);
43 + strncpy(ut.ut_host, addr, UT_HOSTSIZE);
44 + ut.ut_host[UT_HOSTSIZE - 1] = '\0';
45 +
46 + ut.ut_time = time(NULL);
47
48 plog(LLV_INFO, LOCATION, NULL,
49 "Accounting : '%s' logging on '%s' from %s.\n",
50 - ut.ut_user, ut.ut_id, addr);
51 -
52 - pututxline(&ut);
53 + ut.ut_name, ut.ut_line, ut.ut_host);
54
55 + login(&ut);
56 +
57 break;
58 case ISAKMP_CFG_LOGOUT:
59 - ut.ut_type = DEAD_PROCESS;
60
61 plog(LLV_INFO, LOCATION, NULL,
62 "Accounting : '%s' unlogging from '%s'.\n",
63 - usr, ut.ut_id);
64 -
65 - pututxline(&ut);
66 + usr, term);
67
68 + logout(term);
69 +
70 break;
71 default:
72 plog(LLV_ERROR, LOCATION, NULL, "Unepected inout\n");