$OpenBSD: patch-src_main_c,v 1.17 2016/01/26 09:42:35 dcoppa Exp $

Bugfix: add keymap fall back (_XKB_RULES_NAMES, then defaults)

commit a1d1f456a1fbf44bfa5c6a9d041023ac498b0c46
Author: Theo Buehler <theo@math.ethz.ch>
Date:   Thu Jan 14 10:06:34 2016 +0100

Add pledge(2) support for OpenBSD

pledges for i3:
"stdio rpath unix" for talking to the i3 socket usually in /tmp
"proc exec" for executing programs
"wpath cpath" are needed for the restart-in-place functionality

To make this work, @semarie pointed out that it is sufficient to ensure
that we get physical_mem_bytes only once, namely in init_logging().

pledges for i3-msg:
"stdio rpath unix" are needed for talking to the i3-socket

pledges for i3-nagbar
"rpath getpw" to find the home directory
"wpath cpath" to write the script
"proc exec" to execute the script
"unix" for talking to the i3 socket

--- src/main.c.orig	Wed Sep 30 08:55:10 2015
+++ src/main.c	Sun Jan 17 17:55:53 2016
@@ -87,6 +87,7 @@ struct ws_assignments_head ws_assignments = TAILQ_HEAD
 
 /* We hope that those are supported and set them to true */
 bool xcursor_supported = true;
+bool xkb_supported = true;
 
 /*
  * This callback is only a dummy, see xcb_prepare_cb and xcb_check_cb.
@@ -543,6 +544,7 @@ int main(int argc, char *argv[]) {
 
     const xcb_query_extension_reply_t *extreply;
     extreply = xcb_get_extension_data(conn, &xcb_xkb_id);
+    xkb_supported = extreply->present;
     if (!extreply->present) {
         DLOG("xkb is not present on this server\n");
     } else {
@@ -784,6 +786,11 @@ int main(int argc, char *argv[]) {
         xcb_free_gc(conn, gc);
         xcb_free_pixmap(conn, pixmap);
     }
+
+#if defined(__OpenBSD__)
+    if (pledge("stdio rpath wpath cpath proc exec unix", NULL) == -1)
+        err(EXIT_FAILURE, "pledge");
+#endif
 
     struct sigaction action;
 
