1
0

Security_win32.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. #include "benc/Dict.h"
  16. #include "benc/String.h"
  17. #include "exception/Er.h"
  18. #include "util/log/Log.h"
  19. #include "util/Security.h"
  20. #include "memory/Allocator.h"
  21. #include "util/Bits.h"
  22. #include "util/events/EventBase.h"
  23. #include "util/events/Timeout.h"
  24. #include <unistd.h>
  25. Dict* Security_getUser(char* userName, struct Allocator* retAlloc)
  26. {
  27. Dict* ret = Dict_new(retAlloc);
  28. Dict_putString(ret, String_new("error", retAlloc),
  29. String_new("Not supported on windows", retAlloc),
  30. retAlloc);
  31. return ret;
  32. }
  33. Er_DEFUN(void Security_setUser(int uid,
  34. int gid,
  35. bool keepNetAdmin,
  36. struct Log* logger,
  37. struct Allocator* alloc))
  38. {
  39. Er_ret();
  40. }
  41. Er_DEFUN(void Security_nofiles(struct Allocator* errAlloc))
  42. {
  43. Er_ret();
  44. }
  45. Er_DEFUN(void Security_noforks(struct Allocator* errAlloc))
  46. {
  47. Er_ret();
  48. }
  49. Er_DEFUN(void Security_chroot(char* root, struct Allocator* errAlloc))
  50. {
  51. Er_ret();
  52. }
  53. Er_DEFUN(void Security_seccomp(struct Allocator* tempAlloc, struct Log* logger))
  54. {
  55. Er_ret();
  56. }
  57. struct Security_pvt
  58. {
  59. struct Security pub;
  60. struct Allocator* setupAlloc;
  61. struct Log* log;
  62. Identity
  63. };
  64. void Security_setupComplete(struct Security* security)
  65. {
  66. struct Security_pvt* sec = Identity_check((struct Security_pvt*) security);
  67. sec->pub.setupComplete = 1;
  68. Allocator_free(sec->setupAlloc);
  69. }
  70. static void fail(void* vSec)
  71. {
  72. struct Security_pvt* sec = Identity_check((struct Security_pvt*) vSec);
  73. Log_critical(sec->log, "Security_setupComplete() not called in time, exiting");
  74. _exit(232);
  75. }
  76. struct Security* Security_new(struct Allocator* alloc, struct Log* log, struct EventBase* base)
  77. {
  78. struct Security_pvt* sec = Allocator_calloc(alloc, sizeof(struct Security_pvt), 1);
  79. Identity_set(sec);
  80. sec->setupAlloc = Allocator_child(alloc);
  81. Timeout_setInterval(fail, sec, 20000, base, sec->setupAlloc);
  82. sec->log = log;
  83. return &sec->pub;
  84. }
  85. Er_DEFUN(struct Security_Permissions* Security_checkPermissions(struct Allocator* alloc))
  86. {
  87. struct Security_Permissions* out =
  88. Allocator_calloc(alloc, sizeof(struct Security_Permissions), 1);
  89. Er_ret(out);
  90. }