Skip to content

Commit 52ea6f3

Browse files
committed
tests:integration: Fix warning about 01-main.yaml permissions
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.
1 parent 4184208 commit 52ea6f3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

tests/integration/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import tempfile
3535
import time
3636
import unittest
37+
import pathlib
3738

3839
import gi
3940

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

213217
# create static entropy file to avoid draining/blocking on /dev/random
214218
self.entropy_file = os.path.join(self.workdir, 'entropy')

tests/integration/regressions.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ def test_try_accept_lp1949095(self):
8888
f.write('''network:
8989
renderer: %(r)s
9090
version: 2''' % {'r': self.backend})
91-
os.chmod(self.config, mode=0o600)
9291
p = subprocess.Popen(['netplan', 'try'], bufsize=1, text=True,
9392
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
9493
time.sleep(2)
@@ -103,7 +102,6 @@ def test_try_reject_lp1949095(self):
103102
f.write('''network:
104103
renderer: %(r)s
105104
version: 2''' % {'r': self.backend})
106-
os.chmod(self.config, mode=0o600)
107105
p = subprocess.Popen(['netplan', 'try'], bufsize=1, text=True,
108106
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
109107
time.sleep(2)
@@ -151,7 +149,6 @@ def test_try_accept_lp1959570(self):
151149
br54:
152150
addresses:
153151
- "10.0.0.20/24"''' % {'r': self.backend})
154-
os.chmod(self.config, mode=0o600)
155152
del os.environ['PATH'] # clear PATH, to test for LP: #1959570
156153
p = subprocess.Popen(['/usr/sbin/netplan', 'try'], bufsize=1, text=True,
157154
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

0 commit comments

Comments
 (0)