On 2021/03/14 14:17, Martin Vahlensieck wrote:
> Hi
> 
> Here is an update to scdoc version 1.11.1.  I also pledged it while
> there (not sure what the ports policy is for adding pledge patches).

I'm a bit wary in general with pledge in ports because we have been
bitten with pledges added to ports (and in some cases submitted
upstream) that have not been well thought through and result in problems
(we now have ports with patches to *remove* incorrect pledges that have
been committed upstream; this is not really helpful!).
Sometimes it's valid and useful but definitely not everywhere.

There are a couple of main things to consider:

- is the pledge taking into account all possible current codepaths

This software is simple so it's easy to reason with. No config, no
different command-line options, it's just an stdin-to-stdout filter,
so that's good. Let's see what it uses:

$ nm -s scdoc|grep -w U
         U __assert2
         U __errno
         U __sF
         U _csu_finish
         U _ctype_
         U atexit
         U calloc
         U exit
         U fclose
         U fgetc
         U fprintf
         U fputc
         U fread
         U free
         U fseek
         U fwrite
         U getenv
         U gmtime
         U malloc
         U puts
         U realloc
         U snprintf
         U strcmp
         U strerror
         U strftime
         U strstr
         U strtol
         U strtoull
         U time

No problem with stdio for these.

- is it using libraries that are likely to get updated and changed in
such a way that results in changes needed to the pledge?

Not here!

- Are future updates to the port likely to result in problems with the
pledge (especially problems that might not be noticed by the porter
doing an update)?

Again I think we are good.

So in this case I think it's a good candidate and diff is OK with me.
I'll wait for others to comment but as long as I don't forget I'll commit
it soon (or am happy for someone else to commit if they agree).


> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/textproc/scdoc/Makefile,v
> retrieving revision 1.2
> diff -u -p -r1.2 Makefile
> --- Makefile  4 Apr 2020 16:58:26 -0000       1.2
> +++ Makefile  14 Mar 2021 13:17:04 -0000
> @@ -1,7 +1,7 @@
>  # $OpenBSD: Makefile,v 1.2 2020/04/04 16:58:26 schwarze Exp $
>  
>  COMMENT =            convert scdoc text files to man(7) pages
> -VERSION =            1.10.1
> +VERSION =            1.11.1
>  DISTNAME =           scdoc-${VERSION}
>  CATEGORIES =         textproc
>  HOMEPAGE =           https://git.sr.ht/~sircmpwn/scdoc
> @@ -12,6 +12,7 @@ PERMIT_PACKAGE =    Yes
>  MASTER_SITES =               https://git.sr.ht/~sircmpwn/scdoc/
>  DISTFILES =          scdoc-{archive/}${VERSION}${EXTRACT_SUFX}
>  
> +# uses pledge(2)
>  WANTLIB =            c
>  
>  USE_GMAKE =          Yes
> Index: distinfo
> ===================================================================
> RCS file: /cvs/ports/textproc/scdoc/distinfo,v
> retrieving revision 1.2
> diff -u -p -r1.2 distinfo
> --- distinfo  4 Apr 2020 16:58:26 -0000       1.2
> +++ distinfo  14 Mar 2021 13:17:04 -0000
> @@ -1,2 +1,2 @@
> -SHA256 (scdoc-1.10.1.tar.gz) = gOAhxzLMos1mWdzPMwbUb1nuy/j7qk2r21AvU3J4p48=
> -SIZE (scdoc-1.10.1.tar.gz) = 12422
> +SHA256 (scdoc-1.11.1.tar.gz) = EJih7S4IdZb8Cz9lfByKXgBBImeqS682GeNoJDBmRbE=
> +SIZE (scdoc-1.11.1.tar.gz) = 12510
> Index: patches/patch-src_main_c
> ===================================================================
> RCS file: patches/patch-src_main_c
> diff -N patches/patch-src_main_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_main_c  14 Mar 2021 13:17:04 -0000
> @@ -0,0 +1,25 @@
> +$OpenBSD$
> +
> +--- src/main.c.old
> ++++ src/main.c
> +@@ -15,6 +15,7 @@
> + 
> + char *strstr(const char *haystack, const char *needle);
> + char *strerror(int errnum);
> ++int pledge(const char *, const char *);
> + 
> + static struct str *parse_section(struct parser *p) {
> +     struct str *section = str_create();
> +@@ -755,6 +756,12 @@ int main(int argc, char **argv) {
> +             fprintf(stderr, "Usage: scdoc < input.scd > output.roff\n");
> +             return 1;
> +     }
> ++
> ++    if (pledge("stdio", NULL) == -1) {
> ++            fprintf(stderr, "pledge: %s", strerror(errno));
> ++            exit(EXIT_FAILURE);
> ++    }
> ++
> +     struct parser p = {
> +             .input = stdin,
> +             .output = stdout,
> 

Reply via email to