On Sun, Nov 06, 2016 at 12:56:31PM +0100, Theo Buehler wrote:
> The lib/*/obj/.depend files end up having permissions 600 since they are
> created as tempfiles and then moved to the obj directory.  I think that
> there is no deeper reason for such restrictive permissions and it gets
> in the way of having a dedicated build user.
> 
> If we copy the files and then remove the originals, the permissions of
> the .depend fiels are subject to the file creation rules, so they honor
> permissions of the obj directories and the umask.
> 
> ok?
> 
> Index: lib/csu/Makefile
> ===================================================================
> RCS file: /var/cvs/src/lib/csu/Makefile,v
> retrieving revision 1.24
> diff -u -p -r1.24 Makefile
> --- lib/csu/Makefile  15 Oct 2016 13:00:07 -0000      1.24
> +++ lib/csu/Makefile  6 Nov 2016 11:27:23 -0000
> @@ -85,9 +85,8 @@ afterdepend: .depend
>       @TMP=`mktemp .dependXXXXXXXXXX` || exit 1; \

This code comes from a time before sed -i existed. In this time and age
we can just use inline sed.

        sed -i 's/^\([^\.]*\).o[ ]*:/\1.o g\1.o r\1.o:/' .depend

With this we avoid /tmp and the related permission issues altogether.
What do you think?


>       if sed -e 's/^\([^\.]*\).o[ ]*:/\1.o g\1.o r\1.o:/' \
>             < .depend > $$TMP; then \
> -             mv $$TMP .depend; \
> -     else \
> -             rm -f $$TMP; \
> -     fi
> +             cp $$TMP .depend; \
> +     fi; \
> +     rm -f $$TMP
>  
>  .include <bsd.prog.mk>
> Index: share/mk/bsd.lib.mk
> ===================================================================
> RCS file: /var/cvs/src/share/mk/bsd.lib.mk,v
> retrieving revision 1.78
> diff -u -p -r1.78 bsd.lib.mk
> --- share/mk/bsd.lib.mk       15 Oct 2016 13:00:07 -0000      1.78
> +++ share/mk/bsd.lib.mk       6 Nov 2016 11:18:12 -0000
> @@ -230,10 +230,9 @@ afterdepend: .depend
>       @TMP=`mktemp .dependXXXXXXXXXX` || exit 1; \

Same here.

        sed -i 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.do:/' .depend


>       if sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.do:/' \
>             < .depend > $$TMP; then \
> -             mv $$TMP .depend; \
> -     else \
> -             rm -f $$TMP; \
> -     fi
> +             cp $$TMP .depend; \
> +     fi ; \
> +     rm -f $$TMP
>  .endif
>  
>  .if !target(install)
> 

Reply via email to