-/* $OpenBSD: npppd.c,v 1.5 2010/07/02 21:20:57 yasuoka Exp $ */
+/* $OpenBSD: npppd.c,v 1.6 2010/07/31 09:33:09 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* Next pppd(nppd). This file provides a npppd daemon process and operations
* for npppd instance.
* @author Yasuoka Masahiko
- * $Id: npppd.c,v 1.5 2010/07/02 21:20:57 yasuoka Exp $
+ * $Id: npppd.c,v 1.6 2010/07/31 09:33:09 yasuoka Exp $
*/
#include <sys/cdefs.h>
#include "version.h"
#include "net_utils.h"
#include "time_utils.h"
-#ifdef USE_NPPPD_LINKID
-#include "linkid.h"
-#endif
-
#ifdef USE_NPPPD_ARP
#include "npppd_arp.h"
#endif
fprintf(pidfp, "%u\n", _this->pid);
fclose(pidfp);
pidfp = NULL;
-#ifdef USE_NPPPD_LINKID
- linkid_sock_init();
-#endif
#ifdef USE_NPPPD_ARP
arp_set_strictintfnetwork(npppd_config_str_equali(_this, "arpd.strictintfnetwork", "true", ARPD_STRICTINTFNETWORK_DEFAULT));
if (npppd_config_str_equali(_this, "arpd.enabled", "true", ARPD_DEFAULT) == 1)
#ifdef USE_NPPPD_NPPPD_CTL
npppd_ctl_stop(&_this->ctl);
#endif
-#ifdef USE_NPPPD_LINKID
- linkid_sock_fini();
-#endif
#ifdef USE_NPPPD_ARP
arp_sock_fini();
#endif
if (!ppp_ip_assigned(ppp))
return;
-#ifdef USE_NPPPD_LINKID
- linkid_purge(ppp->ppp_framed_ip_address);
-#endif
-
npppd_set_ip_enabled(_this, ppp, 0);
npppd_pool_release_ip(ppp->assigned_pool, ppp);
ppp->assigned_pool = NULL;
-/* $OpenBSD: npppd_ctl.c,v 1.5 2010/07/02 21:20:57 yasuoka Exp $ */
+/* $OpenBSD: npppd_ctl.c,v 1.6 2010/07/31 09:33:09 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* This file provides to open UNIX domain socket which located in
* /var/run/npppd_ctl and accept commmands from the npppdctl command.
*/
-/* $Id: npppd_ctl.c,v 1.5 2010/07/02 21:20:57 yasuoka Exp $ */
+/* $Id: npppd_ctl.c,v 1.6 2010/07/31 09:33:09 yasuoka Exp $ */
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
}
break;
}
- /*
- * related to client authentication
- */
- case NPPPD_CTL_CMD_TERMID_SET_AUTH: {
-#ifndef NPPPD_USE_CLIENT_AUTH
- npppd_ctl_log(_this, LOG_ERR,
- "NPPPD_CTL_CMD_TERMID_SET_AUTH is requested, but "
- "the terminal authentication is disabled.");
- goto fail;
-#else
- struct npppd_ctl_termid_set_auth_request *req;
- npppd_ppp *ppp;
-
- req = (struct npppd_ctl_termid_set_auth_request *)pkt;
- if (pktlen < sizeof(struct npppd_ctl_termid_set_auth_request)) {
- npppd_ctl_log(_this, LOG_ERR,
- "NPPPD_CTL_CMD_TERMID_SET_AUTH is requested, but "
- "the request is invalid.");
- goto fail;
- }
-
- ppp = NULL;
-
- switch (req->ppp_key_type) {
- case NPPPD_CTL_PPP_ID:
- if ((ppp = npppd_get_ppp_by_id(npppd_get_npppd(),
- req->ppp_key.id)) == NULL) {
- npppd_ctl_log(_this, LOG_ERR,
- "NPPPD_CTL_CMD_TERMID_SET_AUTH is "
- "requested, but the requested ppp(id=%d) "
- "is not found.", req->ppp_key.id);
- goto fail;
- }
-
- break;
- case NPPPD_CTL_PPP_FRAMED_IP_ADDRESS:
- if ((ppp = npppd_get_ppp_by_ip(npppd_get_npppd(),
- req->ppp_key.framed_ip_address)) == NULL) {
- npppd_ctl_log(_this, LOG_ERR,
- "NPPPD_CTL_CMD_TERMID_SET_AUTH is "
- "requested, but the requested ppp(ip=%s) "
- "is not found.",
- inet_ntoa(req->ppp_key.framed_ip_address));
- goto fail;
- }
- break;
- default:
- npppd_ctl_log(_this, LOG_ERR,
- "NPPPD_CTL_CMD_TERMID_SET_AUTH is requested, but "
- "the ppp_key_type is invalid.");
- goto fail;
- }
- NPPPD_CTL_ASSERT(ppp != NULL);
-
- ppp_set_client_auth_id(ppp, req->authid);
- strlcpy(respbuf,
- "Set the client authentication information successfully.",
- sizeof(respbuf));
-
- if (sendto(_this->sock, respbuf, strlen(respbuf), 0, peer,
- peer->sa_len) < 0) {
- npppd_ctl_log(_this, LOG_ERR,
- "sendto() failed in %s: %m", __func__);
-
- }
-#endif
- break;
- }
case NPPPD_CTL_CMD_RESET_ROUTING_TABLE:
{
if (npppd_reset_routing_table(_this->npppd, 0) == 0)
-/* $OpenBSD: ppp.c,v 1.4 2010/07/02 21:20:57 yasuoka Exp $ */
+/* $OpenBSD: ppp.c,v 1.5 2010/07/31 09:33:09 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: ppp.c,v 1.4 2010/07/02 21:20:57 yasuoka Exp $ */
+/* $Id: ppp.c,v 1.5 2010/07/31 09:33:09 yasuoka Exp $ */
/**@file
* This file provides PPP(Point-to-Point Protocol, RFC 1661) and
* {@link :: _npppd_ppp PPP instance} related functions.
/* else wait CCP or IPCP */
}
#endif
-
-#ifdef NPPPD_USE_CLIENT_AUTH
-#ifdef USE_NPPPD_LINKID
-#include "linkid.h"
-#endif
-/** Set client authentication Id */
-void
-ppp_set_client_auth_id(npppd_ppp *_this, const char *client_auth_id)
-{
- PPP_ASSERT(_this != NULL);
- PPP_ASSERT(client_auth_id != NULL);
- PPP_ASSERT(strlen(client_auth_id) <= NPPPD_CLIENT_AUTH_ID_MAXLEN);
-
- strlcpy(_this->client_auth_id, client_auth_id,
- sizeof(_this->client_auth_id));
- _this->has_client_auth_id = 1;
-#ifdef USE_NPPPD_LINKID
- linkid_purge(_this->ppp_framed_ip_address);
-#endif
- ppp_log(_this, LOG_NOTICE,
- "Set client authentication id successfully. linkid=\"%s\" client_auth_id=%s",
- _this->username, client_auth_id);
-}
-#endif
-/* $OpenBSD: ppp.h,v 1.3 2010/07/02 21:20:57 yasuoka Exp $ */
+/* $OpenBSD: ppp.h,v 1.4 2010/07/31 09:33:09 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
*/
logged_no_address:1,
logged_rcvd:5;
-#ifdef NPPPD_USE_CLIENT_AUTH
-/** Length of client authentication ID */
-#define NPPPD_CLIENT_AUTH_ID_MAXLEN 32
- char client_auth_id[NPPPD_CLIENT_AUTH_ID_MAXLEN + 1];
- int has_client_auth_id;
-#endif
+
/*
* Statistical informations
*/
void ppp_process_radius_framed_ip (npppd_ppp *, RADIUS_PACKET *);
int ppp_set_radius_attrs_for_authreq (npppd_ppp *, radius_req_setting *, RADIUS_PACKET *);
#endif
-void ppp_set_client_auth_id(npppd_ppp *, const char *);
void ccp_init (ccp *, npppd_ppp *);
void ipcp_init (ipcp *, npppd_ppp *);
-/* $OpenBSD: npppdctl.c,v 1.4 2010/07/02 21:20:57 yasuoka Exp $ */
+/* $OpenBSD: npppdctl.c,v 1.5 2010/07/31 09:33:09 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: npppdctl.c,v 1.4 2010/07/02 21:20:57 yasuoka Exp $ */
+/* $Id: npppdctl.c,v 1.5 2010/07/31 09:33:09 yasuoka Exp $ */
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
static void npppd_who (int);
static void npppd_disconnect (const char *);
static const char *eat_null (const char *);
-static void npppd_ctl_termid_authen(const char *, const char *);
static void npppd_ctl_common(int);
static void print_who(struct npppd_who *);
static void print_stat(struct npppd_who *);
fprintf(stderr,
"usage: %s [-slnuh] [-d ppp_user] [-r rcvbuf_sz] [-p npppd_ctl_path]\n"
- " %s -c [-r rcvbuf_sz] {ppp_id | ip} auth_id\n"
"usage: %s -R\n"
"\t-R: Reset the routing table.\n"
- "\t-c: Set the client auth's auth-id.\n"
"\t-d: Disconnect specified user.\n"
"\t-h: Show this usage.\n"
"\t-l: Use long line to display information.\n"
int
main(int argc, char *argv[])
{
- int ch, sflag, fdgramsock, cflag, rtflag;
+ int ch, sflag, fdgramsock, rtflag;
const char *path = DEFAULT_NPPPD_CTL_SOCK_PATH;
const char *disconn;
struct sockaddr_un sun;
progname = basename(argv[0]);
disconn = NULL;
- sflag = cflag = rtflag = 0;
- while ((ch = getopt(argc, argv, "lcd:sunhp:r:R")) != -1) {
+ sflag = rtflag = 0;
+ while ((ch = getopt(argc, argv, "ld:sunhp:r:R")) != -1) {
switch (ch) {
case 'n':
nflag = 1;
case 'u':
uflag = 1;
break;
- case 'c':
- cflag = 1;
- break;
case 'l':
lflag = 1;
break;
npppd_who(1);
else if (rtflag)
npppd_ctl_common(NPPPD_CTL_CMD_RESET_ROUTING_TABLE);
- else if (cflag > 0) {
- if (argc < 2) {
- usage();
- exit(1);
- }
- npppd_ctl_termid_authen(argv[0], argv[1]);
- } else
+ else
npppd_who(0);
close(sock);
return str;
}
-static void
-npppd_ctl_termid_authen(const char *ppp_key, const char *authid)
-{
- int sz;
- char *ep;
- long lval;
- struct npppd_ctl_termid_set_auth_request req = {
- .command = NPPPD_CTL_CMD_TERMID_SET_AUTH,
- .reserved = 0,
- };
- u_char buf[BUFSIZ];
- struct in_addr ip4;
-
- if (inet_pton(AF_INET, ppp_key, &ip4) == 1) {
- req.ppp_key_type = NPPPD_CTL_PPP_FRAMED_IP_ADDRESS;
- req.ppp_key.framed_ip_address.s_addr = ip4.s_addr;
- } else {
- errno = 0;
- lval = strtol(ppp_key, &ep, 10);
- if (ppp_key[0] == '\0' || *ep != '\0') {
- fprintf(stderr, "not a number: %s\n", ppp_key);
- exit(1);
- }
- if ((errno == ERANGE && (lval == LONG_MAX|| lval == LONG_MIN))||
- lval > UINT_MAX) {
- fprintf(stderr, "out of range: %s\n",
- ppp_key);
- exit(1);
- }
- req.ppp_key_type = NPPPD_CTL_PPP_ID;
- req.ppp_key.id = lval;
- }
- strlcpy(req.authid, authid, sizeof(req.authid));
-
- if (sendto(sock, &req, sizeof(req), 0, (struct sockaddr *)&peersock,
- sizeof(peersock)) < 0) {
- err(1 ,"sendto() failed");
- }
-
- if ((sz = recv(sock, buf, sizeof(buf), 0)) <= 0)
- err(1, "recv");
- buf[sz] = '\0';
-
- printf("%s\n", buf);
-}
-
static void
npppd_ctl_common(int command)
{