~ubuntu-branches/ubuntu/trusty/vsftpd/trusty-proposed

1 by Daniel Jacobowitz
Import upstream version 1.0.0
1
#ifndef VSF_PRIVSOCK_H
2
#define VSF_PRIVSOCK_H
3
4
struct mystr;
5
struct vsf_session;
6
7
/* priv_sock_init()
8
 * PURPOSE
9
 * Initialize the priv_sock system, by opening the communications sockets.
1.2.6 by Daniel Baumann
Import upstream version 2.1.1~pre1
10
 *
1 by Daniel Jacobowitz
Import upstream version 1.0.0
11
 * PARAMETERS
12
 * p_sess       - the current session object
13
 */
14
void priv_sock_init(struct vsf_session* p_sess);
15
1.2.6 by Daniel Baumann
Import upstream version 2.1.1~pre1
16
/* priv_sock_close()
17
 * PURPOSE
18
 * Closes any open file descriptors relating to the priv_sock system.
19
 *
20
 * PARAMETERS
21
 * p_sess       - the current session object
22
 */
23
void priv_sock_close(struct vsf_session* p_sess);
24
25
/* priv_sock_set_parent_context()
26
 * PURPOSE
27
 * Closes the child's fd, e.g. p_sess->child_fd.
28
 *
29
 * PARAMETERS
30
 * p_sess       - the current session object
31
 */
32
void priv_sock_set_parent_context(struct vsf_session* p_sess);
33
34
/* priv_sock_set_child_context()
35
 * PURPOSE
36
 * Closes the parent's fd, e.g. p_sess->parent_fd.
37
 *
38
 * PARAMETERS
39
 * p_sess       - the current session object
40
 */
41
void priv_sock_set_child_context(struct vsf_session* p_sess);
42
1 by Daniel Jacobowitz
Import upstream version 1.0.0
43
/* priv_sock_send_cmd()
44
 * PURPOSE
1.1.1 by LaMont Jones
Import upstream version 2.0.1
45
 * Sends a command, typically to the privileged side of the channel.
1 by Daniel Jacobowitz
Import upstream version 1.0.0
46
 * PARAMETERS
1.1.1 by LaMont Jones
Import upstream version 2.0.1
47
 * fd           - the fd on which to send the command
1 by Daniel Jacobowitz
Import upstream version 1.0.0
48
 * cmd          - the command to send
49
 */
1.1.1 by LaMont Jones
Import upstream version 2.0.1
50
void priv_sock_send_cmd(int fd, char cmd);
1 by Daniel Jacobowitz
Import upstream version 1.0.0
51
52
/* priv_sock_send_str()
53
 * PURPOSE
1.1.1 by LaMont Jones
Import upstream version 2.0.1
54
 * Sends a string to the other side of the channel.
1 by Daniel Jacobowitz
Import upstream version 1.0.0
55
 * PARAMETERS
1.1.1 by LaMont Jones
Import upstream version 2.0.1
56
 * fd           - the fd on which to send the string
1 by Daniel Jacobowitz
Import upstream version 1.0.0
57
 * p_str        - the string to send
58
 */
1.1.1 by LaMont Jones
Import upstream version 2.0.1
59
void priv_sock_send_str(int fd, const struct mystr* p_str);
1 by Daniel Jacobowitz
Import upstream version 1.0.0
60
1.2.6 by Daniel Baumann
Import upstream version 2.1.1~pre1
61
/* priv_sock_send_buf()
62
 * PURPOSE
63
 * Sends a buffer to the other side of the channel. The protocol used is the
64
 * same as priv_sock_send_str()
65
 * PARAMETERS
66
 * fd           - the fd on which to send the buffer
67
 * p_buf        - the buffer to send
68
 * len          - length of the buffer
69
 */
70
void priv_sock_send_buf(int fd, const char* p_buf, unsigned int len);
71
72
/* priv_sock_recv_buf()
73
 * PURPOSE
74
 * Receives a buffer from the other side of the channel. The protocol used is
75
 * the same as priv_sock_recv_str()
76
 * PARAMETERS
77
 * fd           - the fd on which to receive the buffer
78
 * p_buf        - the buffer to write into
79
 * len          - length of the buffer
80
 */
81
void priv_sock_recv_buf(int fd, char* p_buf, unsigned int len);
82
1 by Daniel Jacobowitz
Import upstream version 1.0.0
83
/* priv_sock_get_result()
84
 * PURPOSE
1.1.1 by LaMont Jones
Import upstream version 2.0.1
85
 * Receives a response, typically from the privileged side of the channel.
1 by Daniel Jacobowitz
Import upstream version 1.0.0
86
 * PARAMETERS
1.1.1 by LaMont Jones
Import upstream version 2.0.1
87
 * fd           - the fd on which to receive the response
1 by Daniel Jacobowitz
Import upstream version 1.0.0
88
 * RETURNS
89
 * The response code.
90
 */
