Security_win32.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #include "benc/Dict.h"
  16. #include "benc/String.h"
  17. #include "exception/Except.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. void Security_setUser(int uid,
  34. bool keepNetAdmin,
  35. struct Log* logger,
  36. struct Except* eh,
  37. struct Allocator* alloc)
  38. {
  39. }
  40. void Security_nofiles(struct Except* eh)
  41. {
  42. }
  43. void Security_noforks(struct Except* eh)
  44. {
  45. }
  46. void Security_chroot(char* root, struct Except* eh)
  47. {
  48. }
  49. void Security_seccomp(struct Allocator* tempAlloc, struct Log* logger, struct Except* eh)
  50. {
  51. }
  52. struct Security_pvt
  53. {
  54. struct Security pub;
  55. struct Allocator* setupAlloc;
  56. struct Log* log;
  57. Identity
  58. };
  59. void Security_setupComplete(struct Security* security)
  60. {
  61. struct Security_pvt* sec = Identity_check((struct Security_pvt*) security);
  62. sec->pub.setupComplete = 1;
  63. Allocator_free(sec->setupAlloc);
  64. }
  65. static void fail(void* vSec)
  66. {
  67. struct Security_pvt* sec = Identity_check((struct Security_pvt*) vSec);
  68. Log_critical(sec->log, "Security_setupComplete() not called in time, exiting");
  69. _exit(232);
  70. }
  71. struct Security* Security_new(struct Allocator* alloc, struct Log* log, struct EventBase* base)
  72. {
  73. struct Security_pvt* sec = Allocator_calloc(alloc, sizeof(struct Security_pvt), 1);
  74. Identity_set(sec);
  75. sec->setupAlloc = Allocator_child(alloc);
  76. Timeout_setInterval(fail, sec, 20000, base, sec->setupAlloc);
  77. sec->log = log;
  78. return &sec->pub;
  79. }
  80. struct Security_Permissions* Security_checkPermissions(struct Allocator* alloc, struct Except* eh)
  81. {
  82. struct Security_Permissions* out =
  83. Allocator_calloc(alloc, sizeof(struct Security_Permissions), 1);
  84. return out;
  85. }