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

Port NSBSD system to the latest version of waagent #2828

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azurelinuxagent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
3 changes: 3 additions & 0 deletions azurelinuxagent/common/osutil/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 6 additions & 1 deletion azurelinuxagent/common/osutil/nsbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion config/nsbsd/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down