{"id":436,"date":"2011-02-01T07:28:09","date_gmt":"2011-02-01T07:28:09","guid":{"rendered":"http:\/\/poojanwagh.opalstacked.com\/techblog\/?p=436"},"modified":"2011-02-01T07:28:09","modified_gmt":"2011-02-01T07:28:09","slug":"re-doing-public-samba-share-with-freebsdzfs","status":"publish","type":"post","link":"https:\/\/tech.poojanblog.com\/blog\/unix-linux\/re-doing-public-samba-share-with-freebsdzfs\/","title":{"rendered":"Re-doing Public Samba Share with FreeBSD\/ZFS"},"content":{"rendered":"<p>This time, I&#8217;m going to to try using FreeBSD&#8217;s support for NFS ACL&#8217;s, using <a href=\"http:\/\/forums.freebsd.org\/showthread.php?t=17627\">http:\/\/forums.freebsd.org\/showthread.php?t=17627<\/a> as a reference:<\/p>\n<p><code><br \/>\nserver# zfs set aclmode=passthrough tank\/Users<br \/>\nserver# zfs set aclinherit=passthrough tank\/Users<br \/>\n<\/code><\/p>\n<p>I created ZFS filesystems within tank\/Users\/Public like so:<\/p>\n<p>[cce_bash]<br \/>\nserver% cat add_pub.sh<br \/>\n#!\/bin\/sh<\/p>\n<p>u=&#8221;$1&#8243;<br \/>\nzfs create tank\/Users\/$u<br \/>\nchown nobody:nogroup \/tank\/Users\/$u<br \/>\nfor d in &#8220;Documents&#8221; &#8220;Music&#8221; &#8220;Videos&#8221; &#8220;Pictures&#8221;; do<br \/>\n        zfs create tank\/Users\/$u\/$d<br \/>\n        zfs set aclmode=passthrough tank\/Users\/$u\/$d<br \/>\n        zfs set aclinherit=passthrough tank\/Users\/$u\/$d<br \/>\n        chown nobody:nogroup &#8220;\/tank\/Users\/$u\/$d&#8221;<br \/>\ndone<br \/>\nzfs set compression=gzip tank\/Users\/$u\/Documents<br \/>\n[\/cce_bash]<\/p>\n<p>Note the <code>zfs set aclmode<\/code> and <code>zfs set aclinherit<\/code> lines. These prevent a calculation of effective permissions based on the umask which pretty much renders the ACL commands useless (documented <a href=\"http:\/\/www.thomaskeller.biz\/blog\/2010\/08\/30\/acls-on-a-jailed-zfs-volume-with-freebsd\/\">here<\/a>). Now, to let myself read\/write\/etc tank\/Users\/Public:<\/p>\n<p><code><br \/>\nserver# setfacl -m \"user:Poojan:rwxp:fd:allow\" \/tank\/Users\/Public<br \/>\n<\/code><\/p>\n<p>Or, more generally:<\/p>\n<p>[cce_bash]<br \/>\nserver% cat prm_pub.sh<br \/>\n#!\/bin\/sh<\/p>\n<p>u=&#8221;$1&#8243;<br \/>\nfor d in &#8220;Documents&#8221; &#8220;Music&#8221; &#8220;Videos&#8221; &#8220;Pictures&#8221;; do<br \/>\n        setfacl -m &#8220;user:${u}:rwxp:fd:allow&#8221; &#8220;\/tank\/Users\/Public\/$d&#8221;<br \/>\ndone<br \/>\n[\/cce_bash]<\/p>\n<p>I&#8217;ll admit that I have no idea how this works, but it looks like it does.<\/p>\n<p>For samba, here&#8217;s my smb.conf:<br \/>\n[cce_ini]<br \/>\n# This is the main Samba configuration file. You should read the<br \/>\n# smb.conf(5) manual page in order to understand the options listed<br \/>\n# here. Samba has a huge number of configurable options (perhaps too<br \/>\n# many!) most of which are not shown in this example<br \/>\n#<br \/>\n# For a step to step guide on installing, configuring and using samba,<br \/>\n# read the Samba-HOWTO-Collection. This may be obtained from:<br \/>\n#  http:\/\/www.samba.org\/samba\/docs\/Samba-HOWTO-Collection.pdf<br \/>\n#<br \/>\n# Many working examples of smb.conf files can be found in the<br \/>\n# Samba-Guide which is generated daily and can be downloaded from:<br \/>\n#  http:\/\/www.samba.org\/samba\/docs\/Samba-Guide.pdf<br \/>\n#<br \/>\n# Any line which starts with a ; (semi-colon) or a # (hash)<br \/>\n# is a comment and is ignored. In this example we will use a #<br \/>\n# for commentry and a ; for parts of the config file that you<br \/>\n# may wish to enable<br \/>\n#<br \/>\n# NOTE: Whenever you modify this file you should run the command &#8220;testparm&#8221;<br \/>\n# to check that you have not made any basic syntactic errors.<br \/>\n#<br \/>\n#======================= Global Settings =====================================<br \/>\n[global]<\/p>\n<p># workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH<br \/>\n   workgroup = MYGROUP<\/p>\n<p># server string is the equivalent of the NT Description field<br \/>\n   server string = Samba Server<\/p>\n<p># Security mode. Defines in which mode Samba will operate. Possible<br \/>\n# values are share, user, server, domain and ads. Most people will want<br \/>\n# user level security. See the Samba-HOWTO-Collection for details.<br \/>\n   security = user<\/p>\n<p># This option is important for security. It allows you to restrict<br \/>\n# connections to machines which are on your local network. The<br \/>\n# following example restricts access to two C class networks and<br \/>\n# the &#8220;loopback&#8221; interface. For more examples of the syntax see<br \/>\n# the smb.conf man page<br \/>\n;   hosts allow = 192.168.1. 192.168.2. 127.<\/p>\n<p># If you want to automatically load your printer list rather<br \/>\n# than setting them up individually then you&#8217;ll need this<br \/>\n   load printers = yes<\/p>\n<p># you may wish to override the location of the printcap file<br \/>\n;   printcap name = \/etc\/printcap<\/p>\n<p># on SystemV system setting printcap name to lpstat should allow<br \/>\n# you to automatically obtain a printer list from the SystemV spool<br \/>\n# system<br \/>\n;   printcap name = lpstat<\/p>\n<p># It should not be necessary to specify the print system type unless<br \/>\n# it is non-standard. Currently supported print systems include:<br \/>\n# bsd, cups, sysv, plp, lprng, aix, hpux, qnx<br \/>\n;   printing = cups<\/p>\n<p># Uncomment this if you want a guest account, you must add this to \/etc\/passwd<br \/>\n# otherwise the user &#8220;nobody&#8221; is used<br \/>\n;  guest account = pcguest<\/p>\n<p># this tells Samba to use a separate log file for each machine<br \/>\n# that connects<br \/>\n   log file = \/var\/log\/samba\/log.%m<\/p>\n<p># Put a capping on the size of the log files (in Kb).<br \/>\n   max log size = 50<\/p>\n<p># Use password server option only with security = server<br \/>\n# The argument list may include:<br \/>\n#   password server = My_PDC_Name [My_BDC_Name] [My_Next_BDC_Name]<br \/>\n# or to auto-locate the domain controller\/s<br \/>\n#   password server = *<br \/>\n;   password server = <\/p>\n<p># Use the realm option only with security = ads<br \/>\n# Specifies the Active Directory realm the host is part of<br \/>\n;   realm = MY_REALM<\/p>\n<p># Backend to store user information in. New installations should<br \/>\n# use either tdbsam or ldapsam. smbpasswd is available for backwards<br \/>\n# compatibility. tdbsam requires no further configuration.<br \/>\n;   passdb backend = tdbsam<\/p>\n<p># Using the following line enables you to customise your configuration<br \/>\n# on a per machine basis. The %m gets replaced with the netbios name<br \/>\n# of the machine that is connecting.<br \/>\n# Note: Consider carefully the location in the configuration file of<br \/>\n#       this line.  The included file is read at that point.<br \/>\n;   include = \/usr\/local\/etc\/smb.conf.%m<\/p>\n<p># Most people will find that this option gives better performance.<br \/>\n# See the chapter &#8216;Samba performance issues&#8217; in the Samba HOWTO Collection<br \/>\n# and the manual pages for details.<br \/>\n# You may want to add the following on a Linux system:<br \/>\n;   socket options = SO_RCVBUF=8192 SO_SNDBUF=8192<\/p>\n<p># Configure Samba to use multiple interfaces<br \/>\n# If you have multiple network interfaces then you must list them<br \/>\n# here. See the man page for details.<br \/>\n;   interfaces = 192.168.12.2\/24 192.168.13.2\/24 <\/p>\n<p># Browser Control Options:<br \/>\n# set local master to no if you don&#8217;t want Samba to become a master<br \/>\n# browser on your network. Otherwise the normal election rules apply<br \/>\n;   local master = no<\/p>\n<p># OS Level determines the precedence of this server in master browser<br \/>\n# elections. The default value should be reasonable<br \/>\n;   os level = 33<\/p>\n<p># Domain Master specifies Samba to be the Domain Master Browser. This<br \/>\n# allows Samba to collate browse lists between subnets. Don&#8217;t use this<br \/>\n# if you already have a Windows NT domain controller doing this job<br \/>\n;   domain master = yes <\/p>\n<p># Preferred Master causes Samba to force a local browser election on startup<br \/>\n# and gives it a slightly higher chance of winning the election<br \/>\n;   preferred master = yes<\/p>\n<p># Enable this if you want Samba to be a domain logon server for<br \/>\n# Windows95 workstations.<br \/>\n;   domain logons = yes<\/p>\n<p># if you enable domain logons then you may want a per-machine or<br \/>\n# per user logon script<br \/>\n# run a specific logon batch file per workstation (machine)<br \/>\n;   logon script = %m.bat<br \/>\n# run a specific logon batch file per username<br \/>\n;   logon script = %U.bat<\/p>\n<p># Where to store roving profiles (only for Win95 and WinNT)<br \/>\n#        %L substitutes for this servers netbios name, %U is username<br \/>\n#        You must uncomment the [Profiles] share below<br \/>\n;   logon path = \\\\%L\\Profiles\\%U<\/p>\n<p># Windows Internet Name Serving Support Section:<br \/>\n# WINS Support &#8211; Tells the NMBD component of Samba to enable it&#8217;s WINS Server<br \/>\n;   wins support = yes<\/p>\n<p># WINS Server &#8211; Tells the NMBD components of Samba to be a WINS Client<br \/>\n#\tNote: Samba can be either a WINS Server, or a WINS Client, but NOT both<br \/>\n;   wins server = w.x.y.z<\/p>\n<p># WINS Proxy &#8211; Tells Samba to answer name resolution queries on<br \/>\n# behalf of a non WINS capable client, for this to work there must be<br \/>\n# at least one\tWINS Server on the network. The default is NO.<br \/>\n;   wins proxy = yes<\/p>\n<p># DNS Proxy &#8211; tells Samba whether or not to try to resolve NetBIOS names<br \/>\n# via DNS nslookups. The default is NO.<br \/>\n   dns proxy = no <\/p>\n<p># Charset settings<br \/>\n;   display charset = koi8-r<br \/>\n;   unix charset = koi8-r<br \/>\n;   dos charset = cp866<\/p>\n<p># Use extended attributes to store file modes<br \/>\n;    store dos attributes = yes<br \/>\n;    map hidden = no<br \/>\n;    map system = no<br \/>\n;    map archive = no<\/p>\n<p># Use inherited ACLs for directories<br \/>\n;    nt acl support = yes<br \/>\n;    inherit acls = yes<br \/>\n;    map acl inherit = yes <\/p>\n<p># These scripts are used on a domain controller or stand-alone<br \/>\n# machine to add or delete corresponding unix accounts<br \/>\n;  add user script = \/usr\/sbin\/useradd %u<br \/>\n;  add group script = \/usr\/sbin\/groupadd %g<br \/>\n;  add machine script = \/usr\/sbin\/adduser -n -g machines -c Machine -d \/dev\/null -s \/bin\/false %u<br \/>\n;  delete user script = \/usr\/sbin\/userdel %u<br \/>\n;  delete user from group script = \/usr\/sbin\/deluser %u %g<br \/>\n;  delete group script = \/usr\/sbin\/groupdel %g<\/p>\n<p># This is a DRAFT sample configuration for the ACLs on the ZFS partition.<br \/>\n#<br \/>\n   nt acl support = yes<br \/>\n   inherit acls = no<br \/>\n   map acl inherit = yes<\/p>\n<p>#============================ Share Definitions ==============================<br \/>\n[homes]<br \/>\n   comment = Home Directories<br \/>\n   browseable = no<br \/>\n   writable = yes<br \/>\n   path = \/tank\/Users\/%S<\/p>\n<p># Un-comment the following and create the netlogon directory for Domain Logons<br \/>\n; [netlogon]<br \/>\n;   comment = Network Logon Service<br \/>\n;   path = \/usr\/local\/samba\/lib\/netlogon<br \/>\n;   guest ok = yes<br \/>\n;   writable = no<br \/>\n;   share modes = no<\/p>\n<p># Un-comment the following to provide a specific roving profile share<br \/>\n# the default is to use the user&#8217;s home directory<br \/>\n;[Profiles]<br \/>\n;    path = \/usr\/local\/samba\/profiles<br \/>\n;    browseable = no<br \/>\n;    guest ok = yes<\/p>\n<p># NOTE: If you have a BSD-style print system there is no need to<br \/>\n# specifically define each individual printer<br \/>\n[printers]<br \/>\n   comment = All Printers<br \/>\n   path = \/var\/spool\/samba<br \/>\n   browseable = no<br \/>\n# Set public = yes to allow user &#8216;guest account&#8217; to print<br \/>\n   guest ok = no<br \/>\n   writable = no<br \/>\n   printable = yes<\/p>\n<p># This one is useful for people to share files<br \/>\n;[tmp]<br \/>\n;   comment = Temporary file space<br \/>\n;   path = \/tmp<br \/>\n;   read only = no<br \/>\n;   public = yes<\/p>\n<p># A publicly accessible directory, but read only, except for people in<br \/>\n# the &#8220;staff&#8221; group<br \/>\n;[public]<br \/>\n;   comment = Public Stuff<br \/>\n;   path = \/home\/samba<br \/>\n;   public = yes<br \/>\n;   writable = yes<br \/>\n;   printable = no<br \/>\n;   write list = @staff<\/p>\n<p># Other examples.<br \/>\n#<br \/>\n# A private printer, usable only by fred. Spool data will be placed in fred&#8217;s<br \/>\n# home directory. Note that fred must have write access to the spool directory,<br \/>\n# wherever it is.<br \/>\n;[fredsprn]<br \/>\n;   comment = Fred&#8217;s Printer<br \/>\n;   valid users = fred<br \/>\n;   path = \/homes\/fred<br \/>\n;   printer = freds_printer<br \/>\n;   public = no<br \/>\n;   writable = no<br \/>\n;   printable = yes<\/p>\n<p># A private directory, usable only by fred. Note that fred requires write<br \/>\n# access to the directory.<br \/>\n;[fredsdir]<br \/>\n;   comment = Fred&#8217;s Service<br \/>\n;   path = \/usr\/somewhere\/private<br \/>\n;   valid users = fred<br \/>\n;   public = no<br \/>\n;   writable = yes<br \/>\n;   printable = no<\/p>\n<p># a service which has a different directory for each machine that connects<br \/>\n# this allows you to tailor configurations to incoming machines. You could<br \/>\n# also use the %U option to tailor it by user name.<br \/>\n# The %m gets replaced with the machine name that is connecting.<br \/>\n;[pchome]<br \/>\n;  comment = PC Directories<br \/>\n;  path = \/usr\/pc\/%m<br \/>\n;  public = no<br \/>\n;  writable = yes<\/p>\n<p># A publicly accessible directory, read\/write to all users. Note that all files<br \/>\n# created in the directory by users will be owned by the default user, so<br \/>\n# any user with access can delete any other user&#8217;s files. Obviously this<br \/>\n# directory must be writable by the default user. Another user could of course<br \/>\n# be specified, in which case all files would be owned by that user instead.<br \/>\n;[public]<br \/>\n;   path = \/usr\/somewhere\/else\/public<br \/>\n;   public = yes<br \/>\n;   only guest = yes<br \/>\n;   writable = yes<br \/>\n;   printable = no<\/p>\n<p># The following two entries demonstrate how to share a directory so that two<br \/>\n# users can place files there that will be owned by the specific users. In this<br \/>\n# setup, the directory should be writable by both users and should have the<br \/>\n# sticky bit set on it to prevent abuse. Obviously this could be extended to<br \/>\n# as many users as required.<br \/>\n;[myshare]<br \/>\n;   comment = Mary&#8217;s and Fred&#8217;s stuff<br \/>\n;   path = \/usr\/somewhere\/shared<br \/>\n;   valid users = mary fred<br \/>\n;   public = no<br \/>\n;   writable = yes<br \/>\n;   printable = no<br \/>\n;   create mask = 0765<br \/>\n;<\/p>\n<p># This is a DRAFT sample configuration for the ACLs on the ZFS partition.<br \/>\n#<br \/>\n;   nt acl support = yes<br \/>\n;   inherit acls = no<br \/>\n;   map acl inherit = yes<br \/>\n;<br \/>\n;[zpool]<br \/>\n;    path = \/tank\/zpool<br \/>\n;    unix extensions = no<br \/>\n;    vfs objects = zfsacl<br \/>\n;    nfs4:mode = special<br \/>\n;    nfs4:acedup = merge<br \/>\n;    nfs4:chown = yes<\/p>\n<p>[Public]<br \/>\n  comment = Public (user-wide) directories<br \/>\n  browseable = yes<br \/>\n  read only = no<br \/>\n  path = \/tank\/Users\/Public<br \/>\n  vfs objects = zfsacl<br \/>\n  nfs4:mode = special<br \/>\n  nfs4:acedup = merge<br \/>\n  nfs4:chown = yes<br \/>\n[\/cce_ini]<\/p>\n<div class='wp_likes' id='wp_likes_post-436'><a class='like' href=\"javascript:wp_likes.like(436);\" 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'><b>2<\/b> people like this post.<\/span><\/p>\n<div class='like' ><a href=\"javascript:wp_likes.like(436);\">Like<\/a><\/div>\n<div class='unlike' ><a href=\"javascript:wp_likes.unlike(436);\">Unlike<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This time, I&#8217;m going to to try using FreeBSD&#8217;s support for NFS ACL&#8217;s, using http:\/\/forums.freebsd.org\/showthread.php?t=17627 as a reference: server# zfs set aclmode=passthrough tank\/Users server# zfs set aclinherit=passthrough tank\/Users I created ZFS filesystems within tank\/Users\/Public like so: [cce_bash] server% cat add_pub.sh #!\/bin\/sh u=&#8221;$1&#8243; zfs create tank\/Users\/$u chown nobody:nogroup \/tank\/Users\/$u for d in &#8220;Documents&#8221; &#8220;Music&#8221; &#8220;Videos&#8221; &#8220;Pictures&#8221;; [&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":[10],"tags":[135,121,136,13,3],"class_list":["post-436","post","type-post","status-publish","format-standard","hentry","category-unix-linux","tag-acl","tag-nas","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\/436","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=436"}],"version-history":[{"count":12,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/436\/revisions"}],"predecessor-version":[{"id":456,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/436\/revisions\/456"}],"wp:attachment":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/media?parent=436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/categories?post=436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/tags?post=436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}