| 1 |
cvsd - chroot wrapper to run 'cvs pserver' more securely. |
| 2 |
|
| 3 |
cvsd was originally written by Chris Black <[email protected]>, |
| 4 |
http://cblack.mokey.com/. That was until release 0.6. |
| 5 |
|
| 6 |
cvsd versions up till 0.8b3 were maintained by Philippe Kehl |
| 7 |
<[email protected]>, http://guv.ethz.ch/~flip/cvsd/, |
| 8 |
http://www.oinkzwurgl.org/software/cvsd/. |
| 9 |
|
| 10 |
after that Arthur de Jong <[email protected]> |
| 11 |
took up the work and did a complete rewrite, |
| 12 |
https://arthurdejong.org/cvsd. |
| 13 |
|
| 14 |
Copyright (C) 1999 Chris Black. |
| 15 |
Copyright (C) 2000 Philippe Kehl. |
| 16 |
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, |
| 17 |
2010, 2011, 2012, 2024 Arthur de Jong. |
| 18 |
|
| 19 |
This program is free software; you can redistribute it and/or modify |
| 20 |
it under the terms of the GNU General Public License as published by |
| 21 |
the Free Software Foundation; either version 2, or (at your option) |
| 22 |
any later version. |
| 23 |
|
| 24 |
This program is distributed in the hope that it will be useful, |
| 25 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 26 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 27 |
GNU General Public License for more details. |
| 28 |
|
| 29 |
You should have received a copy of the GNU General Public License |
| 30 |
along with this program; if not, write to the Free Software |
| 31 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 32 |
|
| 33 |
|
| 34 |
INTRODUCTION |
| 35 |
============ |
| 36 |
|
| 37 |
cvsd is a wrapper program for cvs in pserver mode. it will run 'cvs pserver' |
| 38 |
under a special uid/gid in a chroot jail. |
| 39 |
|
| 40 |
cvsd is run as a daemon and is controlled through a configuration file. It is |
| 41 |
relatively easy to configure and provides tools for easy setting up a chroot |
| 42 |
jail. |
| 43 |
|
| 44 |
This server can be useful if you want to run a public cvs pserver. You should |
| 45 |
however be aware of the security limitations of running a cvs pserver. If you |
| 46 |
want any kind of authentication you should really consider using secure shell |
| 47 |
as a secure authentication mechanism and transport. Passwords used in cvs |
| 48 |
pserver are transmitted in plain text. |
| 49 |
|
| 50 |
This wrapper adds a layer of security to the cvs server. cvs is a very |
| 51 |
powerful tool and is capable of running scripts and other things. Running cvs |
| 52 |
in a chroot jail it is possible to limit the amount of "damage" cvs can do if |
| 53 |
it is exploited. It is generally a good idea to run cvsd without any write |
| 54 |
permissions to any directory on the system. |
| 55 |
|
| 56 |
Features of cvsd include: |
| 57 |
* running in chroot jail |
| 58 |
* configuring chroot jail |
| 59 |
* running under a non-root uid |
| 60 |
* set a nice value |
| 61 |
* limit resource usage |
| 62 |
* limit number of connections |
| 63 |
* relatively easy to set up |
| 64 |
|
| 65 |
|
| 66 |
INSTALLING CVSD |
| 67 |
=============== |
| 68 |
|
| 69 |
In short: |
| 70 |
% ./configure |
| 71 |
% make |
| 72 |
% make install |
| 73 |
|
| 74 |
You can add '--sysconfdir=/etc', '--prefix', '--enable-warnings' and/or |
| 75 |
'--enable-debug' options to configure to tune installation. Debugging is only |
| 76 |
recommended for finding bugs. |
| 77 |
|
| 78 |
cvsd is developed on a Debian GNU/Linux system and should work fine on most |
| 79 |
GNU/Linux systems. The code is supposed to be portable but is not regularly |
| 80 |
tested on other platforms. cvsd is known to work on Solaris, FreeBSD, OpenBSD |
| 81 |
and others. |
| 82 |
|
| 83 |
tcp wrappers |
| 84 |
------------ |
| 85 |
|
| 86 |
cvsd currently has experimental support for tcp wrappers. Use './configure |
| 87 |
--with-libwrap' to enable support. Most versions of the tcp wrapper libraries |
| 88 |
have issues with systems supporting IPv6, see the FAQ. |
| 89 |
|
| 90 |
Using this option will have a slight performance hit on the number of |
| 91 |
connections that can be handled per minute. For each incoming connection the |
| 92 |
tcp wrapper reads the configuration files and does a name lookup. This is done |
| 93 |
inside the main loop before the child is forked.. |
| 94 |
|
| 95 |
Also note that you have to edit the hosts.allow and hosts.deny files INSIDE |
| 96 |
the chroot jail since the tcp wrapper libraries reread these files for every |
| 97 |
connection. |
| 98 |
|
| 99 |
|
| 100 |
CONFIGURING CVSD |
| 101 |
================ |
| 102 |
|
| 103 |
cvsd is controlled through a configuration file in /etc/cvsd/cvsd.conf (or |
| 104 |
maybe /usr/local/etc/cvsd/cvsd.conf depending where you set --prefix to with |
| 105 |
configure). The default configuration file is fully commented and has a |
| 106 |
manual page (cvsd.conf(5)) which documents use of the configuration file. |
| 107 |
|
| 108 |
very quick setup guide |
| 109 |
---------------------- |
| 110 |
|
| 111 |
The is just a series of commands to set up cvsd in a typical read-only setup. |
| 112 |
If you don't understand these steps or are looking for commands that work on |
| 113 |
your system you should look below for further details. |
| 114 |
|
| 115 |
# addgroup --system cvsd (or groupadd) |
| 116 |
# adduser --system --ingroup cvsd --home /var/lib/cvsd \ |
| 117 |
--shell /bin/false --gecos 'cvs pserver daemon' cvsd |
| 118 |
# cvsd-buildroot /var/lib/cvsd |
| 119 |
# cvs -d /var/lib/cvsd/myrepos init |
| 120 |
# cvsd-passwd /var/lib/cvsd/myrepos +anonymous |
| 121 |
# touch /var/lib/cvsd/myrepos/CVSROOT/writers |
| 122 |
edit /var/lib/cvsd/myrepos/CVSROOT/config |
| 123 |
add "SystemAuth=no" |
| 124 |
add "PamAuth=no" (on systems that have this option) |
| 125 |
add "LockDir=/tmp/myrepos" |
| 126 |
# mkdir /var/lib/cvsd/tmp/myrepos |
| 127 |
# chown cvsd:cvsd /var/lib/cvsd/tmp/myrepos |
| 128 |
edit /etc/cvsd/cvsd.conf |
| 129 |
set "RootJail /var/lib/cvsd" |
| 130 |
set "Repos /myrepos" |
| 131 |
|
| 132 |
You should now be able to continue with the section "checking the |
| 133 |
configuration" below. |
| 134 |
|
| 135 |
setting up the user and group |
| 136 |
----------------------------- |
| 137 |
|
| 138 |
You should setup a user and group under which cvsd is run. Adding users to |
| 139 |
the system is different on most platforms but this should work for most |
| 140 |
systems: |
| 141 |
# addgroup cvsd |
| 142 |
# adduser --system --ingroup cvsd --home /var/lib/cvsd \ |
| 143 |
--shell /bin/false --gecos 'cvs pserver daemon' cvsd |
| 144 |
or maybe (or some other variation depending on your system): |
| 145 |
# groupadd cvsd |
| 146 |
# useradd -r -M -d /var/lib/cvsd -s /bin/false \ |
| 147 |
-c "cvs pserver daemon" -g cvsd cvsd |
| 148 |
|
| 149 |
(replace /var/lib/cvsd with the place where your chrooted file system is |
| 150 |
located) |
| 151 |
|
| 152 |
setting up a chroot jail |
| 153 |
------------------------ |
| 154 |
|
| 155 |
You can populate a chrooted file system with cvsd-buildroot. You should rerun |
| 156 |
this script if your cvs binary changes or the libraries that it depends upon. |
| 157 |
The place where you create the chroot file system should be specified in the |
| 158 |
configuration file as the 'RootJail'. It is possible (but not advisable) to |
| 159 |
run cvsd without a chrooted file system. |
| 160 |
|
| 161 |
If you plan to run stuff like the scripts from the contrib/ subdirectory in |
| 162 |
cvs, then you have to have all necessary binaries, libraries etc. etc. in the |
| 163 |
chrooted file system. You can just put the needed binaries in the 'bin' |
| 164 |
directory of the chroot jail and 'cvsd-buildroot' will install the needed |
| 165 |
libraries. Please note that this may require manual reconfiguring. |
| 166 |
|
| 167 |
Some systems may require extra libraries to be present in the chrooted file |
| 168 |
system than can not be automatically detected (using ldd). See the FAQ for |
| 169 |
details. |
| 170 |
|
| 171 |
disabling inetd pserver |
| 172 |
----------------------- |
| 173 |
|
| 174 |
If inetd is configured to start cvs /etc/inetd.conf should contain a line |
| 175 |
like this: |
| 176 |
cvspserver stream tcp nowait root /usr/bin/cvs --allow-root /home/cvs |
| 177 |
You should remove or comment out this line or tell cvsd to listen on a |
| 178 |
different port (use Listen option in cvsd.conf). If you change inetd.conf you |
| 179 |
should tell inetd to reload it's configuration by: |
| 180 |
# kill -s HUP <pidofinetd> |
| 181 |
|
| 182 |
setting up a repository |
| 183 |
----------------------- |
| 184 |
|
| 185 |
If you have configured the chroot jail and the user and group id bits you can |
| 186 |
start adding repositories to the chroot jail. There are a couple of ways you |
| 187 |
could do that. |
| 188 |
|
| 189 |
The first is creating an empty repository with something like: |
| 190 |
# cvs -d /var/lib/cvsd/myrepos init |
| 191 |
(where /var/lib/cvsd is the location of the chroot jail and myrepos is the |
| 192 |
name of the new repository) |
| 193 |
|
| 194 |
Another way is copying an already existing repository to the chroot jail. It |
| 195 |
is also possible to do something smart with a tool like 'rsync'. Put this in |
| 196 |
a cronjob for extra effect. |
| 197 |
|
| 198 |
Symbolic linking a repository to the chroot jail is not possible since |
| 199 |
symbolic links will be evaluated within the chroot jail. Hard linking directories |
| 200 |
should be avoided (hard linking in general in my opinion). With Linux 2.4 (and |
| 201 |
probably other systems) it is possible to remount an existing directory |
| 202 |
within another directory. You can use mount: |
| 203 |
# mount --bind /home/user/develrepos /var/lib/cvsd/userrepos |
| 204 |
or add something like this to /etc/fstab: |
| 205 |
/home/user/develrepos /var/lib/cvsd/userrepos none bind 0 0 |
| 206 |
(don't forget to create the /var/lib/cvsd/userrepos directory) |
| 207 |
|
| 208 |
After you have created or copied a repository into the chroot jail you should |
| 209 |
add it to the cvsd.conf configuration file so cvs can access it. Use the |
| 210 |
'Repos' option for this and remember to specify it relative to the chroot |
| 211 |
jail. So if your repository is /var/lib/cvsd/myrepos you should add 'Repos |
| 212 |
/myrepos' to the configuration file. |
| 213 |
|
| 214 |
The last step for making your repository accessible is to add a passwd file |
| 215 |
to the 'CVSROOT' directory of the repository. The cvsd-passwd tool will do |
| 216 |
this for you. |
| 217 |
cvsd-passwd /var/lib/cvsd/myrepos anonymous |
| 218 |
This will add user 'anonymous' to the list of users that can access the |
| 219 |
repository. You will be prompted for a password which can optionally be |
| 220 |
blank. |
| 221 |
|
| 222 |
Note that the cvsd user needs to have the correct permissions to the |
| 223 |
repository. The cvsd user probably should have read access to the repository |
| 224 |
but probably no write permission. You can add all users in the repository |
| 225 |
passwd file to a file named 'readers' in the 'CVSROOT' directory or create an |
| 226 |
empty 'writers' file. Without any of these files all users have write access! |
| 227 |
|
| 228 |
If you set up your repository so that the cvsd user only has read access to |
| 229 |
the files and directories in the repository (through unix file permissions) |
| 230 |
you need to take some extra provisions since cvs creates lockfiles when |
| 231 |
checking out files from the repository. The best way to do this is to create |
| 232 |
a directory for the cvsd user to write the lockfiles to (e.g. |
| 233 |
/var/lib/cvsd/tmp/myrepos) and add "LockDir=/tmp/myrepos" to the |
| 234 |
/var/lib/cvsd/myrepos/CVSROOT/config file. Be sure to create the directory |
| 235 |
and make it writable for the cvsd user. If your cvsd user has write access to |
| 236 |
the repository this should be no problem. |
| 237 |
|
| 238 |
It is also a good idea to put "SystemAuth=no" and maybe "PamAuth=no" in your |
| 239 |
CVSROOT/config file. This way password lookups will only be done to |
| 240 |
CVSROOT/config and not to /etc/passwd inside the chroot jail (that passwd |
| 241 |
file shouldn't contain any passwords) or PAM. |
| 242 |
|
| 243 |
See the "Password authentication server" section in the cvs texinfo document |
| 244 |
for more information about running a pserver and setting up repositories. |
| 245 |
|
| 246 |
|
| 247 |
CHECKING THE CONFIGURATION |
| 248 |
========================== |
| 249 |
|
| 250 |
If you have started cvsd with the provided init script: |
| 251 |
# /etc/init.d/cvsd start |
| 252 |
(or /usr/local/etc/init.d/cvsd start) and configured a repository (say |
| 253 |
myrepos) you should be able to access the server with something like: |
| 254 |
% cvs -d :pserver:anonymous@localhost:/myrepos login |
| 255 |
% cvs -d :pserver:anonymous@localhost:/myrepos checkout . |
| 256 |
For troubleshooting information see the FAQ on debugging. |
| 257 |
|
| 258 |
|
| 259 |
REPORTING BUGS |
| 260 |
============== |
| 261 |
|
| 262 |
If you find any bugs or missing features please send email to |
| 263 |
[email protected] |
| 264 |
Please include as much information as needed (platform, output of configure |
| 265 |
if compilation fails, output of the failure, etc). Most of the configuration |
| 266 |
information can be provided by running cvsd-buginfo. Patches are more than |
| 267 |
welcome. |