patch-main_c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. $OpenBSD: patch-main_c,v 1.2 2016/07/11 07:51:31 czarkoff Exp $
  2. * pledge(2)
  3. * remove srand(3) (see patch-playlist_c)
  4. --- main.c.orig Sun Apr 24 06:23:30 2016
  5. +++ main.c Mon Jul 11 08:57:56 2016
  6. @@ -174,6 +174,8 @@ static void start_moc (const struct parameters *params
  7. case 0: /* child - start server */
  8. set_me_server ();
  9. list_sock = server_init (params->debug, params->foreground);
  10. + if (pledge("stdio rpath wpath cpath inet unix dns audio", NULL) == -1)
  11. + fatal ("pledge() failed: %s", strerror(errno));
  12. rc = write (notify_pipe[1], &i, sizeof(i));
  13. if (rc < 0)
  14. fatal ("write() to notify pipe failed: %s",
  15. @@ -207,10 +209,14 @@ static void start_moc (const struct parameters *params
  16. else if (params->foreground && params->only_server) {
  17. set_me_server ();
  18. list_sock = server_init (params->debug, params->foreground);
  19. + if (pledge("stdio rpath wpath cpath inet unix dns audio", NULL) == -1)
  20. + fatal ("pledge() failed: %s", strerror(errno));
  21. server_loop (list_sock);
  22. }
  23. if (!params->only_server) {
  24. + if (pledge("stdio rpath wpath cpath flock unix tty proc", NULL) == -1)
  25. + fatal ("pledge() failed: %s", strerror(errno));
  26. signal (SIGPIPE, SIG_IGN);
  27. if (ping_server(server_sock)) {
  28. if (!params->dont_run_iface) {
  29. @@ -799,6 +805,9 @@ int main (int argc, char *argv[])
  30. struct utsname uts;
  31. #endif
  32. + if (pledge("stdio rpath wpath cpath flock inet unix dns tty proc prot_exec audio", NULL) == -1)
  33. + fatal ("pledge() failed: %s", strerror(errno));
  34. +
  35. #ifdef PACKAGE_REVISION
  36. logit ("This is Music On Console (revision %s)", PACKAGE_REVISION);
  37. #else
  38. @@ -851,11 +860,12 @@ int main (int argc, char *argv[])
  39. io_init ();
  40. rcc_init ();
  41. decoder_init (params.debug);
  42. - srand (time(NULL));
  43. - if (!params.only_server && params.dont_run_iface)
  44. + if (!params.only_server && params.dont_run_iface) {
  45. + if (pledge("cpath rpath stdio unix", NULL) == -1)
  46. + fatal ("pledge() failed: %s", strerror(errno));
  47. server_command (&params, args);
  48. - else
  49. + } else
  50. start_moc (&params, args);
  51. lists_strs_free (args);