Giter VIP home page Giter VIP logo

unfs3's Introduction

UNFS3, a User-Space NFSv3 Server

(C) 2003-2009, Pascal Schmidt [email protected]

UNFS3 is a user-space implementation of the NFSv3 server specification.

UNFS3 supports all NFSv3 procedures with the exception of the READDIRPLUS procedure. It tries to provide as much information to NFS clients as possible, within the limits possible from user-space.

See the unfsd(8) manpage for restrictions imposed on NFS operations (section RESTRICTIONS) and for possible races with local file system activity (section BUGS).

It is not possible to export to netgroups or wildcard hostnames via /etc/exports, all other addressing methods should work. The following options are recognized in the exports file: ro, rw, root_squash, all_squash, no_root_squash, no_all_squash. If other options are present, they are ignored.

UNFS3 can be used to (re-)export part of an AFS network filesystem. Because AFS does not simulate inodes particularly well, configuring the source with --enable-afs is recommended in this scenario.

Cluster extensions compatible to the older ClusterNFS project are supported when the source is configured with --enable-cluster.

Supported systems

unfs3 is developed and tested on Linux, but should also compile and run on other Unix systems. In the past, versions of unfs3 have been successfully tested on NetBSD, FreeBSD, Solaris, AIX, Irix, and Mac OS X. There is also some support for running on Windows, see doc/README.win for details.

Releases are tested by trying to compile them on Linux using both GNU make and FreeBSD make. The basic tests of the Connectathon NFS testsuite are then used to very basic functionality of the server.

If unfs3 doesn't build or work on a Unix system, a problem report is appreciated.

Building from source

You will need gcc, lex (flex), and yacc (bison) to compile UNFS3.

./bootstrap   # (only when building from git)
./configure
make
make install

Please read the manpage for information about command-line options.

man 8 unfsd

If you decide to modify the code yourself, you can run

make dep

to append dependency information to the Makefile, so that make knows which files depend on each other and recompiles all the necessary files on changes.

unfs3's People

Contributors

cendioossman avatar derfian avatar herbrant avatar jwessel avatar kambala-decapitator avatar kraj avatar skoudmar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unfs3's Issues

Tag 0.9.23 planned?

Assuming master is stable, is there a version bump planned? (e.g. 0.9.23)?

win10 client

I tried it with win10 as client.
but unfortunatley it does not connect.
I don't know if there is way to make it running...

Fix for old NFS clients running 32 bit applications.

Some 32 bit programs on old operating systems like 32 bit Solaris have trouble if the 64 bit fileid is a number too big to fit within 32 bits. Today there is a #define to work around that problem if compiled for WIN32 or with AFS support. However, I would prefer to be able to activate a workaround with a command line parameter even if not compiled for WIN32 or with AFS support.

I have also found 32 bit Solaris application fail when the 64 bit cookie contains a number too big to fit in 32 bits. The attached patch allows such old Solaris clients to work fine when unfsd is started with the command line switch "-3"

32_bit_patch.zip

Configure and make on Oracle Solaris 11.4

I have tried compiling on Oracle Solaris 11.4 x86.
./configure failed

