S 4.333 Secure configuration of Winbind under Samba

Initiation responsibility: IT Security Officer, Head of IT

Implementation responsibility: Administrator

The secure configuration of Windbind plays an important role when Samba is operated in the "domain" or "ads" security mode (see S 4.328 Secure basic configuration of a Samba server). In this case, there is a whole series of recommendations that need to be taken into consideration.

When it joins a domain, smbd is able to authenticate users on the domain controller (DC). Depending on the security mode and client, authentication is performed by evaluating the Kerberos ticket or by querying the DC. The latter is particularly time-consuming, because smbd must first find a DC and then log in to it before it can authenticate the user. This generates at least 30 network packets, only two of which are actually relevant to the authentication process.

Windows operates differently. The Local Security Authority (LSA) establishes a connection to the DC once when the domain member is started and authenticates itself as a machine. In this case, users are only authenticated using this connection. This concept does not work with smbd alone, because there is a separate smbd process for each client and network connections cannot simply be used simultaneously by several different processes.

For this reason, winbindd can be used as a proxy for the connection to the DC. It offers functionality comparable to that offered by LSA when run in Windows. In particular, it opens and maintains a connection to the DC and offers its services to all processes in the system using a Unix domain socket located in /tmp/winbindd/pipe. The smbd processes try to connect to this socket first when attempting to authenticate themselves. The smbd processes only attempt to establish a connection to a DC when authentication via the socket fails.

In addition to successful authentication, Samba also needs extra information on the users. It is necessary for each user to have one Windows and one Unix user account on the Samba server. The Unix user account is needed so that Samba can allow the kernel to control access in the file system, amongst other reasons (see also S 4.332 Secure configuration of the access controls for a Samba server).

This means that every domain user must exist in the Unix operating system together with all their group memberships. It is possible theoretically to manage all domain users manually in Unix. However, this approach should not be used and Winbind should be used instead.

Winbind is able to dynamically create appropriate Unix users and groups matching the Windows users and Windows groups when these users and groups do not yet exist in Unix. In this case, the "nss_winbind" module is used and it can be added by entering it in the file /etc/nsswitch.conf. This entry could be as follows, for example:

passwd: files winbind

group: files winbind

With these settings, the operating system searches for user names in the file /etc/passwd first. If it does not find the right user in this file, it contacts winbindd. In order for winbindd to be able to dynamically create all necessary Unix user attributes (for example the user ID, home directory, or login shell) for a user name, the daemon needs to take two steps. First, Winbind queries the DC for the security identifier (SID) of the user name. After that, Winbind must find a Unix user ID that matches the SID because the DC does not know the Unix user ID of a user. Winbind proceeds in different ways depending on the ID mapping backend configured:

Additional information on the different backends used for ID mapping can be found on their man pages. These man pages are named according to the naming scheme "idmap_<name of the backend>". Entering "man idmap_nss" displays additional information on the nss backend. Every ID mapping backend has its own individual configuration parameters. The "wbinfo" program should be used for troubleshooting.

In addition to the Unix user ID, Winbind generally also needs to assign additional Unix user attributes to each user, for example a home directory. This can be controlled using parameters such as "template homedir" or "template shell". As stated above, another mechanism is only available for the "ad" ID mapping backend.

If only one Samba server is a member of the domain and the Unix user IDs do not need to be synchronised between servers, the "tdb" ID mapping backend can be used.

If several Samba servers are members of the domain and the Unix user IDs need to be synchronised among the servers for this reason, one of the other ID mapping backends must be used.

If there are trust relationships between some of the domains in the information system, the recommendations in the following section "Trust relationships between domains" must be implemented.

Trust relationships between domains

A trust relationship is a relationship between domains that allows the users in one domain to be authenticated by a domain controller located in another domain.

Even if there are no trust relationships between domains in the information system at the moment, it still makes sense to implement the safeguards in this section, because they may be necessary in the future.

Unix user IDs

Windows assigns each user and each group a unique ID, the SID (Security Identifier). The SID contains a 96-bit long domain part and an RID (Relative Identifier) that is unique in the domain. As long as there is only one domain in the information system, Unix can use the RID to calculate a unique Unix user ID. If the information system contains several domains that trust each other mutually, this approach will not work any more. If the domain in which the Samba server is a member trusts another domain, the RID will not be unique any more. RID "500" is generally assigned to the administrator, RID "513" is assigned to the group of domain users, and every domain assigns RIDs sequentially starting with the RID "1000".

The parameter "idmap domains" is available in Samba Version 3.0.25 and higher. This parameter allows configuration of the ID Mapping based on the name of the domain.

[global]

idmap domains = BONN BERLIN

idmap config BONN:backend = rid

idmap config BONN:range = 10000 - 49999

idmap config BERLIN:backend = rid

idmap config BERLIN:range = 50000 - 99999

In the example shown above, the user BONN\administrator was assigned the Unix user ID 10500, while the user BERLIN\administrator would then be assigned the Unix user ID 50500 by Winbind.

If there are trust relationships between domains in the information system, one of the following ID mapping backends must be used:

Unix home directory

The domain of the user should be added to the path of the user's home directory. This prevents name collisions when trust relationships exist. The user "User1" in the BERLIN domain must be assigned a different home directory than "User1" in the BONN domain. This can be realised by entering the following in the smb.conf configuration file:

template homedir = /home/%D/%u

As an alternative, it is also possible to manage the home directories of the users in the Active Directory (AD) when Winbind uses the "ad" ID mapping backend. In the example shown above, the user BERLIN\user1 would be assigned /home/BERLIN/user1 as his Unix home directory.

The home directories are not created automatically by Winbind. However, this is not desirable anyway when the Samba server is used as a file server, for example.

Unix user name

To guarantee the uniqueness of the user names, the Windows user names must be converted in the following manner to Unix user names. The Unix user name of the Windows user BONN\user1 is BONN<winbind separator>user1. By default, the "winbind separator" parameter is set to the ¿\¿ character. If the default separator character setting causes problems on the Unix systems (for example, the character ¿\¿ has a special meaning when entered in a Unix command line prompt), another character can be specified in the configuration file smb.conf.

When changing the character specified in the "winbind separator" parameter, it must first be checked where the domain users and groups are entered or specified (e.g. in the configuration file smb.conf). All of these locations must be modified after changing the parameter.

Review questions: