Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

6


System Data Files and


Infor mation


6.1 Introduction


AUNIX system requires numerous data files for normal operation: the passwordfile
/etc/passwdand the group file/etc/grouparetwo files that arefrequently used by
various programs. For example, the passwordfile is used every time a user logs in to a
UNIX system and every time someone executes anls -lcommand.
Historically,these data files have been ASCII text files and wereread with the
standardI/O library.But for larger systems, a sequential scan through the password
file becomes time consuming. We want to be able to storethese data files in a format
other than ASCII text, but still provide an interface for an application program that
works with any file format. The portable interfaces to these data files arethe subject of
this chapter.Wealso cover the system identification functions and the time and date
functions.

6.2 Password File


The UNIX System’s passwordfile, called the user database by POSIX.1, contains the
fields shown in Figure6.1. These fields arecontained in apasswdstructurethat is
defined in<pwd.h>.

Note that POSIX.1 specifies only 5 of the 10 fields in thepasswdstructure. Most platforms
support at least 7 of the fields. The BSD-derived platforms support all 10.

177
Free download pdf