1#ifndef VSF_SYSDEPUTIL_H
2#define VSF_SYSDEPUTIL_H
3
4#ifndef VSF_FILESIZE_H
5#include "filesize.h"
6#endif
7
8/* VSF_SYSDEPUTIL_H:
9 * Support for highly system dependent features, and querying for support
10 * or lack thereof
11 * TODO: document functions!
12 */
13
14struct mystr;
15
16/* Authentication of local users */
17/* Return 0 for fail, 1 for success */
18int vsf_sysdep_check_auth(const struct mystr* p_user,
19                          const struct mystr* p_pass,
20                          const struct mystr* p_remote_host);
21
22/* Support for fine grained privilege (capabilities) */
23int vsf_sysdep_has_capabilities(void);
24int vsf_sysdep_has_capabilities_as_non_root(void);
25void vsf_sysdep_keep_capabilities(void);
26enum ESysdepCapabilities
27{
28  kCapabilityCAP_CHOWN = 1,
29  kCapabilityCAP_NET_BIND_SERVICE = 2
30  /* NOTE - next one will be 4, this is a bitfield */
31};
32void vsf_sysdep_adopt_capabilities(unsigned int caps);
33
34/* Support for sendfile(), Linux-like interface. Collapses to a read/write
35 * loop under the covers if the target system lacks support.
36 */
37int vsf_sysutil_sendfile(const int out_fd, const int in_fd,
38                         filesize_t* p_offset, filesize_t num_send,
39                         unsigned int max_chunk);
40
41/* Support for changing the process name as reported by the operating system.
42 * A useful status monitor. NOTE - we don't guarantee that this call will
43 * have any effect.
44 */
45void vsf_sysutil_setproctitle_init(int argc, const char* argv[]);
46void vsf_sysutil_setproctitle(const char* p_text);
47void vsf_sysutil_setproctitle_str(const struct mystr* p_str);
48void vsf_sysutil_set_proctitle_prefix(const struct mystr* p_str);
49
50/* For now, maps read/write private pages. API to be extended.. */
51void vsf_sysutil_map_anon_pages_init(void);
52void* vsf_sysutil_map_anon_pages(unsigned int length);
53
54/* File descriptor passing/receiving */
55void vsf_sysutil_send_fd(int sock_fd, int send_fd);
56int vsf_sysutil_recv_fd(int sock_fd);
57
58#endif /* VSF_SYSDEPUTIL_H */
59
60