Bug 12551

Summary: dpkg remove (and update) destroys symlinks to directories
Product: Busybox Reporter: nolange79
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: major CC: busybox-cvs
Priority: P5    
Version: 1.33.x   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description nolange79 2020-02-11 10:07:41 UTC
the target installation has a symlink lib -> usr/lib.
The deb archive contains a file './lib/systemd/system/a.service'

When removing (update does remove the old packet as well), dpkg will do the following:

lstat("/.", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
rmdir("/.")                             = -1 EINVAL (Invalid argument)
lstat("/lib", {st_mode=S_IFLNK|0777, st_size=7, ...}) = 0
unlink("/lib")                          = 0
lstat("/lib/systemd", 0x7ffe2f87b8d0)   = -1 ENOENT (No such file or directory)
lstat("/lib/systemd/system", 0x7ffe2f87b8d0) = -1 ENOENT (No such file or directory)

That leads two 2 problems:

1.  the /lib symlink is now gone, rendering the system unusable.
2.  cleanup is done bottom up, means in this case it fails to remove everything else.
Comment 1 Denys Vlasenko 2020-06-29 12:07:06 UTC
Fixed in git.