patch-memcached_c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. $OpenBSD: patch-memcached_c,v 1.11 2016/09/02 14:20:31 giovanni Exp $
  2. --- memcached.c.orig Fri Jun 24 19:41:24 2016
  3. +++ memcached.c Thu Jun 30 00:02:09 2016
  4. @@ -23,6 +23,7 @@
  5. #include <sys/uio.h>
  6. #include <ctype.h>
  7. #include <stdarg.h>
  8. +#include <unistd.h>
  9. /* some POSIX systems need the following definition
  10. * to get mlockall flags out of sys/mman.h. */
  11. @@ -6100,6 +6101,32 @@ int main (int argc, char **argv) {
  12. if (pid_file != NULL) {
  13. save_pid(pid_file);
  14. + }
  15. +
  16. + if (settings.socketpath != NULL) {
  17. + if (pid_file != NULL) {
  18. + if (pledge("stdio cpath unix", NULL) == -1) {
  19. + fprintf(stderr, "%s: pledge: %s\n", argv[0], strerror(errno));
  20. + exit(1);
  21. + }
  22. + } else {
  23. + if (pledge("stdio unix", NULL) == -1) {
  24. + fprintf(stderr, "%s: pledge: %s\n", argv[0], strerror(errno));
  25. + exit(1);
  26. + }
  27. + }
  28. + } else {
  29. + if (pid_file != NULL) {
  30. + if (pledge("stdio cpath inet", NULL) == -1) {
  31. + fprintf(stderr, "%s: pledge: %s\n", argv[0], strerror(errno));
  32. + exit(1);
  33. + }
  34. + } else {
  35. + if (pledge("stdio inet", NULL) == -1) {
  36. + fprintf(stderr, "%s: pledge: %s\n", argv[0], strerror(errno));
  37. + exit(1);
  38. + }
  39. + }
  40. }
  41. /* Drop privileges no longer needed */