def _dtrace_command_line(target, **kwargs): # dtrace must be run as root on OS X cmd = ["sudo", "/usr/sbin/dtrace"] # Use -C for running clang's C preprocessor over the script cmd += ["-C"] # Use -I for adding a current directory to the search path for #includes cmd += ["-I./"] # Use -Z to allow probe descriptions that match zero probes in a target cmd += ["-Z"] cmd += ["-DANALYSIS_TIMEOUT=%d" % kwargs.get("timeout", -1)] cmd += ["-s", path_for_script("apicalls.d")] cmd += ["-DTOPLEVELSCRIPT=1"] output_file = kwargs["output_file"] cmd += ["-o", output_file.name] cmd += ["-DOUTPUT_FILE=\"%s\"" % output_file.name] run_as_root = kwargs.get("run_as_root", False) # Sanitizing the path was actually causing the commands to fail when called with dtrace. if "args" in kwargs: target_cmd = "%s %s" % (target, " ".join(kwargs["args"])) else: target_cmd = target # When we don't want to run the target as root, we have to drop privileges # with `sudo -u current_user` right before calling the target. if not run_as_root: target_cmd = "sudo -u %s %s" % (getuser(), target_cmd) cmd += ["-DSUDO=1"] cmd += ["-c", target_cmd] import time with open('/Users/cloudmark/cmd.txt', 'w+') as f: f.write(str(cmd)) time.sleep(60) return cmd
def _dtrace_command_line(target, **kwargs): # dtrace must be run as root on OS X cmd = ["sudo", "/usr/sbin/dtrace"] # Use -C for running clang's C preprocessor over the script cmd += ["-C"] # Use -I for adding a current directory to the search path for #includes cmd += ["-I./"] # Use -Z to allow probe descriptions that match zero probes in a target cmd += ["-Z"] cmd += ["-DANALYSIS_TIMEOUT=%d" % kwargs.get("timeout", -1)] cmd += ["-s", path_for_script("apicalls.d")] cmd += ["-DTOPLEVELSCRIPT=1"] output_file = kwargs["output_file"] cmd += ["-o", output_file.name] cmd += ["-DOUTPUT_FILE=\"%s\"" % output_file.name] run_as_root = kwargs.get("run_as_root", False) if "args" in kwargs: target_cmd = "%s %s" % (sanitize_path(target), " ".join( kwargs["args"])) else: target_cmd = sanitize_path(target) # When we don't want to run the target as root, we have to drop privileges # with `sudo -u current_user` right before calling the target. if not run_as_root: target_cmd = "sudo -u %s %s" % (getuser(), target_cmd) cmd += ["-DSUDO=1"] cmd += ["-c", target_cmd] return cmd
def _dtrace_command_line(target, **kwargs): # dtrace must be run as root on OS X cmd = ["sudo", "/usr/sbin/dtrace"] # Use -C for running clang's C preprocessor over the script cmd += ["-C"] # Use -I for adding a current directory to the search path for #includes cmd += ["-I./"] # Use -Z to allow probe descriptions that match zero probes in a target cmd += ["-Z"] cmd += ["-DANALYSIS_TIMEOUT=%d" % kwargs.get("timeout", -1)] cmd += ["-s", path_for_script("apicalls.d")] cmd += ["-DTOPLEVELSCRIPT=1"] output_file = kwargs["output_file"] cmd += ["-o", output_file.name] cmd += ['-DOUTPUT_FILE="%s"' % output_file.name] run_as_root = kwargs.get("run_as_root", False) if "args" in kwargs: target_cmd = "%s %s" % (sanitize_path(target), " ".join(kwargs["args"])) else: target_cmd = sanitize_path(target) # When we don't want to run the target as root, we have to drop privileges # with `sudo -u current_user` right before calling the target. if not run_as_root: target_cmd = "sudo -u %s %s" % (getuser(), target_cmd) cmd += ["-DSUDO=1"] cmd += ["-c", target_cmd] return cmd