Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src move setkey(8) from usr.sbin to sbin, to enable us to initia...



details:   https://anonhg.NetBSD.org/src/rev/c5bb402db88b
branches:  trunk
changeset: 487833:c5bb402db88b
user:      itojun <itojun%NetBSD.org@localhost>
date:      Tue Jun 13 15:15:21 2000 +0000

description:
move setkey(8) from usr.sbin to sbin, to enable us to initialize
IPsec manual key before /usr mount..
(based on "don't use cvsmove" discussion i have seen, I did not use cvsmove)

diffstat:

 distrib/sets/lists/base/mi          |    3 +-
 distrib/sets/lists/base/obsolete.mi |    3 +-
 sbin/Makefile                       |    5 +-
 sbin/setkey/Makefile                |   35 +
 sbin/setkey/parse.y                 |  902 ++++++++++++++++++++++++++++++++++++
 sbin/setkey/sample.cf               |  219 ++++++++
 sbin/setkey/scriptdump.pl           |   58 ++
 sbin/setkey/setkey.8                |  560 ++++++++++++++++++++++
 sbin/setkey/setkey.c                |  578 +++++++++++++++++++++++
 sbin/setkey/test-pfkey.c            |  531 +++++++++++++++++++++
 sbin/setkey/test-policy.c           |  160 ++++++
 sbin/setkey/token.l                 |  314 ++++++++++++
 sbin/setkey/vchar.h                 |   36 +
 usr.sbin/Makefile                   |    4 +-
 usr.sbin/setkey/Makefile            |   35 -
 usr.sbin/setkey/parse.y             |  902 ------------------------------------
 usr.sbin/setkey/sample.cf           |  219 --------
 usr.sbin/setkey/scriptdump.pl       |   58 --
 usr.sbin/setkey/setkey.8            |  560 ----------------------
 usr.sbin/setkey/setkey.c            |  578 -----------------------
 usr.sbin/setkey/test-pfkey.c        |  531 ---------------------
 usr.sbin/setkey/test-policy.c       |  160 ------
 usr.sbin/setkey/token.l             |  314 ------------
 usr.sbin/setkey/vchar.h             |   36 -
 24 files changed, 3403 insertions(+), 3398 deletions(-)

diffs (truncated from 6935 to 300 lines):

diff -r ba0c5a552515 -r c5bb402db88b distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi        Tue Jun 13 14:48:44 2000 +0000
+++ b/distrib/sets/lists/base/mi        Tue Jun 13 15:15:21 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.167 2000/06/13 05:35:47 itojun Exp $
+# $NetBSD: mi,v 1.168 2000/06/13 15:15:51 itojun Exp $
 .
 ./altroot
 ./bin
@@ -130,6 +130,7 @@
 ./sbin/rtsol
 ./sbin/savecore
 ./sbin/scsictl
+./sbin/setkey
 ./sbin/shutdown
 ./sbin/slattach
 ./sbin/swapctl
diff -r ba0c5a552515 -r c5bb402db88b distrib/sets/lists/base/obsolete.mi
--- a/distrib/sets/lists/base/obsolete.mi       Tue Jun 13 14:48:44 2000 +0000
+++ b/distrib/sets/lists/base/obsolete.mi       Tue Jun 13 15:15:21 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: obsolete.mi,v 1.10 2000/06/13 05:35:48 itojun Exp $
+# $NetBSD: obsolete.mi,v 1.11 2000/06/13 15:15:52 itojun Exp $
 /bin/rcorder
 /dev/log
 /etc/rc.d/xntpd
@@ -24,6 +24,7 @@
 /usr/sbin/portmap
 /usr/sbin/rdconfig
 /usr/sbin/scriptdump
+/usr/sbin/setkey
 /usr/sbin/smrsh
 /usr/sbin/statmsg
 /usr/sbin/sysconfd
diff -r ba0c5a552515 -r c5bb402db88b sbin/Makefile
--- a/sbin/Makefile     Tue Jun 13 14:48:44 2000 +0000
+++ b/sbin/Makefile     Tue Jun 13 15:15:21 2000 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.67 2000/03/15 12:05:58 soren Exp $
+#      $NetBSD: Makefile,v 1.68 2000/06/13 15:15:21 itojun Exp $
 #      @(#)Makefile    8.5 (Berkeley) 3/31/94
 
 # Not ported: XNSrouted enpload scsiformat startslip
@@ -33,4 +33,7 @@
 # IPv6
 SUBDIR+= ping6 rtsol
 
+# IPsec
+SUBDIR+= setkey
+
 .include <bsd.subdir.mk>
diff -r ba0c5a552515 -r c5bb402db88b sbin/setkey/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/setkey/Makefile      Tue Jun 13 15:15:21 2000 +0000
@@ -0,0 +1,35 @@
+# $NetBSD: Makefile,v 1.1 2000/06/13 15:15:24 itojun Exp $
+
+PROG=  setkey
+SRCS=  setkey.c parse.y token.l
+
+#CFLAGS+=-g
+CPPFLAGS+=-I${.CURDIR}/../../lib/libipsec
+LDADD+=        -ll -ly
+DPADD+=        ${LIBL} ${LIBY}
+CLEANFILES+=   y.tab.c y.tab.h key_test.o keytest
+YFLAGS+=-d
+
+#SCRIPTS=      scriptdump
+
+all: ${PROG} scriptdump
+
+CPPFLAGS+=-DIPSEC_DEBUG -DINET6 -DYY_NO_UNPUT
+CPPFLAGS+=-I. -I${.CURDIR}
+LDADD+= -lipsec
+DPADD+=        ${LIBIPSEC}
+CLEANFILES+=   scriptdump
+
+# libpfkey.
+# ipsec_strerror.c is for avoiding shlib reference to non-exported function.
+.PATH: ${.CURDIR}/../../lib/libipsec ${.CURDIR}/../../sys/netkey
+SRCS+= pfkey.c pfkey_dump.c key_debug.c ipsec_strerror.c
+CPPFLAGS+=-I${.CURDIR}/../../lib/libipsec -I${.CURDIR}/../../sys/netkey
+
+MAN=   setkey.8
+LOCALPREFIX=   /usr/pkg
+
+scriptdump: scriptdump.pl
+       sed -e 's#@LOCALPREFIX@#${LOCALPREFIX}#' < $> > scriptdump
+
+.include <bsd.prog.mk>
diff -r ba0c5a552515 -r c5bb402db88b sbin/setkey/parse.y
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/setkey/parse.y       Tue Jun 13 15:15:21 2000 +0000
@@ -0,0 +1,902 @@
+/*     $NetBSD: parse.y,v 1.1 2000/06/13 15:15:24 itojun Exp $ */
+/*     $KAME: parse.y,v 1.29 2000/06/10 14:17:44 sakane Exp $  */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+%{
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+
+#include <net/route.h>
+#include <netinet/in.h>
+#include <net/pfkeyv2.h>
+#include <netkey/key_var.h>
+#include <netinet6/ipsec.h>
+#include <arpa/inet.h>
+
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <netdb.h>
+#include <ctype.h>
+#include <errno.h>
+
+#include "libpfkey.h"
+#include "vchar.h"
+
+#define ATOX(c) \
+  (isdigit(c) ? (c - '0') : (isupper(c) ? (c - 'A' + 10) : (c - 'a' + 10) ))
+
+u_int p_type;
+u_int32_t p_spi;
+struct sockaddr *p_src, *p_dst;
+u_int p_prefs, p_prefd, p_upper;
+u_int p_satype, p_ext, p_alg_enc, p_alg_auth, p_replay, p_mode;
+u_int32_t p_reqid;
+u_int p_key_enc_len, p_key_auth_len;
+caddr_t p_key_enc, p_key_auth;
+time_t p_lt_hard, p_lt_soft;
+
+u_int p_policy_len;
+char *p_policy;
+
+/* temporary buffer */
+static struct sockaddr *pp_addr;
+static u_int pp_prefix;
+static u_int pp_port;
+static caddr_t pp_key;
+
+extern u_char m_buf[BUFSIZ];
+extern int m_len;
+extern char cmdarg[8192];
+extern int f_debug;
+
+int setkeymsg __P((void));
+static struct addrinfo *parse_addr __P((char *, char *, int));
+static int setvarbuf __P((int *, struct sadb_ext *, int, caddr_t, int));
+void parse_init __P((void));
+void free_buffer __P((void));
+
+extern int setkeymsg __P((void));
+extern int sendkeymsg __P((void));
+
+extern int yylex __P((void));
+extern void yyfatal __P((const char *));
+extern void yyerror __P((const char *));
+%}
+
+%union {
+       unsigned long num;
+       vchar_t val;
+}
+
+%token EOT
+%token ADD GET DELETE FLUSH DUMP
+%token ADDRESS PREFIX PORT PORTANY
+%token UP_PROTO PR_ESP PR_AH PR_IPCOMP
+%token F_PROTOCOL F_AUTH F_ENC F_REPLAY F_COMP F_RAWCPI
+%token F_MODE MODE F_REQID
+%token F_EXT EXTENSION NOCYCLICSEQ
+%token ALG_AUTH ALG_ENC ALG_ENC_DESDERIV ALG_ENC_DES32IV ALG_COMP
+%token F_LIFETIME_HARD F_LIFETIME_SOFT
+%token DECSTRING QUOTEDSTRING HEXSTRING ANY
+       /* SPD management */
+%token SPDADD SPDDELETE SPDDUMP SPDFLUSH
+%token F_POLICY PL_REQUESTS
+
+%type <num> PORT PREFIX EXTENSION MODE
+%type <num> UP_PROTO PR_ESP PR_AH PR_IPCOMP
+%type <num> ALG_AUTH ALG_ENC ALG_ENC_DESDERIV ALG_ENC_DES32IV ALG_COMP
+%type <num> DECSTRING
+%type <val> ADDRESS PL_REQUESTS
+%type <val> key_string policy_requests
+%type <val> QUOTEDSTRING HEXSTRING
+
+%%
+commands
+       :       /*NOTHING*/
+       |       commands command
+               {
+                       if (f_debug) {
+                               printf("cmdarg:\n%s\n", cmdarg);
+                       } else {
+                               setkeymsg();
+                               sendkeymsg();
+                       }
+                       free_buffer();
+                       parse_init();
+               }
+       ;
+
+command
+       :       add_command
+       |       get_command
+       |       delete_command
+       |       flush_command
+       |       dump_command
+       |       spdadd_command
+       |       spddelete_command
+       |       spddump_command
+       |       spdflush_command
+       ;
+       /* commands concerned with management, there is in tail of this file. */
+
+       /* add command */
+add_command
+       :       ADD { p_type = SADB_ADD; }
+               sa_selector_spec extension_spec algorithm_spec EOT
+       ;
+
+       /* delete */
+delete_command
+       :       DELETE { p_type = SADB_DELETE; }
+               sa_selector_spec extension_spec
+               {
+                       if (p_mode != IPSEC_MODE_ANY)
+                               yyerror("WARNING: mode is obsoleted.");
+               }
+               EOT
+       ;
+
+       /* get command */
+get_command
+       :       GET { p_type = SADB_GET; }
+               sa_selector_spec extension_spec
+               {
+                       if (p_mode != IPSEC_MODE_ANY)
+                               yyerror("WARNING: mode is obsoleted.");
+               }
+               EOT
+       ;
+
+       /* flush */
+flush_command
+       :       FLUSH { p_type = SADB_FLUSH; }
+               protocol_spec EOT
+       ;
+
+       /* dump */
+dump_command
+       :       DUMP { p_type = SADB_DUMP; }
+               protocol_spec EOT
+       ;
+
+       /* sa_selector_spec */
+sa_selector_spec
+       :       ipaddress { p_src = pp_addr; }
+               ipaddress { p_dst = pp_addr; }
+               protocol_spec spi
+       ;
+
+protocol_spec
+       :       /*NOTHING*/ { p_satype = SADB_SATYPE_UNSPEC; }
+       |       PR_ESP
+               {
+                       p_satype = SADB_SATYPE_ESP;
+                       if ($1 == 1)
+                               p_ext |= SADB_X_EXT_OLD;
+                       else



Home | Main Index | Thread Index | Old Index