Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Heartbeat] Rootless pings #13795

Merged
merged 14 commits into from
Sep 25, 2019
Prev Previous commit
Next Next commit
=)
  • Loading branch information
leopucci committed Apr 11, 2019
commit 6daf6f25be584bc26fc0c1e1adbca966202ea237
57 changes: 25 additions & 32 deletions heartbeat/tests/system/test_icmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@ def has_group_permission(self):
try:
result = subprocess.check_output(
['sysctl', 'net.ipv4.ping_group_range']).strip()
result = result.split("= ")
result = result[1].split("\t")
result = map(int, result)
firstGroup = result[0]
lastGroup = result[1]
if any(firstGroup == group for group in runningGroups):
return (True)
if any(lastGroup > group for group in runningGroups):
return (True)
except subprocess.CalledProcessError, e:
print "stdout output:\n", e.output

result = result.split("= ")
result = result[1].split("\t")
result = map(int, result)
firstGroup = result[0]
lastGroup = result[1]
if any(firstGroup == group for group in runningGroups):
return (True)
if any(lastGroup > group for group in runningGroups):
return (True)
print "Error trying sysctl:\n", e.output

return (False)

Expand Down Expand Up @@ -75,28 +74,22 @@ def test_base(self):
**config
)

adminRights = self.has_admin()
if adminRights == True:
proc = self.start_beat()
self.wait_until(lambda: self.log_contains(
"heartbeat is running"))
proc.check_kill_and_wait()
else:
if platform.system() in ["Linux", "Darwin"]:
groupRights = self.has_group_permission()
if groupRights == True:
proc = self.start_beat()
self.wait_until(lambda: self.log_contains(
"heartbeat is running"))
proc.check_kill_and_wait()
else:
exit_code = self.run_beat()
assert exit_code == 1
assert self.log_contains(
"You dont have root permission to run ping") is True
else:
# windows seems to allow all users to run sockets
if platform.system() in ["Linux", "Darwin"]:
adminRights = self.has_admin()
groupRights = self.has_group_permission()
if groupRights == True or adminRights == True:
proc = self.start_beat()
self.wait_until(lambda: self.log_contains(
"heartbeat is running"))
proc.check_kill_and_wait()
else:
exit_code = self.run_beat()
assert exit_code == 1
assert self.log_contains(
"You dont have root permission to run ping") is True
else:
# windows seems to allow all users to run sockets
proc = self.start_beat()
self.wait_until(lambda: self.log_contains(
"heartbeat is running"))
proc.check_kill_and_wait()