mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: Preparing to release 0.9.12
Date: Fri, 26 Jul 2013 02:18:30 -0400	[thread overview]
Message-ID: <20130726061830.GV4284@brightrain.aerifal.cx> (raw)
In-Reply-To: <20130726090751.722d7ea2@vostro>

On Fri, Jul 26, 2013 at 09:07:51AM +0300, Timo Teras wrote:
> On Fri, 26 Jul 2013 01:34:20 -0400
> Rich Felker <dalias@aerifal.cx> wrote:
> 
> > One thing to keep in mind with libc is that you want to be able to
> > safely and atomically replace it during an upgrade without any
> > intermediate state where the system is unusable. This means the actual
> > filename (as opposed to symlink) needs to be something that does not
> > change between versions. If, for example, you had:
> > 
> > /lib/ld-musl-$(ARCH).so.1 -> /lib/musl.so.1.0.0
> > 
> > and wanted to upgrade to musl 1.0.1, you would have to change the
> > symlink to point to a different name. But there is (as far as I know)
> > no way to replace a symlink atomically; you have to unlink it first
> > then make a new symlink. And this leaves a race window during which
> > exec() could fail.
> 
> man rename(2) says:
>        If  oldpath  refers  to a symbolic link the link is renamed; if
>        newpath refers to a symbolic link the link will be overwritten.
> 
> But if this is linux specific, and we want to support other operating
> system kernels than linux, then this might be an issue.

Oh, I was being stupid. Of course this isn't Linux-specific. See
http://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html

So if you want the unversioned name to be a symlink to the versioned
one, then what you do is:

symlink("/lib/musl.so.1.0.1", "/lib/tmp12345");
rename("/lib/tmp12345", "/lib/ld-musl-i386.so.1");

From a shell script, however, it seems you need to explicitly perform
these operations with ln and mv. The "ln -sf" command is specified to
operate via unlink, rather than renaming a temporary link, so it has
the race condition.

This gives us some more flexibility in how the installation and links
work.

Rich


      reply	other threads:[~2013-07-26  6:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-24 20:02 Rich Felker
2013-07-25  7:44 ` Timo Teras
2013-07-25 15:05   ` Szabolcs Nagy
2013-07-25 15:45     ` Timo Teras
2013-07-25 16:39       ` Rich Felker
2013-07-25 16:16   ` Rich Felker
2013-07-25 16:59     ` Timo Teras
2013-07-25 17:18       ` Rich Felker
2013-07-25 17:27         ` Rich Felker
2013-07-26  0:38       ` Isaac
2013-07-26  2:08         ` Rich Felker
2013-07-26  5:13         ` Timo Teras
2013-07-26  5:34           ` Rich Felker
2013-07-26  6:07             ` Timo Teras
2013-07-26  6:18               ` Rich Felker [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=20130726061830.GV4284@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --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).