Annotation of src/usr.bin/cvs/cvsd.h, Revision 1.5
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
1.5 ! jfb 82: #define CVSD_SET_USER 6
! 83: #define CVSD_SET_GROUP 7
1.2 jfb 84:
85:
86: #define CVSD_ST_UNKNOWN 0
87: #define CVSD_ST_IDLE 1
88: #define CVSD_ST_BUSY 2
1.4 jfb 89: #define CVSD_ST_DEAD 3
90: #define CVSD_ST_STOPPED 4
1.2 jfb 91:
92:
93:
1.1 jfb 94: /* message structure to pass data between the parent and the chrooted child */
95: struct cvsd_msg {
96: u_int8_t cm_type;
97: u_int8_t cm_len; /* length of message data in bytes */
98: };
99:
100:
101: struct cvsd_child {
102: pid_t ch_pid;
103: int ch_sock;
1.2 jfb 104: u_int ch_state;
1.1 jfb 105:
106: TAILQ_ENTRY(cvsd_child) ch_list;
107: };
108:
109:
1.2 jfb 110: struct cvsd_addr {
111: sa_family_t ca_fam;
112: union {
113: struct sockaddr_in *sin;
114: struct sockaddr_in6 *sin6;
115: } ca_addr;
116: };
117:
1.1 jfb 118:
119:
1.3 jfb 120: extern uid_t cvsd_uid;
121: extern gid_t cvsd_gid;
1.1 jfb 122:
123:
124:
1.2 jfb 125: int cvsd_set (int, ...);
126: int cvsd_checkperms (const char *);
127: int cvsd_child_fork (struct cvsd_child **);
128: struct cvsd_child* cvsd_child_get (void);
1.4 jfb 129: int cvsd_child_reap (void);
1.2 jfb 130:
131: /* from fdpass.c */
132: int cvsd_sendfd (int, int);
133: int cvsd_recvfd (int);
1.1 jfb 134:
135:
1.2 jfb 136: /* from conf.y */
137: int cvs_conf_read (const char *);
138: u_int cvs_acl_eval (struct cvs_op *);
1.1 jfb 139:
140: /* from msg.c */
141: int cvsd_sendmsg (int, u_int, const void *, size_t);
142: int cvsd_recvmsg (int, u_int *, void *, size_t *);
143:
144: #endif /* CVSD_H */