Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: trace_inputs.py

Issue 13736002: Do not sudo unless necessary. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/swarm_client.git@master
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trace_inputs.py
diff --git a/trace_inputs.py b/trace_inputs.py
index 64a9d4f2451239777ad5c2d1dcb44c68dbbd5c44..26f7ab571cb83846426eb7379e28cbd4c558b740 100755
--- a/trace_inputs.py
+++ b/trace_inputs.py
@@ -24,15 +24,16 @@ import getpass
import glob
import json
import logging
-import unicodedata
import optparse
import os
import re
+import stat
import subprocess
import sys
import tempfile
import threading
import time
+import unicodedata
import weakref
## OS-specific imports
@@ -2247,11 +2248,18 @@ class Dtrace(ApiBase):
self._dummy_file_id, self._dummy_file_name = tempfile.mkstemp(
prefix='trace_signal_file')
+ dtrace_path = '/usr/sbin/dtrace'
+ if not os.path.isfile(dtrace_path):
+ dtrace_path = 'dtrace'
+ elif use_sudo is None and (os.stat(dtrace_path).st_mode & stat.S_ISUID):
+ # No need to sudo. For those following at home, don't do that.
+ use_sudo = False
+
# Note: do not use the -p flag. It's useless if the initial process quits
# too fast, resulting in missing traces from the grand-children. The D
# code manages the dtrace lifetime itself.
trace_cmd = [
- 'dtrace',
+ dtrace_path,
# Use a larger buffer if getting 'out of scratch space' errors.
# Ref: https://wikis.oracle.com/display/DTrace/Options+and+Tunables
'-b', '10m',
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698