mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-20 05:51:18 +02:00
app-emulation/wa-linux-agent: bump agent and allow config of 'core'
Patches have been merged upstream. Add a special case for 'core' user, allowing the agent to configure it.
This commit is contained in:
parent
4562fa778b
commit
47fdbb3507
@ -0,0 +1,34 @@
|
||||
From 8e3f94badcacfd4b681fa72619cf0c9c1d904714 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Crawford <alex.crawford@coreos.com>
|
||||
Date: Fri, 10 Oct 2014 10:58:08 -0700
|
||||
Subject: [PATCH] Allow agent to set password for 'core' user
|
||||
|
||||
---
|
||||
waagent | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/waagent b/waagent
|
||||
index 45ab97a..6b0e0cd 100644
|
||||
--- a/waagent
|
||||
+++ b/waagent
|
||||
@@ -972,6 +972,8 @@ class CoreOSDistro(AbstractDistro):
|
||||
CoreOS Distro concrete class
|
||||
Put CoreOS specific behavior here...
|
||||
"""
|
||||
+ CORE_UID = 500
|
||||
+
|
||||
def __init__(self):
|
||||
super(CoreOSDistro,self).__init__()
|
||||
self.requiredDeps += [ "/usr/bin/systemctl" ]
|
||||
@@ -1059,7 +1061,7 @@ class CoreOSDistro(AbstractDistro):
|
||||
pass
|
||||
if uidmin == None:
|
||||
uidmin = 100
|
||||
- if userentry != None and userentry[2] < uidmin:
|
||||
+ if userentry != None and userentry[2] < uidmin and userentry[2] != self.CORE_UID:
|
||||
Error("CreateAccount: " + user + " is a system user. Will not set password.")
|
||||
return "Failed to set password for system user: " + user + " (0x06)."
|
||||
if userentry == None:
|
||||
--
|
||||
1.9.3
|
||||
|
@ -1,127 +0,0 @@
|
||||
From b6e20c997c444ce754f0b9d75646a169816dce7b Mon Sep 17 00:00:00 2001
|
||||
From: Alex Crawford <alex.crawford@coreos.com>
|
||||
Date: Tue, 30 Sep 2014 14:55:55 -0700
|
||||
Subject: [PATCH 1/2] various fixes for CoreOS distro
|
||||
|
||||
- Clean up service unit
|
||||
- Add /etc/machine-id to deprovision blacklist
|
||||
- Add custom RestartInterface()
|
||||
- Stop networkd before running DHCP client
|
||||
- Remove install/uninstall register/deregister functions
|
||||
---
|
||||
waagent | 51 ++++++++++-----------------------------------------
|
||||
1 file changed, 10 insertions(+), 41 deletions(-)
|
||||
|
||||
diff --git a/waagent b/waagent
|
||||
index f4632c5..2271978 100644
|
||||
--- a/waagent
|
||||
+++ b/waagent
|
||||
@@ -935,22 +935,6 @@ class centosDistro(redhatDistro):
|
||||
# CoreOSDistro
|
||||
############################################################
|
||||
|
||||
-coreos_systemd_conf = """\
|
||||
-[Unit]
|
||||
-Description=Microsoft Azure Agent
|
||||
-After=network.target
|
||||
-After=sshd.service
|
||||
-ConditionFileIsExecutable=/usr/share/oem/waagent/bin/waagent
|
||||
-ConditionPathExists=/etc/systemd/system/waagent.service
|
||||
-
|
||||
-[Service]
|
||||
-Type=simple
|
||||
-ExecStart=/usr/share/oem/python/bin/python /usr/share/oem/waagent/bin/waagent -daemon
|
||||
-
|
||||
-[Install]
|
||||
-WantedBy=multi-user.target
|
||||
-"""
|
||||
-
|
||||
class CoreOSDistro(AbstractDistro):
|
||||
"""
|
||||
CoreOS Distro concrete class
|
||||
@@ -961,7 +945,7 @@ class CoreOSDistro(AbstractDistro):
|
||||
self.requiredDeps += [ "/usr/bin/systemctl" ]
|
||||
self.agent_service_name = 'waagent'
|
||||
self.init_script_file='/etc/systemd/system/waagent.service'
|
||||
- self.init_file=coreos_systemd_conf
|
||||
+ self.fileBlackList.append("/etc/machine-id")
|
||||
self.dhcp_client_name='systemd-networkd'
|
||||
self.getpidcmd='pidof '
|
||||
self.shadow_file_mode=0640
|
||||
@@ -997,35 +981,12 @@ class CoreOSDistro(AbstractDistro):
|
||||
"""
|
||||
return 0
|
||||
|
||||
- def installAgentServiceScriptFiles(self):
|
||||
- try:
|
||||
- SetFileContents(self.init_script_file, self.init_file)
|
||||
- os.chmod(self.init_script_file, 0744)
|
||||
- except OSError, e:
|
||||
- ErrorWithPrefix('installAgentServiceScriptFiles','Exception: '+str(e)+' occured creating ' + self.init_script_file)
|
||||
- return 1
|
||||
- return 0
|
||||
-
|
||||
- def registerAgentService(self):
|
||||
- if self.installAgentServiceScriptFiles() == 0:
|
||||
- return Run('systemctl enable ' + self.agent_service_name)
|
||||
- else :
|
||||
- return 1
|
||||
-
|
||||
def startAgentService(self):
|
||||
return Run('systemctl start ' + self.agent_service_name)
|
||||
|
||||
def stopAgentService(self):
|
||||
return Run('systemctl stop ' + self.agent_service_name)
|
||||
|
||||
- def uninstallAgentService(self):
|
||||
- Run('systemctl disable ' + self.agent_service_name)
|
||||
- return Run('rm ' + self.init_script_file)
|
||||
-
|
||||
- def unregisterAgentService(self):
|
||||
- self.stopAgentService()
|
||||
- return self.uninstallAgentService()
|
||||
-
|
||||
def restartSshService(self):
|
||||
"""
|
||||
Service call to re(start) the SSH service
|
||||
@@ -1034,7 +995,7 @@ class CoreOSDistro(AbstractDistro):
|
||||
if retcode > 0:
|
||||
Error("Failed to restart SSH service with return code:" + str(retcode))
|
||||
return retcode
|
||||
-#
|
||||
+
|
||||
def sshDeployPublicKey(self,fprint,path):
|
||||
"""
|
||||
We support PKCS8.
|
||||
@@ -1044,6 +1005,10 @@ class CoreOSDistro(AbstractDistro):
|
||||
else :
|
||||
return 0
|
||||
|
||||
+ def RestartInterface(self, iface):
|
||||
+ Run("systemctl restart systemd-networkd")
|
||||
+
|
||||
+
|
||||
############################################################
|
||||
# debianDistro
|
||||
############################################################
|
||||
@@ -4307,6 +4272,8 @@ class Agent(Util):
|
||||
Run("route add 255.255.255.255 dev " + ifname,chk_err=False) # We supress error logging on error.
|
||||
if MyDistro.dhcp_client_name == 'wickedd-dhcp4':
|
||||
Run("service " + MyDistro.dhcp_client_name + " stop",chk_err=False)
|
||||
+ if MyDistro.dhcp_client_name == 'systemd-networkd':
|
||||
+ Run("systemctl stop " + MyDistro.dhcp_client_name,chk_err=False)
|
||||
sock.bind(("0.0.0.0", 68))
|
||||
sock.sendto(sendData, ("<broadcast>", 67))
|
||||
sock.settimeout(10)
|
||||
@@ -4336,6 +4303,8 @@ class Agent(Util):
|
||||
Log("DoDhcpWork: Removing broadcast route for DHCP.")
|
||||
if MyDistro.dhcp_client_name == 'wickedd-dhcp4':
|
||||
Run("service " + MyDistro.dhcp_client_name + " start",chk_err=False)
|
||||
+ if MyDistro.dhcp_client_name == 'systemd-networkd':
|
||||
+ Run("systemctl start " + MyDistro.dhcp_client_name,chk_err=False)
|
||||
return None
|
||||
|
||||
def UpdateAndPublishHostName(self, name):
|
||||
--
|
||||
1.9.3
|
||||
|
@ -1,118 +0,0 @@
|
||||
From eebe1780f90058d82b3fc2bb60bdaa1755c1b10a Mon Sep 17 00:00:00 2001
|
||||
From: Alex Crawford <alex.crawford@coreos.com>
|
||||
Date: Tue, 30 Sep 2014 15:31:00 -0700
|
||||
Subject: [PATCH 2/2] refactor DHCP start/stop into its own methods
|
||||
|
||||
---
|
||||
waagent | 46 ++++++++++++++++++++++++++++++++++++++--------
|
||||
1 file changed, 38 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/waagent b/waagent
|
||||
index 2271978..15f817d 100644
|
||||
--- a/waagent
|
||||
+++ b/waagent
|
||||
@@ -184,6 +184,7 @@ class AbstractDistro(object):
|
||||
self.sudoers_dir_base = '/etc'
|
||||
self.waagent_conf_file = WaagentConf
|
||||
self.shadow_file_mode=0600
|
||||
+ self.dhcp_enabled = False
|
||||
|
||||
def isSelinuxSystem(self):
|
||||
"""
|
||||
@@ -556,6 +557,24 @@ class AbstractDistro(object):
|
||||
Error("Can't find host key: {0}".format(path))
|
||||
return False
|
||||
|
||||
+ def isDHCPEnabled(self):
|
||||
+ return self.dhcp_enabled
|
||||
+
|
||||
+ def stopDHCP(self):
|
||||
+ """
|
||||
+ Stop the system DHCP client so that tha agent can bind on its port. If
|
||||
+ the distro has set dhcp_enabled to True, it will need to provide an
|
||||
+ implementation of this method.
|
||||
+ """
|
||||
+ raise NotImplementedError('stopDHCP method missing')
|
||||
+
|
||||
+ def startDHCP(self):
|
||||
+ """
|
||||
+ Start the system DHCP client. If the distro has set dhcp_enabled to
|
||||
+ True, it will need to provide an implementation of this method.
|
||||
+ """
|
||||
+ raise NotImplementedError('startDHCP method missing')
|
||||
+
|
||||
############################################################
|
||||
# GentooDistro
|
||||
############################################################
|
||||
@@ -765,6 +784,7 @@ class SuSEDistro(AbstractDistro):
|
||||
self.grubKernelBootOptionsFile = '/boot/grub/menu.lst'
|
||||
self.grubKernelBootOptionsLine = 'kernel'
|
||||
self.getpidcmd='pidof '
|
||||
+ self.dhcp_enabled=True
|
||||
|
||||
def checkPackageInstalled(self,p):
|
||||
if Run("rpm -q " + p,chk_err=False):
|
||||
@@ -796,6 +816,12 @@ class SuSEDistro(AbstractDistro):
|
||||
def unregisterAgentService(self):
|
||||
self.stopAgentService()
|
||||
return self.uninstallAgentService()
|
||||
+
|
||||
+ def StartDHCP(self):
|
||||
+ Run("service " + self.dhcp_client_name + " start", chk_err=False)
|
||||
+
|
||||
+ def StopDHCP(self):
|
||||
+ Run("service " + self.dhcp_client_name + " stop", chk_err=False)
|
||||
|
||||
############################################################
|
||||
# redhatDistro
|
||||
@@ -951,6 +977,7 @@ class CoreOSDistro(AbstractDistro):
|
||||
self.shadow_file_mode=0640
|
||||
self.waagent_path='/usr/share/oem/waagent/bin'
|
||||
self.python_path='/usr/share/oem/python/bin'
|
||||
+ self.dhcp_enabled=True
|
||||
if 'PATH' in os.environ:
|
||||
os.environ['PATH'] = "{0}:{1}".format(os.environ['PATH'], self.python_path)
|
||||
else:
|
||||
@@ -1008,6 +1035,12 @@ class CoreOSDistro(AbstractDistro):
|
||||
def RestartInterface(self, iface):
|
||||
Run("ip link set dev " + iface + " down && ip link set dev " + iface + " up")
|
||||
|
||||
+ def StartDHCP(self):
|
||||
+ Run("systemctl start " + self.dhcp_client_name, chk_err=False)
|
||||
+
|
||||
+ def StopDHCP(self):
|
||||
+ Run("systemctl stop " + self.dhcp_client_name, chk_err=False)
|
||||
+
|
||||
|
||||
############################################################
|
||||
# debianDistro
|
||||
@@ -4270,10 +4303,9 @@ class Agent(Util):
|
||||
ifname=MyDistro.GetInterfaceName()
|
||||
Log("DoDhcpWork: Missing default route - adding broadcast route for DHCP.")
|
||||
Run("route add 255.255.255.255 dev " + ifname,chk_err=False) # We supress error logging on error.
|
||||
- if MyDistro.dhcp_client_name == 'wickedd-dhcp4':
|
||||
- Run("service " + MyDistro.dhcp_client_name + " stop",chk_err=False)
|
||||
- if MyDistro.dhcp_client_name == 'systemd-networkd':
|
||||
- Run("systemctl stop " + MyDistro.dhcp_client_name,chk_err=False)
|
||||
+ if MyDistro.isDHCPEnabled():
|
||||
+ MyDistro.StopDHCP()
|
||||
+
|
||||
sock.bind(("0.0.0.0", 68))
|
||||
sock.sendto(sendData, ("<broadcast>", 67))
|
||||
sock.settimeout(10)
|
||||
@@ -4301,10 +4333,8 @@ class Agent(Util):
|
||||
#We added this route - delete it
|
||||
Run("route del 255.255.255.255 dev " + ifname,chk_err=False) # We supress error logging on error.
|
||||
Log("DoDhcpWork: Removing broadcast route for DHCP.")
|
||||
- if MyDistro.dhcp_client_name == 'wickedd-dhcp4':
|
||||
- Run("service " + MyDistro.dhcp_client_name + " start",chk_err=False)
|
||||
- if MyDistro.dhcp_client_name == 'systemd-networkd':
|
||||
- Run("systemctl start " + MyDistro.dhcp_client_name,chk_err=False)
|
||||
+ if MyDistro.isDHCPEnabled():
|
||||
+ MyDistro.StartDHCP()
|
||||
return None
|
||||
|
||||
def UpdateAndPublishHostName(self, name):
|
||||
--
|
||||
1.9.3
|
||||
|
@ -1,48 +0,0 @@
|
||||
From a3a728564011481b73e6845202780401842b9002 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Crawford <alex.crawford@coreos.com>
|
||||
Date: Thu, 2 Oct 2014 08:53:48 -0700
|
||||
Subject: [PATCH] add a hook for translating the custom data
|
||||
|
||||
---
|
||||
waagent | 11 ++++++++++-
|
||||
1 file changed, 10 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/waagent b/waagent
|
||||
index f4632c5..4efc810 100644
|
||||
--- a/waagent
|
||||
+++ b/waagent
|
||||
@@ -556,6 +556,12 @@ class AbstractDistro(object):
|
||||
Error("Can't find host key: {0}".format(path))
|
||||
return False
|
||||
|
||||
+ def translateCustomData(self, data):
|
||||
+ """
|
||||
+ Translate the custom data from a Base64 encoding. Default to no-op.
|
||||
+ """
|
||||
+ return data
|
||||
+
|
||||
############################################################
|
||||
# GentooDistro
|
||||
############################################################
|
||||
@@ -1044,6 +1050,9 @@ class CoreOSDistro(AbstractDistro):
|
||||
else :
|
||||
return 0
|
||||
|
||||
+ def translateCustomData(self, data):
|
||||
+ return base64.b64decode(data)
|
||||
+
|
||||
############################################################
|
||||
# debianDistro
|
||||
############################################################
|
||||
@@ -3833,7 +3842,7 @@ class OvfEnv(object):
|
||||
if len(CDSection) > 0 :
|
||||
self.CustomData=GetNodeTextData(CDSection[0])
|
||||
if len(self.CustomData)>0:
|
||||
- SetFileContents(LibDir + '/CustomData',self.CustomData)
|
||||
+ SetFileContents(LibDir + '/CustomData', MyDistro.translateCustomData(self.CustomData))
|
||||
Log('Wrote ' + LibDir + '/CustomData')
|
||||
else :
|
||||
Error('<CustomData> contains no data!')
|
||||
--
|
||||
1.9.3
|
||||
|
@ -7,7 +7,8 @@
|
||||
EAPI=4
|
||||
|
||||
EGIT_REPO_URI="git://github.com/Azure/WALinuxAgent"
|
||||
EGIT_COMMIT="46710d4c0bc7e5eea6827e803d599f14f2b1df17" # v2.0.8
|
||||
EGIT_COMMIT="639581c3e61ce7365020de88999325a36b8cb1d7"
|
||||
EGIT_MASTER="2.0"
|
||||
|
||||
inherit toolchain-funcs git-2
|
||||
|
Loading…
x
Reference in New Issue
Block a user