On 2022/08/13 13:10:00 +0200, Omar Polo <o...@openbsd.org> wrote:
> i was going through the list of non-pledged process in my list and
> found xcape.  It's a simple program that allows to turn some keys
> (e.g. ctrl) to act as another key (e.g. esc) when pressed and released
> by themselves.  It's around 500 lines of code and I haven't spotted
> anything that won't run under pledge `stdio', except for the first
> half of main.
> 
> I'm running it as
> 
>       $ xcape -e 'Control_L=Escape'
> 
> (which I just discovered it's the default so I can drop -e entirely)
> and is working fine.
> 
> % ps aux | grep xcape
> op       28882  0.0  0.0  1664  2392 ??  Sp     12:46PM    0:00.51 xcape -e 
> Con
> 
> ok?

yet another bump.  i'll probably commit it in a couple of days if
nobody objects it, but OK are well accepted ;)

Index: Makefile
===================================================================
RCS file: /home/cvs/ports/x11/xcape/Makefile,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile
--- Makefile    11 Mar 2022 20:17:43 -0000      1.3
+++ Makefile    13 Aug 2022 12:36:38 -0000
@@ -3,12 +3,14 @@ COMMENT =     configure a modifier key when 
 GH_ACCOUNT =   alols
 GH_PROJECT =   xcape
 GH_TAGNAME =   v1.2
+REVISION =     0
 
 CATEGORIES =   x11
 
 # GPLv3+
 PERMIT_PACKAGE =       Yes
 
+# uses pledge()
 WANTLIB +=     X11 Xtst c pthread
 
 MAKE_FLAGS =   PREFIX=${PREFIX} \
Index: patches/patch-xcape_c
===================================================================
RCS file: patches/patch-xcape_c
diff -N patches/patch-xcape_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-xcape_c       9 Sep 2022 12:30:04 -0000
@@ -0,0 +1,18 @@
+pledge it
+
+Index: xcape.c
+--- xcape.c.orig
++++ xcape.c
+@@ -191,6 +191,12 @@ int main (int argc, char **argv)
+     if (self->debug != True)
+         daemon (0, 0);
+ 
++    if (pledge ("stdio", NULL) == -1)
++    {
++        fprintf (stderr, "pledge: %s\n", strerror(errno));
++        exit (EXIT_FAILURE);
++    }
++
+     sigemptyset (&self->sigset);
+     sigaddset (&self->sigset, SIGINT);
+     sigaddset (&self->sigset, SIGTERM);

Reply via email to