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