{"id":503,"date":"2011-08-27T01:56:31","date_gmt":"2011-08-27T01:56:31","guid":{"rendered":"http:\/\/poojanwagh.opalstacked.com\/techblog\/?p=503"},"modified":"2011-12-16T20:12:28","modified_gmt":"2011-12-16T20:12:28","slug":"zfs-nfsv4-acls-for-a-public-samba-share","status":"publish","type":"post","link":"https:\/\/tech.poojanblog.com\/blog\/un\/zfs-nfsv4-acls-for-a-public-samba-share\/","title":{"rendered":"ZFS \/ NFSv4 ACL&#8217;s for a public Samba share"},"content":{"rendered":"<p>I&#8217;ve finally taken the time to figure things out step-by-step. NFSv4 ACL&#8217;s, which are supported by ZFS on FreeBSD (and Solaris) are pretty cool. However, I&#8217;ve never really understand how they work. By taking the time to use the command-line, I&#8217;ve figured out what I think is a good approach for a public share&#8211;one where I store old Recorded TV shows.<\/p>\n<p><!--more--><\/p>\n<p>The end result is that the permissions look like this:<\/p>\n<p><code><br \/>\ngetfacl .<br \/>\n# file: .<br \/>\n# owner: nobody<br \/>\n# group: nogroup<br \/>\nuser:Poojan:&#8212;-D&#8212;&#8212;&#8212;:-d&#8212;-:allow<br \/>\nowner@:&#8212;&#8212;&#8212;&#8212;&#8211;:&#8212;&#8212;:deny<br \/>\nowner@:rwxp&#8212;A-W-Co-:&#8212;&#8212;:allow<br \/>\ngroup@:-w-p&#8212;&#8212;&#8212;-:&#8212;&#8212;:deny<br \/>\ngroup@:r-x&#8212;&#8212;&#8212;&#8211;:&#8212;&#8212;:allow<br \/>\neveryone@:&#8212;-D&#8211;A-W-Co-:-d&#8212;-:deny<br \/>\neveryone@:rwxp&#8211;a-R-c&#8211;s:-d&#8212;-:allow<br \/>\n<\/code><br \/>\nOr, in the more verbose format:<br \/>\n<code><br \/>\ngetfacl -v .<br \/>\n# file: .<br \/>\n# owner: nobody<br \/>\n# group: nogroup<br \/>\nuser:Poojan:delete_child:dir_inherit:allow<br \/>\nowner@:::deny<br \/>\nowner@:read_data\/write_data\/execute\/append_data\/write_attributes\/write_xattr\/write_acl\/write_owner::allow<br \/>\ngroup@:write_data\/append_data::deny<br \/>\ngroup@:read_data\/execute::allow<br \/>\neveryone@:delete_child\/write_attributes\/write_xattr\/write_acl\/write_owner:dir_inherit:deny<br \/>\neveryone@:read_data\/write_data\/execute\/append_data\/read_attributes\/read_xattr\/read_acl\/synchronize:dir_inherit:allow<br \/>\n<\/code><\/p>\n<p>I started by removing all entries to their default, and I took some good advice and simply outputed the result of getfacl . to a text file:<\/p>\n<code><br \/>\nsetfacl -b .<br \/>\ngetfacl . &gt; my_new_acls<br \/>\n<\/code>\n<p>I then could then edit the <code>my_new_acls<\/code> file to get them where I wanted to with vim, and then do a<\/p>\n<code><br \/>\nsetfacl -M my_new_acls .<br \/>\n<\/code>\n<p>which would read them in and set the current directory&#8217;s ACL&#8217;s to my new edits. As <a title=\"Samba and ZFS (NFSv4) ACL settings for FreeBSD\" href=\"http:\/\/poojanwagh.opalstacked.com\/techblog\/unix-linux\/samba-and-zfs-nfsv4-acl-settings-for-freebsd\/\">I&#8217;ve said before<\/a>, I&#8217;ve created a <code>samba_guest<\/code> user and made <code>nobody<\/code> the owner of my directory.<\/p>\n<p>I <em>could<\/em> add permissions under the <code>samba_guest<\/code> directory, but I decided to use the NFSv4 moniker <code>everyone@<\/code> instead. That covers myself, too. What I want is for everyone in my household to be able to add files to the directory, but not do any damage (delete files). From the vanilla ACL set, <code>everyone@<\/code> can append, so that was already taken care of. I found <a href=\"http:\/\/eonstorage.blogspot.com\/2009\/04\/understanding-and-managing-nfsv4-acls.html\" title=\"Unerstanding and Managing NFSv4 ACLs\" target=\"_blank\">this post, with its NFSv4 ACL legend<\/a> to be very useful.<br \/>\n<code><br \/>\n# file: .<br \/>\n# owner: nobody<br \/>\n# group: nogroup<br \/>\n            owner@:::deny<br \/>\n            owner@:read_data\/write_data\/execute\/append_data\/write_attributes\/write_xattr\/write_acl\/write_owner::allow<br \/>\n            group@:write_data\/append_data::deny<br \/>\n            group@:read_data\/execute::allow<br \/>\n         everyone@:write_attributes\/write_xattr\/write_acl\/write_owner::deny<br \/>\n         everyone@:read_data\/write_data\/execute\/append_data\/read_attributes\/read_xattr\/read_acl\/synchronize::allow<br \/>\n<\/code><br \/>\nThe append_data setting on the directory allows new files to be created. However, the problem is that <code>everyone@<\/code> can also remove (delete) files from the directory. Turns out, there&#8217;s a separate flag for deleting: <code>delete_chid<\/code>. I just had to <code>deny<\/code> that for <code>everyone@<\/code>; to be safe, I also put <code>write_data<\/code> in the <code>everyone@<\/code> deny list:<br \/>\n<code><br \/>\n            owner@:::deny<br \/>\n            owner@:read_data\/write_data\/execute\/append_data\/write_attributes\/write_xattr\/write_acl\/write_owner::allow<br \/>\n            group@:write_data\/append_data::deny<br \/>\n            group@:read_data\/execute::allow<br \/>\n         everyone@:write_data\/delete_child\/write_attributes\/write_xattr\/write_acl\/write_owner::deny<br \/>\n         everyone@:read_data\/execute\/append_data\/read_attributes\/read_xattr\/read_acl\/synchronize::allow<br \/>\n<\/code><br \/>\nTurns out that <code>write_data<\/code> was important:<br \/>\n<code><br \/>\nserver% touch foo.txt<br \/>\ntouch: foo.txt: Permission denied<br \/>\n<\/code><br \/>\nLet&#8217;s add it back in:<br \/>\n<code><br \/>\n            owner@:::deny<br \/>\n            owner@:read_data\/write_data\/execute\/append_data\/write_attributes\/write_xattr\/write_acl\/write_owner::allow<br \/>\n            group@:write_data\/append_data::deny<br \/>\n            group@:read_data\/execute::allow<br \/>\n         everyone@:delete_child\/write_attributes\/write_xattr\/write_acl\/write_owner::deny<br \/>\n         everyone@:write_data\/read_data\/execute\/append_data\/read_attributes\/read_xattr\/read_acl\/synchronize::allow<br \/>\n<\/code><br \/>\nWorks:<br \/>\n<code><br \/>\nserver% touch foo.txt<br \/>\nserver% ls -l foo.txt<br \/>\n-rw-r&#8211;r&#8211;  1 my_username    nogroup  0 Aug 26 20:51 foo.txt<br \/>\nserver% rm foo.txt<br \/>\nrm: foo.txt: Operation not permitted<br \/>\n<\/code><\/p>\n<p>OK: so now <code>everyone@<\/code> can create files, but can&#8217;t delete them. Except I have a <code>cron<\/code> job that runs under my user to expire out old shows. So, I need to add in the <code>delete_child<\/code> flag for myself so I can do that:<br \/>\n<code><br \/>\n# file: .<br \/>\n# owner: nobody<br \/>\n# group: nogroup<br \/>\n        user:my_username:delete_child::allow<br \/>\n            owner@:::deny<br \/>\n            owner@:read_data\/write_data\/execute\/append_data\/write_attributes\/write_xattr\/write_acl\/write_owner::allow<br \/>\n            group@:write_data\/append_data::deny<br \/>\n            group@:read_data\/execute::allow<br \/>\n         everyone@:delete_child\/write_attributes\/write_xattr\/write_acl\/write_owner::deny<br \/>\n         everyone@:write_data\/read_data\/execute\/append_data\/read_attributes\/read_xattr\/read_acl\/synchronize::allow<br \/>\n<\/code><br \/>\nWorks:<br \/>\n<code><br \/>\nserver% rm foo.txt<br \/>\n<\/code><br \/>\nThe last step was to make all these flags inheritable&#8211;in case someone creates a new directory underneath.<br \/>\n<code><br \/>\n# file: .<br \/>\n# owner: nobody<br \/>\n# group: nogroup<br \/>\n       user:Poojan:delete_child:dir_inherit:allow<br \/>\n            owner@:::deny<br \/>\n            owner@:read_data\/write_data\/execute\/append_data\/write_attributes\/write_xattr\/write_acl\/write_owner::allow<br \/>\n            group@:write_data\/append_data::deny<br \/>\n            group@:read_data\/execute::allow<br \/>\n         everyone@:delete_child\/write_attributes\/write_xattr\/write_acl\/write_owner:dir_inherit:deny<br \/>\n         everyone@:read_data\/write_data\/execute\/append_data\/read_attributes\/read_xattr\/read_acl\/synchronize:dir_inherit:allow<br \/>\n<\/code><\/p>\n<div class='wp_likes' id='wp_likes_post-503'><a class='like' href=\"javascript:wp_likes.like(503);\" title='Like' ><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/tech.poojanblog.com\/blog\/wp-content\/plugins\/wp-likes\/images\/like.png\" alt='' border='0'\/><\/a><span class='text'>1 person likes this post.<\/span><\/p>\n<div class='like' ><a href=\"javascript:wp_likes.like(503);\">Like<\/a><\/div>\n<div class='unlike' ><a href=\"javascript:wp_likes.unlike(503);\">Unlike<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve finally taken the time to figure things out step-by-step. NFSv4 ACL&#8217;s, which are supported by ZFS on FreeBSD (and Solaris) are pretty cool. However, I&#8217;ve never really understand how they work. By taking the time to use the command-line, I&#8217;ve figured out what I think is a good approach for a public share&#8211;one where [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[135,136,13,3],"class_list":["post-503","post","type-post","status-publish","format-standard","hentry","category-un","tag-acl","tag-nfsv4","tag-samba","tag-zfs"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/503","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/comments?post=503"}],"version-history":[{"count":8,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/503\/revisions"}],"predecessor-version":[{"id":579,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/503\/revisions\/579"}],"wp:attachment":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/media?parent=503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/categories?post=503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/tags?post=503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}