Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

share/unshare SMB support #498

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/libshare/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ lib_LTLIBRARIES = libshare.la

libshare_la_SOURCES = \
$(top_srcdir)/lib/libshare/libshare.c \
$(top_srcdir)/lib/libshare/nfs.c \
$(top_srcdir)/lib/libshare/libshare_impl.h \
$(top_srcdir)/lib/libshare/nfs.h
$(top_srcdir)/lib/libshare/nfs.c \
$(top_srcdir)/lib/libshare/nfs.h \
$(top_srcdir)/lib/libshare/smb.c \
$(top_srcdir)/lib/libshare/smb.h

libshare_la_LDFLAGS = -version-info 1:0:0
19 changes: 16 additions & 3 deletions lib/libshare/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ am__base_list = \
am__installdirs = "$(DESTDIR)$(libdir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
libshare_la_LIBADD =
am_libshare_la_OBJECTS = libshare.lo nfs.lo
am_libshare_la_OBJECTS = libshare.lo nfs.lo smb.lo
libshare_la_OBJECTS = $(am_libshare_la_OBJECTS)
AM_V_lt = $(am__v_lt_$(V))
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
Expand Down Expand Up @@ -340,11 +340,14 @@ AM_CFLAGS = -Wall -Wstrict-prototypes -fno-strict-aliasing \
lib_LTLIBRARIES = libshare.la
libshare_la_SOURCES = \
$(top_srcdir)/lib/libshare/libshare.c \
$(top_srcdir)/lib/libshare/nfs.c \
$(top_srcdir)/lib/libshare/libshare_impl.h \
$(top_srcdir)/lib/libshare/nfs.h
$(top_srcdir)/lib/libshare/nfs.c \
$(top_srcdir)/lib/libshare/nfs.h \
$(top_srcdir)/lib/libshare/smb.c \
$(top_srcdir)/lib/libshare/smb.h

libshare_la_LDFLAGS = -version-info 1:0:0

all: all-am

.SUFFIXES:
Expand Down Expand Up @@ -421,6 +424,7 @@ distclean-compile:

@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libshare.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfs.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/smb.Plo@am__quote@

.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
Expand Down Expand Up @@ -462,6 +466,15 @@ nfs.lo: $(top_srcdir)/lib/libshare/nfs.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nfs.lo `test -f '$(top_srcdir)/lib/libshare/nfs.c' || echo '$(srcdir)/'`$(top_srcdir)/lib/libshare/nfs.c

smb.lo: $(top_srcdir)/lib/libshare/smb.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT smb.lo -MD -MP -MF $(DEPDIR)/smb.Tpo -c -o smb.lo `test -f '$(top_srcdir)/lib/libshare/smb.c' || echo '$(srcdir)/'`$(top_srcdir)/lib/libshare/smb.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/smb.Tpo $(DEPDIR)/smb.Plo
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/lib/libshare/smb.c' object='smb.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o smb.lo `test -f '$(top_srcdir)/lib/libshare/smb.c' || echo '$(srcdir)/'`$(top_srcdir)/lib/libshare/smb.c


mostlyclean-libtool:
-rm -f *.lo

Expand Down
42 changes: 42 additions & 0 deletions lib/libshare/README_smb.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
This is basic information about the 'sharesmb' option in ZFS
On Linux by Turbo Fredriksson <[email protected]>.

REQUIRENMENTS
============================================================
1. Samba (doh! :)
* I'm using version 3.3.3, but any 3.x should
probably work. Please update the tracker with
info..

2. Samba will need to listen to 'localhost' (127.0.0.1),
because that is hardcoded into the zfs module/libraries.

3. Some configuration settings in samba:

usershare max shares = 100
usershare owner only = False

First one is not strictly necessary if you don't have more than
100 volumes you'd like to share.

Second one is if you want to allow non-root users to share
volumes they do NOT own. For a non-user to be able to share
a volume, he/she will have to have write access to the /dev/zfs
device node.

4. A ZFS filesystem or more to export.


TESTING
============================================================
Once configuration in samba have been done, test that this
works with the following commands (in this case, my ZFS
filesystem is called 'share/Test1'):

net -U root -S 127.0.0.1 usershare add Test1 /share/Test1 "Comment: /share/Test1" "Everyone:F"
net usershare list | grep -i test
net -U root -S 127.0.0.1 usershare delete Test1

The first command will create a user share that gives
everyone full access. To limit the access below that,
use normal UNIX commands (chmod, chown etc).
11 changes: 11 additions & 0 deletions lib/libshare/libshare.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <libshare.h>
#include "libshare_impl.h"
#include "nfs.h"
#include "smb.h"

static sa_share_impl_t find_share(sa_handle_impl_t handle,
const char *sharepath);
Expand All @@ -55,6 +56,15 @@ static int update_zfs_shares(sa_handle_impl_t impl_handle, const char *proto);
static int fstypes_count;
static sa_fstype_t *fstypes;

int
file_is_executable(char *file_name)
{
if ((access(file_name, X_OK)) == 0)
/* File found */
return SA_OK;
return SA_NO_SUCH_PATH;
}

sa_fstype_t *
register_fstype(const char *name, const sa_share_ops_t *ops)
{
Expand Down Expand Up @@ -103,6 +113,7 @@ __attribute__((constructor)) static void
libshare_init(void)
{
libshare_nfs_init();
libshare_smb_init();

/*
* This bit causes /etc/dfs/sharetab to be updated before libzfs gets a
Expand Down
1 change: 1 addition & 0 deletions lib/libshare/libshare_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ typedef struct sa_handle_impl {
} *sa_handle_impl_t;

sa_fstype_t *register_fstype(const char *name, const sa_share_ops_t *ops);
int file_is_executable(char *);
Loading