[BACK]Return to anoncvs.shar CVS log [TXT][DIR] Up to [local] / www

Annotation of www/anoncvs.shar, Revision 1.9

1.1       deraadt     1: # This is a shell archive.  Save it in a file, remove anything before
                      2: # this line, and then unpack it by entering "sh file".  Note, it may
                      3: # create directories; files and directories will be owned by you and
                      4: # have default permissions.
                      5: #
                      6: # This archive contains:
                      7: #
1.6       deraadt     8: #      Makefile
1.1       deraadt     9: #      README
                     10: #      anoncvssh.c
                     11: #
1.6       deraadt    12: echo x - Makefile
                     13: sed 's/^X//' >Makefile << 'END-of-Makefile'
                     14: X#CVSROOT=anoncvs@anoncvs1.usa.openbsd.org:/cvs
                     15: XPROG=   anoncvssh
                     16: XBINOWN= root
                     17: XBINMODE=4111
                     18: XBINDIR=/open
                     19: XNOMAN=
                     20: X
                     21: X.include <bsd.prog.mk>
                     22: X
                     23: END-of-Makefile
1.1       deraadt    24: echo x - README
                     25: sed 's/^X//' >README << 'END-of-README'
                     26: X
1.7       beck       27: X      So, you want to run an anoncvs server.
                     28: X
                     29: X        A summary of the steps you'll need to do is:
                     30: X
                     31: X1) Find enough disk space to hold the anoncvs tree, and mount it in an
                     32: Xappropriate place.
                     33: X
                     34: X2) Compile and install anoncvssh, the shell used for the anoncvs user.
                     35: X   ( If you aren't using OpenBSD you'll probably need to compile a sup
                     36: X     client as well. The easier path is to use OpenBSD ;)
                     37: X
                     38: X3) Add the anoncvs user to the password file, with no password, and
                     39: Xanoncvssh as it's shell. Decide on a user that will run sup to maintain
                     40: Xthe archive (this is a different user, NOT the anoncvs user)
                     41: X
                     42: X4) Make a home directory for the anoncvs user. The anoncvs user's home
                     43: Xdirectory is a chroot jail in which the anoncvssh processes run when
                     44: Xservicing anoncvs requests. The jail must contain the cvs binary and
                     45: Xrelated programs (rcs, etc) as well as whatever shared libraries and
                     46: Xsupport files are needed to run them unless you compile and link
                     47: Xeverything staticly. This example shows what is needed for OpenBSD. If
                     48: Xyou use another platform you'll need to be familiar with what needs
                     49: Xto go in a chroot jail for your platform.
                     50: X
                     51: X5) Get permission to use sup to obtain the cvs tree from a server.
1.1       deraadt    52: X
1.7       beck       53: X6) Set up sup to retrieve the cvs tree from an appropriate place.
                     54: X   (If you aren't using OpenBSD you will need to compile and install
                     55: X    a sup client).
1.6       deraadt    56: X
1.7       beck       57: X7) Run sup to retrieve the distribution from the server
1.3       deraadt    58: X
1.7       beck       59: X8) Once you get the distribution in, set up a cron job to run sup
                     60: X   periodically to keep your server up to date.
1.6       deraadt    61: X
1.7       beck       62: X**********************************************************************
                     63: XSTEP 1) find enough disk space.
                     64: X    you need roughly 500MB.
                     65: X    mount it on /open
                     66: X    if you are not able to mount it as /open, substitute it's location
                     67: X    throughout the rest of this description
1.6       deraadt    68: X
1.7       beck       69: X**********************************************************************
                     70: XSTEP 2) compile the anoncvssh binary
                     71: X    in the Makefile, change the variable CVSROOT
                     72: X    install the binary setuid-root in /open/anoncvssh.
1.1       deraadt    73: X
1.7       beck       74: X**********************************************************************
                     75: XSTEP 3) Create the anoncvs account. and decide who will run "sup"
                     76: Xto maintain the archive. The anoncvs account should *NOT* be the one
                     77: Xrunning sup to maintain the archive.
1.1       deraadt    78: X
1.9     ! beck       79: Xcreate an account similar to:
        !            80: X
1.7       beck       81: X    anoncvs::32766:32766:Anonymous CVS User:/open/anoncvs:/open/anoncvssh
1.4       deraadt    82: X
1.9     ! beck       83: Xyes, that is right. the account has no password. Be sure that the uid
        !            84: Xand gid are unique for your system, if the ones above aren't, pick different
        !            85: Xvalues.
        !            86: X
        !            87: XDecide on who will run sup to maintain the archive. call that user $SUPUSER.
1.7       beck       88: XOh, and in case it hasn't been previously mentioned, $SUPUSER should *NOT*
                     89: Xbe the anoncvs user :)
                     90: X
                     91: X**********************************************************************
                     92: XSTEP 4) Build the anoncvs user's home directory chroot jail. This example
                     93: Xassumes that you're using OpenBSD. If you're not you may need different
                     94: Xfiles in the chroot.
