sysdeputil.h 2.6 KB

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