./configure
checking for a BSD-compatible install... /usr/bin/ginstall -c
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for ar... ar
checking for flex... no
checking for lex... lex
checking lex output file root... lex.yy
checking lex library... -ll
checking whether yytext is a pointer... no
checking for bison... no
checking for byacc... no
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/xpg4/bin/grep
checking for egrep... /usr/xpg4/bin/grep -E
checking for ANSI C header files... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking for library containing xdr_int... none required
checking for library containing socket... none required
checking for library containing inet_aton... none required
checking for mntent.h... no
checking for stdint.h... yes
checking for sys/mnttab.h... yes
checking for sys/mount.h... yes
checking for sys/vmount.h... no
checking for rpc/svc_soc.h... yes
checking for linux/ext2_fs.h... no
checking for int32... no
checking for uint32... no
checking for int64... no
checking for uint64... no
checking for struct stat.st_gen... no
checking for statvfs... yes
checking for seteuid... yes
checking for setegid... yes
checking for setresuid... no
checking for setresgid... no
checking for vsyslog... yes
checking for lchown... yes
checking for setgroups... yes
./configure: line 4139: syntax error at line 4143: `(' unexpected_

I commented out line 4143 after checking "pkg search rpc" if libtirpc needs to be installed.
Info: https://docs.oracle.com/cd/E37838_01/html/E61058/rpcintro-46812.html

#PKG_CHECK_MODULES(TIRPC, libtirpc)

configure now works, but make now failed with

make
gcc -g -O2 -Wall -W   -D_GNU_SOURCE -I.  -c  afsgettimes.c
gcc -g -O2 -Wall -W   -D_GNU_SOURCE -I.  -c  afssupport.c
gcc -g -O2 -Wall -W   -D_GNU_SOURCE -I.  -c  attr.c
attr.c: In function 'get_free_bad_dir_entry':
attr.c:560:5: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
  560 |     free(bad_dir_cache[best].path);
      |     ^~~~
attr.c:31:1: note: include '<stdlib.h>' or provide a declaration of 'free'
   30 | #include "Config/exports.h"
  +++ |+#include <stdlib.h>
   31 | 
attr.c:560:5: warning: incompatible implicit declaration of built-in function 'free' [-Wbuiltin-declaration-mismatch]
  560 |     free(bad_dir_cache[best].path);
      |     ^~~~
attr.c:560:5: note: include '<stdlib.h>' or provide a declaration of 'free'
attr.c: In function 'find_bad_dir_entry':
attr.c:577:13: warning: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration]
  577 |         if (strcmp(path, bad_dir_cache[i].path) == 0) {
      |             ^~~~~~
attr.c:31:1: note: include '<string.h>' or provide a declaration of 'strcmp'
   30 | #include "Config/exports.h"
  +++ |+#include <string.h>
   31 | 
attr.c:585:23: warning: implicit declaration of function 'strdup' [-Wimplicit-function-declaration]
  585 |     new_entry->path = strdup(path);
      |                       ^~~~~~
attr.c:585:23: warning: incompatible implicit declaration of built-in function 'strdup' [-Wbuiltin-declaration-mismatch]
gcc -g -O2 -Wall -W   -D_GNU_SOURCE -I.  -c  daemon.c
daemon.c: In function 'get_port':
daemon.c:143:45: error: 'struct sockaddr_in' has no member named 'sin6_port'; did you mean 'sin_port'?
  143 |     return (svc_getcaller(rqstp->rq_xprt))->sin6_port;
      |                                             ^~~~~~~~~
      |                                             sin_port
daemon.c:144:1: warning: control reaches end of non-void function [-Wreturn-type]
  144 | }
      | ^
*** Error code 1
make: Fatal error: Command failed for target `daemon.o'_

unfs3.tar.gz

fh.c:501: fh_decode: Assertion `fh->data.data_len == (21 + obj.len)' failed

Linux, Debian 8.11, 64-bit (x86_64), assertion fails when clients try to do something

(gdb) run
Starting program: /usr/local/sbin/unfsd-2019-01-18 -d -e /usr/local/etc/unfsd-exports -l 10.1.1.207 -u -p -n 12049 -m 12049
UNFS3 unfsd 0.9.23 (C) 2009, Pascal Schmidt <[email protected]>
/m/nfs/dvb: ip 10.1.1.0 mask 255.255.255.0 options 4
/m/nfs/dvb0: ip 10.1.1.0 mask 255.255.255.0 options 4
/m/nfs/dvb1: ip 10.1.1.0 mask 255.255.255.0 options 4
/m/nfs/dvb3: ip 10.1.1.0 mask 255.255.255.0 options 4
/m/nfs/dvb4: ip 10.1.1.0 mask 255.255.255.0 options 4
/m/nfs/dvb6: ip 10.1.1.0 mask 255.255.255.0 options 4
/m/nfs/dvb8: ip 10.1.1.0 mask 255.255.255.0 options 4
unfsd-2019-01-18: fh.c:501: fh_decode: Assertion `fh->data.data_len == (21 + obj.len)' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff7a66067 in __GI_raise (sig=sig@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56      ../nptl/sysdeps/unix/sysv/linux/raise.c: Tiedostoa tai hakemistoa ei ole.
(gdb) up
#1  0x00007ffff7a67448 in __GI_abort () at abort.c:89
89      abort.c: Tiedostoa tai hakemistoa ei ole.
(gdb) 
#2  0x00007ffff7a5f266 in __assert_fail_base (
    fmt=0x7ffff7b97f18 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x412b58 "fh->data.data_len == (21 + obj.len)", 
    file=file@entry=0x412af7 "fh.c", line=line@entry=501, 
    function=function@entry=0x412b86 <__PRETTY_FUNCTION__.7255> "fh_decode")
    at assert.c:92
92      assert.c: Tiedostoa tai hakemistoa ei ole.
(gdb) 
#3  0x00007ffff7a5f312 in __GI___assert_fail (
    assertion=assertion@entry=0x412b58 "fh->data.data_len == (21 + obj.len)", 
    file=file@entry=0x412af7 "fh.c", line=line@entry=501, 
    function=function@entry=0x412b86 <__PRETTY_FUNCTION__.7255> "fh_decode")
    at assert.c:101
101     in assert.c
(gdb) 
#4  0x0000000000405d20 in fh_decode (fh=fh@entry=0x7fffffffe260) at fh.c:501
501         assert(fh->data.data_len == (FH_MINLEN + obj.len));
(gdb) print *fh
$3 = {data = {data_len = 36, data_val = 0xae7cd0 "0\b"}}
(gdb) print obj
$4 = {dev = 2096, ino = 8589934592, gen = 0, pwhash = 2, len = 0 '\000', 
  inos = "\000\000\000\000\000\000\000|\000\000\000\000\000\000\000\020\343\377\377\377\177\000\000`\342\377\377\377\177\000\000 f\335\367\377\177\000\000\320|\256"}

Unexpected Stale NFS file handle errors on NetBSD client

docker-netbsd uses unfs3 0.9.22 built for docker-alpine 3.16.
When I tried this docker-netbsd image on ubuntu 22.04.2 LTS, several build operations triggers NFS errors.
This also happens with unfs3 0.10.0 on a ubuntu 22.04.2 server and a NetBSD client on real machines.
On the other hand, these errors don't occur if a file system on the ubuntu server is converted from ext4 to btrfs.

The following procedure can reproduce this problem

  • setup docker on ubuntu 22.04.2 as https://docs.docker.com/engine/install/ubuntu/
  • pull docker-netbsd
    sudo docker pull madworx/netbsd:latest
  • prepare ssh id_rsa files
  • start docker-netbsd in background:
    sudo docker run --rm -d --device=/dev/kvm -e "SSH_PUBKEY=$(cat ~/.ssh/id_rsa.pub)" -p 2222:22 --name netbsd madworx/netbsd:latest
  • (wait until NetBSD on QEMU starts on docker)
  • login to NetBSD in docker
    ssh -p 2222 root@localhost
  • cd /tmp; mkdir a; rmdir a; touch a; rm a; rmdir a
    unfs3-testcase

I've also created updated docker-netbsd images that use the latest ufs3 0.10.0 on alpine linux but this can still be reproducible.

Unexpected results when reading past the end of a directory

This issue was initially reported on SourceForge
Link: https://sourceforge.net/p/unfs3/bugs/6/
Reporter: TheZeusJuice
Created: 2015-01-27


If a client interleaves readdir() and remove() calls on a mounted NFS share, upon reaching past the end of the directory entries readdir() returns the first directory entry over again, instead of NULL or whatever the signal is supposed to be. This can cause certain programs (in my case, transmission-daemon when removing&trashing a downloaded torrent) to go into an infinite-loop.

More information here (especially comments 3 and laters): https://trac.transmissionbt.com/ticket/5890

I've fixed it in my build by commenting out the following section of readdir.c:

/* ignore cookie if unexpected so we restart from the beginning */
cookie = 0;

However, I don't know if that's an appropriate fix or if there are better ways to fix this problem (because I don't know much C, and even less about the NFS protocol). Just thought you should know about this issue. And also I would like to take this opportunity to thank you for making this awesome and extremely useful program.

Migration to GitHub is not complete

Dear @unfs3 team, @samhed, @astrand, @derfian, @ossman, @CendioOssman,

Can you add a "move" box like https://sourceforge.net/projects/handbrake for example.

To disable/delete tabs, go here: https://sourceforge.net/projects/unfs3/
To add a new tab, go here: https://sourceforge.net/projects/unfs3/
To change informations, go here: https://sourceforge.net/p/unfs3/admin/overview
To export, go here: https://sourceforge.net/p/unfs3/admin/export

The new place can be added in:

Thanks in advance.

Note: Do same for other SF projects ;)

