FS#62366 - Pacman overwrites symlink with a directory despite being listed under NoUpgrade

Attached to Project: Pacman
Opened by Dimitrios Apostolou (jimis) - Tuesday, 16 April 2019, 14:12 GMT
Last edited by Andrew Gregory (andrewgregory) - Monday, 22 April 2019, 05:04 GMT
Task Type Bug Report
Category Backend/Core
Status Closed
Assigned To No-one
Architecture All
Severity Medium
Priority Normal
Reported Version 5.1.3
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Summary: I want to stop pacman from installing the /home empty directory, contained in the filesystem package.

Details:

I have moved all my /home folder to a subdirectory of a new disk, by means of a symlink:

```
# ls -l /home
lrwxrwxrwx 1 root root 13 Apr 16 17:02 /home -> /mnt/newdisk/home/
```

The problem is that every time the `filesystem` package gets upgraded, the symlink `/home` is overwritten and replaced with an empty directory. *No warnings or messages are printed whatsoever*, I found out at first because users could not login.

I have tried to list `home` in pacman.conf under `NoUpgrade` and `NoExtract` but no luck: symlink is overwritten with no warning.

For now I have a workaround: list `filesystem` in `IgnorePkg` and hope nothing breaks in the future.

Any ideas how to stop pacman from touching my symlink?
This task depends upon

Closed by  Andrew Gregory (andrewgregory)
Monday, 22 April 2019, 05:04 GMT
Reason for closing:  Not a bug
Comment by loqs (loqs) - Tuesday, 16 April 2019, 15:26 GMT
pacman should not be overwriting the symlink with a directory unless --force is used.
However pacman is not able to handle symlinks where directories are expected instead of symlinks bind mounts should be used.
Comment by Eli Schwartz (eschwartz) - Tuesday, 16 April 2019, 15:50 GMT
  • Field changed: Attached to Project (Arch Linux → Pacman)
This is just another instance of  FS#58804  -- pacman bug, not general arch-projects bug.

pacman is buggy and really should fatally abort, refusing to allow you to upgrade your system at all until you stop using symlinks and start using bind mounts.

However, the solution is still that you should not be using symlinks at all. It's invalid to replace a directory with a file (even if that file is of type "symbolic link").

Note that another solution, instead of using bind mounts, is to correctly configure the `useradd` command via the file /etc/default/useradd, and set HOME=/some/other/base/directory

This would result in an /etc/passwd which natively contains the correct locations, and is IMHO a far better solution.

I will leave this bug open for a bit, because I'd like Allan or Andrew to confirm if NoUpgrade is supposed to display this behavior of extracting a directory (in this case /home/ which is indeed a directory as far as makepkg is concerned) -- the manpage only specifies that it accepts files, so I'm unsure whether this is correct, a bug, or "undefined behavior" that could be implemented.
Comment by Dimitrios Apostolou (jimis) - Tuesday, 16 April 2019, 16:21 GMT
Thanks for moving this ticket to the right place, I couldn't find a "pacman" category.

The bind mount sounds like a good workaround, I appreciate the advice and I'll apply it. Changing /etc/default/useradd not so much though, it will definitely have side-effects as there are many scripts that presume homes under /home. (yes these tools shouldn't assume /home, but they do)

Looking forward to getting feedback on NoUpgrade, it would definitely be nice to be able to upgrade the system with such symlinks in place.

Otherwise I'm OK with closing this as DUPLICATE, since the one you pointed to ( FS#58804 ) is open and acknowledged as a bug.
Comment by Andrew Gregory (andrewgregory) - Tuesday, 16 April 2019, 21:19 GMT
As already stated, use a mount. NoExtract already works just fine with directories though.

Loading...