1/*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License as
4 * published by the Free Software Foundation; either version 2 of
5 * the License, or (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
15 * MA 02111-1307 USA
16 */
17#ifndef VSF_SYSDEPUTIL_H
18#define VSF_SYSDEPUTIL_H
19
20#ifndef VSF_FILESIZE_H
21#include "filesize.h"
22#endif
23
24/* VSF_SYSDEPUTIL_H:
25 * Support for highly system dependent features, and querying for support
26 * or lack thereof
27 * TODO: document functions!
28 */
29
30struct mystr;
31
32/* Authentication of local users */
33/* Return 0 for fail, 1 for success */
34int vsf_sysdep_check_auth(const struct mystr* p_user,
35                          const struct mystr* p_pass,
36                          const struct mystr* p_remote_host);
37
38/* Support for fine grained privilege (capabilities) */
39int vsf_sysdep_has_capabilities(void);
40int vsf_sysdep_has_capabilities_as_non_root(void);
41void vsf_sysdep_keep_capabilities(void);
42enum ESysdepCapabilities
43{
44  kCapabilityCAP_CHOWN = 1,
45  kCapabilityCAP_NET_BIND_SERVICE = 2
46  /* NOTE - next one will be 4, this is a bitfield */
47};
48void vsf_sysdep_adopt_capabilities(unsigned int caps);
49
50/* Support for sendfile(), Linux-like interface. Collapses to a read/write
51 * loop under the covers if the target system lacks support.
52 */
53int vsf_sysutil_sendfile(const int out_fd, const int in_fd,
54                         filesize_t* p_offset, filesize_t num_send,
55                         unsigned int max_chunk);
56
57/* Support for changing the process name as reported by the operating system.
58 * A useful status monitor. NOTE - we don't guarantee that this call will
59 * have any effect.
60 */
61void vsf_sysutil_setproctitle_init(int argc, const char* argv[]);
62void vsf_sysutil_setproctitle(const char* p_text);
63void vsf_sysutil_setproctitle_str(const struct mystr* p_str);
64void vsf_sysutil_set_proctitle_prefix(const struct mystr* p_str);
65
66/* For now, maps read/write private pages. API to be extended.. */
67void vsf_sysutil_map_anon_pages_init(void);
68void* vsf_sysutil_map_anon_pages(unsigned int length);
69
70/* File descriptor passing/receiving */
71void vsf_sysutil_send_fd(int sock_fd, int send_fd);
72int vsf_sysutil_recv_fd(int sock_fd);
73
74#endif /* VSF_SYSDEPUTIL_H */
75
76