1

I somehow always assumed that when I run a command like apt-get install, remove, purge then at most apt might add configuration dot-files files to my existing local home (not even sure about that), but NEVER modify or delete any files there (without backing up).

Is there any such restriction or at least guideline?

2 Answers 2

5

There are two issues:

  1. Debian policy dictates how home directories are managed and properly packaged .deb should not modify anything in users home directories.

9.2.3. Non-existent home directories The canonical non-existent home directory is /nonexistent. Users who should not have a home directory should have their home directory set to this value.

The Debian autobuilders set HOME to /nonexistent so that packages which try to write to a home directory will fail to build.

10.7.5. User configuration files (“dotfiles”) The files in /etc/skel will automatically be copied into new user accounts by adduser. No other program should reference the files in /etc/skel.

Therefore, if a program needs a dotfile to exist in advance in $HOME to work sensibly, that dotfile should be installed in /etc/skel and treated as a configuration file.

However, programs that require dotfiles in order to operate sensibly are a bad thing, unless they do create the dotfiles themselves automatically.

Furthermore, programs should be configured by the Debian default installation to behave as closely to the upstream default behavior as possible.

Therefore, if a program in a Debian package needs to be configured in some way in order to operate sensibly, that should be done using a site-wide configuration file placed in /etc. Only if the program doesn’t support a site-wide default configuration and the package maintainer doesn’t have time to add it may a default per-user file be placed in /etc/skel.

/etc/skel should be as empty as we can make it. This is particularly true because there is no easy (or necessarily desirable) mechanism for ensuring that the appropriate dotfiles are copied into the accounts of existing users when a package is installed.

See : https://www.debian.org/doc/debian-policy/ for details


HOWEVER .....

  1. Installing .deb requires root authorization and packages can run pre and post install scripts that modify files in home directories in violation of debian policy or people who package .deb may choose to ignore debian policy.

So it is possible for .deb to violate debian policy and alter files in user home directories.

This is one of many considerations or reasons you should be very careful when installing .deb from outside the Ubuntu repositories.

1
  • thx, interesting about /etc/skel. I was not too concerned about new user homes created by useradd, but by existing ones, but still a good answer.
    – tkruse
    Jan 9, 2018 at 4:49
4

No apt installation, update, removal etc should modify files in users' home directories. Not even dotfiles.

Files in your home directory should only be modified by software that you run under your account.

There are reasons for this:

  1. Home directories are designated by the FHS standard as directories under the control of the individual user, not the system.

  2. The install/update/remove scripts have no reason to know or care which users exist on the system and no reason to do anything specific for any specific user.

  3. Any system-wide configuration for any software will go in a system directory (ie /etc). Dotfiles inside user accounts are only for configuration changes made by a particular user.

  4. It is not the system's responsibility to update user-specific configuration. If a piece of software needs a change in the way they are configured that software needs to do the migration itself when run as that user, not when installed or updated.

4
  • 1
    I agree with your answer, but "should" and "can" are different things. According to Debian Policy packages should not modify users home directories as you rightly state, however, they CAN if the packager ignores debian policy or writes a script to do so.
    – Panther
    Jan 9, 2018 at 3:36
  • @Panther OP asks "is there any restriction or at least guideline". The answer makes it clear that this is a guideline, not a restriction. (Indeed, such a restriction cannot exist since packages are installed as root, and root can always do anything.)
    – fkraiem
    Jan 9, 2018 at 3:42
  • As a detail would be good to know if maybe the official ppa repositories had tests that prevent this from happening.
    – tkruse
    Jan 9, 2018 at 4:59
  • All PPAs are unofficial by definition - in the sense that PPAs are not governed or approved by Ubuntu. It would be possible for an install script on a package in a PPA to modify home directories - but still unlikely for the reasons stated in my answer. Jan 9, 2018 at 5:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .