1/* 2 * $Id: pptpd-logwtmp.c,v 1.4 2005/08/03 09:10:59 quozl Exp $ 3 * pptpd-logwtmp.c - pppd plugin to update wtmp for a pptpd user 4 * 5 * Copyright 2004 James Cameron. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 10 * 2 of the License, or (at your option) any later version. 11 */ 12#include <unistd.h> 13#include <utmp.h> 14#include <string.h> 15#include "pppd.h" 16#include "config.h" 17 18char pppd_version[] = PPPD_VERSION; 19 20static char pptpd_original_ip[PATH_MAX+1]; 21static bool pptpd_logwtmp_strip_domain = 0; 22 23static option_t options[] = { 24 { "pptpd-original-ip", o_string, pptpd_original_ip, 25 "Original IP address of the PPTP connection", 26 OPT_STATIC, NULL, PATH_MAX }, 27 { "pptpd-logwtmp-strip-domain", o_bool, &pptpd_logwtmp_strip_domain, 28 "Strip domain from username before logging", OPT_PRIO | 1 }, 29 { NULL } 30}; 31 32static void ip_up(void *opaque, int arg) 33{ 34 char *user = peer_authname; 35 if (pptpd_logwtmp_strip_domain) { 36 char *sep = strstr(user, "//"); 37 if (sep != NULL) 38 user = sep + 2; 39 } 40 if (debug) 41 notice("pptpd-logwtmp.so ip-up %s %s %s", ifname, user, 42 pptpd_original_ip); 43 logwtmp(ifname, user, pptpd_original_ip); 44} 45 46static void ip_down(void *opaque, int arg) 47{ 48 if (debug) 49 notice("pptpd-logwtmp.so ip-down %s", ifname); 50 logwtmp(ifname, "", ""); 51} 52 53void plugin_init(void) 54{ 55 add_options(options); 56 add_notifier(&ip_up_notifier, ip_up, NULL); 57 add_notifier(&ip_down_notifier, ip_down, NULL); 58 if (debug) 59 notice("pptpd-logwtmp: $Version$"); 60} 61