11.Customized programs

11.1.Architecture specification strings

If a program needs to specify anarchitecture specification string insome place, it should select one of the strings provided bydpkg-architecture-L. The strings are in the formatos-arch, though the OSpart is sometimes elided, as when the OS is Linux.

Note that we don’t want to usearch-debian-linux to apply to therulearchitecture-vendor-os since this would make our programsincompatible with other Linux distributions. We also don’t use somethinglikearch-unknown-linux, since theunknown does not look verygood.

11.1.1.Architecture wildcards

A package may specify an architecture wildcard. Architecture wildcardsare in the formatany (which matches every architecture),os-any, or any-cpu.[1]

11.2.Daemons

The configuration files/etc/services,/etc/protocols, and/etc/rpc are managed by thenetbase package and must not bemodified by other packages.

If a package requires a new entry in one of these files, the maintainershould get in contact with thenetbase maintainer, who will add theentries and release a new version of thenetbase package.

The configuration file/etc/inetd.conf must not be modified by thepackage’s scripts except via theupdate-inetd script or theDebianNet.pm Perl module. See their documentation for details on howto add entries.

If a package wants to install an example entry into/etc/inetd.conf,the entry must be preceded with exactly one hash character (#). Suchlines are treated as “commented out by user” by theupdate-inetdscript and are not changed or activated during package updates.

11.3.Using pseudo-ttys and modifying wtmp, utmp and lastlog

Some programs need to create pseudo-ttys. This should be done usingUnix98 ptys if the C library supports it. The resulting program must notbe installed setuid root, unless that is required for otherfunctionality.

The files/var/run/utmp,/var/log/wtmp and/var/log/lastlogmust be installed writable by grouputmp. Programs which need tomodify those files must be installed setgidutmp.

11.4.Editors and pagers

Some programs have the ability to launch an editor or pager program toedit or display a text document. Since there are lots of differenteditors and pagers available in the Debian distribution, the systemadministrator and each user should have the possibility to choose theirpreferred editor and pager.

In addition, every program should choose a good default editor/pager ifnone is selected by the user or system administrator.

Thus, every program that launches an editor or pager must use the EDITORor PAGER environment variable to determine the editor or pager the userwishes to use. If these variables are not set, the programs/usr/bin/editor and/usr/bin/pager should be used, respectively.These commands may be invoked explicitly (e.g., as/usr/bin/editor) orvia a PATH search (e.g., aseditor).

These two files are managed through thedpkg “alternatives”mechanism. Every package providing an editor or pager must call theupdate-alternatives script to register as an alternative for/usr/bin/editor or/usr/bin/pager as appropriate. Thealternative should have a slave alternative for/usr/share/man/man1/editor.1.gz or/usr/share/man/man1/pager.1.gz pointing to the corresponding manualpage.

If it is very hard to adapt a program to make use of the EDITOR or PAGERvariables, that program may be configured to use/usr/bin/sensible-editor and/usr/bin/sensible-pager as theeditor or pager program respectively. These are two scripts provided inthe sensible-utils package that check the EDITOR and PAGER variables andlaunch the appropriate program, and fall back to/usr/bin/editor and/usr/bin/pager if the variable is not set.

A program may also use the VISUAL environment variable to determine theuser’s choice of editor. If it exists, it should take precedence overEDITOR. This is in fact what/usr/bin/sensible-editor does.

It is not required for a package to depend oneditor andpager,nor is it required for a package to provide such virtualpackages.[2]

11.5.Web servers and applications

This section describes the locations and URLs that should be used by allweb servers and web applications in the Debian system.

  1. Cgi-bin executable files are installed in the directory

    /usr/lib/cgi-bin

    or a subdirectory of that directory, and the script

    /usr/lib/cgi-bin/.../cgi-bin-name

    should be referred to as

    http://localhost/cgi-bin/.../cgi-bin-name
  2. (Deleted)

  3. Access to images

    Images for a package should be stored in/usr/share/images/packageand referred to through an alias/images/ as:

    http://localhost/images/package/filename
  4. Web Document Root

    Web Applications should try to avoid storing files in the WebDocument Root. Instead they should use the /usr/share/doc/packagedirectory for documents. If access to the web document root isunavoidable then use

    /var/www/html

    as the Document Root. This might be just a symbolic link to thelocation where the system administrator has put the real documentroot.

  5. Providing httpd and/or httpd-cgi

    All web servers should provide the virtual packagehttpd. If aweb server has CGI support it should providehttpd-cgiadditionally.

    All web applications which do not contain CGI scripts should dependonhttpd, all those web applications whichdo contain CGIscripts, should depend onhttpd-cgi.

11.6.Mail transport, delivery and user agents

Debian packages which process electronic mail, whether mail user agents(MUAs) or mail transport agents (MTAs), must ensure that they arecompatible with the configuration decisions below. Failure to do thismay result in lost mail, brokenFrom: lines, and other serious braindamage!

The mail spool is/var/mail and the interface to send a mail messageis/usr/sbin/sendmail (as per the FHS). On older systems, the mailspool may be physically located in/var/spool/mail, but all accessto the mail spool should be via the/var/mail symlink. The mailspool is part of the base system and not part of the MTA package.

All Debian MUAs, MTAs, MDAs and other mailbox accessing programs (suchas IMAP daemons) must lock the mailbox in an NFS-safe way. This meansthatfcntl() locking must be combined with dot locking. To avoiddeadlocks, a program should usefcntl() first and dot locking afterthis, or alternatively implement the two locking methods in a nonblocking way.[3] Using the functionsmaillock andmailunlock provided by theliblockfile* packages is therecommended way to accomplish this.

Mailboxes are generally either mode 600 and owned by user or mode 660and owned byuser:mail.[4] The local system administrator maychoose a different permission scheme; packages should not makeassumptions about the permission and ownership of mailboxes unlessrequired (such as when creating a new mailbox). A MUA may remove amailbox (unless it has nonstandard permissions) in which case the MTA oranother MUA must recreate it if needed.

The mail spool is 2775root:mail, and MUAs should be setgid mail todo the locking mentioned above (and must obviously avoid accessing otherusers’ mailboxes using this privilege).

/etc/aliases is the source file for the system mail aliases (e.g.,postmaster, usenet, etc.), it is the one which the sysadmin andpostinst scripts may edit. After/etc/aliases is edited theprogram or human editing it must callnewaliases. All MTA packagesmust come with anewaliases program, even if it does nothing, butolder MTA packages did not do this so programs should not fail ifnewaliases cannot be found. Note that because of this, all MTApackages must haveProvides,Conflicts andReplaces: mail-transport-agent control fields.

The convention of writingforwardtoaddress in the mailbox itself is not supported. Use a.forward file instead.

Thermail program used by UUCP for incoming mail should be/usr/sbin/rmail. Likewise,rsmtp, for receivingbatch-SMTP-over-UUCP, should be/usr/sbin/rsmtp if it is supported.

If your package needs to know what hostname to use on (for example)outgoing news and mail messages which are generated locally, you shoulduse the file/etc/mailname. It will contain the portion after theusername and@ (at) sign for email addresses of users on the machine(followed by a newline).

Such a package should check for the existence of this file when it isbeing configured. If it exists, it should be used without comment,although an MTA’s configuration script may wish to prompt the user evenif it finds that this file exists. If the file does not exist, thepackage should prompt the user for the value (preferably usingdebconf) and store it in/etc/mailname as well as using it inthe package’s configuration. The prompt should make it clear that thename will not just be used by that package. For example, in thissituation theinn package could say something like:

Pleaseenterthe"mail name"ofyoursystem.Thisisthehostnameportionoftheaddresstobeshownonoutgoingnewsandmailmessages.Thedefaultissyshostname,yoursystem's host name.Mailname["syshostname"]:

where syshostname is the output ofhostname--fqdn.

11.7.News system configuration

All the configuration files related to the NNTP (news) servers andclients should be located under/etc/news.

There are some configuration issues that apply to a number of newsclients and server packages on the machine. These are:

/etc/news/organization

A string which should appear as the organization header for allmessages posted by NNTP clients on the machine

/etc/news/server

Contains the FQDN of the upstream NNTP server, or localhost if thelocal machine is an NNTP server.

Other global files may be added as required for cross-package newsconfiguration.

11.8.Programs for the X Window System

11.8.1.Providing X support and package priorities

Programs that can be configured with support for the X Window Systemmust be configured to do so and must declare any package dependenciesnecessary to satisfy their runtime requirements when using the X WindowSystem. If such a package is of higher priority than the X packages onwhich it depends, it is required that either the X-specific componentsbe split into a separate package, or that an alternative version of thepackage, which includes X support, be provided, or that the package’spriority be lowered.

11.8.2.Packages providing an X server

Packages that provide an X server that, directly or indirectly,communicates with real input and display hardware should declare intheirProvides control field that they provide the virtual packagexserver.[5]

11.8.3.Packages providing a terminal emulator

Packages that provide a terminal emulator for the X Window System whichmeet the criteria listed below should declare in theirProvidescontrol field that they provide the virtual packagex-terminal-emulator. They should also register themselves as analternative for/usr/bin/x-terminal-emulator, with a priority of 20.That alternative should have a slave alternative for/usr/share/man/man1/x-terminal-emulator.1.gz pointing to thecorresponding manual page.

To be anx-terminal-emulator, a program must:

  • Be able to emulate a DEC VT100 terminal, or a compatible terminal.

  • Support the command-line option-ecommand, which creates a newterminal window[6] and runs the specified command. <command> maybe multiple arguments, which form the argument list to the executedprogram. In other words, the behavior is as though the argumentswere passed directly toexecvp, bypassing the shell.(xterm’s behavior of falling back on using the shell if-ehad a single argument and exec failed is permissible but notrequired.)

  • Support the command-line option-Ttitle, which creates a newterminal window with the window title title.

11.8.4.Packages providing a window manager

Packages that provide a window manager should declare in theirProvides control field that they provide the virtual packagex-window-manager. They should also register themselves as analternative for/usr/bin/x-window-manager, with a prioritycalculated as follows:

  • Start with a priority of 40.

  • If the window manager complies withThe Window Manager SpecificationProject,written by theFree DesktopGroup, add 40 points.

  • If the window manager permits the X session to be restarted using adifferent window manager (without killing the X server) in itsdefault configuration, add 10 points; otherwise add none.

That alternative should have a slave alternative for/usr/share/man/man1/x-window-manager.1.gz pointing to thecorresponding manual page.

11.8.5.Packages providing fonts

Packages that provide fonts for the X Window System[7] must do anumber of things to ensure that they are both available withoutmodification of the X or font server configuration, and that they do notcorrupt files used by other font packages to register information aboutthemselves.

  1. Fonts of any type supported by the X Window System must be in aseparate binary package from any executables, libraries, ordocumentation (except that specific to the fonts shipped, such astheir license information). If one or more of the fonts so packagedare necessary for proper operation of the package with which theyare associated the font package may be Recommended; if the fontsmerely provide an enhancement, a Suggests relationship may be used.Packages must not Depend on font packages.[8]

  2. BDF fonts must be converted to PCF fonts with thebdftopcfutility (available in thexfonts-utils package,gzipped,and placed in a directory that corresponds to their resolution:

    • 100 dpi fonts must be placed in/usr/share/fonts/X11/100dpi/.

    • 75 dpi fonts must be placed in/usr/share/fonts/X11/75dpi/.

    • Character-cell fonts, cursor fonts, and other low-resolutionfonts must be placed in/usr/share/fonts/X11/misc/.

  3. Type 1 fonts must be placed in/usr/share/fonts/X11/Type1/. Iffont metric files are available, they must be placed here as well.

  4. Subdirectories of/usr/share/fonts/X11/ other than those listedabove must be neither created nor used. (ThePEX,CID,Speedo, andcyrillic directories are excepted for historicalreasons, but installation of files into these directories remainsdiscouraged.)

  5. Font packages may, instead of placing files directly in the X fontdirectories listed above, provide symbolic links in that fontdirectory pointing to the files’ actual location in the filesystem.Such a location must comply with the FHS.

  6. Font packages should not contain both 75dpi and 100dpi versions of afont. If both are available, they should be provided in separatebinary packages with-75dpi or-100dpi appended to the namesof the packages containing the corresponding fonts.

  7. Fonts destined for themisc subdirectory should not be includedin the same package as 75dpi or 100dpi fonts; instead, they shouldbe provided in a separate package with-misc appended to itsname.

  8. Font packages must not provide the filesfonts.dir,fonts.alias, orfonts.scale in a font directory:

    • fonts.dir files must not be provided at all.

    • fonts.alias andfonts.scale files, if needed, should beprovided in the directory/etc/X11/fonts/fontdir/package.extension, where fontdir isthe name of the subdirectory of/usr/share/fonts/X11/ wherethe package’s corresponding fonts are stored (e.g.,75dpi ormisc), package is the name of the package that provides thesefonts, and extension is eitherscale oralias, whichevercorresponds to the file contents.

  9. Font packages must declare a dependency onxfonts-utils in theirDepends orPre-Depends control field.

  10. Font packages that provide one or morefonts.scale files asdescribed above must invokeupdate-fonts-scale on each directoryinto which they installed fontsbefore invokingupdate-fonts-dir on that directory. This invocation must occurin both thepostinst (for all arguments) andpostrm (for allarguments exceptupgrade) scripts.

  11. Font packages that provide one or morefonts.alias files asdescribed above must invokeupdate-fonts-alias on each directoryinto which they installed fonts. This invocation must occur in boththepostinst (for all arguments) andpostrm (for allarguments exceptupgrade) scripts.

  12. Font packages must invokeupdate-fonts-dir on each directoryinto which they installed fonts. This invocation must occur in boththepostinst (for all arguments) andpostrm (for allarguments exceptupgrade) scripts.

  13. Font packages must not provide alias names for the fonts theyinclude which collide with alias names already in use by fontsalready packaged.

  14. Font packages must not provide fonts with the same XLFD registryname as another font already packaged.

11.8.6.Application defaults files

Application defaults files must be installed in the directory/etc/X11/app-defaults/ (use of a localized subdirectory of/etc/X11/ as described in theX Toolkit Intrinsics - C LanguageInterface manual is also permitted). They must be registered asconffiles or handled as configuration files.

Customization of programs’ X resources may also be supported with theprovision of a file with the same name as that of the package placed inthe/etc/X11/Xresources/ directory, which must be registered as aconffile or handled as a configuration file.[9]

11.8.7.Installation directory issues

Historically, packages using the X Window System used a separate set ofinstallation directories from other packages. This practice has beendiscontinued and packages using the X Window System should now generallybe installed in the same directories as any other package. Specifically,packages must not install files under the/usr/X11R6/ directory andthe/usr/X11R6/ directory hierarchy should be regarded as obsolete.

Include files previously installed under/usr/X11R6/include/X11/should be installed into/usr/include/X11/. For files previouslyinstalled into subdirectories of/usr/X11R6/lib/X11/, packagemaintainers should determine if subdirectories of/usr/lib/ and/usr/share/ can be used. If not, a subdirectory of/usr/lib/X11/should be used.

Configuration files for window, display, or session managers or otherapplications that are tightly integrated with the X Window System may beplaced in a subdirectory of/etc/X11/ corresponding to the packagename. Other X Window System applications should use the/etc/directory unless otherwise mandated by policy (such as forApplication defaults files).

11.9.Perl programs and modules

Perl programs and modules should follow the current Perl policy.

The Perl policy can be found in theperl-policy files in thedebian-policy package. It is also available from the Debian webmirrors athttps://www.debian.org/doc/packaging-manuals/perl-policy/.

11.10.Emacs lisp programs

Please refer to the “Debian Emacs Policy” for details of how to packageemacs lisp programs.

The Emacs policy is available indebian-emacs-policy.gz of theemacsen-common package. It is also available from the Debian web mirrorsathttps://www.debian.org/doc/packaging-manuals/debian-emacs-policy.

11.11.Games

The permissions on/var/games are mode 755, ownerroot and grouproot.

Each game decides on its own security policy.

Games which require protected, privileged access to high-score files,saved games, etc., may be made set-group-id (mode 2755) and owned byroot:games, and use files and directories with appropriatepermissions (770root:games, for example). They must not be madeset-user-id, as this causes security problems. (If an attacker cansubvert any set-user-id game they can overwrite the executable of anyother, causing other players of these games to run a Trojan horseprogram. With a set-group-id game the attacker only gets access to lessimportant game data, and if they can get at the other players’ accountsat all it will take considerably more effort.)

Some packages, for example some fortune cookie programs, are configuredby the upstream authors to install with their data files or other staticinformation made unreadable so that they can only be accessed throughset-id programs provided. You should not do this in a Debian package:anyone can download the.deb file and read the data from it, sothere is no point making the files unreadable. Not making the filesunreadable also means that you don’t have to make so many programsset-id, which reduces the risk of a security hole.

As described in the FHS, binaries of games should be installed in thedirectory/usr/games. This also applies to games that use the XWindow System. Manual pages for games (X and non-X games) should beinstalled in/usr/share/man/man6.

[1]

Internally, the package system normalizes the GNU triplets and theDebian arches into Debian arch triplets (which are kind of invertedGNU triplets), with the first component of the triplet representingthe libc and ABI in use, and then does matching against thosetriplets. However, such triplets are an internal implementationdetail that should not be used by packages directly. The libc and ABIportion is handled internally by the package system based on the osand cpu.

[2]

The Debian base system already provides an editor and a pagerprogram.

[3]

If it is not possible to establish both locks, the system shouldn’twait for the second lock to be established, but remove the firstlock, wait a (random) time, and start over locking again.

[4]

There are two traditional permission schemes for mail spools: mode600 with all mail delivery done by processes running as thedestination user, or mode 660 and owned by group mail with maildelivery done by a process running as a system user in group mail.Historically, Debian required mode 660 mail spools to enable thelatter model, but that model has become increasingly uncommon and theprinciple of least privilege indicates that mail systems that use thefirst model should use permissions of 600. If delivery to programs ispermitted, it’s easier to keep the mail system secure if the deliveryagent runs as the destination user. Debian Policy therefore permitseither scheme.

[5]

This implements current practice, and provides an actual policy forusage of thexserver virtual package which appears in the virtualpackages list. In a nutshell, X servers that interface directly withthe display and input hardware or via another subsystem (e.g., GGI)should providexserver. Things likeXvfb,Xnest, andXprt should not.

[6]

“New terminal window” does not necessarily mean a new top-level Xwindow directly parented by the window manager; it could, if theterminal emulator application were so coded, be a new “view” in amultiple-document interface (MDI).

[7]

For the purposes of Debian Policy, a “font for the X Window System”is one which is accessed via X protocol requests. Fonts for the Linuxconsole, for PostScript renderer, or any other purpose, do not fitthis definition. Any tool which makes such fonts available to the XWindow System, however, must abide by this font policy.

[8]

This is because an X client may be displayed by a remote X server,in which case X fonts are provided by the remote X server, notretrieved locally; the Debian package system is empowered to dealonly with the local file system.

[9]

Note that this mechanism is not the same as using app-defaults;app-defaults are tied to the client binary on the local file system,whereas X resources are stored in the X server and affect allconnecting clients.