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

[BUG] 'DebianOSBaseUtil' is not defined Kali Linux 2020.2 #1904

Closed
daveinci opened this issue Jun 6, 2020 · 11 comments
Closed

[BUG] 'DebianOSBaseUtil' is not defined Kali Linux 2020.2 #1904

daveinci opened this issue Jun 6, 2020 · 11 comments
Assignees

Comments

@daveinci
Copy link

daveinci commented Jun 6, 2020

Describe the bug: A clear and concise description of what the bug is.
After Azure Marketplace install of Kali Linux. apt-get dist-upgrade or only upgrade of waagent receive the following stack trace when running waagent (-deprovision, -version, etc.):
Traceback (most recent call last):
File "/usr/sbin/waagent", line 11, in
load_entry_point('WALinuxAgent==2.2.47', 'console_scripts', 'waagent')()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 490, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2859, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2450, in load
return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2456, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/usr/lib/python3/dist-packages/azurelinuxagent/agent.py", line 34, in
import azurelinuxagent.common.event as event
File "/usr/lib/python3/dist-packages/azurelinuxagent/common/event.py", line 632, in
event_logger = EventLogger()
File "/usr/lib/python3/dist-packages/azurelinuxagent/common/event.py", line 304, in init
osutil = get_osutil()
File "/usr/lib/python3/dist-packages/azurelinuxagent/common/osutil/factory.py", line 50, in get_osutil
return _get_osutil(distro_name, distro_code_name, distro_version, distro_full_name)
File "/usr/lib/python3/dist-packages/azurelinuxagent/common/osutil/factory.py", line 79, in _get_osutil
return DebianOSBaseUtil()
NameError: name 'DebianOSBaseUtil' is not defined

waagent version: 2

Note: Please add some context which would help us understand the problem better

  1. Section of the log where the error occurs.
  2. Serial console output
  3. Steps to reproduce the behavior. a) Install Kali from Marketplace (currently version 2019.2). b) upgrade distribution (2020.2) or only upgrade waagent (upgrades from 2.2.34 -> 2.2.47) c) check walinuxagent.service status and run waagent --version

Distro and WALinuxAgent details (please complete the following information):

  • Distro and Version: [e.g. Ubuntu 16.04]
    PRETTY_NAME="Kali GNU/Linux Rolling"
    NAME="Kali GNU/Linux"
    ID=kali
    VERSION="2020.2"
    VERSION_ID="2020.2"
    VERSION_CODENAME="kali-rolling"
    ID_LIKE=debian
    ANSI_COLOR="1;31"
    HOME_URL="https://www.kali.org/"
    SUPPORT_URL="https://forums.kali.org/"
    BUG_REPORT_URL="https://bugs.kali.org/"

  • WALinuxAgent version [e.g. 2.2.40, you can copy the output of waagent --version, more info here ]
    2.2.47

Additional context
Add any other context about the problem here.
python3 version: Python 3.8.3
systemctl status walinuxagent.service
● walinuxagent.service - Microsft Azure Linux Agent
Loaded: loaded (/lib/systemd/system/walinuxagent.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2020-06-05 22:12:08 EDT; 28min ago
Process: 690 ExecStart=/usr/sbin/waagent -daemon (code=exited, status=1/FAILURE)
Main PID: 690 (code=exited, status=1/FAILURE)

Jun 05 22:12:08 waagent[690]: event_logger = EventLogger()
Jun 05 22:12:08 waagent[690]: File "/usr/lib/python3/dist-packages/azurelinuxagent/common/event.py", line 304, in init
Jun 05 22:12:08 waagent[690]: osutil = get_osutil()
Jun 05 22:12:08 waagent[690]: File "/usr/lib/python3/dist-packages/azurelinuxagent/common/osutil/factory.py", line 50, in get_osutil
Jun 05 22:12:08 waagent[690]: return _get_osutil(distro_name, distro_code_name, distro_version, distro_full_name)
Jun 05 22:12:08 waagent[690]: File "/usr/lib/python3/dist-packages/azurelinuxagent/common/osutil/factory.py", line 79, in _get_osutil
Jun 05 22:12:08 waagent[690]: return DebianOSBaseUtil()
Jun 05 22:12:08 waagent[690]: NameError: name 'DebianOSBaseUtil' is not defined
Jun 05 22:12:08 systemd[1]: walinuxagent.service: Main process exited, code=exited, status=1/FAILURE
Jun 05 22:12:08 systemd[1]: walinuxagent.service: Failed with result 'exit-code'.

Log file attached
If possible, please provide the full /var/log/waagent.log file to help us understand the problem better and get the context of the issue.

@kevinclark19a
Copy link
Contributor

This one is odd, as DebianOSBaseUtil is pretty clearly imported before it's used on line 79 (where the stack trace indicates). It's weird, then, that there wasn't an ImportError instead of the NameError we see...
This will definitely require running this exact scenario to further debug.

@jaark
Copy link

jaark commented Jul 25, 2020

Are you using the version in the Kali apt repository?

I am seeing the same problem and it looks to be an issue with the Kali package. It is probably an old version of WALinux.
The version of common/osutil/factory.py in Kali does not import DebianOSBaseUtil

@manishrana2016
Copy link

manishrana2016 commented Sep 14, 2020

@jaark - right. It is issue with kali package. The official fix from offsec will take time i believe. But I was able to quickly fix it by manually importing the package DebianOSBaseUtil in common/osutil/factory.py.

@kevinclark19a
Copy link
Contributor

The removal of the import line might have been a change made by the kali package maintainers; our code for v2.2.47 does in fact have the necessary import. Additionally, we never actually went through with a release for 2.2.47, so I'm not quite sure what's going on there. Regardless, I think the work around of manually importing the package as @manishrana2016 mentioned is the best mitigation we can do until the kali package is updated.

I'm going to mark this issue as closed in the meantime.

@cymylau
Copy link

cymylau commented Mar 13, 2021

@manishrana2016 could you explain (in as much detail as possible) how you resolved the issue, like you're talking to a five year old (me?). Thanks.

@Javy26
Copy link

Javy26 commented Mar 17, 2021

@manishrana2016 how did you go about importing it manually? Facing the same issue

@manishrana2016
Copy link

manishrana2016 commented Mar 17, 2021

@richjjoh and @Javy26
Below are the steps:
Step 1: sudo nano /usr/lib/python3/dist-packages/azurelinuxagent/common/osutil/factory.py
Step 2: Find the line: from .debian import DebianOSModernUtil
Step 3: Replace with: from .debian import DebianOSModernUtil,DebianOSBaseUtil
Step 4: CTRL+O and Enter
Step 5: CTRL +X and Enter

@cymylau
Copy link

cymylau commented Mar 17, 2021

Thank you! @manishrana2016 Really appreciate you taking the time.

@Javy26
Copy link

Javy26 commented Mar 17, 2021

Much appreciated @manishrana2016

@fastlorenzo
Copy link

Thanks for the hint @manishrana2016
In order to have it fixed in Debian repo (and thus Kali), I'll try to make a PR here (https://salsa.debian.org/waldi/waagent/-/blob/master/azurelinuxagent/common/osutil/factory.py#L25) - once my account is approved.

@fastlorenzo
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants