Getting OwnCloud External SMB/CIFS Storage to work

Status
Not open for further replies.

svemuri

Cadet
Joined
Feb 8, 2016
Messages
2
I've been digging through sources and logs for a day to figure out why OwnCloud External SMB/CIFS mounts do not work with the latest stable FreeNAS (9.3) and OwnCloud 8.2.2 (I rolled my own instead of plugin). I think I've found the problem and possible solution. Hope this helps someone.

First, OC complains that it can't find smbclient and SMB/CIFS external mount is not available. So, I install samba41-4.1.22 package in the jail. It still complains about not finding smbclient. After much digging, I figured out that lighttpd sets the path to a very minimal path that does NOT include /usr/local/bin, where smbclient is installed. Solution is to set the path variable in the lighttpd startup script (/usr/local/etc/rc.d/lighttpd and add a line at the beginning
export PATH=$PATH:/usr/local/sbin:/usr/local/bin. Now, it finds smbclient.

Now, any share I add goes "red", and log indicates that it is failing to read anything from smbclient. So, I went through the code for hours, debugged with error_log statements in apps/files_external/3rdparty/icewind/smb/src and figured out the problem. proc_open and pipes are being used to communicate with smbclient for stdin/out as well as providing credentials. The command being issued is smbclient --authentication-file=/proc/self/fd/3. Since FreeBSD doesn't have a /proc/self/fd (this is a linux thing), it is a no go. It appears that github for these files was updated just yesterday (what a coincidence) to account for this.

So, I changed all references of /proc/self/fd to /dev/fd, which is available in FreeBSD. Still doesn't work. after much googling, it turns out that by default FreeBSD only provides /dev/fd/0-2 (stdin,out,err). Any additional pipes opened are not there. However, more googling reveals fdescfs does provide what we need. Only problem is, fdescfs is not available in a jail. More googling. Turns out, fdescfs can be mounted in to the jail from main shell ( mount -t fdescfs fdesc /mnt/<path-to-jail>/dev/fd ). Once I did that, things worked as they should. But this mounting command probably needs to be in a start-up script somewhere (I am thinking /etc/rc.freenas in jail_post_start or perhaps in jail_post_start in the jails metadata dir). FreeBSD 10.2 appears to have a setting that allows this, but we are not there yet.

In summary:
1. Install Samba4 in Jail.
2. Make sure the path is exported to your httpd
3. Change all references to /proc/self/fd to /dev/fd in the source code at apps/files_external/3rdparty/icewind/smb/src
4. Mount /dev/fd of the jail from main freenas shell (mount -t fdescfs fdesc /mnt/<path-to-jail>/dev/fd ). Perhaps, add it to a startup script.

FreeBSD 10.2+ and OwnCloud current main branch has fixes for this, with FreeBSD having a setting.

Also, libsmbclient-php is a substitute for having smbclient, but a package is not yet available for FreeBSD and I didn't have a make environment to compile from sources. Perhaps this is a better route.

Hope this helps.

Sarat.
 

m0nkey_

MVP
Joined
Oct 27, 2015
Messages
2,739
Turns out, fdescfs can be mounted in to the jail from main shell ( mount -t fdescfs fdesc /mnt/<path-to-jail>/dev/fd ). Once I did that, things worked as they should. But this mounting command probably needs to be in a start-up script somewhere (I am thinking /etc/rc.freenas in jail_post_start or perhaps in jail_post_start in the jails metadata dir). FreeBSD 10.2 appears to have a setting that allows this, but we are not there yet.
You can try and edit the fstab for the jail to include fdescfs. The fstab can be found under /path/to/jails/.<jailname>.meta/fstab.
 

anodos

Sambassador
iXsystems
Joined
Mar 6, 2014
Messages
9,554
You could probably also do the following:
OPTION 1
(1) Configure your media dataset to have "unix" permissions type
(2) disable the zfsacl VFS object in your share definition by setting the auxiliary parameter "vfs objects = streams_xattr"
(3) Define share permissions using "valid users" and "write list" parameters.
(4) set "oplocks = no" as a share auxiliary parameter

OPTION 2
(1) Use the "force group" auxiliary parameter for your CIFS share.
(2) Set default permissions on your media dataset with the dataset owned by the group set in (1).
(3) Create a group with the same GID as the GID of the group you configured with "force group" in your main config. Then make your owncloud user a member of this group.
(4) set "oplocks = no" as a share auxiliary parameter.
 
Status
Not open for further replies.
Top