Skip to content
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
24 changes: 24 additions & 0 deletions Common/WALinuxAgent-2.0.16/waagent
Original file line number Diff line number Diff line change
Expand Up @@ -6509,10 +6509,13 @@ def DistInfo(fullname=0):
distinfo[0] = distinfo[0].strip() # remove trailing whitespace in distro name
if not distinfo[0]:
distinfo = dist_info_SLES15()
if not distinfo[0]:
distinfo = dist_info_opensuse15()
Comment on lines 6510 to +6513
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems rather inefficient. Why not have one method that figures out the distinfo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix is needed because the library we use to determine the OS and distro fails for newer distros which stopped having release files like they used to, e.g. /etc/suse-release has been dropped in newer distors in favor of /etc/os-release.

We have had to add such methods do deal with these cases since we can't rely on one single method to determine distinfo

return distinfo
else:
return platform.dist()


def dist_info_SLES15():
os_release_filepath = "/etc/os-release"
if not os.path.isfile(os_release_filepath):
Expand All @@ -6535,6 +6538,27 @@ def dist_info_SLES15():
return ["","",""]


def dist_info_opensuse15():
os_release_filepath = "/etc/os-release"
if not os.path.isfile(os_release_filepath):
return ["","",""]
info = open(os_release_filepath).readlines()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this throw if we don't have the permissions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OS release is readable for everyone in every distro. Yes, it could throw if somebody were to lock down something as fundamental as /etc/os-release but that would be a really far-fetched corner case.

found_name_opensuse_leap = False
found_id_opensuse_leap = False
version_id = ""
for line in info:
if "NAME=\"openSUSE" in line and "Leap" in line:
found_name_opensuse_leap = True
if "ID=\"opensuse-leap\"" in line:
found_id_opensuse_leap = True
if "VERSION_ID" in line:
match = re.match(r'VERSION_ID="([.0-9]+)"', line)
if match:
version_id = match.group(1)
if found_name_opensuse_leap and found_id_opensuse_leap and version_id:
return "SuSE", version_id, "suse"
return ["","",""]


def PackagedInstall(buildroot):
"""
Expand Down
2 changes: 1 addition & 1 deletion VMAccess/manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ExtensionImage xmlns="http://schemas.microsoft.com/windowsazure">
<ProviderNameSpace>Microsoft.OSTCExtensions</ProviderNameSpace>
<Type>VMAccessForLinux</Type>
<Version>1.5.3</Version>
<Version>1.5.4</Version>
<Label>Microsoft Azure VM Access Extension for Linux Virtual Machines</Label>
<HostingResources>VmRole</HostingResources>
<MediaLink></MediaLink>
Expand Down