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

Annotation of www/anoncvs.shar, Revision 1.6

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: Xfind enough disk space.
                     27: X    you need roughly 300MB.
                     28: X    mount it on /open
                     29: X    if you are not able to mount it as /open, substitute it's location
                     30: X    throughout this description
                     31: X
                     32: Xcompile the anoncvssh binary
                     33: X    in the Makefile, change the variable CVSROOT
1.3       deraadt    34: X    install the binary setuid-root.
1.1       deraadt    35: X
                     36: Xcreate an account:
1.2       deraadt    37: X    anoncvs::32766:32766:Anonymous CVS User:/open/anoncvs:/open/anoncvssh
                     38: Xyes, that is right. the account has no password.
1.1       deraadt    39: X
1.6     ! deraadt    40: XFor :pserver: support (optional)
        !            41: X  - Create an entry in /etc/services
        !            42: X     cvspserver               2401/tcp                # CVS client/server operations
        !            43: X  - Create an entry in /etc/inetd.conf
        !            44: X     cvspserver       stream  tcp nowait anoncvs /open/anoncvssh anoncvssh pserver
        !            45: X
1.1       deraadt    46: Xinstall a crontab entry which runs as any user besides anoncvs (ie. run
                     47: Xit as yourself, or as root). call that user $SUPUSER