1.4       deraadt    95: X
1.1       deraadt    96: Xmkdir /open/anoncvs
                     97: Xmkdir /open/anoncvs/cvs
1.6       deraadt    98: Xmkdir /open/anoncvs/sup
                     99: Xchown -R $SUPUSER /open/anoncvs/cvs /open/anoncvs/sup /open/anoncvs
1.1       deraadt   100: X
1.7       beck      101: Xstart filling the account up with nice stuff. You are building a chroot
                    102: Xjail for anoncvs in /open/anoncvs.
                    103: X
1.1       deraadt   104: X    cd /open/anoncvs
                    105: X    touch .hushlogin
                    106: X    touch .profile
                    107: X
                    108: Xput a message like the following in .plan:
1.6       deraadt   109: X    To use anonymous CVS install the latest version of CVS on your local
                    110: X    machine.
1.1       deraadt   111: X    Then set your CVSROOT environment variable to the following value:
                    112: X            anoncvs@anoncvs.openbsd.org:/cvs
                    113: X
                    114: X    chown root.wheel .hushlogin .profile .plan
                    115: X
                    116: X    mkdir bin dev tmp usr var etc
                    117: X    cp /bin/{cat,pwd,rm,sh} bin/
                    118: X
                    119: Xusing mknod, make a dev/null that has the same major/minor numbers as
                    120: X    your /dev/null, and make it mode 666.
                    121: X
                    122: Xsome shared library systems require a dev/zero created in the same way
                    123: X
                    124: Xfill etc space for the account
                    125: X    cp /etc/{group,hosts,passwd,protocols} etc/
                    126: X    cp /etc/{pwd.db,resolv.conf,services,ttys} etc/
                    127: X    modify these files to suit your idea of system security
                    128: X
1.3       deraadt   129: Xanoncvssh (by setting the environment variable CVSREADONLYFS) uses an
                    130: Xtiny extension provided in the openbsd cvs server code which permits
                    131: Xthe use of read-only cvs repositories.  therefore you MUST compile the
                    132: Xopenbsd version of cvs.  luckily this is not a problem on a
                    133: Xnon-openbsd machine since the cvs sources are imported verbatim into
                    134: Xthe openbsd tree.  they are in gnu/usr.bin/cvs.  The sources are
                    135: Xintegrated such that Makefile.bsd-wrapper knows how to build the
                    136: Xsources on an OpenBSD machine, using obj directories.
1.1       deraadt   137: X
                    138: Xcreate tmp space for the account
                    139: X    cd var; ln -s ../tmp tmp
                    140: X    chmod a+rwx tmp
                    141: X
                    142: X    mkdir usr/{bin,lib}
                    143: X    cp /usr/bin/{ci,co,cvs,diff,diff3,gzip,rcs,rcsclean} usr/bin/
                    144: X    cp /usr/bin/{rcsdiff,rcsfreeze,rcsmerge,rlog,sdiff,zdiff} usr/bin/
1.6       deraadt   145: X    cp /usr/bin/grep usr/bin
1.1       deraadt   146: X
                    147: Xif your system has ld.so in /usr/libexec,
                    148: X    mkdir usr/libexec
                    149: X    cp /usr/libexec/ld.so usr/libexec/
                    150: X
                    151: Xif using shared libraries, copy the shared libs you might need:
                    152: X    cp /usr/lib/lib*.so.* usr/lib/
                    153: X
                    154: Xas a final pass, make sure that all the files you have just created are
1.7       beck      155: Xnot world writable (except dev/null)
1.1       deraadt   156: X
1.7       beck      157: XFor :pserver: support (optional)
                    158: X  - Create an entry in /etc/services
                    159: X     cvspserver               2401/tcp                # CVS client/server operations
                    160: X  - Create an entry in /etc/inetd.conf
                    161: X     cvspserver       stream  tcp nowait anoncvs /open/anoncvssh anoncvssh pserver
                    162: X
                    163: XSee the example layout below for full details.
                    164: X
                    165: X**********************************************************************
                    166: XSTEP 5): Get sup permission.
                    167: Xsend mail to sup@openbsd.org
                    168: X1) to have sup permissions granted on an appropriate machine for you
                    169: X   to sup from.
1.3       deraadt   170: X2) to have an anoncvsN.COUNTRY.openbsd.org alias created
                    171: X3) to have your site mentioned in the http://www.openbsd.org page.
                    172: X
