diff --git a/azurelinuxagent/agent.py b/azurelinuxagent/agent.py index 8c303482e..af63c068b 100644 --- a/azurelinuxagent/agent.py +++ b/azurelinuxagent/agent.py @@ -104,7 +104,7 @@ def __init__(self, verbose, conf_file_path=None): if os.path.isfile(ext_log_dir): raise Exception("{0} is a file".format(ext_log_dir)) if not os.path.isdir(ext_log_dir): - fileutil.mkdir(ext_log_dir, mode=0o755, owner="root") + fileutil.mkdir(ext_log_dir, mode=0o755, owner=self.osutil.get_root_username()) except Exception as e: logger.error( "Exception occurred while creating extension " diff --git a/azurelinuxagent/common/osutil/default.py b/azurelinuxagent/common/osutil/default.py index 9fb97f157..6430f83ec 100644 --- a/azurelinuxagent/common/osutil/default.py +++ b/azurelinuxagent/common/osutil/default.py @@ -374,6 +374,9 @@ def get_userentry(username): except KeyError: return None + def get_root_username(self): + return "root" + def is_sys_user(self, username): """ Check whether use is a system user. diff --git a/azurelinuxagent/common/osutil/nsbsd.py b/azurelinuxagent/common/osutil/nsbsd.py index 016f506f0..00723aa0b 100644 --- a/azurelinuxagent/common/osutil/nsbsd.py +++ b/azurelinuxagent/common/osutil/nsbsd.py @@ -28,6 +28,7 @@ class NSBSDOSUtil(FreeBSDOSUtil): def __init__(self): super(NSBSDOSUtil, self).__init__() + self.agent_conf_file_path = '/etc/waagent.conf' if self.resolver is None: # NSBSD doesn't have a system resolver, configure a python one @@ -37,7 +38,7 @@ def __init__(self): except ImportError: raise OSUtilError("Python DNS resolver not available. Cannot proceed!") - self.resolver = dns.resolver.Resolver() + self.resolver = dns.resolver.Resolver(configure=False) servers = [] cmd = "getconf /usr/Firewall/ConfigFiles/dns Servers | tail -n +2" ret, output = shellutil.run_get_output(cmd) # pylint: disable=W0612 @@ -47,6 +48,7 @@ def __init__(self): server = server[:-1] # remove last '=' cmd = "grep '{}' /etc/hosts".format(server) + " | awk '{print $1}'" ret, ip = shellutil.run_get_output(cmd) + ip = ip.strip() # Remove new line char servers.append(ip) self.resolver.nameservers = servers dns.resolver.override_system_resolver(self.resolver) @@ -74,6 +76,9 @@ def conf_sshd(self, disable_password): logger.info("{0} SSH password-based authentication methods." .format("Disabled" if disable_password else "Enabled")) + def get_root_username(self): + return "admin" + def useradd(self, username, expiration=None, comment=None): """ Create user account with 'username' diff --git a/config/nsbsd/waagent.conf b/config/nsbsd/waagent.conf index 9d0ce74d8..d7f6f2759 100644 --- a/config/nsbsd/waagent.conf +++ b/config/nsbsd/waagent.conf @@ -80,7 +80,7 @@ OS.SudoersDir=/usr/local/etc/sudoers.d # DetectScvmmEnv=n # -Lib.Dir=/usr/Firewall/var/waagent +Lib.Dir=/usr/Firewall/lib/waagent # # DVD.MountPoint=/mnt/cdrom/secure