1.1.1 by LaMont Jones
Import upstream version 2.0.1
91
char priv_sock_get_result(int fd);
1 by Daniel Jacobowitz
Import upstream version 1.0.0
92
93
/* priv_sock_get_cmd()
94
 * PURPOSE
1.1.1 by LaMont Jones
Import upstream version 2.0.1
95
 * Receives a command, typically on the privileged side of the channel.
1 by Daniel Jacobowitz
Import upstream version 1.0.0
96
 * PARAMETERS
1.1.1 by LaMont Jones
Import upstream version 2.0.1
97
 * fd           - the fd on which to receive the command.
1 by Daniel Jacobowitz
Import upstream version 1.0.0
98
 * RETURNS
99
 * The command that was sent.
100
 */
1.1.1 by LaMont Jones
Import upstream version 2.0.1
101
char priv_sock_get_cmd(int fd);
1 by Daniel Jacobowitz
Import upstream version 1.0.0
102
103
/* priv_sock_get_str()
104
 * PURPOSE
1.1.1 by LaMont Jones
Import upstream version 2.0.1
105
 * Receives a string from the other side of the channel.
1 by Daniel Jacobowitz
Import upstream version 1.0.0
106
 * PARAMETERS
1.1.1 by LaMont Jones
Import upstream version 2.0.1
107
 * fd           - the fd on which to receive the string
1 by Daniel Jacobowitz
Import upstream version 1.0.0
108
 * p_dest       - where to copy the received string
109
 */
1.1.1 by LaMont Jones
Import upstream version 2.0.1
110
void priv_sock_get_str(int fd, struct mystr* p_dest);
1 by Daniel Jacobowitz
Import upstream version 1.0.0
111
112
/* priv_sock_send_result()
113
 * PURPOSE
1.1.1 by LaMont Jones
Import upstream version 2.0.1
114
 * Sends a command result, typically to the unprivileged side of the channel.
1 by Daniel Jacobowitz
Import upstream version 1.0.0
115
 * PARAMETERS
1.1.1 by LaMont Jones
Import upstream version 2.0.1
116
 * fd           - the fd on which to send the result
1 by Daniel Jacobowitz
Import upstream version 1.0.0
117
 * res          - the result to send
118
 */
1.1.1 by LaMont Jones
Import upstream version 2.0.1
119
void priv_sock_send_result(int fd, char res);
120
121
/* priv_sock_send_fd()
122
 * PURPOSE
123
 * Sends a file descriptor to the other side of the channel.
124
 * PARAMETERS
125
 * fd           - the fd on which to send the descriptor 
126
 * send_fd      - the descriptor to send
127
 */
128
void priv_sock_send_fd(int fd, int send_fd);
129
130
/* priv_sock_recv_fd()
131
 * PURPOSE
132
 * Receives a file descriptor from the other side of the channel.
133
 * PARAMETERS
134
 * fd           - the fd on which to receive the descriptor
135
 * RETURNS
136
 * The received file descriptor
137
 */
138
int priv_sock_recv_fd(int fd);
139
140
/* priv_sock_send_int()
141
 * PURPOSE
142
 * Sends an integer to the other side of the channel.
143
 * PARAMETERS
144
 * fd           - the fd on which to send the integer
145
 * the_int      - the integer to send
146
 */
147
void priv_sock_send_int(int fd, int the_int);
148
149
/* priv_sock_get_int()
150
 * PURPOSE
151
 * Receives an integer from the other side of the channel.
152
 * PARAMETERS
153
 * fd           - the fd on which to receive the integer
154
 * RETURNS
155
 * The integer that was sent.
156
 */
157
int priv_sock_get_int(int fd);
1 by Daniel Jacobowitz
Import upstream version 1.0.0
158
159
#define PRIV_SOCK_LOGIN             1
160
#define PRIV_SOCK_CHOWN             2
161
#define PRIV_SOCK_GET_DATA_SOCK     3
1.1.1 by LaMont Jones
Import upstream version 2.0.1
162
#define PRIV_SOCK_GET_USER_CMD      4
163
#define PRIV_SOCK_WRITE_USER_RESP   5
1.2.6 by Daniel Baumann
Import upstream version 2.1.1~pre1
164
#define PRIV_SOCK_DO_SSL_HANDSHAKE  6
165
#define PRIV_SOCK_DO_SSL_CLOSE      7
166
#define PRIV_SOCK_DO_SSL_READ       8
167
#define PRIV_SOCK_DO_SSL_WRITE      9
1.5.1 by Daniel Baumann
Import upstream version 2.2.0~pre1
168
#define PRIV_SOCK_PASV_CLEANUP      10
169
#define PRIV_SOCK_PASV_ACTIVE       11
170
#define PRIV_SOCK_PASV_LISTEN       12
171
#define PRIV_SOCK_PASV_ACCEPT       13
1 by Daniel Jacobowitz
Import upstream version 1.0.0
172
173
#define PRIV_SOCK_RESULT_OK         1
174
#define PRIV_SOCK_RESULT_BAD        2
175
176
#endif /* VSF_PRIVSOCK_H */
177