[hackers] [sic] add support for pledge()
Hi,
please find below a diff for sic to enable pledge() to be used on
OpenBSD. This diff was originally submitted by Ali H. Fardan via
ports_AT_openbsd.org. While here, I enabled the usage of strlcpy()
from libc on OpenBSD.
Honestly, I'm not sure about how such portability goo should be
handled the suckless way, but since I see similar #ifdef __linux__
instances in slock, I guess the proposed way is okay?
Thanks,
Regards,
Joerg
diff --git a/sic.c b/sic.c
index ce6d216..b22ea06 100644
--- a/sic.c
+++ b/sic.c
_AT_@ -182,6 +182,8 @@ main(int argc, char *argv[]) {
setbuf(stdout, NULL);
setbuf(srv, NULL);
setbuf(stdin, NULL);
+ if (pledge("stdio", NULL) == -1)
+ eprint("error: pledge:");
for(;;) { /* main loop */
FD_ZERO(&rd);
FD_SET(0, &rd);
diff --git a/util.c b/util.c
index 8afa58f..88ea06e 100644
--- a/util.c
+++ b/util.c
_AT_@ -40,12 +40,16 @@ dial(char *host, char *port) {
return srv;
}
+#ifndef __OpenBSD__
+#define pledge(promises, paths) 0
+
#define strlcpy _strlcpy
static void
strlcpy(char *to, const char *from, int l) {
memccpy(to, from, '\0', l);
to[l-1] = '\0';
}
+#endif
static char *
eat(char *s, int (*p)(int), int r) {
Received on Sun Aug 14 2016 - 00:30:46 CEST
This archive was generated by hypermail 2.3.0
: Sun Aug 14 2016 - 00:36:18 CEST