There was a vulnerability for Samba 4.3.11 on Ubuntu 16.04. We were asked to update the Samba version to the latest 4.8 or above on one Ubuntu machine. The problem is that the highest version of Samba offered for Ubuntu 16.04 is 4.3.11. Therefore, we cannot just use apt-get to update the package to the latest version. One option is to obtain the source code and compile it by ourselves.
When I googled for compiling Samba on Ubuntu, there were not a lot of posts about this topic. The samba.org also does not have detailed instructions about how to do it. I think this might be helpful for someone who is in the same situation.
Install the dependencies
Before we actually compile the code, we need to install the required dependencies. Please see this page about the dependencies. There is a link specific to Ubuntu 16.04. The link is a script to install the dependencies on Ubuntu 16.04. Here is the direct link. Note that depending on the features you want to enable, additional dependencies might be required.
Download the source code
To download the source code, use the following command
wget https://download.samba.org/pub/samba/samba-latest.tar.gz
At the time of compiling, the version is 4.10.5. You will get a newer version if you get the samba-latest.tar.gz. You can download different version of Samba here.
Use this command to extract the files.
tar xvzf samba-latest.tar.gz
Compile the source code
Change the directory to where the source code is and configure it. This is the (not so) fun part. There is little documentation about the options. I consulted with several pages, here is what I used:
./configure \ --with-systemd \ --systemd-install-services \ --with-systemddir=/etc/systemd/system \ --sysconfdir=/etc \ --localstatedir=/var \ --enable-selftest \ --with-smbpasswd-file=/etc/samba/smbpasswd \ --enable-fhs
Note that the binaries are in /usr/local/samba/bin and /usr/local/samba/sbin . You need to modify your PATH variable to use them in your command line. To see all the available options, you can type “./configure –help” without the quotes to see them. Once the configuration is done, type the following to compile and install it.
make make install
Enable the service
If you want to start the service when the system is rebooted, use this command.
systemctl enable smb
Note that if you are setting up a Samba server in AD, you might need to use “systemctl enable samba” instead.
This post may contain affiliated links. When you click on the link and purchase a product, we receive a small commision to keep us running. Thanks.
Leave a Reply