Security.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of 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, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef Security_H
  16. #define Security_H
  17. #include "benc/Dict.h"
  18. #include "memory/Allocator.h"
  19. #include "exception/Except.h"
  20. #include "util/log/Log.h"
  21. #include "util/events/EventBase.h"
  22. #include "util/Linker.h"
  23. #ifdef win32
  24. Linker_require("util/Security_win32.c");
  25. #else
  26. Linker_require("util/Security.c");
  27. #endif
  28. #include <stdint.h>
  29. #include <stdbool.h>
  30. struct Security_Permissions
  31. {
  32. int noOpenFiles;
  33. int seccompExists;
  34. int seccompEnforcing;
  35. int uid;
  36. };
  37. struct Security
  38. {
  39. bool setupComplete;
  40. };
  41. void Security_setUser(int uid,
  42. int gid,
  43. bool keepNetAdmin,
  44. struct Log* logger,
  45. struct Except* eh,
  46. struct Allocator* alloc);
  47. void Security_nofiles(struct Except* eh);
  48. void Security_noforks(struct Except* eh);
  49. void Security_chroot(char* root, struct Except* eh);
  50. void Security_seccomp(struct Allocator* tempAlloc, struct Log* logger, struct Except* eh);
  51. void Security_setupComplete(struct Security* security);
  52. struct Security* Security_new(struct Allocator* alloc, struct Log* log, struct EventBase* base);
  53. Dict* Security_getUser(char* userName, struct Allocator* retAlloc);
  54. struct Security_Permissions* Security_checkPermissions(struct Allocator* alloc, struct Except* eh);
  55. #endif