[BACK]Return to cvsd.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / cvs

Annotation of src/usr.bin/cvs/cvsd.h, Revision 1.2

1.1       jfb         1: /*     $OpenBSD$       */
                      2: /*
                      3:  * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
                      4:  * All rights reserved.
                      5:  *
                      6:  * Redistribution and use in source and binary forms, with or without
                      7:  * modification, are permitted provided that the following conditions
                      8:  * are met:
                      9:  *
                     10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
                     12:  * 2. The name of the author may not be used to endorse or promote products
                     13:  *    derived from this software without specific prior written permission.
                     14:  *
                     15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
                     16:  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
                     17:  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
                     18:  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
                     19:  * EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLUDING, BUT NOT LIMITED TO,
                     20:  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
                     21:  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
                     22:  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
                     23:  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
                     24:  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     25:  */
                     26:
                     27: #ifndef CVSD_H
                     28: #define CVSD_H
                     29:
                     30: #include <sys/types.h>
                     31: #include <sys/queue.h>
                     32: #include <sys/stat.h>
1.2     ! jfb        33: #include <sys/socket.h>
        !            34:
        !            35: #include <netinet/in.h>
1.1       jfb        36:
                     37: #include <pwd.h>
                     38: #include <signal.h>
                     39:
                     40: #include "cvs.h"
                     41:
                     42: #define CVSD_USER   "_cvsd"
                     43: #define CVSD_GROUP  "_cvsd"
1.2     ! jfb        44: #define CVSD_CONF   "/etc/cvsd.conf"
1.1       jfb        45:
                     46: #define CVSD_CHILD_DEFMIN    3
                     47: #define CVSD_CHILD_DEFMAX    5
                     48:
                     49:
                     50:
                     51: #define CVSD_FPERM  (S_IRUSR | S_IWUSR)
                     52: #define CVSD_DPERM  (S_IRWXU)
                     53:
                     54:
                     55: /* requests */
                     56: #define CVSD_MSG_GETUID    1
                     57: #define CVSD_MSG_GETUNAME  2
1.2     ! jfb        58: #define CVSD_MSG_GETGID    3
        !            59: #define CVSD_MSG_GETGNAME  4
        !            60: #define CVSD_MSG_PASSFD    5   /* server passes client file descriptor */
        !            61: #define CVSD_MSG_SETIDLE   6   /* client has no further processing to do */
1.1       jfb        62:
                     63: /* replies */
                     64: #define CVSD_MSG_UID       128
                     65: #define CVSD_MSG_UNAME     129
1.2     ! jfb        66: #define CVSD_MSG_GID       130
        !            67: #define CVSD_MSG_GNAME     131
1.1       jfb        68:
                     69: #define CVSD_MSG_SHUTDOWN  253
                     70: #define CVSD_MSG_OK        254
                     71: #define CVSD_MSG_ERROR     255
                     72:
                     73: #define CVSD_MSG_MAXLEN    256
                     74:
                     75:
1.2     ! jfb        76: #define CVSD_SET_ROOT        1
        !            77: #define CVSD_SET_CHMIN       2
        !            78: #define CVSD_SET_CHMAX       3
        !            79: #define CVSD_SET_ADDR        4
        !            80: #define CVSD_SET_SOCK        5
        !            81:
        !            82:
        !            83: #define CVSD_ST_UNKNOWN      0
        !            84: #define CVSD_ST_IDLE         1
        !            85: #define CVSD_ST_BUSY         2
        !            86:
        !            87:
        !            88:
1.1       jfb        89: /* message structure to pass data between the parent and the chrooted child */
                     90: struct cvsd_msg {
                     91:        u_int8_t  cm_type;
                     92:        u_int8_t  cm_len;    /* length of message data in bytes */
                     93: };
                     94:
                     95:
                     96: struct cvsd_child {
                     97:        pid_t  ch_pid;
                     98:        int    ch_sock;
1.2     ! jfb        99:        u_int  ch_state;
1.1       jfb       100:
                    101:        TAILQ_ENTRY(cvsd_child) ch_list;
                    102: };
                    103:
                    104:
1.2     ! jfb       105: struct cvsd_addr {
        !           106:        sa_family_t ca_fam;
        !           107:        union {
        !           108:                struct sockaddr_in *sin;
        !           109:                struct sockaddr_in6 *sin6;
        !           110:        } ca_addr;
        !           111: };
        !           112:
1.1       jfb       113:
                    114:
                    115: extern volatile sig_atomic_t running;
                    116: extern volatile sig_atomic_t restart;
                    117:
                    118:
                    119:
                    120:
1.2     ! jfb       121: int                cvsd_set        (int, ...);
        !           122: int                cvsd_checkperms (const char *);
        !           123: int                cvsd_child_fork (struct cvsd_child **);
        !           124: struct cvsd_child* cvsd_child_get  (void);
        !           125: int                cvsd_child_reap (struct cvsd_child *);
        !           126:
        !           127: /* from fdpass.c */
        !           128: int   cvsd_sendfd  (int, int);
        !           129: int   cvsd_recvfd  (int);
1.1       jfb       130:
                    131:
1.2     ! jfb       132: /* from conf.y */
        !           133: int    cvs_conf_read (const char *);
        !           134: u_int  cvs_acl_eval  (struct cvs_op *);
1.1       jfb       135:
                    136: /* from msg.c */
                    137: int    cvsd_sendmsg (int, u_int, const void *, size_t);
                    138: int    cvsd_recvmsg (int, u_int *, void *, size_t *);
                    139:
                    140: #endif /* CVSD_H */