Security_win32.c 2.8 KB

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