vmware / open-vm-tools

Official repository of VMware open-vm-tools project
http://sourceforge.net/projects/open-vm-tools/
2.26k stars 427 forks source link

Need better build/compile instructions #642

Open captainfalcon23 opened 1 year ago

captainfalcon23 commented 1 year ago

Describe the bug

I recently spent the better half of a day trying to build this tool, and had to sticky tape instructions together from various sites. It would be nice if there was a readme which clearly identified all of the packages needed to be installed prior e.g. These are all needed in centos7:

sudo yum install -y wget gcc gcc-c++ kernel-devel glib2 glib2-devel pam-devel openssl-devel libxml2-devel xmlsec1-devel libX*-devel gdk-pixbuf2-devel gtk3-devel gtkmm30-devel libtool-ltdl-devel 

sudo yum groupinstall -y "Development Tools"

In addition, there is no mention in the docs to create a service file like this (again, mr google helped, ref: https://www.virten.net/2020/10/vmware-tools-for-debian-10-arm64-on-esxi-arm/):

cat > /etc/systemd/system/vmtoolsd.service << EOF
[Unit]
Description=Service for virtual machines hosted on VMware
Documentation=http://github.com/vmware/open-vm-tools
After=network-online.target

[Service]
ExecStart=/usr/local/bin/vmtoolsd
Restart=always
TimeoutStopSec=5

[Install]
WantedBy=multi-user.target
EOF

Reproduction steps

Try and build using the steps in the readme:

Project build information:
The following steps will work on most recent Linux distributions:

autoreconf -i
./configure
make
sudo make install
sudo ldconfig

Expected behavior

Something like this should be documented (at least once per major OS - this is for RHEL/Centos7):

sudo yum install -y wget gcc gcc-c++ kernel-devel glib2 glib2-devel pam-devel openssl-devel libxml2-devel xmlsec1-devel libX*-devel gdk-pixbuf2-devel gtk3-devel gtkmm30-devel libtool-ltdl-devel 
sudo yum groupinstall -y "Development Tools"

sudo autoreconf -i
sudo ./configure --enable-deploypkg=no
sudo make
sudo make install
sudo ldconfig

sudo cat > /etc/systemd/system/vmtoolsd.service << EOF
[Unit]
Description=Service for virtual machines hosted on VMware
Documentation=http://github.com/vmware/open-vm-tools
After=network-online.target

[Service]
ExecStart=/usr/local/bin/vmtoolsd
Restart=always
TimeoutStopSec=5

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl enable vmtoolsd.service
sudo systemctl start vmtoolsd.service

Additional context

No response

PaTHml commented 1 year ago

An internal bug has been filed to track this issue.

nascarsayan commented 1 year ago

These were the steps I documented while installing in ubuntu20.04:

1. Dependencies for ubuntu 20.04:

sudo apt install -y libcurl4-openssl-dev curl protobuf-compiler libprotobuf-dev protobuf-compiler-grpc libgrpc++-dev golang-github-containerd-containerd-dev golang-github-gogo-protobuf-dev autoconf libtool pkg-config libmspack-dev libglib2.0-dev ubuntu-dev-tools libpam0g-dev libssl-dev libxml2-dev libxmlsec1-dev libx11-dev libxext-dev libxinerama-dev libxi-dev xserver-xorg-dev xorg-dev libgdk-pixbuf2.0-dev libgtk-3-dev libgtkmm-3.0-dev

2. Installation:

As per https://github.com/vmware/open-vm-tools#project-build-information

autoreconf -i
./configure
make
sudo make install
sudo ldconfig

3. Fix PAM for vmware

The fix below is for Ubuntu. For other distros, we might need to verify what works.

As of this date, make install was copying the wrong PAM file to /etc/pam.d/vmtoolsd. For Ubuntu, this file should be copied.

Hence, change the contents of /etc/pam.d/vmtoolsd to the following. You could optionally backup /etc/pam.d/vmtoolsd

# sudo vim /etc/pam.d/vmtoolsd
# PAM configuration for vmtoolsd

@include common-auth

account     required    pam_shells.so
@include common-account

If you don't do this fix, you might get the following errors in /var/log/auth.log later.

Feb 23 11:32:51 sn-ubuntu20 VGAuth[1819]: PAM unable to dlopen(pam_unix_auth.so): /lib/security/pam_unix_auth.so: cannot open shared object file: No such file or directory
Feb 23 11:32:51 sn-ubuntu20 VGAuth[1819]: PAM adding faulty module: pam_unix_auth.so
Feb 23 11:32:51 sn-ubuntu20 VGAuth[1819]: PAM unable to dlopen(pam_unix_acct.so): /lib/security/pam_unix_acct.so: cannot open shared object file: No such file or directory
Feb 23 11:32:51 sn-ubuntu20 VGAuth[1819]: PAM adding faulty module: pam_unix_acct.so
Feb 23 11:32:51 sn-ubuntu20 VGAuth[1819]: pam_unix(vmtoolsd:auth): authentication failure; logname= uid=0 euid=0 tty= ruser= rhost=  user=arcuser@arcvmw.local
Feb 23 11:32:53 sn-ubuntu20 VGAuth[1819]: vmtoolsd: Username and password mismatch for 'arcuser@arcvmw.local'.

4. Create the systemd service unit files

4.1 vgauth service

sudo vim /lib/systemd/system/vgauth.service

[Unit]
Description=Authentication service for virtual machines hosted on VMware
Documentation=http://github.com/vmware/open-vm-tools
ConditionVirtualization=vmware
DefaultDependencies=no
After=systemd-remount-fs.service systemd-tmpfiles-setup.service
After=apparmor.service
PartOf=open-vm-tools.service

[Service]
ExecStart=/usr/local/bin/VGAuthService
# When installed via apt, bin path is /usr/bin/VGAuthService
TimeoutStopSec=5

[Install]
RequiredBy=open-vm-tools.service

4.2 open-vm-tools or vmtoolsd service

sudo vim /lib/systemd/system/open-vm-tools.service

[Unit]
Description=Service for virtual machines hosted on VMware
Documentation=http://open-vm-tools.sourceforge.net/about.php
ConditionVirtualization=vmware
DefaultDependencies=no
Before=cloud-init-local.service
After=vgauth.service
After=apparmor.service
RequiresMountsFor=/tmp
After=systemd-remount-fs.service systemd-tmpfiles-setup.service systemd-modules-load.service

[Service]
ExecStart=/usr/local/bin/vmtoolsd
# When installed via apt, bin path is /usr/bin/vmtoolsd
TimeoutStopSec=5

[Install]
WantedBy=multi-user.target
Alias=vmtoolsd.service

5. Enable and start the systemd services

sudo systemctl enable vgauth.service
sudo systemctl enable open-vm-tools.service
sudo systemctl daemon-reload
sudo systemctl start vgauth.service
sudo systemctl start open-vm-tools.service