add pledge support - clic - Clic is an command line interactive client for gopher written in Common LISP HTML git clone git://bitreich.org/clic/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/clic/ DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit 2f63cd38c68eee0baa1493d432a295f4009136af DIR parent fd42b4e1718565c5bc2f411e3fd4e120ca2dbd97 HTML Author: Solene Rapenne <solene@perso.pw> Date: Thu, 21 Jun 2018 10:41:00 +0200 add pledge support Diffstat: M clic.lisp | 33 +++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) --- DIR diff --git a/clic.lisp b/clic.lisp @@ -11,12 +11,22 @@ #include <sys/ioctl.h> #include <limits.h> #include <unistd.h> + + #ifdef __OpenBSD__ + void gotoPledge() { + pledge(\"dns inet stdio rpath tty wpath cpath proc exec\",NULL); + } + #endif + int ttyPredicate() { return isatty(fileno(stdout)); } unsigned int getTerminalHeight() { struct winsize w; return ioctl(1,TIOCGWINSZ,&w)<0?UINT_MAX:w.ws_row;}") (ffi:def-function + ("gotoPledge" c-pledge) + () :returning :void) + (ffi:def-function ("getTerminalHeight" c-termsize) () :returning :unsigned-int) (ffi:def-function @@ -717,8 +727,7 @@ with a parameter not of type 1, so it will fetch the content, display it and exit and finally, the redirected case where clic will print to stdout and exit." - - (clear) + (c-pledge) (ignore-errors ;; lisp is magic (let ((destination (car (last (loop for element in (get-argv) @@ -730,15 +739,17 @@ ;; is there an output redirection ? (if (ttyp) - ;; if we don't ask a menu, not going interactive - (if (not (string= "1" (location-type destination))) - ;; not interactive - (visit destination) - ;; if user want to drop from first page we need - ;; to look it here - (when (not (eq 'end (visit destination))) - ;; we continue to the shell if we are in a terminal - (shell))) + (progn + (clear) + ;; if we don't ask a menu, not going interactive + (if (not (string= "1" (location-type destination))) + ;; not interactive + (visit destination) + ;; if user want to drop from first page we need + ;; to look it here + (when (not (eq 'end (visit destination))) + ;; we continue to the shell if we are in a terminal + (shell)))) (pipe-to-stdout destination))))) ;; we allow ecl to use a new kind of argument