From: Sapan Bhatia Date: Fri, 25 Jun 2010 14:36:31 +0000 (+0000) Subject: This directory has been moved to vsys-scripts. X-Git-Tag: vsys-0.99-0~10 X-Git-Url: http://git.onelab.eu/?p=vsys.git;a=commitdiff_plain;h=65f0b4dd113321ced69ea976a64f6f06fb4e3660 This directory has been moved to vsys-scripts. --- diff --git a/Makefile b/Makefile index cbed53d..ad1fc19 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ splice_stub.o: splice_stub.c gcc -c -I /usr/lib/ocaml -I /usr/lib64/ocaml splice_stub.c -o splice_stub.o vsys: ocaml_inotify-0.4/inotify.cmxa globals.cmx fdwatcher.cmx conffile.cmx splice_stub.o splice.cmx dirwatcher.cmx fifowatcher.cmx frontend.cmx unixsocketwatcher.cmx backend.cmx main.cmx docs - ocamlopt -I ocaml_inotify-0.4 str.cmxa unix.cmxa inotify.cmxa globals.cmx fdwatcher.cmx dirwatcher.cmx splice.cmx splice_stub.o directfifowatcher.cmx unixsocketwatcher.cmx frontend.cmx backend.cmx str.cmxa conffile.cmx main.cmx -o vsys + ocamlopt -I ocaml_inotify-0.4 str.cmxa unix.cmxa inotify.cmxa globals.cmx fdwatcher.cmx dirwatcher.cmx splice.cmx splice_stub.o directfifowatcher.cmx unixsocketwatcher.cmx frontend.cmx backend.cmx conffile.cmx main.cmx -o vsys vsys.b: ocaml_inotify-0.4/inotify.cma inotify.cmi globals.ml fdwatcher.ml dirwatcher.ml directfifowatcher.ml frontend.ml backend.ml main.ml ocamlc -g str.cma unix.cma ocaml_inotify-0.4/inotify.cma globals.cmo fdwatcher.cmo dirwatcher.cmo directfifowatcher.cmo frontend.cmo backend.cmo str.cma conffile.cmo main.cmo -o vsys.b diff --git a/factory/comon_exec b/factory/comon_exec deleted file mode 100755 index df6e7c0..0000000 --- a/factory/comon_exec +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/perl -use strict; - -####################################################### -# -# run any (allowed) progam in the root context -# -####################################################### - -my @allowed = ("/bin/df"); # allowed commands -my $cmdline; -my $path; -my $p; - -# read command line -$cmdline = ; -chomp($cmdline); - -# identify the path -if ($cmdline =~ /\s*(.+)\s+/) { - $path = $1; -} else { - $path = $cmdline; -} - -# run the program if it's executable and allowed to run -if (-x $path) { - foreach $p (@allowed) { - if ($p eq $path) { - system($cmdline); - exit(0); - } - } - print "fatal: '$cmdline' is not allowed to run\n"; -} else { - print "fatal: $path either does not exist or is not executable\n"; -} - -# some error occurred -exit(-1); diff --git a/factory/hide_netif b/factory/hide_netif deleted file mode 100755 index c7ae234..0000000 --- a/factory/hide_netif +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# Remove hide_netif network attribute. Attribute is used to hide interfaces that don't have an IP attached. - -# $Id$ - -nattribute --set --nid $1 --flag ~hide_netif diff --git a/factory/nfsmount b/factory/nfsmount deleted file mode 100755 index 04115dc..0000000 --- a/factory/nfsmount +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/perl - -use strict; - -my $slicename=$ARGV[0]; -my $already_mounted_testfile = "/tmp/$slicename"."_nfsmounted"; - -my $slice_dir="/vservers/$slicename/"; - -if (-f $already_mounted_testfile) { - die("Sorry, only one successful NFS mount allowed per slice!"); -} - -my $remotepath = ; -my $localpath = ; -chomp($localpath); -chomp($remotepath); -$localpath=~s/\.\.//g; - -$localpath=$slice_dir.$localpath; - -unless (-d $localpath) { - die("Localpath does not exist, please create it first."); -} - -my $hostexpr="(?=^.{1,254}$)(^(?:(?!\d+\.|-)[a-zA-Z0-9_\-]{1,63}(?$already_mounted_testfile"; - print FIL "$remotepath $localpath"; - close FIL; -} diff --git a/factory/pfmount b/factory/pfmount deleted file mode 100755 index 0282c76..0000000 --- a/factory/pfmount +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# Mount the planetflow directory in a slice - -#mount --bind /usr/local/fprobe /vservers/$1/pf -# changed from request of Faiyaz -DEST="/vservers/$1/pf" -mount | grep "on $DEST type" > /dev/null -if [ $? -eq 1 ]; then - mount --bind /var/local/fprobe -o ro $DEST -fi diff --git a/factory/pl-ps b/factory/pl-ps deleted file mode 100755 index eafdf5b..0000000 --- a/factory/pl-ps +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/perl -use strict; - -############################################### -# pl-ps for slicestat by KyoungSoo Park -############################################### - -my %slice_id; -my %slice; - -open THIS_PIPE, "/bin/awk -F: \'{print \$1, \$3}\' /etc/passwd |"; -while() { - if (/(.+)\s+(\d+)/) { - $slice_id{$1} = $2; - $slice{$2} = $1; - } -} -close THIS_PIPE; - -open THIS_PIPE, "/usr/sbin/vps -eo pid,user | sed 1d | awk \'{print \$1, \$2}\' | sort -k 2 |"; -while() { - if (/(\d+)\s+(.+)$/) { - my $pid = $1; - my ($id, $sl); - - if (defined($slice_id{$2})) { - $id = $slice_id{$2}; - $sl = $2; - } else { - $id = $2; - $sl = $slice{$2}; - } - print sprintf("%s %s %s\n", $id, $sl, $pid); - } -} -close THIS_PIPE; diff --git a/factory/portsummary b/factory/portsummary deleted file mode 100755 index f800632..0000000 --- a/factory/portsummary +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/python - -import os -import sys - -# NOTE: '--inet' lists only ipv4 addresses. -ns = os.popen("ncontext --nid 1 --migrate -- vcontext --xid 1 --migrate -- netstat -apnlut --inet", 'r') -port_summary = {} -for line in ns: - try: - ns_fields = line.split() - if ns_fields[0] == "tcp" or ns_fields[0] == "udp": - (src_ip, src_port) = ns_fields[3].split(':') - (dst_ip, dst_port) = ns_fields[4].split(':') - - port_key='%s-%s' % (src_port, dst_port) - - if src_ip is not "0.0.0.0" and port_key in port_summary: - # skip INADDR_ANY addresses and ports we've already seen. - continue - - conn_state = ns_fields[5] - if ns_fields[0] == "tcp": - proc_field = ns_fields[6] - else: - if conn_state == "ESTABLISHED": - proc_field = ns_fields[6] - else: - proc_field = ns_fields[5] - - if proc_field != "-": - (pid,procname)= proc_field.split('/') - else: - # NOTE: without a PID there is no way to associate with an XID - continue - - if ( ns_fields[0] == "tcp" and src_ip == "0.0.0.0" and conn_state == "LISTEN" ) or \ - ( ns_fields[0] == "udp" and src_ip == "0.0.0.0" ): - type='C' - elif src_ip == "127.0.0.1": - type='l' - elif src_ip != "0.0.0.0" and src_ip != "127.0.0.1": - type='c' - else: - type='?' - - xid_stream = os.popen("vserver-info %s XID" % pid) - xid = xid_stream.read() - - port_summary[port_key] = {'prot' : ns_fields[0], - 'src_port' : src_port, - 'dst_port' : dst_port, - 'slice' : xid[:-1], - 'type': type} - except: - import traceback; traceback.print_exc() - print line - -ports = port_summary.keys() -ports.sort() -for port in ports: - print "%(prot)4s\t%(src_port)6s\t%(dst_port)6s\t%(slice)5s\t%(type)s" % port_summary[port] - diff --git a/factory/setup-link b/factory/setup-link deleted file mode 100755 index cc800ce..0000000 --- a/factory/setup-link +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/sh +x - -SLICE=$1 -SLICEID=`id -u $SLICE` -read INDEX -read REMOTE -read KEY - -LINK=${KEY}if${INDEX} - -modprobe ip_gre - -### Setup EGRE tunnel -EGRE=d$LINK -ip tunnel add $EGRE mode gre type eth remote $REMOTE key $KEY ttl 64 -ip link set $EGRE up - -### Setup etun -ETUN0=a$LINK -ETUN1=b$LINK -ip link add name $ETUN0 type veth peer name $ETUN1 -ifconfig $ETUN0 mtu 1458 up -ifconfig $ETUN1 up - -### Setup bridge -BRIDGE=c$LINK -brctl addbr $BRIDGE -brctl addif $BRIDGE $EGRE -brctl addif $BRIDGE $ETUN1 -ifconfig $BRIDGE up - -### Setup iptables so that packets are visible in the vserver -iptables -t mangle -A FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID - -### Create "grab link" script -GRAB=/vsys/local_grab-$ETUN0 -echo $SLICE > $GRAB.acl -rm -f $GRAB -cat > $GRAB < $BIND.acl -rm -f $BIND -cat > $BIND < $DELETE.acl -rm -f $DELETE -cat > $DELETE < $GRAB.acl -rm -f $GRAB -cat > $GRAB < $DELETE.acl -rm -f $DELETE -cat > $DELETE <) { - print; -} -close THIS_PIPE; diff --git a/globals.ml b/globals.ml index fde6ffc..93dd803 100644 --- a/globals.ml +++ b/globals.ml @@ -9,7 +9,7 @@ let log_filepath = ref "/var/log/vsys" let failsafe = ref false let logfd = ref Pervasives.stdout -let logprint fmt = Printf.fprintf !logfd (fmt ^^ "%!") +let logprint fmt = Printf.printf fmt let debprint fmt = if (!debug) then Printf.fprintf !logfd (fmt ^^ "%!") let print fmt = Printf.printf (fmt ^^ "%!") diff --git a/tests/vsys_conctest.c b/tests/vsys_conctest.c index 2d174a0..daca830 100644 --- a/tests/vsys_conctest.c +++ b/tests/vsys_conctest.c @@ -11,8 +11,8 @@ int main() { FILE *fp = NULL, *fp_in = NULL; FILE *out_fp = NULL, *diff_fp = NULL; - const char* topcmd = "fe/test.out"; - const char* top_in_file = "fe/test.in"; + const char* topcmd = "frontend/test.out"; + const char* top_in_file = "frontend/test.in"; char buf[4096]; int fd_in = -1, fd_out; int res;