[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.4

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>
1.3       jfb        38: #include <grp.h>
1.1       jfb        39: #include <signal.h>
                     40:
                     41: #include "cvs.h"
                     42:
                     43: #define CVSD_USER   "_cvsd"
                     44: #define CVSD_GROUP  "_cvsd"
1.2       jfb        45: #define CVSD_CONF   "/etc/cvsd.conf"
1.1       jfb        46:
                     47: #define CVSD_CHILD_DEFMIN    3
                     48: #define CVSD_CHILD_DEFMAX    5
                     49:
                     50:
                     51:
                     52: #define CVSD_FPERM  (S_IRUSR | S_IWUSR)
                     53: #define CVSD_DPERM  (S_IRWXU)
                     54:
                     55:
                     56: /* requests */
                     57: #define CVSD_MSG_GETUID    1
                     58: #define CVSD_MSG_GETUNAME  2
1.2       jfb        59: #define CVSD_MSG_GETGID    3
                     60: #define CVSD_MSG_GETGNAME  4
                     61: #define CVSD_MSG_PASSFD    5   /* server passes client file descriptor */
                     62: #define CVSD_MSG_SETIDLE   6   /* client has no further processing to do */
1.1       jfb        63:
                     64: /* replies */
                     65: #define CVSD_MSG_UID       128
                     66: #define CVSD_MSG_UNAME     129
1.2       jfb        67: #define CVSD_MSG_GID       130
                     68: #define CVSD_MSG_GNAME     131
1.1       jfb        69:
                     70: #define CVSD_MSG_SHUTDOWN  253
                     71: #define CVSD_MSG_OK        254
                     72: #define CVSD_MSG_ERROR     255
                     73:
                     74: #define CVSD_MSG_MAXLEN    256
                     75:
                     76:
1.2       jfb        77: #define CVSD_SET_ROOT        1
                     78: #define CVSD_SET_CHMIN       2
                     79: #define CVSD_SET_CHMAX       3
                     80: #define CVSD_SET_ADDR        4
                     81: #define CVSD_SET_SOCK        5
                     82:
                     83:
                     84: #define CVSD_ST_UNKNOWN      0
                     85: #define CVSD_ST_IDLE         1
                     86: #define CVSD_ST_BUSY         2
1.4     ! jfb        87: #define CVSD_ST_DEAD         3
        !            88: #define CVSD_ST_STOPPED      4
1.2       jfb        89:
                     90:
                     91:
1.1       jfb        92: /* message structure to pass data between the parent and the chrooted child */
                     93: struct cvsd_msg {
                     94:        u_int8_t  cm_type;
                     95:        u_int8_t  cm_len;    /* length of message data in bytes */
                     96: };
                     97:
                     98:
                     99: struct cvsd_child {
                    100:        pid_t  ch_pid;
                    101:        int    ch_sock;
1.2       jfb       102:        u_int  ch_state;
1.1       jfb       103:
                    104:        TAILQ_ENTRY(cvsd_child) ch_list;
                    105: };
                    106:
                    107:
1.2       jfb       108: struct cvsd_addr {
                    109:        sa_family_t ca_fam;
                    110:        union {
                    111:                struct sockaddr_in *sin;
                    112:                struct sockaddr_in6 *sin6;
                    113:        } ca_addr;
                    114: };
                    115:
1.1       jfb       116:
                    117:
                    118: extern volatile sig_atomic_t running;
                    119: extern volatile sig_atomic_t restart;
                    120:
1.3       jfb       121: extern uid_t    cvsd_uid;
                    122: extern gid_t    cvsd_gid;
1.1       jfb       123:
                    124:
                    125:
1.2       jfb       126: int                cvsd_set        (int, ...);
                    127: int                cvsd_checkperms (const char *);
                    128: int                cvsd_child_fork (struct cvsd_child **);
                    129: struct cvsd_child* cvsd_child_get  (void);
1.4     ! jfb       130: int                cvsd_child_reap (void);
1.2       jfb       131:
                    132: /* from fdpass.c */
                    133: int   cvsd_sendfd  (int, int);
                    134: int   cvsd_recvfd  (int);
1.1       jfb       135:
                    136:
1.2       jfb       137: /* from conf.y */
                    138: int    cvs_conf_read (const char *);
                    139: u_int  cvs_acl_eval  (struct cvs_op *);
1.1       jfb       140:
                    141: /* from msg.c */
                    142: int    cvsd_sendmsg (int, u_int, const void *, size_t);
                    143: int    cvsd_recvmsg (int, u_int *, void *, size_t *);
                    144:
                    145: #endif /* CVSD_H */