Security.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 <https://www.gnu.org/licenses/>.
  14. */
  15. #ifndef Security_H
  16. #define Security_H
  17. #include "memory/Allocator.h"
  18. #include "exception/Err.h"
  19. #include "util/log/Log.h"
  20. #include "util/events/EventBase.h"
  21. #include "util/Linker.h"
  22. #ifdef win32
  23. Linker_require("util/Security_win32.c")
  24. #else
  25. Linker_require("util/Security.c")
  26. #endif
  27. #include <stdint.h>
  28. #include <stdbool.h>
  29. struct Security_Permissions
  30. {
  31. int noOpenFiles;
  32. int uid;
  33. };
  34. struct Security
  35. {
  36. bool setupComplete;
  37. };
  38. Err_DEFUN Security_setUser(int uid,
  39. int gid,
  40. bool keepNetAdmin,
  41. struct Log* logger,
  42. struct Allocator* alloc);
  43. Err_DEFUN Security_nofiles(struct Allocator* errAlloc);
  44. Err_DEFUN Security_noforks(struct Allocator* errAlloc);
  45. Err_DEFUN Security_chroot(char* root, struct Allocator* errAlloc);
  46. void Security_setupComplete(struct Security* security);
  47. struct Security* Security_new(struct Allocator* alloc, struct Log* log, EventBase_t* base);
  48. Dict* Security_getUser(char* userName, struct Allocator* retAlloc);
  49. Err_DEFUN Security_checkPermissions(struct Security_Permissions** out, struct Allocator* alloc);
  50. #endif