"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Tracey Emery <tracey@traceyemery.net>
Subject:
Re: tog: call pledge() from main()
To:
gameoftrees@openbsd.org
Date:
Fri, 4 Dec 2020 16:19:25 -0700

Download raw body.

Thread
On Sat, Dec 05, 2020 at 12:15:10AM +0100, Stefan Sperling wrote:
> All of tog's pledges are currently the same, and they must be the same
> because tog allows switching between available views.
> 
> So calling pledge() from just one place is enough.
> 
> ok?

Makes sense to me. ok

> 
> diff 41ad2652808e8c045a2a82b97bb309e35fde2887 /home/stsp/src/got
> blob - 50fefd43b456ae573fe7ef9c214a59c72cb42a9e
> file + tog/tog.c
> --- tog/tog.c
> +++ tog/tog.c
> @@ -2645,12 +2645,6 @@ cmd_log(int argc, char *argv[])
>  	int ch, log_branches = 0;
>  	struct tog_view *view;
>  
> -#ifndef PROFILE
> -	if (pledge("stdio rpath wpath cpath flock proc tty exec sendfd unveil",
> -	    NULL) == -1)
> -		err(1, "pledge");
> -#endif
> -
>  	while ((ch = getopt(argc, argv, "bc:r:")) != -1) {
>  		switch (ch) {
>  		case 'b':
> @@ -3732,11 +3726,6 @@ cmd_diff(int argc, char *argv[])
>  	const char *errstr;
>  	struct tog_view *view;
>  
> -#ifndef PROFILE
> -	if (pledge("stdio rpath wpath cpath flock proc tty exec sendfd unveil",
> -	    NULL) == -1)
> -		err(1, "pledge");
> -#endif
>  	while ((ch = getopt(argc, argv, "aC:r:w")) != -1) {
>  		switch (ch) {
>  		case 'a':
> @@ -4634,12 +4623,6 @@ cmd_blame(int argc, char *argv[])
>  	int ch;
>  	struct tog_view *view;
>  
> -#ifndef PROFILE
> -	if (pledge("stdio rpath wpath cpath flock proc tty exec sendfd unveil",
> -	    NULL) == -1)
> -		err(1, "pledge");
> -#endif
> -
>  	while ((ch = getopt(argc, argv, "c:r:")) != -1) {
>  		switch (ch) {
>  		case 'c':
> @@ -5435,12 +5418,6 @@ cmd_tree(int argc, char *argv[])
>  	int ch;
>  	struct tog_view *view;
>  
> -#ifndef PROFILE
> -	if (pledge("stdio rpath wpath cpath flock proc tty exec sendfd unveil",
> -	    NULL) == -1)
> -		err(1, "pledge");
> -#endif
> -
>  	while ((ch = getopt(argc, argv, "c:r:")) != -1) {
>  		switch (ch) {
>  		case 'c':
> @@ -6144,12 +6121,6 @@ cmd_ref(int argc, char *argv[])
>  	int ch;
>  	struct tog_view *view;
>  
> -#ifndef PROFILE
> -	if (pledge("stdio rpath wpath cpath flock proc tty exec sendfd unveil",
> -	    NULL) == -1)
> -		err(1, "pledge");
> -#endif
> -
>  	while ((ch = getopt(argc, argv, "r:")) != -1) {
>  		switch (ch) {
>  		case 'r':
> @@ -6407,6 +6378,12 @@ main(int argc, char *argv[])
>  		return 0;
>  	}
>  
> +#ifndef PROFILE
> +	if (pledge("stdio rpath wpath cpath flock proc tty exec sendfd unveil",
> +	    NULL) == -1)
> +		err(1, "pledge");
> +#endif
> +
>  	if (argc == 0) {
>  		if (hflag)
>  			usage(hflag, 0);

-- 

Tracey Emery