[BUG] WALinuxAgent parses private systemd state
- Dominant language
- Python
- Stars
- 581
- Forks
- 397
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 9
Description
**WALinuxAgent parses data explicitly listed as internal to systemd and not for direct access**
#2979 updated WALinuxAgent to handle Ubuntu's switch to from ISC DHCP Client to systemd-networkd. That change introduced code that reads from files in `/run/systemd/netif/leases/`, which begin with a line indicating that they contain "private data. Do not parse."
As this is an internal interface to systemd, it may change at any time in a way that could break WALinuxAgent. This issue was [discussed](https://github.com/Azure/WALinuxAgent/pull/2979#pullrequestreview-1723570562) in the original PR and concludes that "there is no proper way of getting the lease file details." This was an accurate statement at the time, but that has been addressed with systemd 256, which exposes the DHCP lease details through the systemd-networkd dbus interface.
An example of obtaining option 245 using via the dbus interface on the commandline using busctl and jq (for parsing the json responses) is:
```plain
noahm@scratch:~$ busctl -j --system call \
org.freedesktop.network1 \
/org/freedesktop/network1/link/_32 \
org.freedesktop.network1.Link \
Describe \
| jq -r '.data[0]' | \
jq -r '.DHCPv4Client.PrivateOptions | map(select(.Option == 245)) | .[].PrivateOptionData'
a83f8110
```
This can, of course, be implemented in pure python.
It would be good to update WALinuxAgent to use supported interfaces where possible. Distros using systemd <256 will likely need to continue parsing internal systemd-networkd state.
Contributor guide
Research direction
Start by locating the WALinuxAgent code added for #2979 that reads files under /run/systemd/netif/leases/. Review the systemd-networkd D-Bus Describe interface and the busctl/jq example for option 245. Done means using the supported interface with systemd 256 or newer while retaining internal-state parsing for older distributions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, python
- Domain
- networking, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100