1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
|
'\" t
.\" Title: nss_wrapper
.\" Author: Samba Team
.\" Generator: Asciidoctor 2.0.23
.\" Date: 2024-07-05
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
.TH "NSS_WRAPPER" "1" "2024-07-05" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.ss \n[.ss] 0
.nh
.ad l
.de URL
\fI\\$2\fP <\\$1>\\$3
..
.als MTO URL
.if \n[.g] \{\
. mso www.tmac
. am URL
. ad l
. .
. am MTO
. ad l
. .
. LINKSTYLE blue R < >
.\}
.SH "NAME"
nss_wrapper \- A wrapper for the user, group and hosts NSS API
.SH "SYNOPSIS"
.sp
LD_PRELOAD=libnss_wrapper.so NSS_WRAPPER_PASSWD=/path/to/passwd NSS_WRAPPER_GROUP=/path/to/group NSS_WRAPPER_HOSTS=/path/to/host \fB./myapplication\fP
.SH "DESCRIPTION"
.sp
There are projects which provide daemons needing to be able to create, modify
and delete Unix users. Or just switch user ids to interact with the system e.g.
a user space file server. To be able to test that you need the privilege to
modify the passwd and groups file. With nss_wrapper it is possible to define
your own passwd and groups file which will be used by software to act correctly
while under test.
.sp
If you have a client and server under test they normally use functions to
resolve network names to addresses (dns) or vice versa. The nss_wrappers allow
you to create a hosts file to setup name resolution for the addresses you use
with socket_wrapper.
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
. sp -1
. IP \(bu 2.3
.\}
Provides information for user and group accounts.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
. sp -1
. IP \(bu 2.3
.\}
Network name resolution using a hosts file.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
. sp -1
. IP \(bu 2.3
.\}
Loading and testing of NSS modules.
.RE
.SH "LIMITATIONS"
.sp
Some calls in nss_wrapper will only work if uid_wrapper is loaded and active.
One of this functions is initgroups() which needs to run setgroups() to set
the groups for the user. setgroups() is wrapped by uid_wrapper.
.SH "ENVIRONMENT VARIABLES"
.sp
\fBNSS_WRAPPER_PASSWD\fP, \fBNSS_WRAPPER_GROUP\fP
.RS 4
For user and group accounts you need to create two files: \fIpasswd\fP and \fIgroup\fP.
The format of the passwd file we support is:
.RE
.sp
name:password:UID:GID:GECOS:directory:shell
.sp
The format of the group file we support is:
.sp
group_name:password:GID:user_list
.sp
They are also described in \fIman passwd.5\fP and \fIman group.5\fP on Linux. You can
fill these files with made up accounts. You point
nss_wrapper to them using the two variables
NSS_WRAPPER_PASSWD=/path/to/your/passwd and
NSS_WRAPPER_GROUP=/path/to/your/group.
.sp
\fBNSS_WRAPPER_HOSTS\fP
.RS 4
If you also need to emulate network name resolution in your environment,
especially with socket_wrapper, you can write a hosts file. The format is
described in \fIman 5 hosts\fP. Then you can point nss_wrapper to your hosts
file using: NSS_WRAPPER_HOSTS=/path/to/your/hosts
.RE
.sp
\fBNSS_WRAPPER_HOSTNAME\fP
.RS 4
If you need to return a hostname which is different from the one of your
machine is using you can use: NSS_WRAPPER_HOSTNAME=test.example.org
.RE
.sp
\fBNSS_WRAPPER_MODULE_SO_PATH\fP, \fBNSS_WRAPPER_MODULE_FN_PREFIX\fP
.RS 4
If you have a project which also provides user and group information out of a
database, you normally write your own nss modules. nss_wrapper is able to load
nss modules and ask them first before looking into the faked passwd and group
file. To point nss_wrapper to the module you can do that using
NSS_WRAPPER_MODULE_SO_PATH=/path/to/libnss_yourmodule.so. As each nss module
has a special prefix like _nss_winbind_getpwnam() you need to set the prefix
too so nss_wrapper can load the functions with
NSS_WRAPPER_MODULE_FN_PREFIX=<prefix>.
.RE
.sp
For _nss_winbind_getpwnam() this would be:
.sp
.if n .RS 4
.nf
.fam C
NSS_WRAPPER_MODULE_FN_PREFIX=winbind
.fam
.fi
.if n .RE
.sp
\fBNSS_WRAPPER_DEBUGLEVEL\fP
.RS 4
If you need to see what is going on in nss_wrapper itself or try to find a
bug, you can enable logging support in nss_wrapper if you built it with
debug symbols.
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
. sp -1
. IP \(bu 2.3
.\}
0 = ERROR
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
. sp -1
. IP \(bu 2.3
.\}
1 = WARNING
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
. sp -1
. IP \(bu 2.3
.\}
2 = DEBUG
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
. sp -1
. IP \(bu 2.3
.\}
3 = TRACE
.RE
.RE
.sp
\fBNSS_WRAPPER_DISABLE_DEEPBIND\fP
.RS 4
This allows you to disable deep binding in nss_wrapper. This is useful for
running valgrind tools or sanitizers like (address, undefined, thread).
.RE
.SH "EXAMPLE"
.sp
.if n .RS 4
.nf
.fam C
$ echo "bob:x:1000:1000:bob gecos:/home/test/bob:/bin/false" > passwd
$ echo "root:x:65534:65532:root gecos:/home/test/root:/bin/false" >> passwd
$ echo "users:x:1000:" > group
$ echo "root:x:65532:" >> group
$ LD_PRELOAD=libnss_wrapper.so NSS_WRAPPER_PASSWD=passwd \(rs
NSS_WRAPPER_GROUP=group getent passwd bob
bob:x:1000:1000:bob gecos:/home/test/bob:/bin/false
$ LD_PRELOAD=libnss_wrapper.so NSS_WRAPPER_HOSTNAME=test.example.org hostname
test.example.org
.fam
.fi
.if n .RE
.SH "AUTHOR"
.sp
Samba Team
|