netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Aring <alex.aring@gmail.com>
To: linux-wpan@vger.kernel.org
Cc: kernel@pengutronix.de, netdev@vger.kernel.org,
	phoebe.buckheister@itwm.fraunhofer.de,
	Alexander Aring <alex.aring@gmail.com>
Subject: [PATCH wpan-tools 2/2] security: add store and restore scripts
Date: Mon, 28 Sep 2015 09:25:34 +0200	[thread overview]
Message-ID: <1443425134-27910-2-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1443425134-27910-1-git-send-email-alex.aring@gmail.com>

This patch adds two new bash script commands."iwpan-store" and
"iwpan-restore" which can store and restore the current security
table settings. This is currently a very KISS solution, we should lookup
iptables implementation for storing and restoring the tables.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 src/Makefile.am   |  4 ++++
 src/iwpan-restore | 36 ++++++++++++++++++++++++++++++++++++
 src/iwpan-store   | 39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+)
 create mode 100755 src/iwpan-restore
 create mode 100755 src/iwpan-store

diff --git a/src/Makefile.am b/src/Makefile.am
index b2177a2..37a6d82 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,10 @@
 bin_PROGRAMS = \
 	iwpan
 
+bin_SCRIPTS = \
+	iwpan-store \
+	iwpan-restore
+
 iwpan_SOURCES = \
 	iwpan.c \
 	iwpan.h \
diff --git a/src/iwpan-restore b/src/iwpan-restore
new file mode 100755
index 0000000..0e305f6
--- /dev/null
+++ b/src/iwpan-restore
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+WPAN_DEV=""
+FILE=""
+
+function usage() {
+	echo "usage: -d \$WPAN_DEV -f \$FILE"
+}
+
+while getopts "d:f:" opt; do
+	case $opt in
+		d)
+			WPAN_DEV=$OPTARG
+			;;
+		f)
+			FILE=$OPTARG
+			;;
+		?)
+			usage
+			;;
+	esac
+done
+
+if [ -z $FILE ] || [ -z $WPAN_DEV ]
+then
+	usage
+	exit 1
+fi
+
+function failed() {
+	echo "failed" >&2
+}
+
+export WPAN_DEV &&
+/bin/bash $FILE ||
+failed
diff --git a/src/iwpan-store b/src/iwpan-store
new file mode 100755
index 0000000..acce807
--- /dev/null
+++ b/src/iwpan-store
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+WPAN_DEV=""
+FILE=""
+
+function usage() {
+	echo "usage: -d \$WPAN_DEV -f \$FILE"
+}
+
+while getopts "d:f:" opt; do
+	case $opt in
+		d)
+			WPAN_DEV=$OPTARG
+			;;
+		f)
+			FILE=$OPTARG
+			;;
+		?)
+			usage
+			;;
+	esac
+done
+
+if [ -z $FILE ] || [ -z $WPAN_DEV ]
+then
+	usage
+	exit 1
+fi
+
+function failed() {
+	echo "failed" >&2
+	rm $FILE
+}
+
+iwpan dev $WPAN_DEV seclevel dump > $FILE &&
+iwpan dev $WPAN_DEV device dump >> $FILE &&
+iwpan dev $WPAN_DEV devkey dump >> $FILE &&
+iwpan dev $WPAN_DEV key dump >> $FILE ||
+failed
-- 
2.5.3

  reply	other threads:[~2015-09-28  7:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-28  7:25 [PATCH wpan-tools 1/2] security: add nl802154 security support Alexander Aring
2015-09-28  7:25 ` Alexander Aring [this message]
2015-09-30 14:09   ` [PATCH wpan-tools 2/2] security: add store and restore scripts Stefan Schmidt
2015-09-30 14:46 ` [PATCH wpan-tools 1/2] security: add nl802154 security support Stefan Schmidt
2015-09-30 17:46   ` Alexander Aring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1443425134-27910-2-git-send-email-alex.aring@gmail.com \
    --to=alex.aring@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-wpan@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=phoebe.buckheister@itwm.fraunhofer.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).