Project should build with sunrpc

The tirpc library is currently Linux-only. This project should really also build with standard sunrpc for actual portability.

We need this e.g. for FreeBSD where tirpc currently does not build due to conflicts with the system's sunrpc implementation.

Dependencies and error with make

On Ubuntu, unfs3 has dependencies on autoconf flex gcc bison make.
Consider adding them.

Occurs without sudo:

make install
/usr/bin/install -c -d /usr/local/sbin
/usr/bin/install -c -d /usr/local/share/man/man7
/usr/bin/install: cannot change permissions of ‘/usr/local/share/man/man7’: No such file or directory
make: *** [Makefile:42: install] Error 1

Given that this is userspace-nfs, you might consider adding a hint whether sudo is required or not and whether installation with sudo is safe and secure or breaks stuff.

What local and remote file system can be exported?

Hello,
I know that NFS from linux kernel can only export local file systems, while I read that unfsd may also export AFS file systems. Does this means that many remote file system are exportable? Does unfsd exports mounted cifs file systems?

Thank you,
Giuseppe

IPv6

Is IPv6 supported? I tried several variants to put in a subnet in /etc/exports, but each time I get syntax error in '/etc/exports', exporting nothing.

IPv4 addresses are working fine.

undefined reference to `yywrap'

Hi,

I want to use cross compiler, arm-linux-gnueabihf-gcc, to build unfs3.
However I get the error as bellow.
unfs3/Config/lex.yy.c:980: undefined reference to `yywrap'

Is anyone here willing to provide some way to help me solve this problem?

PKG_CHECK_MODULES error

I exec ./configure cmd using ubuntu22.04 and got the following error:
./configure: line 4525: syntax error near unexpected token TIRPC,' ./configure: line 4525: PKG_CHECK_MODULES(TIRPC, libtirpc)'

READ procedure does not end with count==0

This issue was initially reported on SourceForge
Link: https://sourceforge.net/p/unfs3/bugs/9/
Reporter: Yaakov Selkowitz
Created: 2016-11-22


I have been dealing with the following issue while using gvfs-nfs with a unfs3 server:

In 0.9.22, unfsd was returning 4 bytes of garbage at the conclusion of an async read, causing the operation to never end. With SVN trunk, it is now returning INVALID instead of count==0, causing gvfs to think the operation has failed ("bad address") even though the file is actually transferred.

The libnfs developer believes this is a bug in unfsd, quoting from RFC1813:

offset
The position within the file at which the read is to
begin. An offset of 0 means to read data starting at
the beginning of the file. If offset is greater than or
equal to the size of the file, the status, NFS3_OK, is
returned with count set to 0 and eof set to TRUE,
subject to access permissions checking.

RW Mount from Windows allows to read and modify but does not write.

Hi,

So we've got unfs3 latest installed on a tiny root-only (Libreelec) server.
It's a tight (almost) read-only distro so I cannot create a different user.

An RW mount using "all-squash" and registry trick to change user ID to anon 65534 allows me to read and browse and execute files. also deleting and modifying of a single file, BUT creating new file and deleting a directory end with error 0x800703EE

It does write from other linux machine when mounting root <-> root

What is wrong, where is the cause ? Any advices ?
I tried all combinations with all-squash, non-squash, etc... as well as using user ID=0 (root) and permissions are 777 everywhere.

Currently here is my export:
/var/media 10.9.8.0/24(rw,async,all_squash,insecure,anonuid=65534,anongid=65534,no_subtree_check)

mount.nfs: mount system call failed for /mnt

Hi there!

I'm trying UNFS3 on Kubuntu 24.04. It builds, starts but no way to mount the share.

My exports file:

/srv    192.168.1.0/24(rw,no_root_squash)

My server command:

# /opt/unfs3/prefix/sbin/unfsd -d -e /opt/unfs3/prefix/exports

Client(same machine):

# mount -t nfs -o nfsvers=3 192.168.1.5:/srv /mnt
mount.nfs: mount system call failed for /mnt

Please help. Maybe I'm missing some options.

distfile doesn't ship m4 directory

The unfs3-10.0.0.tar.gz tarball doesn't ship the m4 directory. Thus we are unable to patch the configure script in the FreeBSD port. Please re-roll the distfile with the m4 directory.

I also noticed that you stopped shipping the pre-generated parser in 10.0.0. While not needed for our purposes, you might be interested in shipping it for consistency.