1.3       deraadt    48: X
1.6     ! deraadt    49: XFor example:  To run every three hours 'sup -v supfile', and thrice
        !            50: Xweekly 'sup -vo supfile' .. because sup is not reliable ..
        !            51: X
        !            52: X0 0,3,6,9,12,15,18,21 * * 0,2,4,5 sup -v  /open/anoncvs/sup/ss > /dev/null
        !            53: X0 0,12,15,18,21       * *  1,3,6  sup -v  /open/anoncvs/sup/ss > /dev/null
        !            54: X0 3                   * *  1,3,6  sup -vo /open/anoncvs/sup/ss > /dev/null
        !            55: X
        !            56: Xanoncvs5.usa.openbsd.org uses this particular set of entries.  A `sup
1.3       deraadt    57: X-o' is done every few days because sup is not very robust.
1.1       deraadt    58: X
                     59: Xthe file /open/sup/ss contains
                     60: X    cvs host=cvs.openbsd.org hostbase=/ base=/open/anoncvs delete
                     61: X
1.4       deraadt    62: Xthe file /open/sup/cvs/refuse should contain the single line
                     63: X    cvs/CVSROOT/history
                     64: Xif you ever fetch the file cvs/CVSROOT/history, delete it. it will
                     65: Xcause you problems.
                     66: X
                     67: Xon an IRIX or other SYSV machine, ensure that your kernel does not allow
                     68: Xa user to chown a file to another user. this will cause sup to give away
                     69: Xthe files to root before chmod'ing them readable. michaels@openbsd.org
                     70: Xknows how to fix this.
                     71: X
1.1       deraadt    72: Xmkdir /open/
                     73: Xmkdir /open/anoncvs
                     74: Xmkdir /open/anoncvs/cvs
1.6     ! deraadt    75: Xmkdir /open/anoncvs/sup
        !            76: Xchown -R $SUPUSER /open/anoncvs/cvs /open/anoncvs/sup /open/anoncvs
1.1       deraadt    77: X
                     78: Xstart filling the account up with nice stuff
                     79: X    cd /open/anoncvs
                     80: X    touch .hushlogin
                     81: X    touch .profile
                     82: X
                     83: Xput a message like the following in .plan:
1.6     ! deraadt    84: X    To use anonymous CVS install the latest version of CVS on your local
        !            85: X    machine.
1.1       deraadt    86: X    Then set your CVSROOT environment variable to the following value:
                     87: X            anoncvs@anoncvs.openbsd.org:/cvs
                     88: X
                     89: X    chown root.wheel .hushlogin .profile .plan
                     90: X
                     91: X    mkdir bin dev tmp usr var etc
                     92: X    cp /bin/{cat,pwd,rm,sh} bin/
                     93: X
                     94: Xusing mknod, make a dev/null that has the same major/minor numbers as
                     95: X    your /dev/null, and make it mode 666.
                     96: X
                     97: Xsome shared library systems require a dev/zero created in the same way
                     98: X
                     99: Xfill etc space for the account
                    100: X    cp /etc/{group,hosts,passwd,protocols} etc/
                    101: X    cp /etc/{pwd.db,resolv.conf,services,ttys} etc/
                    102: X    modify these files to suit your idea of system security
                    103: X
1.3       deraadt   104: Xanoncvssh (by setting the environment variable CVSREADONLYFS) uses an
                    105: Xtiny extension provided in the openbsd cvs server code which permits
                    106: Xthe use of read-only cvs repositories.  therefore you MUST compile the
                    107: Xopenbsd version of cvs.  luckily this is not a problem on a
                    108: Xnon-openbsd machine since the cvs sources are imported verbatim into
                    109: Xthe openbsd tree.  they are in gnu/usr.bin/cvs.  The sources are
                    110: Xintegrated such that Makefile.bsd-wrapper knows how to build the
                    111: Xsources on an OpenBSD machine, using obj directories.
1.1       deraadt   112: X
                    113: Xcreate tmp space for the account
                    114: X    cd var; ln -s ../tmp tmp
                    115: X    chmod a+rwx tmp
                    116: X
                    117: X    mkdir usr/{bin,lib}
                    118: X    cp /usr/bin/{ci,co,cvs,diff,diff3,gzip,rcs,rcsclean} usr/bin/
                    119: X    cp /usr/bin/{rcsdiff,rcsfreeze,rcsmerge,rlog,sdiff,zdiff} usr/bin/
1.6     ! deraadt   120: X    cp /usr/bin/grep usr/bin
1.1       deraadt   121: X
                    122: Xif your system has ld.so in /usr/libexec,
                    123: X    mkdir usr/libexec
                    124: X    cp /usr/libexec/ld.so usr/libexec/
                    125: X
                    126: Xif using shared libraries, copy the shared libs you might need:
                    127: X    cp /usr/lib/lib*.so.* usr/lib/
                    128: X
                    129: Xas a final pass, make sure that all the files you have just created are
                    130: Xnot world writeable (except dev/null)
                    131: X
1.3       deraadt   132: Xsend mail to deraadt@openbsd.org
                    133: X1) to have sup permissions granted.
                    134: X2) to have an anoncvsN.COUNTRY.openbsd.org alias created
                    135: X3) to have your site mentioned in the http://www.openbsd.org page.
                    136: X
                    137: XExample layout. In this example "deraadt" is the $SUPUSER.
                    138: X
                    139: X[eap open 5 ]> cd /open
                    140: X[eap open 6 ]> ls -alF
                    141: Xtotal 46
                    142: Xdrwxr-xr-x   7 root     wheel    512 Feb 20 09:58 ./
                    143: Xdrwxr-xr-x  17 root     wheel    512 Jun 14 14:05 ../
                    144: Xdrwxr-xr-x   9 root     wheel    512 Jan  3 21:55 anoncvs/
                    145: X---s--x--x   1 root     bin    16384 Nov 30  1995 anoncvssh*
                    146: Xlrwxr-xr-x   1 root     wheel     11 Jan  3 21:52 cvs@ -> anoncvs/cvs
                    147: Xdrwxr-xr-x   5 root     wheel    512 Feb 22 13:22 ftp/
                    148: Xdrwxrwxrwt   2 anoncvs  wheel   1024 Jan  1 13:18 lost+found/
                    149: Xdrwxr-xr-x   4 root     wheel    512 Nov 30  1995 src/
                    150: Xdrwxrwxr-x   3 deraadt  wheel    512 Dec  4  1995 sup/
                    151: X[eap open 7 ]> cd anoncvs
                    152: X[eap anoncvs 8 ]> ls -alF
                    153: Xtotal 20
                    154: Xdrwxr-xr-x  9 root     wheel  512 Jan  3 21:55 ./
                    155: Xdrwxr-xr-x  7 root     wheel  512 Feb 20 09:58 ../
                    156: X-r--r--r--  1 root     wheel    0 Nov 30  1995 .hushlogin
                    157: X-r--r--r--  1 root     wheel  188 Nov 30  1995 .plan
                    158: X-r--r--r--  1 root     wheel    0 Nov 29  1995 .profile
                    159: Xdrwxrwxrwx  2 deraadt  wheel  512 Nov 29  1995 bin/
                    160: Xdrwxrwxr-x  6 deraadt  cvs    512 Jun 16 20:28 cvs/
                    161: Xdrwxr-xr-x  2 root     wheel  512 Nov 30  1995 dev/
                    162: Xdrwxr-xr-x  2 root     wheel  512 Nov 29  1995 etc/
                    163: Xdrwxrwxrwx  3 root     wheel  512 Jun 22 07:42 tmp/
                    164: Xdrwxr-xr-x  5 deraadt  wheel  512 Nov 30  1995 usr/
                    165: Xdrwxr-xr-x  2 root     wheel  512 Jan  3 21:55 var/
                    166: X[eap anoncvs 8 ]> ls -alFR bin usr tmp etc dev
                    167: Xbin:
                    168: Xtotal 948
                    169: Xdrwxrwxrwx  2 deraadt  wheel     512 Nov 29  1995 ./
                    170: Xdrwxr-xr-x  9 root     wheel     512 Jan  3 21:55 ../
                    171: X--wx--x--x  1 deraadt  wheel   40960 Jun 18 09:45 cat*
                    172: X--wx--x--x  1 deraadt  wheel   40960 Jun 18 09:45 pwd*
                    173: X--wx--x--x  1 deraadt  wheel  122880 Jun 18 09:45 rm*
                    174: X--wx--x--x  1 deraadt  wheel  262144 Jun 18 09:45 sh*
                    175: X
                    176: Xdev:
                    177: Xtotal 4
                    178: Xdrwxr-xr-x  2 root  wheel       512 Nov 30  1995 ./
                    179: Xdrwxr-xr-x  9 root  wheel       512 Jan  3 21:55 ../
                    180: Xcrw-rw-rw-  1 root  wheel    2,   2 Nov 30  1995 null
                    181: X
                    182: Xetc:
                    183: Xtotal 112
                    184: Xdrwxr-xr-x  2 root  wheel    512 Nov 29  1995 ./
                    185: Xdrwxr-xr-x  9 root  wheel    512 Jan  3 21:55 ../
                    186: X-rw-r--r--  1 root  wheel    252 Nov 29  1995 group
                    187: X-rw-r--r--  1 root  wheel    296 Nov 29  1995 hosts
                    188: X-rw-r--r--  1 root  wheel    540 Nov 29  1995 passwd
                    189: X-rw-r--r--  1 root  wheel   1094 Nov 29  1995 protocols
                    190: X-rw-r--r--  1 root  wheel  40960 Nov 29  1995 pwd.db
                    191: X-rw-r--r--  1 root  wheel     89 Nov 29  1995 resolv.conf
                    192: X-rw-r--r--  1 root  wheel   5529 Nov 29  1995 services
                    193: X-rw-r--r--  1 root  wheel   1361 Nov 29  1995 ttys
                    194: X
                    195: Xusr:
                    196: Xtotal 10
                    197: Xdrwxr-xr-x  5 deraadt  wheel   512 Nov 30  1995 ./
                    198: Xdrwxr-xr-x  9 root     wheel   512 Jan  3 21:55 ../
                    199: Xdrwxr-xr-x  2 deraadt  wheel   512 Nov 30  1995 bin/
                    200: Xdrwxr-xr-x  2 deraadt  wheel  1024 Jun 18 09:50 lib/
                    201: Xdrwxr-xr-x  2 deraadt  wheel   512 Nov 29  1995 libexec/
                    202: X
                    203: Xusr/bin:
                    204: Xtotal 1968
                    205: Xdrwxr-xr-x  2 deraadt  wheel     512 Nov 30  1995 ./
                    206: Xdrwxr-xr-x  5 deraadt  wheel     512 Nov 30  1995 ../
                    207: X--wx--x--x  1 deraadt  wheel   73728 Jun 18 09:46 ci*
                    208: X--wx--x--x  1 deraadt  wheel   73728 Jun 18 09:46 co*
                    209: X--wx--x--x  1 deraadt  wheel  317787 Jun 18 09:46 cvs*
                    210: X--wx--x--x  1 deraadt  wheel   73728 Jun 18 09:46 diff*
                    211: X--wx--x--x  1 deraadt  wheel   24576 Jun 18 09:46 diff3*
                    212: X--wx--x--x  1 deraadt  wheel   90112 Jun 18 09:46 gzip*
                    213: X--wx--x--x  1 deraadt  wheel   73728 Jun 18 09:46 rcs*
                    214: X--wx--x--x  1 deraadt  wheel   65536 Jun 18 09:46 rcsclean*
                    215: X--wx--x--x  1 deraadt  wheel   57344 Jun 18 09:46 rcsdiff*
                    216: X--wx--x--x  1 deraadt  wheel    3228 Jun 18 09:46 rcsfreeze*
                    217: X--wx--x--x  1 deraadt  wheel   57344 Jun 18 09:46 rcsmerge*
                    218: X--wx--x--x  1 deraadt  wheel   57344 Jun 18 09:46 rlog*
                    219: X--wx--x--x  1 deraadt  wheel   24576 Jun 18 09:46 sdiff*
                    220: X--wx--x--x  1 deraadt  wheel    2006 Jun 18 09:46 zdiff*
                    221: X
                    222: Xusr/lib:
                    223: Xtotal 5594
                    224: Xdrwxr-xr-x  2 deraadt  wheel    1024 Jun 18 09:50 ./
                    225: Xdrwxr-xr-x  5 deraadt  wheel     512 Nov 30  1995 ../
                    226: X-rw-r--r--  1 deraadt  wheel   16665 Jun 18 09:50 libacl.so.4.0
                    227: X-rw-r--r--  1 deraadt  wheel  351730 Jun 18 09:50 libc.so.12.3
                    228: X-rw-r--r--  1 deraadt  wheel  377359 Jun 18 09:50 libc.so.12.6
                    229: X-rw-r--r--  1 deraadt  wheel   16608 Jun 18 09:50 libcrypt.so.0.0
                    230: X-rw-r--r--  1 deraadt  wheel   16465 Jun 18 09:50 libcrypt.so.1.0
                    231: X-rw-r--r--  1 deraadt  wheel   44424 Jun 18 09:50 libcurses.so.2.1
                    232: X-rw-r--r--  1 deraadt  wheel   86198 Jun 18 09:50 libcurses.so.3.0
                    233: X-rw-r--r--  1 deraadt  wheel   42254 Jun 18 09:50 libdes.so.4.1
                    234: X-rw-r--r--  1 deraadt  wheel   66099 Jun 18 09:50 libedit.so.0.0
                    235: X-rw-r--r--  1 deraadt  wheel   43131 Jun 18 09:50 libform.so.0.0
                    236: X-rw-r--r--  1 deraadt  wheel  387976 Jun 18 09:50 libg++.so.2.0
                    237: X-rw-r--r--  1 deraadt  wheel  305738 Jun 18 09:50 libg++.so.27.1
                    238: X-rw-r--r--  1 deraadt  wheel   25544 Jun 18 09:50 libgnumalloc.so.0.0
                    239: X-rw-r--r--  1 deraadt  wheel   42696 Jun 18 09:50 libiberty.so.0.0
                    240: X-rw-r--r--  1 deraadt  wheel   25282 Jun 18 09:50 libkadm.so.4.0
                    241: X-rw-r--r--  1 deraadt  wheel   16610 Jun 18 09:50 libkafs.so.4.0
                    242: X-rw-r--r--  1 deraadt  wheel   25539 Jun 18 09:50 libkdb.so.4.0
                    243: X-rw-r--r--  1 deraadt  wheel   59943 Jun 18 09:50 libkrb.so.4.0
                    244: X-rw-r--r--  1 deraadt  wheel   25328 Jun 18 09:50 libkvm.so.4.0
                    245: X-rw-r--r--  1 deraadt  wheel  102104 Jun 18 09:50 libm.so.0.1
                    246: X-rw-r--r--  1 deraadt  wheel   26540 Jun 18 09:50 libmenu.so.0.0
                    247: X-rw-r--r--  1 deraadt  wheel   44424 Jun 18 09:50 libocurses.so.2.1
                    248: X-rw-r--r--  1 deraadt  wheel   16881 Jun 18 09:50 libpanel.so.0.0
                    249: X-rw-r--r--  1 deraadt  wheel   60222 Jun 18 09:50 libpcap.so.0.0
                    250: X-rw-r--r--  1 deraadt  wheel   25060 Jun 18 09:50 libresolv.so.1.0
                    251: X-rw-r--r--  1 deraadt  wheel   16465 Jun 18 09:50 libresolv.so.2.0
                    252: X-rw-r--r--  1 deraadt  wheel   33538 Jun 18 09:50 libskey.so.0.0
                    253: X-rw-r--r--  1 deraadt  wheel   25764 Jun 18 09:50 libss.so.4.0
                    254: X-rw-r--r--  1 deraadt  wheel  277954 Jun 18 09:50 libstdc++.so.27.1
                    255: X-rw-r--r--  1 deraadt  wheel   16835 Jun 18 09:50 libtelnet.so.1.0
                    256: X-rw-r--r--  1 deraadt  wheel   16691 Jun 18 09:50 libtermcap.so.0.0
                    257: X-rw-r--r--  1 deraadt  wheel   16691 Jun 18 09:50 libtermlib.so.0.0
                    258: X-rw-r--r--  1 deraadt  wheel   75039 Jun 18 09:50 libtermlib.so.1.0
                    259: X-rw-r--r--  1 deraadt  wheel   16625 Jun 18 09:50 libutil.so.3.1
                    260: X-rw-r--r--  1 deraadt  wheel   25628 Jun 18 09:50 libutil.so.3.2
                    261: X
                    262: Xusr/libexec:
                    263: Xtotal 100
                    264: Xdrwxr-xr-x  2 deraadt  wheel    512 Nov 29  1995 ./
                    265: Xdrwxr-xr-x  5 deraadt  wheel    512 Nov 30  1995 ../
                    266: X-rwxr-xr-x  1 deraadt  wheel  49152 Jun 18 09:47 ld.so*
                    267: X
                    268: X[eap anoncvs 14 ]> ls cvs
                    269: XCVSROOT/        src/            sup/            www/
1.6     ! deraadt   270: X[eap anoncvs 15 ]> cd /open
1.3       deraadt   271: X[eap anoncvs 16 ]> ls -alF sup
                    272: Xtotal 8
                    273: Xdrwxrwxr-x  3 deraadt  wheel  512 Dec  4  1995 ./
                    274: Xdrwxr-xr-x  7 root     wheel  512 Feb 20 09:58 ../
                    275: Xdrwxr-xr-x  2 deraadt  wheel  512 Jun 22 06:05 cvs/
                    276: X-rw-rw-r--  1 deraadt  wheel   54 Dec  4  1995 ss
                    277: X
                    278: X
                    279: XThat's pretty much it.
1.6     ! deraadt   280: X
        !           281: XFrom Todd Fries <toddf@acm.org> to the adventurous.
        !           282: XA note for those installing anoncvs on non-OpenBSD operating systems.
        !           283: XYou are in for some fun.
        !           284: X
        !           285: XFor OSF1, on a DEC alpha, I had to do the following in addition to the
        !           286: Xabove:
        !           287: X
        !           288: X- I do not know how to setup dynamic libraries on osf1 and as a result
        !           289: X  everything had to be compiled statically.
        !           290: X- Therefore, everything but /bin/sh I had to recmpile in order to
        !           291: X  get the chroot setup.  In order that there be no guesswork
        !           292: X  involved, the following packages' binaries must exist in the chroot
        !           293: X  environment:
        !           294: X
        !           295: X GNU
        !           296: X   cvs         (from the OpenBSD source tree)
        !           297: X   diff[utils] (unless you're running *BSD, probably better get it from a gnu
        !           298: X                 mirror...the Makefile doesn't work otherwise)
        !           299: X   rcs         (from the OpenBSD source tree)
        !           300: X
        !           301: XSome notes on compiling.
        !           302: X
        !           303: X   rcs must have diff3 capable of diff3 -m during configure.
        !           304: X   OSF doesn't by default, thus I had to compile diffutils first.
        !           305: X
        !           306: X   cvs fails to install if you don't have makeinfo ... just search for the
        !           307: X   string ' install-info$' with regex and remove it from the Makefile for the
        !           308: X   install and you'll be fine, or install 'texinfo', your choice.
1.1       deraadt   309: END-of-README
                    310: echo x - anoncvssh.c
                    311: sed 's/^X//' >anoncvssh.c << 'END-of-anoncvssh.c'
                    312: X/*
                    313: X * anoncvssh
                    314: X */
                    315: X
1.4       deraadt   316: X#include <stdio.h>
                    317: X#include <stdlib.h>
                    318: X#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)
                    319: X#include <paths.h>
                    320: X#endif
                    321: X#include <pwd.h>
                    322: X#include <unistd.h>
                    323: X#include <sys/types.h>
                    324: X
                    325: X#ifndef __CONCAT
                    326: X#if defined(__STDC__) || defined(__cplusplus)
                    327: X#define __CONCAT(x,y)         x ## y
                    328: X#else
                    329: X#define __CONCAT(x,y)         x/**/y
                    330: X#endif
                    331: X#endif
                    332: X
                    333: X#ifndef __CONCAT3
                    334: X#if defined(__STDC__) || defined(__cplusplus)
                    335: X#define __CONCAT3(x,y,z)      x ## y ## z
                    336: X#else
                    337: X#define __CONCAT3(x,y,z)      x/**/y/**/z
                    338: X#endif
                    339: X#endif
                    340: X
                    341: X#ifndef __P
                    342: X#if defined(__STDC__) || defined(__cplusplus)
                    343: X#define       __P(protos)     protos          /* full-blown ANSI C */
                    344: X#else
                    345: X#define       __P(protos)     ()              /* traditional C preprocessor */
                    346: X#endif
                    347: X#endif
                    348: X
                    349: X/*
                    350: X * You may need to change this path to ensure that RCS, CVS and diff
                    351: X * can be found
                    352: X */
                    353: X#ifndef _PATH_DEFPATH
                    354: X#define       _PATH_DEFPATH   "/bin:/usr/bin"
                    355: X#endif
                    356: X
                    357: X/*
                    358: X * This should not normally have to be changed
                    359: X */
                    360: X#ifndef _PATH_BSHELL
                    361: X#define _PATH_BSHELL  "/bin/sh"
                    362: X#endif
                    363: X
                    364: X/*
                    365: X * Location of CVS tree, relative to the anonymous CVS user's
                    366: X * home directory
                    367: X */
                    368: X#ifndef LOCALROOT
                    369: X#define       LOCALROOT       "/cvs"
                    370: X#endif
                    371: X
                    372: X/*
                    373: X * Account and host name to be used when accessing the
                    374: X * CVS repository remotely
                    375: X */
                    376: X#ifndef HOSTNAME
                    377: X#define       HOSTNAME        "anoncvs@anoncvs1.usa.openbsd.org"
                    378: X#endif
                    379: X
                    380: X/*
                    381: X * $CVSROOT is created based on HOSTNAME and LOCALROOT above
                    382: X */
1.1       deraadt   383: X#ifndef CVSROOT
1.4       deraadt   384: X#define       CVSROOT         __CONCAT3(HOSTNAME,":",LOCALROOT)
1.1       deraadt   385: X#endif
                    386: X
1.4       deraadt   387: Xint main __P((int, char *[]));
                    388: X
                    389: Xchar * const env[] = {
                    390: X      __CONCAT("PATH=",_PATH_DEFPATH),
                    391: X      __CONCAT("SHELL=",_PATH_BSHELL),
                    392: X      __CONCAT("CVSROOT=",LOCALROOT),
                    393: X      "HOME=/",
                    394: X      "CVSREADONLYFS=1",
                    395: X      NULL
                    396: X};
1.1       deraadt   397: X
                    398: Xint
                    399: Xmain(argc, argv)
                    400: Xint argc;
                    401: Xchar *argv[];
                    402: X{
                    403: X      struct passwd *pw;
1.5       deraadt   404: X#ifdef DEBUG
                    405: X      int i;
                    406: X#endif /* DEBUG */
1.1       deraadt   407: X
                    408: X      pw = getpwuid(getuid());
                    409: X      if (pw == NULL) {
                    410: X              fprintf(stderr, "no user for uid %d\n", getuid());
                    411: X              exit(1);
                    412: X      }
                    413: X      if (pw->pw_dir == NULL) {
                    414: X              fprintf(stderr, "no directory\n");
                    415: X              exit(1);
                    416: X      }
                    417: X      seteuid(0);
                    418: X      if (chroot(pw->pw_dir) == -1) {
                    419: X              perror("chroot");
                    420: X              exit (1);
                    421: X      }
                    422: X      chdir("/");
1.4       deraadt   423: X      setuid(getuid());
1.1       deraadt   424: X
                    425: X      /*
                    426: X       * program now "safe"
                    427: X       */
1.6     ! deraadt   428: X
        !           429: X      /* If we want pserver functionality */
        !           430: X      if (strcmp("pserver", argv[1])) {
        !           431: X              execle("/usr/bin/cvs", "cvs", "pserver", NULL, env);
        !           432: X              perror("execle: cvs");
        !           433: X              fprintf(stderr, "unable to exec CVS pserver!\n");
        !           434: X              exit(1);
        !           435: X              /* NOTREACHED */
        !           436: X      }
1.1       deraadt   437: X
                    438: X      if (argc != 3 ||
                    439: X              strcmp("anoncvssh",  argv[0]) != 0 ||
                    440: X              strcmp("-c",         argv[1]) != 0 ||
1.5       deraadt   441: X              (strcmp("cvs server", argv[2]) != 0 &&
                    442: X               strcmp(__CONCAT3("cvs -d ",LOCALROOT," server"), argv[2]) != 0)) {
1.1       deraadt   443: X
                    444: X              fprintf(stderr, "\nTo use anonymous CVS install the latest ");
                    445: X              fprintf(stderr,"version of CVS on your local machine.\n");
                    446: X              fprintf(stderr,"Then set your CVSROOT environment variable ");
                    447: X              fprintf(stderr,"to the following value:\n");
                    448: X              fprintf(stderr,"\t%s\n\n", CVSROOT);
1.5       deraadt   449: X#ifdef DEBUG
                    450: X              fprintf(stderr, "argc = %d\n", argc);
                    451: X              for (i = 0 ; i < argc ; i++)
                    452: X                      fprintf(stderr, "argv[%d] = \"%s\"\n", i, argv[i]);
                    453: X#endif /* DEBUG */
1.1       deraadt   454: X              sleep(10);
                    455: X              exit(0);
                    456: X      }
                    457: X
1.4       deraadt   458: X      execle("/usr/bin/cvs", "cvs", "server", NULL, env);
                    459: X      perror("execle: cvs");
1.1       deraadt   460: X      fprintf(stderr, "unable to exec CVS server!\n");
                    461: X      exit(1);
1.5       deraadt   462: X      /* NOTREACHED */
1.1       deraadt   463: X}
                    464: X
                    465: END-of-anoncvssh.c
                    466: exit
                    467: