Chromium Code Reviews| Index: media/tools/constrained_network_server/traffic_control.py |
| diff --git a/media/tools/constrained_network_server/traffic_control.py b/media/tools/constrained_network_server/traffic_control.py |
| index c27a255365b766cdd68ade24204916fc9d02285d..8de3ef0034c43ae104ef28cb18756b6055edd946 100755 |
| --- a/media/tools/constrained_network_server/traffic_control.py |
| +++ b/media/tools/constrained_network_server/traffic_control.py |
| @@ -9,6 +9,7 @@ Traffic to the constrained port is forwarded to a specified server port. |
| """ |
| import logging |
| +import os |
| import re |
| import subprocess |
| @@ -37,6 +38,22 @@ class TrafficControlError(BaseException): |
| self.error = error |
| +def CheckRequirements(): |
| + """Checks if permissions are available to run traffic control commands. |
| + |
| + Raises: |
| + TrafficControlError: If permissions to run traffic control commands are not |
| + available. |
| + """ |
| + if os.geteuid() != 0: |
| + _Exec(['sudo', '-n', 'tc', '-help'], |
| + msg=('Cannot run traffic control \'tc\' command. ' |
|
DaleCurtis
2012/01/10 21:35:08
Better written as "Cannot run 'tc' command. Traffi
|
| + 'Please check that you have root access.')) |
| + _Exec(['sudo', '-n', 'iptables', '-help'], |
| + msg=('Cannot run traffic control \'iptables\' command. ' |
| + 'Please check that you have root access.')) |
| + |
| + |
| def CreateConstrainedPort(config): |
| """Creates a new constrained port. |