Score:0

Weird Samba username mapping

cn flag

I have a very weird problem with Samba and username map. The mapping file is like this:

username map = /etc/samba/users.map

Contents of /etc/samba/users.map:

master = johndoe user2 user3
regular = johndoe user5 user6
restricted = johndoe user8 user9

The problem is that Samba always maps johndoe to the last local user listed in /etc/samba/users.map file. In the example above, johndoe will always be mapped to restricted, so if I have a share that allows only master and anohter share that allows only restricted, I will not be able to access both, although johndoe is listed in both entries.

Is this a normal behaviour or not?

Șerban avatar
cn flag
@matigo Yes, the goal is to have johndoe access some shares that other users can. If these shares intersect, how should I make the lists so I don't get the same behavior?
Score:0
in flag

Correct. This is by design. From the documentation:

The map file is parsed line by line. Each line should contain a single UNIX username on the left then a '=' followed by a list of usernames on the right. The list of usernames on the right may contain names of the form @group in which case they will match any UNIX username in that group. The special client name '*' is a wildcard and matches any name. Each line of the map file may be up to 1023 characters long.

The file is processed on each line by taking the supplied username and comparing it with each username on the right hand side of the '=' signs. If the supplied name matches any of the names on the right hand side then it is replaced with the name on the left. Processing then continues with the next line.

As a result, having the same user account appear in multiple lines will not include them in every map, but in the last map defined.

If the goal is to have a “super user”, then you may need to look at share-specific lists or mapping account groups rather than users.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.