-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprivsock.h
119 lines (103 loc) · 3.09 KB
/
privsock.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifndef VSF_PRIVSOCK_H
#define VSF_PRIVSOCK_H
struct mystr;
struct vsf_session;
/* priv_sock_init()
* PURPOSE
* Initialize the priv_sock system, by opening the communications sockets.
* PARAMETERS
* p_sess - the current session object
*/
void priv_sock_init(struct vsf_session* p_sess);
/* priv_sock_send_cmd()
* PURPOSE
* Sends a command, typically to the privileged side of the channel.
* PARAMETERS
* fd - the fd on which to send the command
* cmd - the command to send
*/
void priv_sock_send_cmd(int fd, char cmd);
/* priv_sock_send_str()
* PURPOSE
* Sends a string to the other side of the channel.
* PARAMETERS
* fd - the fd on which to send the string
* p_str - the string to send
*/
void priv_sock_send_str(int fd, const struct mystr* p_str);
/* priv_sock_get_result()
* PURPOSE
* Receives a response, typically from the privileged side of the channel.
* PARAMETERS
* fd - the fd on which to receive the response
* RETURNS
* The response code.
*/
char priv_sock_get_result(int fd);
/* priv_sock_get_cmd()
* PURPOSE
* Receives a command, typically on the privileged side of the channel.
* PARAMETERS
* fd - the fd on which to receive the command.
* RETURNS
* The command that was sent.
*/
char priv_sock_get_cmd(int fd);
/* priv_sock_get_str()
* PURPOSE
* Receives a string from the other side of the channel.
* PARAMETERS
* fd - the fd on which to receive the string
* p_dest - where to copy the received string
*/
void priv_sock_get_str(int fd, struct mystr* p_dest);
/* priv_sock_send_result()
* PURPOSE
* Sends a command result, typically to the unprivileged side of the channel.
* PARAMETERS
* fd - the fd on which to send the result
* res - the result to send
*/
void priv_sock_send_result(int fd, char res);
/* priv_sock_send_fd()
* PURPOSE
* Sends a file descriptor to the other side of the channel.
* PARAMETERS
* fd - the fd on which to send the descriptor
* send_fd - the descriptor to send
*/
void priv_sock_send_fd(int fd, int send_fd);
/* priv_sock_recv_fd()
* PURPOSE
* Receives a file descriptor from the other side of the channel.
* PARAMETERS
* fd - the fd on which to receive the descriptor
* RETURNS
* The received file descriptor
*/
int priv_sock_recv_fd(int fd);
/* priv_sock_send_int()
* PURPOSE
* Sends an integer to the other side of the channel.
* PARAMETERS
* fd - the fd on which to send the integer
* the_int - the integer to send
*/
void priv_sock_send_int(int fd, int the_int);
/* priv_sock_get_int()
* PURPOSE
* Receives an integer from the other side of the channel.
* PARAMETERS
* fd - the fd on which to receive the integer
* RETURNS
* The integer that was sent.
*/
int priv_sock_get_int(int fd);
#define PRIV_SOCK_LOGIN 1
#define PRIV_SOCK_CHOWN 2
#define PRIV_SOCK_GET_DATA_SOCK 3
#define PRIV_SOCK_GET_USER_CMD 4
#define PRIV_SOCK_WRITE_USER_RESP 5
#define PRIV_SOCK_RESULT_OK 1
#define PRIV_SOCK_RESULT_BAD 2
#endif /* VSF_PRIVSOCK_H */