1.7       beck      173: X**********************************************************************
                    174: XSTEP 6): Configure sup
                    175: X
                    176: XIf you're running OpenBSD, you already have a sup client in
                    177: X/usr/bin/sup.  If not you may need to build it. On an IRIX or other
                    178: XSYSV machine, ensure that your kernel does not allow a user to chown a
                    179: Xfile to another user (You may have heard of this particular brand of
                    180: Xevil referred to as "chown giveaway"). this will cause sup to give
                    181: Xaway the files to root before chmod'ing them
                    182: Xreadable. michaels@openbsd.org knows how to fix this.
                    183: X
                    184: XThe file /open/sup/ss contains a line that tells sup where to get the
                    185: Xcvs tree from. it can contain *one* of:
                    186: X
                    187: X    cvs host=anoncvs1.ca.openbsd.org hostbase=/usr/OpenBSD base=/open/anoncvs delete
                    188: X    cvs host=cvs.openbsd.org hostbase=/ base=/open/anoncvs delete
                    189: X
                    190: X    You should ask which one to use when obtaining sup permission.
                    191: X
                    192: XThe file /open/sup/cvs/refuse tells sup what files it should not get.
                    193: XIt should contain the single line:
                    194: X
                    195: X    cvs/CVSROOT/history
                    196: X
                    197: Xif you ever fetch the file cvs/CVSROOT/history, delete it. it will
                    198: Xcause you problems.
                    199: X
                    200: X**********************************************************************
                    201: XSTEP 7): Run sup to retrieve the tree for the first time
                    202: X
                    203: XLog in as or become the $SUPUSER, and run
                    204: X
                    205: Xsup -v  /open/anoncvs/sup/ss > /tmp/suplog &; tail -f /tmp/suplog
                    206: X
                    207: XIf you have sup permission, and have specified the correct host and
                    208: Xhostbase in /open/anoncvs/sup/ss you should see a list of files start
                    209: Xcoming in after a short while. Don't panic if nothing happens
                    210: Ximmediately.  Watch for errors (sup can timeout or die). If you can't
                    211: Xaccess files contact the sup server maintainer, If you get a timeout
                    212: Xor if sup dies you can restart and it should continue where it left off.
                    213: X
                    214: XIt can take a good while (and a couple of restarts) to obtain the
                    215: Xwhole tree for the first time.
                    216: X
                    217: X**********************************************************************
                    218: XSTEP 8): Set up cron to keep the tree up to date.
                    219: X
                    220: XYou run sup periodically from the cron by setting up the crontab file
                    221: Xof the $SUPUSER.
                    222: X
                    223: XFor example:  To run every three hours 'sup -v supfile', and thrice
                    224: Xweekly 'sup -vo supfile' .. because sup is not reliable ..
                    225: X
                    226: X0 0,3,6,9,12,15,18,21 * * 0,2,4,5 sup -v  /open/anoncvs/sup/ss > /dev/null
                    227: X0 0,12,15,18,21       * *  1,3,6  sup -v  /open/anoncvs/sup/ss > /dev/null
                    228: X0 3                   * *  1,3,6  sup -vo /open/anoncvs/sup/ss > /dev/null
                    229: X
                    230: Xanoncvs5.usa.openbsd.org uses this particular set of entries.  A `sup
                    231: X-o' is done every few days because sup is not very robust.
                    232: X
                    233: X**********************************************************************
                    234: XEXAMPLE LAYOUT
                    235: X
                    236: XExample layout for OpenBSD. In this example "deraadt" is the $SUPUSER.
1.3       deraadt   237: X
                    238: X[eap open 5 ]> cd /open
                    239: X[eap open 6 ]> ls -alF
                    240: Xtotal 46
                    241: Xdrwxr-xr-x   7 root     wheel    512 Feb 20 09:58 ./
                    242: Xdrwxr-xr-x  17 root     wheel    512 Jun 14 14:05 ../
                    243: Xdrwxr-xr-x   9 root     wheel    512 Jan  3 21:55 anoncvs/
                    244: X---s--x--x   1 root     bin    16384 Nov 30  1995 anoncvssh*
                    245: Xlrwxr-xr-x   1 root     wheel     11 Jan  3 21:52 cvs@ -> anoncvs/cvs
                    246: Xdrwxr-xr-x   5 root     wheel    512 Feb 22 13:22 ftp/
                    247: Xdrwxrwxrwt   2 anoncvs  wheel   1024 Jan  1 13:18 lost+found/
                    248: Xdrwxr-xr-x   4 root     wheel    512 Nov 30  1995 src/
                    249: Xdrwxrwxr-x   3 deraadt  wheel    512 Dec  4  1995 sup/
                    250: X[eap open 7 ]> cd anoncvs
                    251: X[eap anoncvs 8 ]> ls -alF
                    252: Xtotal 20
                    253: Xdrwxr-xr-x  9 root     wheel  512 Jan  3 21:55 ./
                    254: Xdrwxr-xr-x  7 root     wheel  512 Feb 20 09:58 ../
                    255: X-r--r--r--  1 root     wheel    0 Nov 30  1995 .hushlogin
                    256: X-r--r--r--  1 root     wheel  188 Nov 30  1995 .plan
                    257: X-r--r--r--  1 root     wheel    0 Nov 29  1995 .profile
                    258: Xdrwxrwxrwx  2 deraadt  wheel  512 Nov 29  1995 bin/
                    259: Xdrwxrwxr-x  6 deraadt  cvs    512 Jun 16 20:28 cvs/
                    260: Xdrwxr-xr-x  2 root     wheel  512 Nov 30  1995 dev/
                    261: Xdrwxr-xr-x  2 root     wheel  512 Nov 29  1995 etc/
                    262: Xdrwxrwxrwx  3 root     wheel  512 Jun 22 07:42 tmp/
                    263: Xdrwxr-xr-x  5 deraadt  wheel  512 Nov 30  1995 usr/
                    264: Xdrwxr-xr-x  2 root     wheel  512 Jan  3 21:55 var/
                    265: X[eap anoncvs 8 ]> ls -alFR bin usr tmp etc dev
                    266: Xbin:
                    267: Xtotal 948
                    268: Xdrwxrwxrwx  2 deraadt  wheel     512 Nov 29  1995 ./
                    269: Xdrwxr-xr-x  9 root     wheel     512 Jan  3 21:55 ../
                    270: X--wx--x--x  1 deraadt  wheel   40960 Jun 18 09:45 cat*
                    271: X--wx--x--x  1 deraadt  wheel   40960 Jun 18 09:45 pwd*
                    272: X--wx--x--x  1 deraadt  wheel  122880 Jun 18 09:45 rm*
                    273: X--wx--x--x  1 deraadt  wheel  262144 Jun 18 09:45 sh*
                    274: X
                    275: Xdev:
                    276: Xtotal 4
                    277: Xdrwxr-xr-x  2 root  wheel       512 Nov 30  1995 ./
                    278: Xdrwxr-xr-x  9 root  wheel       512 Jan  3 21:55 ../
                    279: Xcrw-rw-rw-  1 root  wheel    2,   2 Nov 30  1995 null
                    280: X
                    281: Xetc:
                    282: Xtotal 112
                    283: Xdrwxr-xr-x  2 root  wheel    512 Nov 29  1995 ./
                    284: Xdrwxr-xr-x  9 root  wheel    512 Jan  3 21:55 ../
                    285: X-rw-r--r--  1 root  wheel    252 Nov 29  1995 group
                    286: X-rw-r--r--  1 root  wheel    296 Nov 29  1995 hosts
                    287: X-rw-r--r--  1 root  wheel    540 Nov 29  1995 passwd
                    288: X-rw-r--r--  1 root  wheel   1094 Nov 29  1995 protocols
                    289: X-rw-r--r--  1 root  wheel  40960 Nov 29  1995 pwd.db
                    290: X-rw-r--r--  1 root  wheel     89 Nov 29  1995 resolv.conf
                    291: X-rw-r--r--  1 root  wheel   5529 Nov 29  1995 services
                    292: X-rw-r--r--  1 root  wheel   1361 Nov 29  1995 ttys
                    293: X
                    294: Xusr:
                    295: Xtotal 10
                    296: Xdrwxr-xr-x  5 deraadt  wheel   512 Nov 30  1995 ./
                    297: Xdrwxr-xr-x  9 root     wheel   512 Jan  3 21:55 ../
                    298: Xdrwxr-xr-x  2 deraadt  wheel   512 Nov 30  1995 bin/
                    299: Xdrwxr-xr-x  2 deraadt  wheel  1024 Jun 18 09:50 lib/
                    300: Xdrwxr-xr-x  2 deraadt  wheel   512 Nov 29  1995 libexec/
                    301: X
                    302: Xusr/bin:
                    303: Xtotal 1968
                    304: Xdrwxr-xr-x  2 deraadt  wheel     512 Nov 30  1995 ./
                    305: Xdrwxr-xr-x  5 deraadt  wheel     512 Nov 30  1995 ../
                    306: X--wx--x--x  1 deraadt  wheel   73728 Jun 18 09:46 ci*
                    307: X--wx--x--x  1 deraadt  wheel   73728 Jun 18 09:46 co*
                    308: X--wx--x--x  1 deraadt  wheel  317787 Jun 18 09:46 cvs*
                    309: X--wx--x--x  1 deraadt  wheel   73728 Jun 18 09:46 diff*
                    310: X--wx--x--x  1 deraadt  wheel   24576 Jun 18 09:46 diff3*
                    311: X--wx--x--x  1 deraadt  wheel   90112 Jun 18 09:46 gzip*
                    312: X--wx--x--x  1 deraadt  wheel   73728 Jun 18 09:46 rcs*
                    313: X--wx--x--x  1 deraadt  wheel   65536 Jun 18 09:46 rcsclean*
                    314: X--wx--x--x  1 deraadt  wheel   57344 Jun 18 09:46 rcsdiff*
                    315: X--wx--x--x  1 deraadt  wheel    3228 Jun 18 09:46 rcsfreeze*
                    316: X--wx--x--x  1 deraadt  wheel   57344 Jun 18 09:46 rcsmerge*
                    317: X--wx--x--x  1 deraadt  wheel   57344 Jun 18 09:46 rlog*
                    318: X--wx--x--x  1 deraadt  wheel   24576 Jun 18 09:46 sdiff*
                    319: X--wx--x--x  1 deraadt  wheel    2006 Jun 18 09:46 zdiff*
                    320: X
                    321: Xusr/lib:
                    322: Xtotal 5594
                    323: Xdrwxr-xr-x  2 deraadt  wheel    1024 Jun 18 09:50 ./
                    324: Xdrwxr-xr-x  5 deraadt  wheel     512 Nov 30  1995 ../
                    325: X-rw-r--r--  1 deraadt  wheel   16665 Jun 18 09:50 libacl.so.4.0
                    326: X-rw-r--r--  1 deraadt  wheel  351730 Jun 18 09:50 libc.so.12.3
                    327: X-rw-r--r--  1 deraadt  wheel  377359 Jun 18 09:50 libc.so.12.6
                    328: X-rw-r--r--  1 deraadt  wheel   16608 Jun 18 09:50 libcrypt.so.0.0
                    329: X-rw-r--r--  1 deraadt  wheel   16465 Jun 18 09:50 libcrypt.so.1.0
                    330: X-rw-r--r--  1 deraadt  wheel   44424 Jun 18 09:50 libcurses.so.2.1
                    331: X-rw-r--r--  1 deraadt  wheel   86198 Jun 18 09:50 libcurses.so.3.0
                    332: X-rw-r--r--  1 deraadt  wheel   42254 Jun 18 09:50 libdes.so.4.1
                    333: X-rw-r--r--  1 deraadt  wheel   66099 Jun 18 09:50 libedit.so.0.0
                    334: X-rw-r--r--  1 deraadt  wheel   43131 Jun 18 09:50 libform.so.0.0
                    335: X-rw-r--r--  1 deraadt  wheel  387976 Jun 18 09:50 libg++.so.2.0
                    336: X-rw-r--r--  1 deraadt  wheel  305738 Jun 18 09:50 libg++.so.27.1
                    337: X-rw-r--r--  1 deraadt  wheel   25544 Jun 18 09:50 libgnumalloc.so.0.0
                    338: X-rw-r--r--  1 deraadt  wheel   42696 Jun 18 09:50 libiberty.so.0.0
                    339: X-rw-r--r--  1 deraadt  wheel   25282 Jun 18 09:50 libkadm.so.4.0
                    340: X-rw-r--r--  1 deraadt  wheel   16610 Jun 18 09:50 libkafs.so.4.0
                    341: X-rw-r--r--  1 deraadt  wheel   25539 Jun 18 09:50 libkdb.so.4.0
                    342: X-rw-r--r--  1 deraadt  wheel   59943 Jun 18 09:50 libkrb.so.4.0
                    343: X-rw-r--r--  1 deraadt  wheel   25328 Jun 18 09:50 libkvm.so.4.0
                    344: X-rw-r--r--  1 deraadt  wheel  102104 Jun 18 09:50 libm.so.0.1
                    345: X-rw-r--r--  1 deraadt  wheel   26540 Jun 18 09:50 libmenu.so.0.0
                    346: X-rw-r--r--  1 deraadt  wheel   44424 Jun 18 09:50 libocurses.so.2.1
                    347: X-rw-r--r--  1 deraadt  wheel   16881 Jun 18 09:50 libpanel.so.0.0
                    348: X-rw-r--r--  1 deraadt  wheel   60222 Jun 18 09:50 libpcap.so.0.0
                    349: X-rw-r--r--  1 deraadt  wheel   25060 Jun 18 09:50 libresolv.so.1.0
                    350: X-rw-r--r--  1 deraadt  wheel   16465 Jun 18 09:50 libresolv.so.2.0
                    351: X-rw-r--r--  1 deraadt  wheel   33538 Jun 18 09:50 libskey.so.0.0
                    352: X-rw-r--r--  1 deraadt  wheel   25764 Jun 18 09:50 libss.so.4.0
                    353: X-rw-r--r--  1 deraadt  wheel  277954 Jun 18 09:50 libstdc++.so.27.1
                    354: X-rw-r--r--  1 deraadt  wheel   16835 Jun 18 09:50 libtelnet.so.1.0
                    355: X-rw-r--r--  1 deraadt  wheel   16691 Jun 18 09:50 libtermcap.so.0.0
                    356: X-rw-r--r--  1 deraadt  wheel   16691 Jun 18 09:50 libtermlib.so.0.0
                    357: X-rw-r--r--  1 deraadt  wheel   75039 Jun 18 09:50 libtermlib.so.1.0
                    358: X-rw-r--r--  1 deraadt  wheel   16625 Jun 18 09:50 libutil.so.3.1
                    359: X-rw-r--r--  1 deraadt  wheel   25628 Jun 18 09:50 libutil.so.3.2
                    360: X
                    361: Xusr/libexec:
                    362: Xtotal 100
                    363: Xdrwxr-xr-x  2 deraadt  wheel    512 Nov 29  1995 ./
                    364: Xdrwxr-xr-x  5 deraadt  wheel    512 Nov 30  1995 ../
                    365: X-rwxr-xr-x  1 deraadt  wheel  49152 Jun 18 09:47 ld.so*
                    366: X
                    367: X[eap anoncvs 14 ]> ls cvs
                    368: XCVSROOT/        src/            sup/            www/
1.6       deraadt   369: X[eap anoncvs 15 ]> cd /open
1.3       deraadt   370: X[eap anoncvs 16 ]> ls -alF sup
                    371: Xtotal 8
                    372: Xdrwxrwxr-x  3 deraadt  wheel  512 Dec  4  1995 ./
                    373: Xdrwxr-xr-x  7 root     wheel  512 Feb 20 09:58 ../
                    374: Xdrwxr-xr-x  2 deraadt  wheel  512 Jun 22 06:05 cvs/
                    375: X-rw-rw-r--  1 deraadt  wheel   54 Dec  4  1995 ss
                    376: X
                    377: X
1.7       beck      378: X***************************************************************
                    379: XNOTES FOR OTHER PLATFORMS:
                    380: X
                    381: XIf you're not that familiar with your other platform (i.e. you haven't
                    382: Xbuilt a chroot jail for a server on it) You may be better off
                    383: Xfinding an OpenBSD machine to use. (and duplicating the example above)
                    384: X
                    385: X**SunOS 5)
                    386: XBob Beck <beck@panopticon.ucs.ualberta.ca> has done this. E-mail for
                    387: Xhelp if you need it.
1.6       deraadt   388: X
1.7       beck      389: X**OSF 1)
1.6       deraadt   390: XFrom Todd Fries <toddf@acm.org> to the adventurous.
                    391: XA note for those installing anoncvs on non-OpenBSD operating systems.
                    392: XYou are in for some fun.
                    393: X
                    394: XFor OSF1, on a DEC alpha, I had to do the following in addition to the
                    395: Xabove:
                    396: X
                    397: X- I do not know how to setup dynamic libraries on osf1 and as a result
                    398: X  everything had to be compiled statically.
                    399: X- Therefore, everything but /bin/sh I had to recmpile in order to
                    400: X  get the chroot setup.  In order that there be no guesswork
                    401: X  involved, the following packages' binaries must exist in the chroot
                    402: X  environment:
                    403: X
                    404: X GNU
                    405: X   cvs         (from the OpenBSD source tree)
                    406: X   diff[utils] (unless you're running *BSD, probably better get it from a gnu
                    407: X                 mirror...the Makefile doesn't work otherwise)
                    408: X   rcs         (from the OpenBSD source tree)
                    409: X
                    410: XSome notes on compiling.
                    411: X
                    412: X   rcs must have diff3 capable of diff3 -m during configure.
                    413: X   OSF doesn't by default, thus I had to compile diffutils first.
                    414: X
                    415: X   cvs fails to install if you don't have makeinfo ... just search for the
                    416: X   string ' install-info$' with regex and remove it from the Makefile for the
                    417: X   install and you'll be fine, or install 'texinfo', your choice.
1.1       deraadt   418: END-of-README
                    419: echo x - anoncvssh.c
                    420: sed 's/^X//' >anoncvssh.c << 'END-of-anoncvssh.c'
                    421: X/*
                    422: X * anoncvssh
                    423: X */
                    424: X
1.4       deraadt   425: X#include <stdio.h>
                    426: X#include <stdlib.h>
                    427: X#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)
                    428: X#include <paths.h>
                    429: X#endif
                    430: X#include <pwd.h>
                    431: X#include <unistd.h>
                    432: X#include <sys/types.h>
                    433: X
                    434: X#ifndef __CONCAT
                    435: X#if defined(__STDC__) || defined(__cplusplus)
                    436: X#define __CONCAT(x,y)         x ## y
                    437: X#else
                    438: X#define __CONCAT(x,y)         x/**/y
                    439: X#endif
                    440: X#endif
                    441: X
                    442: X#ifndef __CONCAT3
                    443: X#if defined(__STDC__) || defined(__cplusplus)
                    444: X#define __CONCAT3(x,y,z)      x ## y ## z
                    445: X#else
                    446: X#define __CONCAT3(x,y,z)      x/**/y/**/z
                    447: X#endif
                    448: X#endif
                    449: X
                    450: X#ifndef __P
                    451: X#if defined(__STDC__) || defined(__cplusplus)
                    452: X#define       __P(protos)     protos          /* full-blown ANSI C */
                    453: X#else
                    454: X#define       __P(protos)     ()              /* traditional C preprocessor */
                    455: X#endif
                    456: X#endif
                    457: X
                    458: X/*
                    459: X * You may need to change this path to ensure that RCS, CVS and diff
                    460: X * can be found
                    461: X */
                    462: X#ifndef _PATH_DEFPATH
                    463: X#define       _PATH_DEFPATH   "/bin:/usr/bin"
                    464: X#endif
                    465: X
                    466: X/*
                    467: X * This should not normally have to be changed
                    468: X */
                    469: X#ifndef _PATH_BSHELL
                    470: X#define _PATH_BSHELL  "/bin/sh"
                    471: X#endif
                    472: X
                    473: X/*
                    474: X * Location of CVS tree, relative to the anonymous CVS user's
                    475: X * home directory
                    476: X */
                    477: X#ifndef LOCALROOT
                    478: X#define       LOCALROOT       "/cvs"
                    479: X#endif
                    480: X
                    481: X/*
                    482: X * Account and host name to be used when accessing the
                    483: X * CVS repository remotely
                    484: X */
                    485: X#ifndef HOSTNAME
                    486: X#define       HOSTNAME        "anoncvs@anoncvs1.usa.openbsd.org"
                    487: X#endif
                    488: X
                    489: X/*
                    490: X * $CVSROOT is created based on HOSTNAME and LOCALROOT above
                    491: X */
1.1       deraadt   492: X#ifndef CVSROOT
1.4       deraadt   493: X#define       CVSROOT         __CONCAT3(HOSTNAME,":",LOCALROOT)
1.1       deraadt   494: X#endif
                    495: X
1.8       beck      496: X/*
                    497: X * We define PSERVER_SUPPORT to allow anoncvssh to spawn a "cvs pserver".
                    498: X * You may undefine this if you aren't going to be running pserver.
                    499: X */
                    500: X#ifndef PSERVER_SUPPORT
                    501: X#define PSERVER_SUPPORT
                    502: X#endif
                    503: X
                    504: X/*
                    505: X * Define USE_SYSLOG if you want anoncvssh to log pserver connections
                    506: X * using syslog()
                    507: X */
                    508: X#define USE_SYSLOG
                    509: X
                    510: X#ifdef USE_SYSLOG
                    511: X#include <string.h>
                    512: X#include <syslog.h>
                    513: X#include <netinet/in.h>
                    514: X#include <sys/socket.h>
                    515: X#include <arpa/inet.h>
                    516: X#define LOG_FACILITY LOG_DAEMON
                    517: X#define LOG_PRIO LOG_INFO
                    518: X#endif
                    519: X
                    520: X/* Define ANONCVS_USER if you want anoncvssh to complain if invoked by
                    521: X * anyone other than root or ANONCVS_USER.
                    522: X */
                    523: X/* #define ANONCVS_USER "anoncvs" */
                    524: X
1.4       deraadt   525: Xint main __P((int, char *[]));
                    526: X
                    527: Xchar * const env[] = {
                    528: X      __CONCAT("PATH=",_PATH_DEFPATH),
                    529: X      __CONCAT("SHELL=",_PATH_BSHELL),
                    530: X      __CONCAT("CVSROOT=",LOCALROOT),
                    531: X      "HOME=/",
                    532: X      "CVSREADONLYFS=1",
                    533: X      NULL
                    534: X};
1.1       deraadt   535: X
                    536: Xint
                    537: Xmain(argc, argv)
                    538: Xint argc;
                    539: Xchar *argv[];
                    540: X{
                    541: X      struct passwd *pw;
1.5       deraadt   542: X#ifdef DEBUG
                    543: X      int i;
                    544: X#endif /* DEBUG */
1.1       deraadt   545: X
                    546: X      pw = getpwuid(getuid());
                    547: X      if (pw == NULL) {
                    548: X              fprintf(stderr, "no user for uid %d\n", getuid());
                    549: X              exit(1);
                    550: X      }
                    551: X      if (pw->pw_dir == NULL) {
                    552: X              fprintf(stderr, "no directory\n");
                    553: X              exit(1);
                    554: X      }
1.8       beck      555: X
                    556: X#ifdef USE_SYSLOG
                    557: X      openlog("anoncvssh", LOG_PID | LOG_NDELAY, LOG_FACILITY);
                    558: X#endif /* USE_SYSLOG */
                    559: X
                    560: X#ifdef ANONCVS_USER
                    561: X      /*
                    562: X       * I love lusers who have to test every setuid binary on my machine.
                    563: X       */
                    564: X      if (getuid() != 0 && (strcmp (pw->pw_name, ANONCVS_USER) != 0)) {
                    565: X              fprintf(stderr, "You're not supposed to be running me!\n");
                    566: X#ifdef USE_SYSLOG
                    567: X              syslog(LOG_NOTICE,
                    568: X                     "User %s(%d) invoked anoncvssh - Possible twink?",
                    569: X                     pw->pw_name, pw->pw_uid);
                    570: X#endif /* USE_SYSLOG */
                    571: X              exit(1);
                    572: X      }
                    573: X#endif /* ANONCVS_USER */
                    574: X
                    575: X
1.1       deraadt   576: X      seteuid(0);
                    577: X      if (chroot(pw->pw_dir) == -1) {
                    578: X              perror("chroot");
                    579: X              exit (1);
                    580: X      }
                    581: X      chdir("/");
1.4       deraadt   582: X      setuid(getuid());
1.1       deraadt   583: X
                    584: X      /*
                    585: X       * program now "safe"
                    586: X       */
1.6       deraadt   587: X
1.8       beck      588: X#ifdef PSERVER_SUPPORT
1.6       deraadt   589: X      /* If we want pserver functionality */
1.8       beck      590: X      if ((argc == 2) && (strcmp("pserver", argv[1]) == 0)) {
                    591: X#ifdef USE_SYSLOG
                    592: X              int slen;
                    593: X              struct sockaddr_in my_sa, peer_sa;
                    594: X              char *us, *them;
                    595: X
                    596: X              slen = sizeof(my_sa);
                    597: X              if (getsockname(0, (struct sockaddr *) &my_sa, &slen)
                    598: X                  != 0) {
                    599: X                perror("getsockname");
                    600: X                exit(1);
                    601: X              }
                    602: X              us = strdup(inet_ntoa(my_sa.sin_addr));
                    603: X              if (us == NULL) {
                    604: X                fprintf(stderr, "malloc failed\n");
                    605: X                exit(1);
                    606: X              }
                    607: X              slen = sizeof(peer_sa);
                    608: X              if (getpeername(0, (struct sockaddr *) &peer_sa, &slen)
                    609: X                  != 0) {
                    610: X                perror("getpeername");
                    611: X                exit(1);
                    612: X              }
                    613: X              them=strdup(inet_ntoa(peer_sa.sin_addr));
                    614: X              if (them == NULL) {
                    615: X                fprintf(stderr, "malloc failed\n");
                    616: X                exit(1);
                    617: X              }
                    618: X              syslog(LOG_PRIO,
                    619: X                     "pserver connection from %s:%d to %s:%d\n",
                    620: X                     them, ntohs(peer_sa.sin_port),
                    621: X                     us, ntohs(my_sa.sin_port));
                    622: X#endif /* USE_SYSLOG */
1.6       deraadt   623: X              execle("/usr/bin/cvs", "cvs", "pserver", NULL, env);
                    624: X              perror("execle: cvs");
                    625: X              fprintf(stderr, "unable to exec CVS pserver!\n");
                    626: X              exit(1);
                    627: X              /* NOTREACHED */
                    628: X      }
1.8       beck      629: X#endif
1.1       deraadt   630: X
                    631: X      if (argc != 3 ||
                    632: X              strcmp("anoncvssh",  argv[0]) != 0 ||
                    633: X              strcmp("-c",         argv[1]) != 0 ||
1.5       deraadt   634: X              (strcmp("cvs server", argv[2]) != 0 &&
                    635: X               strcmp(__CONCAT3("cvs -d ",LOCALROOT," server"), argv[2]) != 0)) {
1.1       deraadt   636: X              fprintf(stderr, "\nTo use anonymous CVS install the latest ");
                    637: X              fprintf(stderr,"version of CVS on your local machine.\n");
                    638: X              fprintf(stderr,"Then set your CVSROOT environment variable ");
                    639: X              fprintf(stderr,"to the following value:\n");
                    640: X              fprintf(stderr,"\t%s\n\n", CVSROOT);
1.5       deraadt   641: X#ifdef DEBUG
                    642: X              fprintf(stderr, "argc = %d\n", argc);
                    643: X              for (i = 0 ; i < argc ; i++)
                    644: X                      fprintf(stderr, "argv[%d] = \"%s\"\n", i, argv[i]);
                    645: X#endif /* DEBUG */
1.1       deraadt   646: X              sleep(10);
                    647: X              exit(0);
                    648: X      }
1.4       deraadt   649: X      execle("/usr/bin/cvs", "cvs", "server", NULL, env);
                    650: X      perror("execle: cvs");
1.1       deraadt   651: X      fprintf(stderr, "unable to exec CVS server!\n");
                    652: X      exit(1);
1.5       deraadt   653: X      /* NOTREACHED */
1.1       deraadt   654: X}
                    655: X
                    656: END-of-anoncvssh.c
                    657: exit
                    658: