Browse Source

fix: reset after os.system, add setup-script

micha 3 years ago
parent
commit
131ecb9b0e
2 changed files with 18 additions and 0 deletions
  1. 2 0
      netns/exec
  2. 16 0
      netns/setup.sh

+ 2 - 0
netns/exec

@@ -41,4 +41,6 @@ print(cmd)
 cmd2=cmd.format(user=username,id=options.id,cmd=options.cmd)
 print(cmd2)
 os.system(cmd2)
+os.system("reset")
+os.system("echo 'reset ok'")
 

+ 16 - 0
netns/setup.sh

@@ -0,0 +1,16 @@
+#copy this dir ASP/netns to /opt/ as root 
+cp -r ../netns /opt/
+chown -R root:root /opt/netns
+
+# add with sudo visudo
+echo "insert into visudo"
+echo "user      ALL=(ALL) NOPASSWD:/opt/netns/_exec, /opt/netns/create"
+
+read tmp
+visudo
+
+# now "user" can create "ip netns" with
+#sudo /opt/netns/create 14
+
+# and attache as "user" any cmd to it with
+#/opt/netns/exec --id=14 --cmd=bash