~ubuntu-branches/ubuntu/quantal/quantum/quantal-proposed

« back to all changes in this revision

Viewing changes to quantum/rootwrap/filters.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-09-26 15:14:31 UTC
  • mfrom: (2.1.14)
  • Revision ID: package-import@ubuntu.com-20120926151431-7fm7pjmrikct0iey
Tags: 2012.2~rc3-0ubuntu1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
            return True
82
82
        return False
83
83
 
84
 
    def is_ip_netns_cmd(self, argv):
85
 
        if ((argv[0] == "ip") and
86
 
            (argv[1] == "netns") and
87
 
            (argv[2] == "exec")):
 
84
    def is_dnsmasq_env_vars(self, argv):
 
85
        if (argv[0].startswith("QUANTUM_RELAY_SOCKET_PATH=") and
 
86
            argv[1].startswith("QUANTUM_NETWORK_ID=")):
88
87
            return True
89
88
        return False
90
89
 
91
90
    def match(self, userargs):
92
91
        """This matches the combination of the leading env
93
 
        vars, plus either "dnsmasq" (for the case where we're
94
 
        not using netns) or "ip" "netns" "exec" <foo> "dnsmasq"
95
 
        (for the case where we are)"""
96
 
        if ((userargs[0].startswith("QUANTUM_RELAY_SOCKET_PATH=") and
97
 
             userargs[1].startswith("QUANTUM_NETWORK_ID=") and
98
 
             (self.is_dnsmasq_cmd(userargs[2:]) or
99
 
              (self.is_ip_netns_cmd(userargs[2:]) and
100
 
               self.is_dnsmasq_cmd(userargs[6:]))))):
 
92
        vars plus "dnsmasq" """
 
93
        if (self.is_dnsmasq_env_vars(userargs) and
 
94
            self.is_dnsmasq_cmd(userargs[2:])):
101
95
            return True
102
96
        return False
103
97
 
111
105
        return env
112
106
 
113
107
 
 
108
class DnsmasqNetnsFilter(DnsmasqFilter):
 
109
    """Specific filter for the dnsmasq call (which includes env)"""
 
110
 
 
111
    def is_ip_netns_cmd(self, argv):
 
112
        if ((argv[0] == "ip") and
 
113
            (argv[1] == "netns") and
 
114
            (argv[2] == "exec")):
 
115
            return True
 
116
        return False
 
117
 
 
118
    def match(self, userargs):
 
119
        """This matches the combination of the leading env
 
120
        vars plus "ip" "netns" "exec" <foo> "dnsmasq" """
 
121
        if (self.is_dnsmasq_env_vars(userargs) and
 
122
            self.is_ip_netns_cmd(userargs[2:]) and
 
123
            self.is_dnsmasq_cmd(userargs[6:])):
 
124
            return True
 
125
        return False
 
126
 
 
127
 
114
128
class KillFilter(CommandFilter):
115
129
    """Specific filter for the kill calls.
116
130
       1st argument is the user to run /bin/kill under