From 81287bce75c81fdcbcf5f7c16a6454960e200d38 Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Mon, 8 Jun 2020 14:29:29 +0200 Subject: Chown vsftpd config file to root while bootstrapping Change-Id: I48716f544bd34b05a5524b58500cdff7c96a9578 Issue-ID: INT-1617 Signed-off-by: Bartek Grzybowski --- test/mocks/mass-pnf-sim/MassPnfSim.py | 7 ++++++- test/mocks/mass-pnf-sim/test_lifecycle.py | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'test/mocks') diff --git a/test/mocks/mass-pnf-sim/MassPnfSim.py b/test/mocks/mass-pnf-sim/MassPnfSim.py index cdf97fcf9..023c4cbf4 100755 --- a/test/mocks/mass-pnf-sim/MassPnfSim.py +++ b/test/mocks/mass-pnf-sim/MassPnfSim.py @@ -4,7 +4,7 @@ from subprocess import run, CalledProcessError import argparse import ipaddress from sys import exit -from os import chdir, getcwd, path, popen, kill, mkdir +from os import chdir, getcwd, path, popen, kill, getuid, stat, mkdir from shutil import copytree, rmtree, move from json import loads, dumps from yaml import load, SafeLoader @@ -276,6 +276,11 @@ class MassPnfSim: ftps_pasv_port_start += ftps_pasv_port_num_of_ports + 1 ftps_pasv_port_end += ftps_pasv_port_num_of_ports + 1 + # ugly hack to chown vsftpd config file to root + if getuid(): + self._run_cmd('sudo chown root config/vsftpd_ssl.conf', f'{self.sim_dirname_pattern}{i}') + self.logger.debug(f"vsftpd_ssl.conf file owner UID: {stat(self.sim_dirname_pattern + str(i) + '/config/vsftpd_ssl.conf').st_uid}") + self.logger.info(f'Done setting up instance #{i}') def build(self): diff --git a/test/mocks/mass-pnf-sim/test_lifecycle.py b/test/mocks/mass-pnf-sim/test_lifecycle.py index 0f77c9664..9bfb3dc7a 100644 --- a/test/mocks/mass-pnf-sim/test_lifecycle.py +++ b/test/mocks/mass-pnf-sim/test_lifecycle.py @@ -1,6 +1,6 @@ from MassPnfSim import MassPnfSim from glob import glob -from os import popen +from os import popen, stat from yaml import load, SafeLoader from ipaddress import ip_address from test_settings import * @@ -60,6 +60,10 @@ def test_bootstrap(args_bootstrap, parser, caplog): start_port += 2 print(yml['ippnfsim']) + # Verify vsftpd config file has proper permissions + for cfg in glob(f'{sim_dirname_pattern}*/config/vsftpd_ssl.conf'): + assert stat(cfg).st_uid == 0 + def test_bootstrap_status(args_status, caplog): MassPnfSim(args_status).status() for _ in range(SIM_INSTANCES): -- cgit 1.2.3-korg