<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Technical Diary &#187; facl</title>
	<atom:link href="http://andriigrytsenko.net/tag/facl/feed/" rel="self" type="application/rss+xml" />
	<link>http://andriigrytsenko.net</link>
	<description>With Andrii Grytsenko</description>
	<lastBuildDate>Tue, 17 Aug 2010 08:25:33 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>File ACL Mini-HOWTO</title>
		<link>http://andriigrytsenko.net/2009/07/file-acl-mini-howto/</link>
		<comments>http://andriigrytsenko.net/2009/07/file-acl-mini-howto/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 10:14:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[facl]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=253</guid>
		<description><![CDATA[Here I will try to explain you how FACL works in Linux environment and put it into the practice. 

I will skip all theory about subject just say that FACL provide more flexibility file access manager in comparison with traditional filesystem permission model. 
To make it work you need to mount system with acl option. [...]]]></description>
			<content:encoded><![CDATA[<p>Here I will try to explain you how FACL works in Linux environment and put it into the practice. </p>
<p><span id="more-253"></span></p>
<p>I will skip all theory about subject just say that FACL provide more flexibility file access manager in comparison with traditional filesystem permission model. </p>
<p>To make it work you need to mount system with <em>acl</em> option. Assuming you want to make filesystem /home work with ACL, then edit your <em>/etc/fstab</em>. Put <em>acl</em> in your option section in front of /home. Like this:</p>
<pre>/dev/hda4  /home  ext3 defautls,acl 0 0</pre>
<p>Remount your <em>/home </em> to make changes affected:</p>
<pre>mount -o remount /home </pre>
<p>Now you can work with ACL. Let&#8217;s make test directory with fully access for owner, read and execute access for group and no access for other: </p>
<pre>$mkdir test
$chmod 750 test
$ls -ld test
drwxr-x--- .... .</pre>
<p>Command
<pre>getfacl</pre>
<p> display all extended permission : </p>
<pre>$ getfacl dir
# file: test
# owner: user1
# group: user1
user::rwx
group::r-x
other::--- </pre>
<p>There is small table which describe FACL structure. I think it will be helpful for you: </p>
<table border="1" cellpadding="3">
<tbody>
<tr>
<th align="left">
<b>Entry type</b> </th>
<th align="left">
<b>Text form</b> </th>
</tr>
<tr>
<td align="left">
Owner </font></td>
<td align="left">
<tt>user::<i>rwx</i></tt></td>
</tr>
<tr>
<td align="left">
Named user </td>
<td align="left">
<tt>user:<i>name</i>:<i>rwx</i></tt></td>
</tr>
<tr>
<td align="left">
Owning group </td>
<td align="left">
<tt>group::<i>rwx</i></tt></td>
</tr>
<tr>
<td align="left">
Named group </td>
<td align="left">
<tt>group:<i>name</i>:<i>rwx</i></tt></td>
</tr>
<tr>
<td align="left">
Mask </td>
<td align="left">
<tt>mask::<i>rwx</i></tt></td>
</tr>
<tr>
<td align="left">
Others </td>
<td align="left">
<tt>other::<i>rwx</i></tt></td>
</tr>
</tbody>
</table>
<p>Now grant fully access for user2 using command
<pre>setfacl</pre>
<p> with option
<pre>-m</pre>
<p> (modify):</p>
<pre>$ setfacl -m user:user2:rwx test
$ getfacl --omit-header test
user::rwx
user:user2:rwx
group::r-x
mask::rwx
other::---</pre>
<p>Also you can use next syntax to set more then one entry:</p>
<pre>$ setfacl -m user:user2:rwx,group::r-x,user::rwx test</pre>
<p>or </p>
<pre>$ setfacl -m u:user2:rwx,g::r-x,u::rwx test</pre>
<p>make ls -ld again and you will see symbol &#8220;+&#8221; in the ending of the first field : </p>
<pre>$ls -ld test
rwxr-x---+ ...</pre>
<p>This symbol is pointing out file or directory with has extended file permission. </p>
<p>Now, try to change group permission over the chmod: </p>
<pre>$chmod g+w test
$getfacl --omit-header test
user::rwx
user:user2:rwx
group::r-x
mask::rwx
other::---</pre>
<p>As shown, in extended permission is nothing changed. That means the chmod has no influence on facl.  Also facl has more priority then basic permission model. We can easily see that in next example: </p>
<pre># usermod -g user1 user3
user1$ chmod g+w test
user3$ echo > ~user1/test/file1
-bash: /home/user1/test/file1: Permission denied
user1$ setfacl -m group::rwx test
user3$ echo > ~user1/test/file1
user1$ ls -l test/file1
-rw-r--r-- 1 user3 user1 0 .......</pre>
<p>If you want to restrict some access for someone. For example try to delete write access for group: There is at least two ways for this: </p>
<pre>$ setfacl -m group::rx test</pre>
<p>OR </p>
<pre>$ setfacl -m group::r-x test </pre>
<p>Also we can set default permissions for the directory. This means that all created objects in this directory will inherit permissions of top level object. </p>
<pre>$ touch test/file
$ getfacl --omit-header test/file
user::rw-
group::rw-
other::r--
$ setfacl -d -m user:user2:r-x test
$ getfacl --omit-header test
user::rwx
user:user2:rwx
group::-w-
mask::rwx
other::---
default:user::rwx
default:user:user2:r-x
default:group::r-x
default:mask::rwx
default:other::---
$ rm test/file ; touch test/file
$ getfacl --omit-header test/file
user::rw-
user:user2:r-x
group::-w-
mask::rw-
other::---</pre>
<p>To delete default permission involve <b>&#8220;-k&#8221;</b> option. Like this:</p>
<pre>$ setfacl -k test
$ $ getfacl --omit-header test
user::rwx
user:user2:rwx
group::-w-
mask::rwx
other::---</pre>
<p>More information you can get from this <a href="http://www.cs.unc.edu/cgi-bin/howto?howto=linux-file-acls">document</a> or from manual documents.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/07/file-acl-mini-howto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
