From: Tim Cuthbertson <tim@gfxmonk.net>
To: Rich Felker <dalias@libc.org>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Bug: installed symlinks are unreadable on MacOS
Date: Fri, 2 Feb 2024 13:42:24 +1100 [thread overview]
Message-ID: <CAC-LLDhoHomKK4yfb61bkhpeQoE7jH4JxyLjj4PVwHeuqhTvoA@mail.gmail.com> (raw)
In-Reply-To: <20240131233251.GZ22081@brightrain.aerifal.cx>
[-- Attachment #1.1: Type: text/plain, Size: 1195 bytes --]
Ah that makes sense, attached an updated patch. I don't know whether the
`umask 077` after making the symlink is strictly necessary but it might
avoid nasty surprises later on in the script.
Cheers,
- Tim
On Thu, 1 Feb 2024 at 10:32, Rich Felker <dalias@libc.org> wrote:
> On Thu, Feb 01, 2024 at 09:39:56AM +1100, Tim Cuthbertson wrote:
> > Yeah, setting it to `chmod 000` in just the symlink branch seems good to
> me
> > too.
> >
> > Looking at the script more closely, `mode` is always set and so I'm
> unclear
> > why there is also a `umask 077` at all. Whatever permissions we create
> the
> > file with, we `chmod` it explicitly before doing anything else.
> >
> > Is that line just there to undo the potential change to `umask` in the
> > mkdirp branch? If so, maybe that should be done explicitly by capturing
> the
> > old umask? e.g:
>
> No, it's so that the install.sh never exposes a file to users who
> should not have access to it via the existing umask being more
> permissive than the requested install mode. Normally this does not
> matter for use as part of musl's install process, but the script is
> written to be general and not have security bugs like that.
>
> Rich
>
[-- Attachment #1.2: Type: text/html, Size: 1601 bytes --]
[-- Attachment #2: musl-chmod.patch --]
[-- Type: application/octet-stream, Size: 536 bytes --]
commit 60ab5657d006f36032fe5a348349f9c38330ed91
Author: Tim Cuthbertson <tim@gfxmonk.net>
Date: Wed Jan 31 12:45:06 2024 +1100
install.sh: clear umask when making a symlink, so permissions on MacOS match Linux
diff --git a/tools/install.sh b/tools/install.sh
index d913b60b..855a8ca2 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -48,7 +48,9 @@ trap 'rm -f "$tmp"' EXIT INT QUIT TERM HUP
umask 077
if test "$symlink" ; then
+umask 000
ln -s "$1" "$tmp"
+umask 077
else
cat < "$1" > "$tmp"
chmod "$mode" "$tmp"
prev parent reply other threads:[~2024-02-02 2:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-31 2:30 Tim Cuthbertson
2024-01-31 13:47 ` Rich Felker
2024-01-31 22:39 ` Tim Cuthbertson
2024-01-31 23:32 ` Rich Felker
2024-02-02 2:42 ` Tim Cuthbertson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAC-LLDhoHomKK4yfb61bkhpeQoE7jH4JxyLjj4PVwHeuqhTvoA@mail.gmail.com \
--to=tim@gfxmonk.net \
--cc=dalias@libc.org \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).