dskvr / opkg

Automatically exported from code.google.com/p/opkg
0 stars 0 forks source link

[PATCH] update-alternatives: use 'ln -n' #95

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Using the '-n' option (--no-dereference) is a better way to solve the
do-not-link-into-directory issue.  Using only 'ln -sf' can cause problems
on SELinux enabled hosts when target is inaccessible; e.g. when preparing
an offline rootsystem:

 | $ cd <offline root>
 | $ ln -sf /lib/systemd/systemd sbin/init     # alternative #1
 | $ ln -sf /bin/busybox sbin/init             # alternative #2
 | ln: accessing `sbin/init': Permission denied
 | 
 |  --> strace:
 | brk(0)                                  = 0x102b000
 | stat("sbin/init", 0x7fffaa91c900)       = -1 EACCES (Permission denied)
 | ...
 | exit_group(1)                           = ?

Now with '-n':

 | $ ln -snf /bin/busybox sbin/init
 | lstat("sbin/init", {st_mode=S_IFLNK|0777, st_size=20, ...}) = 0
 | lstat("sbin/init", {st_mode=S_IFLNK|0777, st_size=20, ...}) = 0
 | stat("/bin/busybox", 0x7fff8c1a3bd0)    = -1 ENOENT (No such file or directory)
 | symlink("/bin/busybox", "sbin/init")    = -1 EEXIST (File exists)
 | unlink("sbin/init")                     = 0
 | symlink("/bin/busybox", "sbin/init")    = 0

The '-n' flag is well supported (coreutils have it at least since
1999, busybox at least since 0.60.3 (2002)) and it obsoletes the
explicit check whether target is a directory.

Original issue reported on code.google.com by scholz.e...@gmail.com on 13 Oct 2012 at 10:21

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by pixdamix@gmail.com on 22 Nov 2012 at 9:24

GoogleCodeExporter commented 8 years ago
I don't see this one commited yet. Do you have something more to commit?

Original comment by Martin.J...@gmail.com on 22 Nov 2012 at 9:57