tweak wifi example, fix waf problems (thanks to Gustavo)
authorCraig Dowell <craigdo@ee.washington.edu>
Tue, 03 Feb 2009 08:31:48 -0800
changeset 4179 2758871405b7
parent 4178 bd8625e5913a
child 4180 1ec09ce94019
tweak wifi example, fix waf problems (thanks to Gustavo)
examples/tap-wifi-dumbbell.cc
src/devices/tap-bridge/tap-creator.cc
wscript
--- a/examples/tap-wifi-dumbbell.cc	Mon Feb 02 11:43:10 2009 -0800
+++ b/examples/tap-wifi-dumbbell.cc	Tue Feb 03 08:31:48 2009 -0800
@@ -55,9 +55,6 @@
 //    ./waf --run tap-wifi-dumbbell&
 //    ping 10.1.1.3
 //
-//    Take a look at the pcap traces and note that the timing of the packet
-//    movement reflects the delay configured on the CSMA lan.
-//
 // 2) Configure a route in the linux host and ping once of the nodes on the 
 //    right, across the point-to-point link.  You will see relatively large
 //    delays due to CBR background traffic on the point-to-point (see next
--- a/src/devices/tap-bridge/tap-creator.cc	Mon Feb 02 11:43:10 2009 -0800
+++ b/src/devices/tap-bridge/tap-creator.cc	Tue Feb 03 08:31:48 2009 -0800
@@ -19,6 +19,7 @@
 #include <unistd.h>
 #include <stdint.h>
 #include <string>
+#include <string.h> // for strerror
 #include <iostream>
 #include <iomanip>
 #include <sstream>
@@ -38,7 +39,7 @@
 
 #define TAP_MAGIC 95549
 
-static int gVerbose = 0;
+static int gVerbose = 0; // Set to true to turn on logging messages.
 
 #define LOG(msg) \
   if (gVerbose) \
--- a/wscript	Mon Feb 02 11:43:10 2009 -0800
+++ b/wscript	Tue Feb 03 08:31:48 2009 -0800
@@ -17,6 +17,7 @@
 ccroot.USE_TOP_LEVEL = True
 
 import Task
+import Constants
 import Utils
 import Build
 import Configure
@@ -287,26 +288,37 @@
 class SuidBuildTask(Task.TaskBase):
     """task that makes a binary Suid
     """
-    after = 'link'
+    after = 'cxx_link cc_link'
+    maxjobs = 1
     def __init__(self, bld, program):
         self.m_display = 'build-suid'
         self.__program = program
         self.__env = bld.env.copy ()
         super(SuidBuildTask, self).__init__()
-
-    def run(self):
         try:
             program_obj = wutils.find_program(self.__program.target, self.__env)
         except ValueError, ex:
             raise Utils.WafError(str(ex))
+        program_node = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj))
+        self.filename = program_node.abspath(self.__env)
 
-        program_node = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj))
-        filename = program_node.abspath(self.__env)
-        print 'setting suid bit on executable ' + filename
-        p = subprocess.Popen('sudo chown root ' + filename, shell=True)
-        os.waitpid(p.pid, 0)
-        p = subprocess.Popen('sudo chmod u+s ' + filename, shell=True)
-        os.waitpid(p.pid, 0)
+
+    def run(self):
+        print >> sys.stderr, 'setting suid bit on executable ' + self.filename
+        if subprocess.Popen(['sudo', 'chown', 'root', self.filename]).wait():
+            return 1
+        if subprocess.Popen(['sudo', 'chmod', 'u+s', self.filename]).wait():
+            return 1
+        return 0
+
+    def runnable_status(self):
+        "RUN_ME SKIP_ME or ASK_LATER"
+        st = os.stat(self.filename)
+        if st.st_uid == 0:
+            return Constants.SKIP_ME
+        else:
+            return Constants.RUN_ME
+
 
 def create_suid_program(bld, name):
     program = bld.new_task_gen('cxx', 'program')