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 <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. 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, EventBase_t* 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. Er_DEFUN(struct Security_Permissions* Security_checkPermissions(struct Allocator* alloc))
  82. {
  83. struct Security_Permissions* out =
  84. Allocator_calloc(alloc, sizeof(struct Security_Permissions), 1);
  85. Er_ret(out);
  86. }