[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Is there still a point in installing libgcrypt to /lib instead of /usr/lib



On 2/21/20 2:00 AM, Wouter Verhelst wrote:
Even so, if we want to do so, this can be done correctly by a preinst
script in new libc, by way of a script that does the following:

cp -a /lib/<dynamic linker name> /usr/lib/<dynamic linker name>
ln -sf /lib/<dynamic linker name> /usr/lib/<dynamic linker name>

The first of the above two creates the new file; the second replaces the
old file, atomically, by a symlink.

Errr, pretty sure you meant to have the ln arguments in the opposite order. The link name is the second argument to ln.

Besides that, you need a sync after the cp. Otherwise (in the event of an ill-timed crash) the data may not be written out, and you might wind up with /usr/lib/<dynamic linker name> being, e.g., a zero-byte file (with /lib/<dynamic linker name> a symlink to it). Possibly you even end up with /usr/lib/<dynamic linker name> missing, and /lib/<dynamic linker name> a dangling link.

(It appears ln does not do a sync of any sort between the symlinkat and rename syscalls, no idea if that is also a bug.)


Reply to: