Skip to content

Commit

Permalink
tests:integration: Fix warning about 01-main.yaml permissions
Browse files Browse the repository at this point in the history
Avoid warnings like this across the test suite:

** (process:7269): WARNING **: 09:18:54.621: Permissions for /etc/netplan/01-main.yaml are too open. Netplan configuration should NOT be accessible by others.
  • Loading branch information
slyon committed Feb 6, 2025
1 parent 4184208 commit 52ea6f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 4 additions & 0 deletions tests/integration/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import tempfile
import time
import unittest
import pathlib

import gi

Expand Down Expand Up @@ -209,6 +210,9 @@ def setUp(self):
self.workdir = self.workdir_obj.name
self.config = '/etc/netplan/01-main.yaml'
os.makedirs('/etc/netplan', exist_ok=True)
# prepare common config file with proper permissions
pathlib.Path(self.config).touch()
os.chmod(self.config, 0o600)

# create static entropy file to avoid draining/blocking on /dev/random
self.entropy_file = os.path.join(self.workdir, 'entropy')
Expand Down
3 changes: 0 additions & 3 deletions tests/integration/regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def test_try_accept_lp1949095(self):
f.write('''network:
renderer: %(r)s
version: 2''' % {'r': self.backend})
os.chmod(self.config, mode=0o600)
p = subprocess.Popen(['netplan', 'try'], bufsize=1, text=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
time.sleep(2)
Expand All @@ -103,7 +102,6 @@ def test_try_reject_lp1949095(self):
f.write('''network:
renderer: %(r)s
version: 2''' % {'r': self.backend})
os.chmod(self.config, mode=0o600)
p = subprocess.Popen(['netplan', 'try'], bufsize=1, text=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
time.sleep(2)
Expand Down Expand Up @@ -151,7 +149,6 @@ def test_try_accept_lp1959570(self):
br54:
addresses:
- "10.0.0.20/24"''' % {'r': self.backend})
os.chmod(self.config, mode=0o600)
del os.environ['PATH'] # clear PATH, to test for LP: #1959570
p = subprocess.Popen(['/usr/sbin/netplan', 'try'], bufsize=1, text=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Expand Down

0 comments on commit 52ea6f3

Please sign in to comment.