From: Manoj Srivastava
The new package's files are unpacked, overwriting any that may be on the system already, for example any @@ -2888,13 +2887,14 @@ Package: libc6
+ If the package is being upgraded, call
If this fails,
This is the point of no return - if
When we configure a package (this happens with dpkg
- --install, or with --configure), we first
+ --install and dpkg --configure), we first
update any conffiles and then call:
- The conffiles and any backup files (~-files,
- #*# files, %-files,
- .dpkg-{old,new,tmp}, etc.) are removed.
@@ -3741,9 +3743,9 @@ Replaces: mail-transport-agent
must call@@ -4626,7 +4628,7 @@ test -f program-executed-later-in-script || exit 0 scripts whose values control the bahaviour of the scripts, and which a system administrator is likely to want to change. As the scripts themselves are frequently - conffiles, modifying them requires that the + conffiles, modifying them requires that the administrator merge in their changes each time the package is upgraded and the conffile changes. To ease the burden on the system administrator, such configurable @@ -5795,21 +5797,25 @@ ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
- A file that affects the operation of program, or
+
+ A file that affects the operation of a program, or
provides site- or host-specific information, or
- otherwise customizes the behavior of program.
+ otherwise customizes the behavior of a program.
Typically, configuration files are intended to be
modified by the system administrator (if needed or
- desired) to conform to local policy or provide more
- useful site-specific behavior.
+
A file listed in a package's conffiles
file, and is treated specially by
The distinction between these two is important; they are not interchangeable concepts. Almost all - conffiles are configuration files, but many - configuration files are not conffiles.
+ conffiles are configuration files, but many + configuration files are not conffiles. +Note that a script that embeds configuration information - (such as most of the files in /etc/init.d and + (such as most of the files in /etc/default and /etc/cron.{daily,weekly,monthly}) is de-facto a - configuration file and should be treated as such.
+ configuration file and should be treated as such. +local changes must be preserved during a package - upgrade
++ local changes must be preserved during a package + upgrade, and +
configuration files must be preserved when the +
+ configuration files must be preserved when the package is removed, and only deleted when the - package is purged.
+ package is purged. +
The easy way to achieve this behavior is to make the
@@ -5882,199 +5895,226 @@ ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
Rationale: There are two problems with hard links.
The first is that some editors break the link while
editing one of the files, so that the two files may
- unwittingly become different. The second is that
-
- The other way to do it is via the maintainer scripts.
- In this case, the configuration file must not be listed as
- a conffile and must not be part of the package
+ The other way to do it is via the maintainer scripts. In
+ this case, the configuration file must not be listed as a
+ conffile and must not be part of the package
distribution. If the existence of a file is required for
the package to be sensibly configured it is the
- responsibility of the package maintainer to write scripts
- which correctly create, update, maintain and
- remove-on-purge the file. These scripts must be idempotent
- (i.e., must work correctly if
- The scripts are not required to configure every possible option for
- the package, but only those necessary to get the package
- running on a given system. Ideally the sysadmin should not
- have to do any configuration other than that done
- (semi-)automatically by the
- A common practice is to create a script called
- package-configure and have the
- package's
+ The scripts are not required to configure every possible
+ option for the package, but only those necessary to get
+ the package running on a given system. Ideally the
+ sysadmin should not have to do any configuration other
+ than that done (semi-)automatically by the
+
+ A common practice is to create a script called
+ package-configure and have the
+ package's
These two styles of configuration file handling must
not be mixed, for that way lies madness:
- Packages which specify the same file as - `conffile' must be tagged as conflicting - with each other. -
+ Packages which specify the same file as a + conffile must be tagged as conflicting + with each other. (This is an instance of the general rule + about not sharing files. Note that neither alternatives + nor diversions are likely to be appropriate in this case.) +- The maintainer scripts must not alter the conffile of - any package, including the one the scripts belong - to.
+ The maintainer scripts must not alter a conffile + of any package, including the one the scripts + belong to. +If two or more packages use the same configuration file and it is reasonable for both to be installed at the same time, one of these packages must be defined as owner of the configuration file, i.e., it will be - the package to list that distributes the file and lists it - as a conffile. Other packages that use the - configuration file must depend on the owning package if - they require the configuration file to operate. If the - other package will use the configuration file if present, - but is capable of operating without it, no dependency need - be declared.
+ the package which handles that file as a configuration + file. Other packages that use the configuration file must + depend on the owning package if they require the + configuration file to operate. If the other package will + use the configuration file if present, but is capable of + operating without it, no dependency need be declared.
If it is desirable for two or more related packages to
share a configuration file and for all of the
related packages to be able to modify that configuration
file, then the following should be done:
-
- have one of the related packages (the "core"
- package) manage the configuration file with
- maintainer scripts as described in the previous
- section.
- the core package should also provide a program that - the other packages may use to modify the - configuration file.
++ The owning package should also provide a program + that the other packages may use to modify the + configuration file. +
- the related packages must use the provided program - to make any modifications to the configuration file. - They should either depend on the core package to - guarantee that the configuration modifier program is - available or accept gracefully that they cannot - modify the configuration file if it is not.
+ The related packages must use the provided program + to make any desired modifications to the + configuration file. They should either depend on + the core package to guarantee that the configuration + modifier program is available or accept gracefully + that they cannot modify the configuration file if it + is not. (This is in addition to the fact that the + configuration file may not even be present in the + latter scenario.) +Sometimes it's appropriate to create a new package which provides the basic infrastructure for the other packages - and which manages the shared configuration files. (Check - out the sgml-base package as an example.)
+ and which manages the shared configuration files. (The + sgml-base package is a good example.) +
- Files in /etc/skel will automatically be copied
- into new user accounts by
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 listed in - conffiles, if it is not generated and modified dynamically - by the package's installation scripts).
+ should be installed in /etc/skel and treated as a + configuration file. +However, programs that require dotfiles in order to operate sensibly (dotfiles that they do not create - themselves automatically, that is) are a bad thing, and - programs should be configured by the Debian default - installation as close to normal as possible.
+ themselves automatically, that is) are a bad thing. + Furthermore, programs should be configured by the Debian + default installation as behave as closely to the upstream + default behaviour as possible. +Therefore, if a program in a Debian package needs to be - configured in some way in order to operate sensibly that - configuration should be done in a site-wide global - configuration file elsewhere 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.
+ 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 - mechanism for ensuring that the appropriate dotfiles are - copied into the accounts of existing users when a package - is installed.
+ 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. +- The traditional approach to log files has been to set up ad - hoc log rotation schemes using simple shell scripts and - cron. While this approach is highly customizable, it - requires quite a lot of sysadmin work. Even though the - original Debian system helped a little by automatically - installing a system which can be used as a template, this - was deemed not enough. -
- -- A better scheme is to use logrotate, a GPL'd program - developed by Red Hat, which centralizes log management. It - has both a configuration file (/etc/logrotate.conf) - and a directory where packages can drop logrotation info - (/etc/logrotate.d). -
-Log files should usually be named /var/log/package.log. If you have many - log files, or need a separate directory for permissions + log files, or need a separate directory for permission reasons (/var/log is writable only by root), you should usually create a directory named - /var/log/package.
+ /var/log/package and place your log + files there. +
- Log files must be rotated occasionally so
- that they don't grow indefinitely; the best way to do this
- is to drop a script into the directory
+ Log files must be rotated occasionally so that they don't
+ grow indefinitely; the best way to do this is to drop a log
+ rotation configuration file into the directory
/etc/logrotate.d and use the facilities provided by
- logrotate. Here is a good example for a logrotate config
+ logrotate.
+
+ The traditional approach to log files has been to set up
+ ad hoc log rotation schemes using simple shell
+ scripts and cron. While this approach is highly
+ customizable, it requires quite a lot of sysadmin work.
+ Even though the original Debian system helped a little
+ by automatically installing a system which can be used
+ as a template, this was deemed not enough.
+
+ The use of
Log files should be removed when the package is
- purged (but not when it is only removed), by checking the
- argument to the
Files should be owned by root.root, and made writable only by the owner and universally readable (and - executable, if appropriate).
+ executable, if appropriate), that is mode 644 or 755. +Directories should be mode 755 or (for group-writability) mode 2775. The ownership of the directory should be consistent with its mode: if a directory is mode 2775, it should be owned by the group that needs write access to - it.
+ it. +Setuid and setgid executables should be mode 4755 or 2755 @@ -6128,30 +6171,44 @@ endscript They should not be made unreadable (modes like 4711 or 2711 or even 4111); doing so achieves no extra security, because anyone can find the binary in the freely available - Debian package, it is merely inconvenient. For the same + Debian package; it is merely inconvenient. For the same reason you should not restrict read or execute permissions - on non-set-id executables.
+ on non-set-id executables. +Some setuid programs need to be restricted to particular sets of users, using file permissions. In this case they - should be owned by the uid to which they are set-id, and - by the group which should be allowed to execute them. - They should have mode 4754; there is no point in making + should be owned by the uid to which they are set-id, and by + the group which should be allowed to execute them. They + should have mode 4754; again there is no point in making them unreadable to those users who must not be allowed to - execute them.
+ execute them. +
- You must not arrange that the system administrator can only
+ It is possible to arrange that the system administrator can
reconfigure the package to correspond to their local
- security policy by changing the permissions on a binary.
- Ordinary files installed by
+ Ordinary files installed by
If you need to create a new user or group for your package @@ -6164,37 +6221,105 @@ endscript
If you need a statically allocated id, you must ask for a - user or group id from the base system - maintainer, and must not release the package until you - have been allocated one. Once you have been allocated one - you must make the package depend on a version of the base - system with the id present in /etc/passwd or - /etc/group, or alternatively arrange for your - package to create the user or group itself with the - correct id (using adduser) in its pre- or - post-installation script (the latter is to be preferred if - it is possible).
- -
- On the other hand, the program might be able to determine the
- uid or gid from the group name at runtime, so that a
- dynamic id can be used. In this case you should choose an
- appropriate user or group name, discussing this on
-
- Note that changing the numeric value of an id associated with a name - is very difficult, and involves searching the file system for all - appropriate files. You need to think carefully whether a static or - dynamic id is required, since changing your mind later will cause - problems.
+ user or group id from the base-passwd maintainer, + and must not release the package until you have been + allocated one. Once you have been allocated one you must + either make the package depend on a version of the + base-passwd package with the id present in + /etc/passwd or /etc/group, or arrange for + your package to create the user or group itself with the + correct id (using adduser) in its +
+ On the other hand, the program might be able to determine
+ the uid or gid from the user or group name at runtime, so
+ that a dynamically allocated id can be used. In this case
+ you should choose an appropriate user or group name,
+ discussing this on
+ Note that changing the numeric value of an id associated + with a name is very difficult, and involves searching the + file system for all appropriate files. You need to think + carefully whether a static or dynamic id is required, since + changing your mind later will cause problems. +
+ +
+ This section is not intended as policy, but as a
+ description of the use of
+
+ If a system administrator wishes to have a file (or
+ directory or other such thing) installed with owner and
+ permissions different from those in the distributed Debian
+ package, he can use the
+ Given the above,