Showing posts with label ACL. Show all posts
Showing posts with label ACL. Show all posts

Friday, March 25, 2016

W2K & NFSv4 ACL mapping

This post is a development of another post, SMB & NFSv4 ACL mapping. It's specific to the Windows 2000 (and later) family systems. If necessary, please, check back the aforementioned "parent" post.

My discussion will be based on the following minimal scenario:
(box-01 is a Solaris 11.3 acting as a Windows 2000 Server)
 


























The graphical interface of the (directory and files) unified ACL editor (Properties | Security) seems good to manage basic settings such as: List Folder Contents, Read & Execute, Modify and Full Control. But it is impossible to get the big picture at once, it may be confusing for handling inheritance and it mixes in more complex permissions sets. The point is: it should allow us to see the permissions for all names at once, it shouldn't have the confusing Read and Write options and it should have a more objective approach (other than the confusing dimmed or grayed out checkboxes alongside the Allow inheritable... checkbox) on the inheritance status. And on top of all this, by clicking on the checkboxes on a certain order (check Modify then clear Write, you would expect to be left with Read & Execute but you don't!) it's possible to mistakenly generate unwanted special permissions.
 




























Unfortunately, the design of the Advanced option, entitled Access Control Settings is also bad because it adopts horizontal scrolling (which is terrible; they don't even persist the tedious adjustments of the listview columns that someone does in order to better see all the information without scrolling) instead of more concise graphical elements and filtering, or even a resize-able dialog, in order to really help an administrator do its job. Bottom line is it's also cumbersome as the basic one. Again, unfortunately, especially because Windows is so centric on ergonomics and GUI design. It's like this area has been greatly overlooked or treated with laziness (many out there could do a lot better than that...).
 




























Still similarly to what I have done for Windows NT 4.0 (and before) let's initially focus just on the permissions sets that are displayed on the basic (Properties | Security) dialog.

The first thing to note is that the legacy permission flags (R, W, X, D, P and O) have all gone. They were replaced by other 13 (frequently even more confusing) flags which have no compact names but just descriptions and are only accessible after yet another click and more scrolling and a bunch more clicks. As you can see, a nightmare (I'm still not sure if they really wanted to discourage people or hide their mess, perhaps both, but there would be better ways, but, that's Windows!). In order to help put things in order we have the following 1-1 mapping between the each NFSv4 and Windows permission flag:
 
















To help even more here is a mapping for the Windows 2000 basic permission sets dialog together with each flag setting, bor for the unnamed Windows flags and the UNIX NFSv4 ACLs (for simplicity here I'm intentionally omitting the name of the associated user or group that should be prefixed to each UNIX ACL and I'm also representing the 13 Windows flags as an ordered row resulting from a counter-clockwise rotation of 90°): 




Full Control

+Modify   +Read & Execute   +List Folder Contents   +Read   +Write

      
                
rwxpdDaARWcCos:fd-----:allow



Modify

+Read & Execute   +List Folder Contents   +Read   +Write

              
          rwx
pd-aARWc--s:fd-----:allow



Read & Execute

+List Folder Contents   +Read

           
             r-x---a-R-c--
s:fd-----:allow



List Folder Contents


                        r-x---a-R-c--s:-d-----:allow



Read


                        r-----a-R-c--s:fd-----:allow



Write


                        -w-p---A-W---s:fd-----:allow

NOTE
The preceding series of ACLs is formatted in terms of directory permissions but the same translation applies to file permissions (except, of course, List Folder Contents) if you disregard the respective ACL inheritance flags (between both colons in my listing) which contains an f and/or d. For instance, the Full Control for a file is depicted by rwxpdDaARWcCos:-------:allow, but depending on the inheritance it may show a trailing I inheritance flag.

NOTE
If needed, the Add & Read permission set from Windows NT 4.0 (and before)  must be manually created from the scratch by adding the following two permission sets to the desired user and directory:

r-x---a-R-c--s:f-i----:allow
rwxp--aARWc--s:-d-----:allow

Which, in other words, basically means:

Read & Execute for files and
Read, Write & Execute for directories (not their contents).

NOTE
As a variation of the Add & Read permission set above it could be interesting to have the possibility to add a folder just to a certain subtree root (or share) while all other permissions are inherited (as for giving read access to a group and so on). In that case, it's assumed (of course) that amongst the inherited permissions is the Full Control for the CREATOR OWNER identity. The permission that has to be added to the desired subtree root is:

r-xp--a-R-c--s:-------:allow

Well, beyond all the above, who knows, maybe someone can devise some useful and unanticipated sort of special access, but in general what's been seen is pretty much all about that.

With the knowledge of this post, it's not necessary to resort to a Windows box in order to set meaningful permissions according to Windows by using its GUI editors. You can do it from a Solaris 11.3 shell by using chmod(1).
   

Thursday, March 24, 2016

NT4 & NFSv4 ACL mapping

This post is a development of another post, SMB & NFSv4 ACL mapping. It's specific to the Windows NT 4.0 (and before) family systems. If necessary, please, check back the aforementioned "parent" post.

The graphical interface of the ACL editors (Directory Permissions and File Permissions) are powerful yet reasonably nice, simple, concise and straightforward. And I mostly like it.























Let's focus just on the permissions sets which are listed on the "second colon" of the listboxes labeled Name for each user or group to which the ACL is to be enforced.

The first thing to note is that Directories Permissions have two pairs of parenthesis while Files Permissions just have one. On the former, the first pair of parenthesis refers to the permissions that apply just to the directory (not the files in it), while the second pair of parenthesis refers to the permissions of the (current or new) files in the directory (depending on the setting of the checkbox which text is Replace Permissions on Existing Files).

The second thing to note is that most of the permissions sets that are list on the dropdown-listbox labeled Type of Access are the "standard" ones (according to Windows). Whatever deviates from these is considered a Special Access case and treated accordingly in the interface.

The third thing to note is that on this world, exactly 6 permission flags (independent among each other) are recognized and they are as follows (but there are a few caveats around their names and effective meanings as it shall become more clear on the permissions sets below):

       Permission Flag
    R  Read 
    W  Write 
    X  Execute 
    D  Delete 
    P  Change Permissions 
    O  Take Ownership

The fourth thing to note is that from the Windows GUI ACL editors there's no direct way of telling if an ACL is being inherited or not. The rule is that if you override any ACL for a file system object than then what's previously inherited is copied alongside what's been changed.

Still solely from the Windows perspective let's summarize the ("standard", except for the Special Access) permissions sets as they are recognized by the system:

For directories:
                        Permission Set 
   (None  )   (None  )  No Access
   (R_X___)   (None  )  List
   (R_X___)   (R_X___)  Read
   (_WX___)   (None  )  Add
   (RWX___)   (R_X___)  Add & Read 
   (RWXD__)   (RWXD__)  Change
   (All   )   (All   )  Full Control
   (Other )   (Other )  Special Access


For files:
                        Permission Set 
              (None  )  No Access
              (R_X___)  Read 
              (RWXD__)  Change 
              (All   )  Full Control
              (Other )  Special Access
 

Now from the UNIX NFSv4 ACLs perspective each of the above permission set (interestingly) translates into the following (for simplicity here I'm intentionally omitting the name of the associated user or group that should be prefixed to each ACL):

No Access

 (None)(None)           rwxpdDaARWcCos:f-i----:deny
                        rwxpdDaARWcCos:-d-----:deny 
List

 (RX)(Not Specified)    r-x---a-R-c--s:-d-----:allow
Read

 (RX)(RX)               r-x---a-R-c--s:f-i----:allow
                        r-x---a-R-c--s:-d-----:allow
Add

 (WX)(Not Specified)    -wxp--aA-Wc--s:-d-----:allow
Add & Read

 (RWX)(RX)              r-x---a-R-c--s:f-i----:allow
                        rwxp--aARWc--s:-d-----:allow
Change

 (RWXD)(RWXD)           rwxpd-aARWc--s:f-i----:allow
                        rwxpd-aARWc--s:-d-----:allow
Full Control

 (All)(All)             rwxpdDaARWcCos:f-i----:allow
                        rwxpdDaARWcCos:-d-----:allow

NOTE
The preceding series of ACLs is formatted in terms of directory permissions but the same translation applies to file permissions if you consider just the second pair of parenthesis and the respective ACL inheritance flags (between both colons in my listing) which contain an f but removing both the f and i. For instance, the Full Control for a file is depicted by the ACL rwxpdDaARWcCos:-------:allow

So, as one can see, for directories, except when (Not Specified) is involved, each pair of parenthesis actually translates into 2 NFSv4 ACLs, one for the directory (which contains the d flag) and another (which contains the f flag) for files (for being implictly inherited by new files or overriden in existing files within the directory, this last case depending on the checkbox which text is Replace Permissions on Existing Files).

For attempting the ultimate fine-grained ACL mapping between NT4 and UNIX I'll put the following (hopefully) final listing of this (long) post:
 
 (Special Access)(R)    r-----a-R-c--s:-------:allow
 (Special Access)(W)    -w-p---A-Wc--s:-------:allow
 (Special Access)(X)    --x---a---c--s:-------:allow
 (Special Access)(D)    ----d--------s:-------:allow
 (Special Access)(P)    -----------C-s:-------:allow
 (Special Access)(O)    ------------os:-------:allow

Well, beyond all the above, who knows, maybe someone can devise some useful and unanticipated sort of special access, but in general what's been seen is pretty much all about that.

With the knowledge of this post, it's not necessary to resort to a Windows box in order to set meaningful permissions according to Windows by using its GUI editors. You can do it from a Solaris 11.3 shell by using chmod(1).
    

SMB & NFSv4 ACL mapping

Let's take a quick look at how Windows and UNIX NFSv4 ACLs can kind of co-exist. The purpose of this post is to clear out the inevitable hurdles on mapping permissions between these two systems when a UNIX system shares something to Windows via the SMB/CIFS protocol. To be honest, much of the trouble comes from the cumbersome permission flags (or its unexpected combinations and side-effects) from Windows which may in part reveal how clumsy Windows internals are (and why it's not surprising the vast amount of bugs/flaws per month that have to be patched; a nightmare).

To focus on what matters the scenario assumes no Active Directory, Kerberos, LDAP, and so on..., just plain WORKGROUP operational mode (which implies just the weak NTLM or NTLMv2 authentication mechanisms).

First I'll take at the legacy Windows NT family, then at the next-generation Windows NT family. With the former I cover the legacy and with the later I cover the more recent releases. I think Windows had a good chance by the time of these two mentioned releases, but then it seems to have lost its path amongst a vast amount of crap that was kicked into its code base. But that's not the topic of this post!
 
Windows NT 4.0 (and before - the legacy family)
Please check the details on the post NT4 & NFSv4 ACL mapping.

Windows 2000 (and later - the next-generation family)
Please check the details on the post W2K & NFSv4 ACL mapping.
 
And by the way, what's the point of this post?

Well, Windows is "viral" (sorry, just joking, forgive me) or at least it used to be a decade ago or so and it's still inevitable to interact with it at some point in time. Worse than that, it has spread it's SMB/CIFS protocol throughout the industry and there are many platforms out there which supports it, ranging from Mac laptops to high-end storage systems. And that's why Solaris 11.3 better than ever supports SMB/CIFS protocol, specially on the server side with its SMB version 2.1 implementation which, at least for file-sharing purposes, ranks Solaris 11.3 as a fast Windows 2000 Server (or Windows NT 5.0 Server) amongst other Windows boxes, which is more than enough for most purposes on this area. One silent advantage of SMB 2.1 is it's better operation over WAN, that is, links with moderate-to-high latency. On the client side, Solaris 11.3 stays as a SMB 1.0 client, but frankly, who cares?

root@box-01:/export/project# share
IPC$                      smb   -   Remote IPC
c$       /var/smb/cvol    smb   -   Default Share
Project  /export/project  smb   -
  
 

Tuesday, April 8, 2014

NIS & roles

I've already posted about NIS & logins.
This post is a similar one but about NIS & roles.

A role is an account that is used to indirectly access the system.
As a login it posses the concepts of credential and home directory.
Those resources are conveniently centrally managed by NIS services.
Unfortunately NIS can't provide nowadays security requirements.
Nevertheless, it may still be very useful on restricted scenarios.

I reinstate the assumptions listed on NIS & logins.
Nevertheless I make one exception (just for illustration):
the NIS master host nis-1 is an immutable zones of host-1.

On this example, I'll create a role called nis.
The goal is to manage NIS through this role avoiding the cumbersome sudo.

To perform the series of changes on nis-1 reboot it into read-write mode:
(when finished, reboot it once again to reenter the read-only mode)

host-1# zoneadm -z nis-1 reboot -w

Create the role account on the NIS master:

nis-1# roleadd -c "NIS" -K roleauth=user nis

nis-1# getent passwd nis
nis:x:103:10:NIS:/export/home/nis:/usr/bin/pfbash


nis-1# passwd nis
New Password:
Re-enter new Password:
passwd: password successfully changed for nis


Copy the role basic configuration to the appropriate maps' sources:

nis-1# grep nis /etc/passwd >> /var/nis/acct/passwd
nis-1# grep nis /etc/shadow >> /var/nis/acct/shadow

Clean up the local role account from the NIS master:

nis-1# roledel nis

Edit the group and home directory configuration on the passwd map.
It should look like as follows:

nis-1# grep nis /var/nis/acct/passwd
nis:x:103:1001:NIS:/home/nis:/usr/bin/pfbash


nis-1# grep nis /var/nis/group
nis::1001:

Edit the netgroup configuration.
It should look somewhat similar to:
 
nis-1# cat /var/nis/netgroup
...
nisadmin ... (-,nis,business.corp) ...
...

Edit the project configuration on the project map.
It should look like as follows:

nis-1# grep nis /var/nis/project
nisadmin:200:NISAdmin:nis::


nis-1# grep nis /var/nis/user_attr  
nis::::type=role;project=nisadmin;profiles=All;roleauth=user

Edit the automounter configuration on the auto_home map.
It should look like as follows:

nis-1# grep nis /var/nis/auto_home
nis nfs-1.business.corp:/export/home/&


Run make on the updated sources:

nis-1:/var/yp# make
updated passwd
pushed passwd
updated ageing
updated netid
pushed netid
updated project
pushed project
updated netgroup
pushed netgroup
updated auto.home
pushed auto.home
updated user_attr
pushed user_attr


Verify that the maps were correctly updated:

nis-2$ ypmatch -k nis passwd
nis: nis:...:103:1001:NIS:/home/nis:/usr/bin/pfbash

 
nis-2$ ypmatch -k nis auto.home
nis: nfs-1.business.corp:/export/home/&

 
nis-2$ ypmatch -k nisadmin project
nisadmin: nisadmin:102:NISAdmin:nis::

nis-2$ ypmatch -k nis user_attr
nis: nis::::project=nisadmin;type=role;roleauth=user;...

 
nis-2$ ypcat -k netgroup | grep nis
nisadmin (-,nis,business.corp)


Create and export the home directory:

nfs-1# zfs create \
> -o quota=1g \
> -o share.nfs.sec.sys.rw="desktops:servers" \
> rpool/export/home/nis

nfs-1# cp /etc/skel/.profile /export/home/nis
nfs-1# cp /etc/skel/.bashrc /export/home/nis

nfs-1# chown -R nis:root /export/home/nis

nfs-1# ll -a /export/home/nis
total 11
drwxr-xr-x   5 root     root    ... ..
drwxr-xr-x   2 nis     
nis     ... .
-rw-r--r--   1 nis     
nis     ... .profile
-r--r--r--   1 nis     
nis     ... .bashrc

nfs-1# zfs set share.nfs=on rpool/export/home/nis

nfs-1# zfs get -o value share rpool/export/home/nis
VALUE
name=...,path=/export/home/nis,...,rw=servers:desktops


In addition to the update of NIS maps, if there were changes on any NIS netgroup that's referenced on some NFS share, then it's necessary to refresh the NFS service.

In order to be useful, roles must be associated with logins.
To associate the role nis with the login user2 alter the user_attr NIS map.

nis-1# grep nis /var/nis/user_attr  
nis::::project=project1;roles=nis

Then run make on the updated source:

nis-1:/var/yp# make
...

   
NOTE
It's important to note that during this processes there were no disruption of service to clients as all NIS clients should have been associated only to NIS slave servers.
  

Friday, January 3, 2014

NIS & logins

Last year I believe to have covered a great deal of NIS services.
I have tried to exemplify each feature and functionality.
But I think a more real example would be useful.
I intend to give an example dealing with new logins.

A login is an account that is used to directly access the system.
Along with its credential, its home directory is an essential resource.
Those resources are conveniently centrally managed by NIS services.
Unfortunately NIS can't provide nowadays security requirements.
Nevertheless, it may still be very useful on restricted scenarios.

Beyond defaults I make the following assumptions for the example:
 
  • There's no DNS infrastructure in place yet. 
  • The RPC domain is business.corp.
  • The nis-1 host is the NIS master.
  • The nis-2 and nis-3 hosts are the NIS slaves.
  • The desktop-1 host is the NIS client.
  • The nfs-1 host is the NFSv4 server.
  • The automounter is used accordingly.
  • The new login to be created is user2.
  • The group is customer (gid=1000)
  • The default project is project1.
  • The pam_list allowed users on NIS master doesn't list user2
  • Customized versions of .profile and .bashrc exist. 
  • The hosts, notably nis-1, aren't immutable zones.

As a best practice, before doing any changes, take a backup.
I prefer ZFS snapshots but they aren't allowed on immutable zones.
On an immutable zone, user management tools won't work either.
I consider worthwhile reboot the zones in temporary write mode (-w).
Another possibility is to use a Revision Control System.

Create the login account locally on the NIS master:

nis-1# useradd -c "User 2" user2

nis-1# getent passwd user2
user2:x:102:10:User 2:/export/home/user2:/usr/bin/bash


nis-1# passwd user2
New Password:
Re-enter new Password:
passwd: password successfully changed for user2


nis-1# passwd -l user2
passwd: password information changed for user2


Copy the login basic configuration to the account maps' sources:

nis-1# grep user2 /etc/passwd >> /var/nis/acct/passwd
nis-1# grep user2 /etc/shadow >> /var/nis/acct/shadow

Clean up the local login account from the NIS master:

nis-1# userdel user2

Edit the group and home directory configurations on the passwd map.
It should look like as follows:

nis-1# grep user2 /var/nis/acct/passwd
user2:x:102:1000:User 2:/home/user2:/usr/bin/bash


nis-1# grep user2 /var/nis/acct/shadow
user2:*LK*$5$...:0::::::


Edit the netgroup configuration.
It should look somewhat similar to:
 
nis-1# cat /var/nis/netgroup
...
users ... (-,user2,business.corp) ...
...
 
Edit the project configuration on the project map.
It should look like as follows:

nis-1# grep user2 /var/nis/project
project1:100:Project 1:user1,user2::


nis-1# grep user2 /var/nis/user_attr
user2::::project=project1


Edit the automounter configuration on the auto_home map.
It should look like as follows:

nis-1# grep user2 /var/nis/auto_home
user2 nfs-1.business.corp:/export/home/&


Run make on the updated sources:

nis1:/var/yp# make
updated passwd
pushed passwd
updated ageing
updated netid
pushed netid
updated project
pushed project

updated netgroup
pushed netgroup
 

updated auto.home
pushed auto.home

updated user_attr
pushed user_attr


Verify that the maps were correctly updated:

nis-2$ ypmatch -k user2 passwd
user2: user2::102:1000:User 2:/home/user2:/usr/bin/bash 


nis-2$ ypmatch -k user2 auto.home
user2: nfs-1.business.corp:/export/home/&


nis-2$ ypmatch -k project1 project
project1: project1:100:Project 1:user1,user2::


nis-2$ ypmatch -k user2 user_attr
user2: user2::::project=project1

 
nis-2$ ypcat -k netgroup | grep user2
users ... (-,user2,business.corp) ...

Create and export the home directory:

nfs-1# zfs create \
> -o quota=1g \
> -o share.nfs.sec.sys.rw="desktops:servers" \
> rpool/export/home/user2

nfs-1# cp /etc/skel/.profile /export/home/user2
nfs-1# cp /etc/skel/.bashrc /export/home/user2

nfs-1# chown -R user2:customer /export/home/user2

nfs-1# ll -a /export/home/user2
total 11
drwxr-xr-x   5 root     root         ... ..
drwxr-xr-x   2 user2    customer     ... .
-rw-r--r--   1 user2    customer     ... .profile
-r--r--r--   1 user2    customer     ... .bashrc


nfs-1# zfs set share.nfs=on rpool/export/home/user2

nfs-1# zfs get -o value share rpool/export/home/user2
VALUE
name=...,path=/export/home/user2,...,rw=servers:desktops


In addition to the update of NIS maps, if there were changes on any NIS netgroup that's referenced on some NFS share, then it's necessary to refresh the NFS service:

nfs-1# svcadm refresh nfs/server 

Finally, unlock the account (remove the *LK* prefix) so it can be used:

nis-1# grep user2 /var/nis/acct/shadow
user2:$5$...:0::::::


nis-1:/var/yp# make
...

NOTE
If user2 is going to be used on a Solaris 11 desktop, then, to avoid the remote directory bug in Login Assistant, make sure that the Gnome file .dmrc exists in the home directory and contains the following:
nfs-1$ cat /export/home/user2/.dmrc

[Desktop]
Language=en_US.UTF-8
Layout=us
  
For an variation of this post see also NIS & roles.

NOTE
It's important to note that during this processes there were no disruption of service to clients as all NIS clients should have been associated only to NIS slave servers.
  

Friday, June 22, 2012

NFSv4 ACL example 7

Granting webservd modify access on the contents of new subdirectories created by bob.
This could be viewed as a variation of example 1 but the action of creation depends on bob.
No other action will be necessary to prevent webservd from deleting the new subdirectories.

bob@box-01:~/dir1 $ mkdir subdir2
bob@
box-01:~/dir1 $ ll -dV subdir2 
drwxr-xr-x   2 bob      staff      2 Jun 21 13:29 subdir2
                 owner@:rwxp-DaARWcCos:-------:allow
                 group@:r-x---a-R-c--s:-------:allow
              everyone@:r-x---a-R-c--s:-------:allow

bob@
box-01:~/dir1 $ chmod A+user:webservd:w:di:allow subdir2
bob@
box-01:~/dir1 $ ll -dV subdir2 
drwxr-xr-x+  2 bob      staff      2 Jun 21 13:29 subdir2
          user:webservd:-w------------:-di----:allow
                 owner@:rwxp-DaARWcCos:-------:allow
                 group@:r-x---a-R-c--s:-------:allow
              everyone@:r-x---a-R-c--s:-------:allow

webservd@
box-01:/home/bob/dir1 $ ll
total 3
drwxr-xr-x+  2 bob      staff      2 Jun 21 13:29 subdir2

webservd@
box-01:/home/bob/dir1 $ echo Hello > subdir2/file21
bash: subdir2/file21: Permission denied

webservd@
box-01:/home/bob/dir1 $ mkdir subdir3
mkdir: Failed to make directory "subdir3"; Permission denied

bob@
box-01:~/dir1 $ mkdir subdir2/folder1
bob@
box-01:~/dir1 $ ll -dV subdir2/folder1/
drwxr-xr-x+  2 bob      staff      2 Jun 21 13:37 subdir2/folder1/
          user:webservd:-w------------:-d----I:allow
                 owner@:rwxp-DaARWcCos:-------:allow
                 group@:r-x---a-R-c--s:-------:allow
              everyone@:r-x---a-R-c--s:-------:allow

webservd@
box-01:/home/bob/dir1 $ echo Hi > subdir2/folder1/file211 
webservd@box-01:/home/bob/dir1 $ echo Yup > subdir2/folder1/file212
webservd@box-01:/home/bob/dir1 $ ll subdir2/folder1/
total 3
-rw-r--r--   1 webservd webservd   3 Jun 21 13:40 file211
-rw-r--r--   1 webservd webservd   4 Jun 21 13:40 file212

webservd@
box-01:/home/bob/dir1 $ rm -r subdir2/folder1
rm: Unable to remove directory subdir2/folder1: Permission denied

webservd@
box-01:/home/bob/dir1 $ ll subdir2/folder1/
total 0

webservd@
box-01:/home/bob/dir1 $ rm -fr subdir2
rm: Unable to remove directory subdir2/folder1: Permission denied
rm: Unable to remove directory subdir2: Permission denied