1.\" $NetBSD: mount_umap.8,v 1.21 2019/08/20 21:07:21 wiz Exp $ 2.\" 3.\" Copyright (c) 1992, 1993, 1994 4.\" The Regents of the University of California. All rights reserved. 5.\" All rights reserved. 6.\" 7.\" This code is derived from software donated to Berkeley by 8.\" Jan-Simon Pendry and from John Heidemann of the UCLA Ficus project. 9.\" 10.\" Redistribution and use in source and binary forms, with or without 11.\" modification, are permitted provided that the following conditions 12.\" are met: 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in the 17.\" documentation and/or other materials provided with the distribution. 18.\" 3. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)mount_umap.8 8.4 (Berkeley) 5/1/95 35.\" 36.Dd March 6, 2001 37.Dt MOUNT_UMAP 8 38.Os 39.Sh NAME 40.Nm mount_umap 41.Nd user and group ID remapping file system layer 42.Sh SYNOPSIS 43.Nm 44.Op Fl i Ar fsid 45.Op Fl o Ar options 46.Fl g Ar gid-mapfile 47.Fl u Ar uid-mapfile 48.Ar target 49.Ar mount-point 50.Sh DESCRIPTION 51The 52.Nm 53command is used to mount a sub-tree of an existing file system 54that uses a different set of uids and gids than the local system. 55Such a file system could be mounted from a remote site via NFS, 56a local file system on removable media brought from some foreign 57location that uses a different user/group database, or could be 58a local file system for another operating system which does not 59support Unix-style user/group IDs, or which uses a different 60numbering scheme. 61.Pp 62Both 63.Ar target 64and 65.Ar mount-point 66are converted to absolute paths before use. 67.Pp 68The options are as follows: 69.Bl -tag -width indent 70.It Fl g Ar gid-mapfile 71Use the group ID mapping specified in 72.Ar gid-mapfile . 73This flag is required. 74.It Fl i Ar fsid 75Use the specified 76.Ar fsid 77for the file system ID, rather than choosing one at random. 78This is useful if the file system is to be exported. 79.It Fl o 80Options are specified with a 81.Fl o 82flag followed by a comma separated string of options. 83See the 84.Xr mount 8 85man page for possible options and their meanings. 86.It Fl u Ar uid-mapfile 87Use the user ID mapping specified in 88.Ar uid-mapfile . 89This flag is required. 90.El 91.Pp 92The 93.Nm 94command uses a set of files provided by the user to make correspondences 95between uids and gids in the sub-tree's original environment and 96some other set of ids in the local environment. 97For instance, user smith might have uid 1000 in the original environment, 98while having uid 2000 in the local environment. 99The 100.Nm 101command allows the subtree from smith's original environment to be 102mapped in such a way that all files with owning uid 1000 look like 103they are actually owned by uid 2000. 104.Pp 105.Em target 106should be the current location of the sub-tree in the 107local system's name space. 108.Em mount-point 109should be a directory 110where the mapped subtree is to be placed. 111.Em uid-mapfile 112and 113.Em gid-mapfile 114describe the mappings to be made between identifiers. 115.Pp 116The format of the user and group ID mapping files is very simple. 117The first line of the file is the total number of mappings present 118in the file. 119The remaining lines each consist of two numbers: the 120ID in the mapped subtree and the ID in the original subtree. 121.Pp 122For example, to map uid 1000 in the original subtree to uid 2000 123in the mapped subtree: 124.Bd -unfilled -offset indent 1251 1262000 1000 127.Ed 128.Pp 129For user IDs in the original subtree for which no mapping exists, 130the user ID will be mapped to the user 131.Dq nobody . 132For group IDs in the original subtree for which no mapping exists, 133the group ID will be mapped to the group 134.Dq nobody . 135.Pp 136There is a limit of 64 user ID mappings and 16 group ID mappings. 137.Pp 138The mapfiles can be located anywhere in the file hierarchy, but they 139must be owned by root, and they must be writable only by root. 140.Nm 141will refuse to map the sub-tree if the ownership or permissions on 142these files are improper. 143It will also report an error if the count 144of mappings in the first line of the map files is not correct. 145.Sh SEE ALSO 146.Xr mount 8 , 147.Xr mount_null 8 148.Sh HISTORY 149The 150.Nm 151utility first appeared in 152.Bx 4.4 . 153.Sh BUGS 154The implementation is not very sophisticated. 155