$OpenBSD: patch-main_c,v 1.2 2016/07/11 07:51:31 czarkoff Exp $

 * pledge(2)
 * remove srand(3) (see patch-playlist_c)

--- main.c.orig	Sun Apr 24 06:23:30 2016
+++ main.c	Mon Jul 11 08:57:56 2016
@@ -174,6 +174,8 @@ static void start_moc (const struct parameters *params
 			case 0: /* child - start server */
 				set_me_server ();
 				list_sock = server_init (params->debug, params->foreground);
+				if (pledge("stdio rpath wpath cpath inet unix dns audio", NULL) == -1)
+					fatal ("pledge() failed: %s", strerror(errno));
 				rc = write (notify_pipe[1], &i, sizeof(i));
 				if (rc < 0)
 					fatal ("write() to notify pipe failed: %s",
@@ -207,10 +209,14 @@ static void start_moc (const struct parameters *params
 	else if (params->foreground && params->only_server) {
 		set_me_server ();
 		list_sock = server_init (params->debug, params->foreground);
+		if (pledge("stdio rpath wpath cpath inet unix dns audio", NULL) == -1)
+			fatal ("pledge() failed: %s", strerror(errno));
 		server_loop (list_sock);
 	}
 
 	if (!params->only_server) {
+		if (pledge("stdio rpath wpath cpath flock unix tty proc", NULL) == -1)
+			fatal ("pledge() failed: %s", strerror(errno));
 		signal (SIGPIPE, SIG_IGN);
 		if (ping_server(server_sock)) {
 			if (!params->dont_run_iface) {
@@ -799,6 +805,9 @@ int main (int argc, char *argv[])
 	struct utsname uts;
 #endif
 
+	if (pledge("stdio rpath wpath cpath flock inet unix dns tty proc prot_exec audio", NULL) == -1)
+		fatal ("pledge() failed: %s", strerror(errno));
+
 #ifdef PACKAGE_REVISION
 	logit ("This is Music On Console (revision %s)", PACKAGE_REVISION);
 #else
@@ -851,11 +860,12 @@ int main (int argc, char *argv[])
 	io_init ();
 	rcc_init ();
 	decoder_init (params.debug);
-	srand (time(NULL));
 
-	if (!params.only_server && params.dont_run_iface)
+	if (!params.only_server && params.dont_run_iface) {
+		if (pledge("cpath rpath stdio unix", NULL) == -1)
+			fatal ("pledge() failed: %s", strerror(errno));
 		server_command (&params, args);
-	else
+	} else
 		start_moc (&params, args);
 
 	lists_strs_free (args);