read function out-of-order

The offset argument of the read function is not incremented in order, and occasionally it is out of order
I want the offset to be in increasing order. Is there any good way

getsockopt: Function not implemented

I try to run unfsd on a VMware ESXi server. When starting unfsd on ESXi 7.0.3, I get the error:

getsockopt: Function not implemented

I unterstand that libc on ESXi does not include getsockopt and setsockopt, which is used by daemon.c.
My questions are:

  • Is it possible to migrate unfsd, so it will run on ESXi?
  • Is there an alternative to getsockopt()?
  • Will static linking help?

Thanks for your help!

lutimes for symlink file failed with "Stale file handle"

This issue was initially reported on SourceForge
Link: https://sourceforge.net/p/unfs3/bugs/12/
Reporter: Rui Wang
Created: 2018-06-13


I am not sure if this is a bug. I found if I try to modify the timestamp of a symlink file pointing to a none existence file with lutimes(), the program will get an error: Stale file handle. But if the symlink file points to an exist file, the operation will success. I found this in yocto nfsroot. And I write a simple program to reproduce the issue.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/time.h>

int main()
{
        int rc; 
        struct timeval stamps[2] = { 
                {.tv_sec = 0, .tv_usec = 0}, 
                {.tv_sec = 0, .tv_usec = 0}, 
        };

        printf("create symlink file test -> target\n");
        rc = symlink("target", "test");
        if (rc)
                perror("symlink");

        printf("**** target file is not exist ****\n");
        rc = lutimes("test", stamps);
        if (rc)
                perror("lutimes test");
        else
                printf("lutimes test success\n");

        system("touch target");

        printf("**** target file is exist ****\n");
        rc = lutimes("test", stamps);
        if (rc)
                perror("lutimes test");
        else
                printf("lutimes test success\n");

        system("rm test target");
        return 0;
}

Does not scale past 50 clients connecting

This issue was initially reported on SourceForge
Link: https://sourceforge.net/p/unfs3/bugs/2/
Reporter: Ned Wolpert
Created: 2013-10-07


The 0.9.22 version seems to fail once >50 hosts attach. (64 bit centos 5.7 clients and servers) Adding the latest 64-bit patch does not change this behavior. The behavior with active connections is just to slow down more and more. Strace doesn't really show what the server is doing. (We use 400+ servers mounting a standard directory just fine via NFS on Centos 5.7)

reference of an uninitialized automatic strucuture variable

In nfsproc3_create_3_svc() in nfs.c, new_attr is initialized only in argp->how.mode != EXCLUSIVE case but also rerenfeced inargp->how.mode == EXCLUSIVE case:

unfs3/nfs.c

Lines 513 to 525 in 2b3d174

if (argp->how.mode != EXCLUSIVE) {
new_attr = argp->how.createhow3_u.obj_attributes;
result.status = join(result.status, atomic_attr(new_attr));
}
/* Try to open the file */
if (result.status == NFS3_OK) {
if (argp->how.mode != EXCLUSIVE) {
fd = backend_open_create(obj, flags, create_mode(new_attr));
} else {
fd = backend_open_create(obj, flags, create_mode(new_attr));
}
}

(not sure what the second if (argp->how.mode != EXCLUSIVE) clause intended though)

create_mode() just checks new.mode.set_mode3_u.mode

unfs3/attr.c

Lines 483 to 490 in 2b3d174

mode_t create_mode(sattr3 new)
{
if (new.mode.set_it == TRUE)
return new.mode.set_mode3_u.mode;
else
return S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP |
S_IROTH | S_IXOTH;
}

so it would be enough to explicitly initialize new_attr?

diff --git a/nfs.c b/nfs.c
index 3e92f87..cc4cb4e 100644
--- a/nfs.c
+++ b/nfs.c
@@ -495,7 +495,7 @@ CREATE3res *nfsproc3_create_3_svc(CREATE3args * argp, struct svc_req * rqstp)
     static CREATE3res result;
     char *path;
     char obj[NFS_MAXPATHLEN];
-    sattr3 new_attr;
+    sattr3 new_attr = { 0 };
     int fd = -1, res = -1;
     backend_statstruct buf;
     uint32 gen;

fuse-nfs issue

nfsproc3_read_3_svc function ise out-of -order for file offset

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.