Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Linux Forums > Linux - Security
User Name
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.


Search this Thread
Old 03-12-2010, 06:56 PM   #1
Registered: Dec 2007
Posts: 71

Rep: Reputation: 16
Modifying Linux ACLs with Windows Server 2003 via Samba [LONG]

Ok everyone, so I'm in middle of a pretty crazy project, but I'm making progress and I feel like I'm ALMOST there!

I'll give you a little background: I had a shared drive on a Windows 2003 server that filled up. The server was about to be phased out, so I decided rather than get a new hard drive, I'd move all the info from the Windows server to my sexy new SLES10 Linux server sitting next to it, with a terabyte of unused space.

All's well. I set up Samba, Winbind, nsswitch, all of those goodies, and I was able to connect to my Samba share on the Linux box via any Windows PC by using any active directory username/password housed on the Windows server (sweet, right?)

Ok, so that part's cool. Now I get to worry about security. I am at the point where I've mounted the shared drive on the linux side with the "acl" option, so I can use setfacl to add/remove permissions from the drives. So, for argument's sake, let's say my drive is called "company" - here's what I've done:
setfacl -R -m u::--- /company #Remove owner access from /company, recursively
setfacl -R -m g::--- /company #Remove all group access from /company, recursively
setfacl -R -m o::--- /company #Remove all world access from /company, recursively
Cool right? Now nobody has access to anything unless I specify it. Here's the fun part:

setfacl -R -m g:randomADgroup:rwx /company #Now everyone in randomADgroup (a group I've created and added a few people to in AD on the Windows server) has rwx access to /company and everything in it
I can fine tune my security in this way, but I don't want to do it via Unix. I want to do it via the Windows security dialogs (i.e. right click a folder, properties, security tab, check/uncheck the boxes, etc). According to this and this I should be able to do it, as Samba provides mechanisms to map the Windows permissions settings into Unix ACLs as you set them on the Windows side.

When I try to change the settings via the Windows security dialog boxes, I get "access is denied." (i.e. if I try to add someone to a folder's access list in Windows, I can add them to the box but when I click apply it tells me access is denied). Now, I suspect that this is because in Unix, I need to execute chmod commands as root, and when I connect to the Samba share from Windows I am connecting as "Administrator" or as another active directory user. I thought that I could get around this by creating a note in the smb.conf file to map the username "administrator" to "root" using a user map file. I created the file in /etc/samba and then set the parameter username map = /etc/samba/ in smb.conf. According to this quote from the Samba documentation, that should work:

username map (G)

This option allows you to specify a file containing a mapping of usernames from the clients to the server. This can be used for several purposes. The most common is to map usernames that users use on DOS or Windows machines to those that the UNIX box uses. The other is to map multiple users to a single username so that they can more easily share files.

Please note that for user or share mode security, the username map is applied prior to validating the user credentials. Domain member servers (domain or ads) apply the username map after the user has been successfully authenticated by the domain controller and require fully qualified enties in the map table (e.g. biddle = DOMAIN\foo).

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.

If any line begins with a '#' or a ';' then it is ignored.

If any line begins with an '!' then the processing will stop after that line if a mapping was done by the line. Otherwise mapping continues with every line being processed. Using '!' is most useful when you have a wildcard mapping line later in the file.

For example to map from the name admin or administrator to the UNIX name root you would use:

root = admin administrator

Or to map anyone in the UNIX group system to the UNIX name sys you would use:

sys = @system

You can have as many mappings as you like in a username map file.

If your system supports the NIS NETGROUP option then the netgroup database is checked before the /etc/group database for matching groups.

You can map Windows usernames that have spaces in them by using double quotes around the name. For example:

tridge = "Andrew Tridgell"

would map the windows username "Andrew Tridgell" to the unix username "tridge".

The following example would map mary and fred to the unix user sys, and map the rest to guest. Note the use of the '!' to tell Samba to stop processing if it gets a match on that line:

!sys = mary fred
guest = *

Note that the remapping is applied to all occurrences of usernames. Thus if you connect to \\server\fred and fred is remapped to mary then you will actually be connecting to \\server\mary and will need to supply a password suitable for mary not fred. The only exception to this is the username passed to the password server (if you have one). The password server will receive whatever username the client supplies without modification.

Also note that no reverse mapping is done. The main effect this has is with printing. Users who have been mapped may have trouble deleting print jobs as PrintManager under WfWg will think they don't own the print job.

Samba versions prior to 3.0.8 would only support reading the fully qualified username (e.g.: DOMAIN\user) from the username map when performing a kerberos login from a client. However, when looking up a map entry for a user authenticated by NTLM[SSP], only the login name would be used for matches. This resulted in inconsistent behavior sometimes even on the same server.

The following functionality is obeyed in version 3.0.8 and later:

When performing local authentication, the username map is applied to the login name before attempting to authenticate the connection.

When relying upon a external domain controller for validating authentication requests, smbd will apply the username map to the fully qualified username (i.e. DOMAIN\user) only after the user has been successfully authenticated.

An example of use is:

username map = /usr/local/samba/lib/

Default: username map = # no username map
And by the way, my file just has a single line:

root = Administrator
To me, this whole setup says that when I connect to the Samba share from my Windows server as "Administrator" I should be "tricking" unix into thinking I'm connecting as root, and I should be able to do anything root can do, like change file permissions. But...I can't.


See, it's such a simple question


(and by the way, there are obviously much larger motivations for doing this than not wanting to buy a new hard drive. I am part of a rapidly expanding company and it would be so nice to use a single windows server to handle access to all shared drives. If I can make this work, I will hardly ever need to worry about integration of companies we may acquire whether they use windows, linux, even Mac OSX, because I will be able to handle all integration from my trusty windows server )
Old 03-15-2010, 02:00 PM   #2
Registered: Dec 2007
Posts: 71

Original Poster
Rep: Reputation: 16
I feel like this is so innovative since no one has responded to either of my threads on this so far. Haha, maybe I should write a tutorial or something when I'm done. In the mean time, I assume no one here has an insight? Thanks


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
If I run a windows 2003 server continusely... how long will it crash? pleasehelpme General 5 12-10-2007 04:59 PM
Samba and Windows Server 2003 SP1 campbellop Linux - Networking 5 08-18-2005 11:41 PM
samba server in windows 2003 domain aizkorri Linux - Networking 1 04-07-2005 11:36 AM
Mandrake 9.2 Samba and Windows 2003 Server heho Linux - Networking 1 01-06-2004 09:48 AM

All times are GMT -5. The time now is 01:17 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration