unfsd(8)
π unfsd(8) β NFS server process π
okay so bestie, welcome to unfsd, aka the NFS server process, and honestly this one is kind of a big deal π. It lives at /usr/sbin/unfsd and it's the whole reason your clients can reach into your filesystem and grab stuff. Let's get into it β¨
πΈ SYNOPSIS πΈ
/usr/sbin/unfsd [options]
π DESCRIPTION π
So like, the unfsd program implements the MOUNT and NFS version 3 protocols. It sits there listening for client requests, does the actual work on the server's local filesystem, and then hands the results right back to the clients. main character energy fr fr π
At startup, unfsd reads the exports file β /etc/exports by default β to figure out which directories are available to clients and which options are in effect (peep the EXPORTS FILE section below for the syntax and the possible options π).
Normally, unfsd should be run as the root user. When it is, it switches its effective user and group id to the numbers listed in incoming NFS requests. That means filesystem operations get performed as if they were done by a local user with the same ids β cute, right? If the incoming request is for user or group id 0 (meaning root), unfsd will switch to the user and group id of the nobody user before doing any filesystem operations (this is what we call root squashing π). If the nobody user doesn't exist on the system, a user and group id of 65534 gets used instead. You can tweak this behavior with the no_root_squash and all_squash options in the exports file, plus the anonuid and anongid options on a per-share basis β¨
If unfsd is running as a normal unprivileged user, there's no switching of the effective user and group id at all. Instead, every filesystem operation is performed with the id of the user running unfsd. no cap π«Ά
π¦ RESTRICTIONS π¦
Some NFS clients may attempt operations that unfsd simply cannot fully support. Not her fault, she's doing her best π
π Object Creation
When creating filesystem objects, it is only possible to specify the initial mode for the object. The initial user and group ownership, object size, and timestamps cannot be specified and will just be set to default values. yeah. that's the deal π
π File Locking
The network lock manager (NLM) protocol is not supported. Which means clients may have to mount with special mount options, disabling locking on the mounted NFS volume (nolock for Linux clients). lowkey important, don't skip this one π
β¨ OPTIONS β¨
-hβ Display a short option summary. the little snack version of the manual π-e <file>β Use the given file as the exports file, instead of using/etc/exports. Note that the file needs to be specified using an absolute path β no shortcuts bestie, absolute or nothing π-i <file>β Use the given file as pid file. When the daemon starts up, it writes its pid (process id) to the given file. Upon exit, the daemon removes the file. Failure to create or remove the pid file is not considered fatal and is only reported to syslog. so like, she tries, but it's not that deep π«Ά-uβ Use an unprivileged port for NFS and MOUNT service. Normallyunfsduses port number2049, which is the standard port for NFS. When this option is in effect, arbitrary ports chosen by the RPC library will be used. You may need this one when runningunfsdfrom a normal user account β¨-n <port>β Use the specified port for the NFS service.-m <port>β Use the specified port for the MOUNT service. The default is to use port number2049, same as for the NFS service. You can use the same port for both services if you want β sharing is caring π-tβ TCP only operation. By default,unfsdserves clients using either UDP or TCP as the communications protocol. When this option is present, only TCP connections are serviced.-pβ Do not register with portmap/rpcbind. This prevents other hosts from finding out the port numbers used for the MOUNT and NFS services by querying the portmap or rpcbind daemon. Clients will need to manually specify the port numbers to use (on Linux clients, use themountportandportmount options). stealth mode activated π-cβ Enable cluster extensions. This feature is only available whenunfsdwas compiled with cluster support. When enabled, so-called tagged files are handled differently from normal files, making it possible to serve different file contents to different clients for the same filename. Seetags(7)for a description of tagged files. Heads up though: this option causes a performance hit π-C <path>β Limit the use of cluster extensions to a list of colon-separated directories. When this option is present, the performance hit caused by clustering extensions only applies to the listed directories and their subdirectories. smart girl behavior, limiting the damage π-sβ Single user mode; activate basic uid translation. This option is useful when the server and client are using different user and group ids. All requests from the client will be served from the user id that startedunfsd, and no user id switching will take place (even ifunfsdwas started by root). Ownership is reported as follows: files belonging to the user id runningunfsdwill look as if they're owned by the client's user. Other files will look as if they're owned by root. The same principle applies to group ownership π-bβ Enable brute force file searching. Normally, when you rename a file across several directories on an NFS volume, the filehandle for that file becomes stale. When this option is enabled,unfsdwill attempt a recursive search on the relevant server filesystem to find the file referenced by the filehandle. Big warning though: this can have a huge performance impact, because it will also happen for files that were really deleted (by another NFS client) instead of moved β and those can't be found π-l <addr>β Bind to interface with specified address. The default is to bind to all local interfaces.-dβ Debug mode. When this option is present,unfsdwill not fork into the background at startup, and all messages that would normally go to the system log go tostdoutinstead. front-row seat to the drama π-rβ Report unreadable executables as readable. This applies both to returned attributes and ACCESS requests. Please note that READ requests for unreadable executables are always allowed ifunfsdis running as root, regardless of this option. iykyk π-Tβ Test exports file and exit. When this option is given,unfsdtries to parse the exports file and exits with status0if that's successful. If there's a syntax error in the exports file, a message is printed on standard error andunfsdexits with status1. vibe check for your config β¨
π SIGNALS π
SIGTERMandSIGINTβ will causeunfsdto unregister itself from the portmapper and exit. bye bestie πSIGHUPβ will causeunfsdto re-read its configuration data. Currently, this means the program queries the passwd database to find out the user and group id of usernobody.unfsdwill also attempt to reload the exports file. If the exports file contains errors,unfsdsends a warning message to the system log and nothing is exported until the situation is corrected and anotherSIGHUPis sent. so like, fix it and poke her again π«ΆSIGUSR1β will causeunfsdto output statistics about its filehandle and file descriptor cache to the system log. For the filehandle cache, it outputs the number of filehandles in the cache, the total number of cache accesses, and the number of hits and misses. For the file descriptor cache, it outputs the number of currently held open READ and WRITE file descriptors. numbers girlies rise π
π EXPORTS FILE π
The exports file β /etc/exports by default β is basically the VIP list that decides which directories on the server NFS clients are allowed to access. Hereβs an example, bestie:
# sample NFS exports file
/home trusted(rw,no_root_squash) (ro)
"/with spaces" weirdo
/usr 1.2.3.4(rw) 192.168.2.0/24(ro,all_squash)
/home/foo bar(rw) 10.0.0.0/255.0.0.0(root_squash)
/home/joe joes_pc(anonuid=1100,anongid=1100,rw,all_squash)
Comments start with a # character and cause the rest of the line to be ignored. Extremely long exports can be split across multiple lines by escaping the intermediate newlines with a backslash character.
Each line starts with a directory that is to be exported. If the directory name contains whitespace, it must be enclosed in double quotes. To the right of the directory name, a list of client specifications can be given. If this list is missing, the directory is exported to everyone, using default options (ro and root_squash).
If the directory name contains symbolic links, they are expanded. This means that you have to force unfsd to reload the exports file if the symlinks happen to change.
Clients can be specified using either a hostname, an IP address, or an IP network. Networks can be given by specifying the number of leading 1 bits in the netmask or by giving the full netmask. If the hostname is empty, the directory is exported to everyone.
Options can follow a client specification and have to be enclosed in parenthesis, with the opening paren directly following the client name or address. If no options are given, ro and root_squash are enabled by default. The following options are supported by unfsd:
root_squashβ turns on root squashing, mapping all NFS requests done with a user id of0to the user id of thenobodyuser. This one is enabled by default, no cap.no_root_squashβ disables root squashing. When this is present, NFS requests done with a user id of0will be done as the root user of the server, effectively disabling all permissions checks. π³all_squashβ squashes all users. When this is present, all NFS requests will be done as thenobodyuser of the server.no_all_squashβ does not squash all users. This option is enabled by default.rwβ allows read and write access on the exported directory. When this is present, clients are allowed to modify files and directories on the server.roβ allows only read access on the exported directory. When this is present, clients are not allowed to modify files and directories on the server. This option is enabled by default.anonuid/anongidβ sets the uid and gid for anonymous mounts for this share. By default the uid fornobodywill be used, but using these options you can change this on a per-share basis.secureβ allows only mount requests coming from a source port below1024. Using these ports requires super-user privileges on many operating systems. This option is enabled by default.insecureβ allows mount requests coming from any source port.removableβ considers this directory to be on a removable medium. When this option is present,unfsdwill not keep files open across multiple read or write requests. This allows unmounting of the underlying filesystem on the server at any time. Also,unfsdwill not require that the exported path exists at startup or mount time. If the path does not exist, an empty directory will be presented to the client. This is useful for exporting mount points handled byautofs.fixedβ considers this directory to be on a fixed medium. This option is enabled by default and allowsunfsdto keep files open between multiple read or write requests.password=<password>β to be able to mount this export, the specified password is required. The password needs be given in the mount request, as in"mount yourhost:@password:gazonk/tmp /mnt". One time passwords are also supported. When using passwords, the file handles will include a hash of the password. This means that if you change the password, all clients will need to remount this export. See the file"doc/passwords.txt"in the source for more information.
If options not present on this list are encountered by unfsd, they are silently ignored.
π BUGS π
There are a few possible race conditions with other processes on the server. They can happen if unfsd is performing an operation on a filesystem object while another process is simultaneously first (a) removing the object and then (b) creating a new object of the same name. If this happens, unfsd will attempt to perform the operation on the wrong, new object. The time window in which this can happen is small.
When a client does a CREATE EXCLUSIVE procedure call, unfsd stores the verifier data in the mtime and atime attributes of the created file. Malicious processes on the server could manipulate those attributes, breaking the semantics of the exclusive create operation. A process attempting to do so would need to be able to see the NFS network traffic.
unfsd always uses the "nohide" semantics, which means that clients will see all file systems mounted below the exported path. However, some NFS clients do not cope well with this situation as, for instance, it is then possible for two files in the one apparent filesystem to have the same inode number. To avoid this, make sure that the client mounts each exported file system.
Due to the way unfsd operates, it needs execute (lookup) and read permission on all directories from the root directory all the way up to exported directories. For example, if /usr/share is exported, unfsd is going to need permission for /, /usr, and /usr/share. Since root squashing can be in effect, unfsd may run as the nobody user, which normally means having to grant execute (lookup) and read permission for everybody on the server. In the above example, unfsd also needs permission to access /usr/share/.., which can be different from /usr for some special setups (for example when using bind mounts under Linux).
π FILES π
/etc/exportsβ the default exports file.
π AUTHOR π
Pascal Schmidt
π SEE ALSO π
Later, bestie β this unfsd(8) page is dated 05 Jan 2008 ππβ¨
π¦ where this page comes from
- alpine 3.22: unfs3-doc 0.10.0-r2 Β· BSD-3-Clause
- alpine 3.23: unfs3-doc 0.10.0-r2 Β· BSD-3-Clause
- alpine 3.24: unfs3-doc 0.10.0-r2 Β· BSD-3-Clause
- (C) 2008, Pascal Schmidt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms