Annotation of src/usr.bin/cvs/cvsd.h, Revision 1.6
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.6 ! krapht 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: #define CVSD_SET_USER 6
! 83: #define CVSD_SET_GROUP 7
! 84: #define CVSD_SET_MODDIR 8
1.2 jfb 85:
86:
87: #define CVSD_ST_UNKNOWN 0
88: #define CVSD_ST_IDLE 1
89: #define CVSD_ST_BUSY 2
1.4 jfb 90: #define CVSD_ST_DEAD 3
91: #define CVSD_ST_STOPPED 4
1.2 jfb 92:
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: #define CVSD_SESS_LOCAL 0
! 111: #define CVSD_SESS_REMOTE 1
! 112:
! 113: struct cvsd_sess {
! 114: int cs_fd;
! 115: int cs_type;
! 116: uid_t cs_uid; /* user ID of the session */
! 117: struct cvsd_addr cs_raddr; /* remote address */
! 118: };
! 119:
! 120:
1.1 jfb 121: struct cvsd_child {
122: pid_t ch_pid;
123: int ch_sock;
1.2 jfb 124: u_int ch_state;
1.1 jfb 125:
1.6 ! krapht 126: struct cvsd_sess *ch_sess;
! 127:
1.1 jfb 128: TAILQ_ENTRY(cvsd_child) ch_list;
129: };
130:
131:
132:
1.3 jfb 133: extern uid_t cvsd_uid;
134: extern gid_t cvsd_gid;
1.1 jfb 135:
136:
137:
1.2 jfb 138: int cvsd_set (int, ...);
139: int cvsd_checkperms (const char *);
140: int cvsd_child_fork (struct cvsd_child **);
141: struct cvsd_child* cvsd_child_get (void);
1.4 jfb 142: int cvsd_child_reap (void);
1.2 jfb 143:
1.1 jfb 144:
1.2 jfb 145: /* from conf.y */
146: int cvs_conf_read (const char *);
147: u_int cvs_acl_eval (struct cvs_op *);
1.1 jfb 148:
149: /* from msg.c */
150: int cvsd_sendmsg (int, u_int, const void *, size_t);
151: int cvsd_recvmsg (int, u_int *, void *, size_t *);
1.6 ! krapht 152: int cvsd_sendfd (int, int);
! 153: int cvsd_recvfd (int);
! 154:
! 155:
! 156: struct cvsd_sess* cvsd_sess_alloc (int);
! 157: void cvsd_sess_free (struct cvsd_sess *);
! 158:
1.1 jfb 159:
160: #endif /* CVSD_H */