--- embedaddon/ipsec-tools/src/racoon/isakmp_cfg.c 2014/06/15 16:39:18 1.1.1.1.4.1 +++ embedaddon/ipsec-tools/src/racoon/isakmp_cfg.c 2016/11/02 10:45:57 1.1.1.2 @@ -1,4 +1,4 @@ -/* $NetBSD: isakmp_cfg.c,v 1.24 2010/09/21 13:14:17 vanhu Exp $ */ +/* $NetBSD: isakmp_cfg.c,v 1.24.4.1 2013/04/12 10:04:21 tteras Exp $ */ /* Id: isakmp_cfg.c,v 1.55 2006/08/22 18:17:17 manubsd Exp */ @@ -38,7 +38,9 @@ #include #include -#include +#if __FreeBSD_version >= 900007 +#include +#endif #if defined(__APPLE__) && defined(__MACH__) #include #endif @@ -1000,6 +1002,9 @@ isakmp_cfg_varlen(iph1, attr, string, len) struct isakmp_data *new; char *data; + if (!len) + return NULL; + if ((buffer = vmalloc(sizeof(*attr) + len)) == NULL) { plog(LLV_ERROR, LOCATION, NULL, "Cannot allocate memory\n"); return NULL; @@ -1660,9 +1665,9 @@ isakmp_cfg_accounting_system(port, raddr, usr, inout) char *usr; int inout; { +#if __FreeBSD_version >= 900007 int error = 0; - struct utmp ut; - char term[UT_LINESIZE]; + struct utmpx ut; char addr[NI_MAXHOST]; if (usr == NULL || usr[0]=='\0') { @@ -1671,42 +1676,40 @@ isakmp_cfg_accounting_system(port, raddr, usr, inout) return -1; } - sprintf(term, TERMSPEC, port); + memset(&ut, 0, sizeof ut); + gettimeofday((struct timeval *)&ut.ut_tv, NULL); + snprintf(ut.ut_id, sizeof ut.ut_id, TERMSPEC, port); switch (inout) { case ISAKMP_CFG_LOGIN: - strncpy(ut.ut_name, usr, UT_NAMESIZE); - ut.ut_name[UT_NAMESIZE - 1] = '\0'; + ut.ut_type = USER_PROCESS; + strncpy(ut.ut_user, usr, sizeof ut.ut_user); - strncpy(ut.ut_line, term, UT_LINESIZE); - ut.ut_line[UT_LINESIZE - 1] = '\0'; - GETNAMEINFO_NULL(raddr, addr); - strncpy(ut.ut_host, addr, UT_HOSTSIZE); - ut.ut_host[UT_HOSTSIZE - 1] = '\0'; + strncpy(ut.ut_host, addr, sizeof ut.ut_host); - ut.ut_time = time(NULL); - plog(LLV_INFO, LOCATION, NULL, "Accounting : '%s' logging on '%s' from %s.\n", - ut.ut_name, ut.ut_line, ut.ut_host); + ut.ut_user, ut.ut_id, addr); - login(&ut); + pututxline(&ut); break; case ISAKMP_CFG_LOGOUT: + ut.ut_type = DEAD_PROCESS; plog(LLV_INFO, LOCATION, NULL, "Accounting : '%s' unlogging from '%s'.\n", - usr, term); + usr, ut.ut_id); - logout(term); + pututxline(&ut); break; default: plog(LLV_ERROR, LOCATION, NULL, "Unepected inout\n"); break; } +#endif return 0; }