Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Absolute BSD - The Ultimate Guide To FreeBSD (2002).pdf
Скачиваний:
25
Добавлен:
17.08.2013
Размер:
8.15 Mб
Скачать

NOPORTDOCS=true Various pieces of software in the ports collection have extensive documentation that is generally installed under /usr/local/share. If you set this option, this documentation is not installed. If you have a test machine or workstation where you can install the documentation, you can set this option on your servers.

HAVE_MOTIF=yes Motif is a software graphics library that many ports try to use to provide various graphic widgets. Motif was very expensive for several years, but free versions are available under /usr/ports/x11−toolkits/lesstif and /usr/ports/x11−toolkits/open−motif. If you have either of these toolkits installed, set HAVE_MOTIF.

/etc/master.passwd

This file contains usernames and passwords. When you log in, the password you type is compared with the one in this file.

The /etc/master.passwd file is important enough that there's a special program just for editing it. Vipw(8) calls up the text editor from $EDITOR, allows you to make your changes, and checks the file syntax before allowing you to save it. Vipw also updates the password databases. This prevents many of the more basic mistakes, but if you're really bent on corrupting /etc/master.passwd, vipw will make life more difficult but won't stop you.

When vipw finally allows you to save your work, it also recreates the file /etc/passwd. This file can only be read by root.

If the information in /etc/master.passwd conflicts with that in other files, programs generally assume that /etc/master.passwd is correct. For example, /etc/group sometimes doesn't list a user's primary group. The primary group that appears in /etc/passwd is correct, even when it isn't listed in /etc/group.

Many programs need access to the information in /etc/master.passwd–for example, shells and home directories must be public information. Rather than allowing anyone to read this file and try to reverse−engineer the encrypted passwords, FreeBSD provides globally readable bits of this file in /etc/passwd.

Fields

Each line in /etc/master.passwd contains ten fields, separated by colons. These are described in the following sections.

Username The first field in lines in /etc/master.passwd is the username. This is either an account created by the administrator and used by a real user, or a user created at install time to provide some system service. FreeBSD includes a variety of system accounts, such as root, toor, daemon, games, uucp, and so on. Each of these users owns some part of the system. Various programs can run as these users.

Encrypted Password The second field is the encrypted password. System users don't generally have a password, so you can't log in as them. User accounts have a string of random−looking characters here.

One simple way to temporarily disable a user account is to edit the password file and put an asterisk

(*) in front of the password. While the account will still be active, nobody will be able to log in to it. I've used this to great effect when a client was behind on a bill; they call quite quickly when they

207

can't log in.

User ID The third field is the user ID number, or UID. Every user has a unique UID.

Group ID Similarly, the fourth field is the group ID number, or GID. This is the user's primary group, as discussed in Chapter 7. Usually, this is the same as the UID, and the group has the same name as the username.

User's Class The next field is the user's class as defined in /etc/login.conf. You can change a user's class by using vipw and editing master.passwd directly, or with chsh(1).

Password Expiration The sixth field is the password expiration field. If you leave this blank, or if you're not running system accounting, passwords will not expire. The expiration field is filled in as seconds since the epoch. (The epoch is midnight, January 1, 1970).

Number of Seconds Since the Epoch Similarly, the seventh field is the number of seconds since the epoch until the entire account expires. If you aren't using system accounting, this is useless.

Gecos The gecos field contains the user's real name, office number, work phone number, and home phone number, all separated by commas. Do not use colons in this field; colons are reserved specifically for separating fields in /etc/master.passwd itself.

User's Home Directory The ninth field is the user's home directory. While this defaults to /home, you can move this anywhere you like. You'll just need to move the actual home directory when you change this field.

User's Shell Finally, the tenth field gives the user's shell. If this field is empty, the system assumes the user gets boring old /bin/sh.

/etc/motd

The motd, or message of the day file, is displayed to users when they log in. You can put system notices in this file, or other information you want shell users to see. Note that who sees this file is controlled by the welcome option in /etc/login.conf. You can have multiple message files, one for each login class.

/etc/mtree/*

The system upgrade processes use the /etc/mtree files. They have no effect on the daily running of the system. Mtree(8) builds directory hierarchies, usually so an automated installer can put programs in them. While you don't need to edit these files, it's nice to know why they're here.

/etc/namedb/*

The /etc/namedb files control the system nameserver. See Chapter 12 for details of how the files in /etc/namedb work.

/etc/newsyslog.conf

This file configures the rotation and deletion of logs. See Chapter 19 for details of the system logger.

208

/etc/passwd

Many programs require access to user information such as shell, real name, and so on. In older UNIX systems, this was stored in the /etc/passwd file, along with the actual encrypted passwd, and everyone could read this file. This became a problem as UNIX spread into universities. Computer science students had great fun trying to crack encrypted passwords, and regretfully succeeded on too many occasions. Hackers made /etc/passwd their target. Eventually, the encrypted passwords were moved to /etc/master.passwd. The /etc/passwd file remained as an information source for other programs.

The /etc/passwd file is generated from the /etc/master.passwd file by stripping out the class, change, and expire fields. The encrypted password is replaced with an asterisk. These are the remaining fields:

username

password (asterisk)

user ID number

group ID number

name

home directory

shell

See the /etc/master.passwd section for details on these fields.

/etc/periodic.conf and /etc/defaults/periodic.conf

The /etc/periodic.conf file is another one with a default in /etc/defaults, and overrides in /etc. Periodic(8) runs every day to handle basic daily maintenance. It's the source of the status messages mailed to root every day, and it can handle a variety of tasks, which are stored as shell scripts under /etc/periodic. (By default, periodic tries to run quite a few tasks that you might or might not need; the scripts are generally intelligent, though, and put as little load as possible on the system.) Every function available to the periodic program is enabled or disabled in periodic.conf.

Periodic runs programs either daily, weekly, or monthly. Each set of programs has its own settings; for example, programs that run daily are configured separately from programs that run monthly. These settings are controlled by entries in the /etc/periodic.conf file. Here are some standard entries from that file.

...............................................................................................

periodic_conf_files=" /etc/periodic.conf /etc/periodic.conf.local"

...............................................................................................

The preceding line tells the periodic program where to look for override files, and you can choose a location other than /etc/ for your customized configuration. Many systems mount their root filesystem as read−only, so you can put your override file elsewhere if you need to.

daily_output="root" This option tells periodic where to send the results of its daily checks. If you give a username, periodic will mail that user. Unless you have a user whose job it is to specifically read periodic mail, it's best to leave this at the default and forward root's email to an account you read. Alternatively, you can put a filename here and periodic will write to it like a log file. In this case, you can have newsyslog (see Chapter 19) rotate the periodic log.

209

daily_show_success="YES" If daily_show_success is set to yes, the daily message will include information on all successful checks.

daily_show_info="YES" When daily_show_info is set to yes, the daily message will include general information from the commands it runs.

daily_show_badconfig="NO" The daily message will include information on periodic commands it tried to run, but couldn't. These are generally harmless, and if you set daily_show_badconfig to no, you won't miss much. If you're interested, however, you can set this to yes and get a look at everything that happens.

Each of the scripts in the daily, weekly, and monthly directories under /etc/periodic has a brief description at the top of the script. Skim through those quickly. The defaults that are enabled are sensible for most circumstances, but there's extra functionality there that you might want to enable on some systems. Each script has a tunable knob in /etc/periodic.conf to enable or disable it, and more are being added continuously. Since anything I could list here would be obsolete before I could deliver the manuscript, let alone before the book reached you, I won't go into detail about the various scripts.

/etc/printcap

The /etc/printcap file controls printer setup. There are literally dozens and dozens of options for printers, from the cost per page to manually setting a string to feed a new sheet of paper. (We won't cover all of the options, but we will discuss the basics of printer management here.)

A UNIX printer system makes assumptions about a printer. By defining variables in /etc/printcap, you tell your printer system how your hardware differs from the classic UNIX printers of two decades ago. As you might guess, these differences can be extensive. (Fortunately, most printers understand PostScript. This greatly simplifies printer maintenance.)

If you're using FreeBSD on a network with an existing print server, you probably want to use that existing server. (See Chapter 21 for some example configurations.) When doing fine−grained printer tweaking, you might need some of the more exotic options FreeBSD provides. We'll discuss some of the ones you might need on a modern system in the following section.

Working with Printcap Entries

Each printer has its own /etc/printcap entry. Since all these variables let you create some very, very long lines, use a backslash character (\) to indicate that the entry hasn't finished and is continued on the next line. Use colons to separate variables. If you're using a backslash to make your entries readable, the second and subsequent lines must have a colon at both the beginning and end of the variable assignments.

The first entry in /etc/printcap is the printer name. If a printer has many names–such as "ThirdFloor", "AccountingOffice", and "BigLaserJet", list all of those names, separated by the pipe symbol (|).

Note In FreeBSD, and almost all other versions of UNIX, the default printer is named "lp". Various programs expect to find a printer named lp. It's simplest to assign this name to your preferred printer.

After the printer's name, list the variables that define that particular printer. A comprehensive list would contain much that you'll never need, but we'll look at some of the variables that are either in

210

more common use today or that are useful on modern networks. Let's first look at a simple sample printcap entry and see how it's set up. Then we can examine the variables that allow you to fine−tune your printer's behavior.

...............................................................................................

lp|SalesPS|ThirdFloorPrinter:\

:rp=SalesPS:\

:rm=printserver:\

:sd=/var/spool/output/lpd:\

:lf=/var/log/lpd−errs:

...............................................................................................

This printer is called lp, as well as SalesPS and ThirdFloorPrinter. The remote printer name, as the print server calls it, is SalesPS. The print server is a machine with a TCP/IP network name of printserver. Print jobs are stored in /var/spool/output/lpd while they're being processed, and printing errors are logged to /var/log/lpd−errs. (See Chapter 21 for some hints on setting up a printer.)

The following are some of the most commonly set options for printing in UNIX.

...............................................................................................

:ct=120:

...............................................................................................

This is the network connection timout. You can use ct to control the timeout for remote network printers. If a printer does not respond, the printer service will wait ct=x seconds before returning a failure. The default is 120 seconds, which is far too high for a modern local area network. Usually, if a printer doesn't respond within 30 seconds, you have a problem. Alternatively, if you're printing to some device on another continent, you might need to increase this to as high as 240.

...............................................................................................

:fo=false:

...............................................................................................

This stands for "form feed upon open." If this is set, the system will start each printing job with a blank sheet.

...............................................................................................

:if=/usr/libexec/lpr/input−filter:

...............................................................................................

As the preceding line shows, FreeBSD can preprocess printing requests it receives over the network. This allows you to do some nifty things, such as make a boring desktop inkjet printer behave like a PostScript printer. See /usr/ports/print/apsfilter for an excellent example of how this is done.

...............................................................................................

:lf=/var/log/printername:

...............................................................................................

This lets you specify the log file for this particular printer.

...............................................................................................

:lp=/dev/lp:

...............................................................................................

211