From: John Wolfe Date: Thu, 4 Mar 2021 21:48:46 +0000 (-0800) Subject: Reduce or eliminate Linux dependency on the "net-tools" package. X-Git-Tag: stable-11.3.0~129 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9bdfa71a8d86b7182c0ed2b8ea9e42f6aa0d33e8;p=thirdparty%2Fopen-vm-tools.git Reduce or eliminate Linux dependency on the "net-tools" package. The "ifconfig" and "netstat" commands are deprecated in more recent releases of Linux. Update the Linux vm-support script to use the "ip" and "ss" commands when available. If Available: Fallback: ip ifconfig ip route route ss netstat Addresses: https://github.com/vmware/open-vm-tools/issues/446 --- diff --git a/open-vm-tools/scripts/common/vm-support b/open-vm-tools/scripts/common/vm-support index 18786534e..f8e3b29b2 100644 --- a/open-vm-tools/scripts/common/vm-support +++ b/open-vm-tools/scripts/common/vm-support @@ -216,8 +216,6 @@ stageLinux() if which apt > /dev/null; then runcmd "/tmp/apt-list.txt" apt list fi - runcmd "/tmp/netstat-lan.txt" netstat -lan - runcmd "/tmp/route.txt" route runcmd "/tmp/free.txt" free } @@ -260,6 +258,22 @@ cleanup() fi } +collectNetworkDetails() +{ + if which ip >/dev/null; then + runcmd "/tmp/ip-addr.txt" ip addr + runcmd "/tmp/ip-route.txt" ip route + else + runcmd "/tmp/ifconfig.txt" ifconfig -a + runcmd "/tmp/route.txt" route + fi + + if which ss >/dev/null; then + runcmd "/tmp/ss-lan.txt" ss -lan + else + runcmd "/tmp/netstat-lan.txt" netstat -lan + fi +} # This executable may run with root privileges, so hardcode a PATH where # unprivileged users cannot write. @@ -350,7 +364,7 @@ addfile /var/log/cloud-init-output.log addfile /etc/cloud/cloud.cfg runcmd "/tmp/df.txt" df -runcmd "/tmp/ifconfig.txt" ifconfig -a +collectNetworkDetails runcmd "/tmp/mount.txt" mount runcmd "/tmp/dmesg.txt" dmesg runcmd "/tmp/ulimit-a.txt" ulimit -a