Annotation of src/usr.bin/cvs/cvsd.h, Revision 1.8
1.8 ! jfb 1: /* $OpenBSD: cvsd.h,v 1.7 2004/12/07 17:10:56 tedu Exp $ */
1.1 jfb 2: /*
3: * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
1.7 tedu 4: * All rights reserved.
1.1 jfb 5: *
1.7 tedu 6: * Redistribution and use in source and binary forms, with or without
7: * modification, are permitted provided that the following conditions
8: * are met:
1.1 jfb 9: *
1.7 tedu 10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
1.1 jfb 12: * 2. The name of the author may not be used to endorse or promote products
1.7 tedu 13: * derived from this software without specific prior written permission.
1.1 jfb 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
1.7 tedu 24: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.1 jfb 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"
45:
1.8 ! jfb 46: #define CVSD_PATH_CONF "/etc/cvsd.conf"
! 47: #define CVSD_PATH_CHILD "/usr/sbin/cvsd-child"
! 48:
1.1 jfb 49: #define CVSD_CHILD_DEFMAX 5
1.8 ! jfb 50: #define CVSD_CHILD_SOCKFD 3
1.1 jfb 51:
52:
53: #define CVSD_FPERM (S_IRUSR | S_IWUSR)
54: #define CVSD_DPERM (S_IRWXU)
55:
56:
57: /* requests */
58: #define CVSD_MSG_GETUID 1
59: #define CVSD_MSG_GETUNAME 2
1.2 jfb 60: #define CVSD_MSG_GETGID 3
61: #define CVSD_MSG_GETGNAME 4
62: #define CVSD_MSG_PASSFD 5 /* server passes client file descriptor */
63: #define CVSD_MSG_SETIDLE 6 /* client has no further processing to do */
1.1 jfb 64:
65: /* replies */
66: #define CVSD_MSG_UID 128
67: #define CVSD_MSG_UNAME 129
1.2 jfb 68: #define CVSD_MSG_GID 130
69: #define CVSD_MSG_GNAME 131
1.1 jfb 70:
71: #define CVSD_MSG_SHUTDOWN 253
72: #define CVSD_MSG_OK 254
73: #define CVSD_MSG_ERROR 255
74:
75: #define CVSD_MSG_MAXLEN 256
76:
77:
1.6 krapht 78: #define CVSD_SET_ROOT 1
79: #define CVSD_SET_CHMIN 2
80: #define CVSD_SET_CHMAX 3
81: #define CVSD_SET_ADDR 4
82: #define CVSD_SET_SOCK 5
83: #define CVSD_SET_USER 6
84: #define CVSD_SET_GROUP 7
85: #define CVSD_SET_MODDIR 8
1.2 jfb 86:
87:
88: #define CVSD_ST_UNKNOWN 0
89: #define CVSD_ST_IDLE 1
90: #define CVSD_ST_BUSY 2
1.4 jfb 91: #define CVSD_ST_DEAD 3
92: #define CVSD_ST_STOPPED 4
1.2 jfb 93:
94:
1.1 jfb 95: /* message structure to pass data between the parent and the chrooted child */
96: struct cvsd_msg {
97: u_int8_t cm_type;
98: u_int8_t cm_len; /* length of message data in bytes */
99: };
100:
101:
1.6 krapht 102: struct cvsd_addr {
103: sa_family_t ca_fam;
104: union {
105: struct sockaddr_in sin;
106: struct sockaddr_in6 sin6;
107: } ca_addr;
108: };
109:
110:
1.1 jfb 111: struct cvsd_child {
112: pid_t ch_pid;
113: int ch_sock;
1.2 jfb 114: u_int ch_state;
1.1 jfb 115:
1.8 ! jfb 116: TAILQ_ENTRY(cvsd_child) ch_list;
! 117: };
1.6 krapht 118:
1.8 ! jfb 119:
! 120: /*
! 121: * The following structures are used to vehicle information to and from the
! 122: * cvsd-child process handling the cvs session.
! 123: */
! 124:
! 125: struct cvsd_req {
! 126: int cr_op; /* operation (see CVS_OP_* in cvs.h) */
! 127: int cr_nfiles;
! 128: };
! 129:
! 130: struct cvsd_resp {
! 131: int cr_code;
1.1 jfb 132: };
133:
134:
1.8 ! jfb 135: /* cvsd-child response codes */
! 136: #define CVSD_RESP_OK 0
! 137: #define CVSD_RESP_INVREQ 1 /* invalid request */
! 138: #define CVSD_RESP_DENIED 2 /* access denied */
! 139: #define CVSD_RESP_SYSERR 3 /* system error */
! 140: #define CVSD_RESP_RDONLY 4 /* repository is read-only */
! 141: #define CVSD_RESP_INVFILE 5 /* one or more files are unknown */
! 142: #define CVSD_RESP_INVMOD 6
! 143:
! 144:
1.3 jfb 145: extern uid_t cvsd_uid;
146: extern gid_t cvsd_gid;
1.1 jfb 147:
148:
1.8 ! jfb 149: int cvsd_set (int, ...);
! 150: struct cvsd_child* cvsd_child_fork (int);
! 151: int cvsd_child_reap (void);
1.2 jfb 152:
1.1 jfb 153:
1.2 jfb 154: /* from conf.y */
155: int cvs_conf_read (const char *);
156: u_int cvs_acl_eval (struct cvs_op *);
1.1 jfb 157:
158: /* from msg.c */
159: int cvsd_sendmsg (int, u_int, const void *, size_t);
160: int cvsd_recvmsg (int, u_int *, void *, size_t *);
1.6 krapht 161: int cvsd_sendfd (int, int);
162: int cvsd_recvfd (int);
163:
164:
165: struct cvsd_sess* cvsd_sess_alloc (int);
166: void cvsd_sess_free (struct cvsd_sess *);
167:
1.1 jfb 168:
169: #endif /* CVSD_H */