Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

196 System Data Files and Information Chapter 6


zone. If the variable is defined to be a null string, such asTZ=,then UTC is normally
used. The value of this environment variable is often something likeTZ=EST5EDT,but
POSIX.1 allows a much moredetailed specification. Refer to the Environment Variables
chapter of the Single UNIX Specification[Open Group 2010]for all the details on theTZ
variable.

Moreinformation on theTZenvironment variable can be found in thetzset(3) manual page.

6.11 Summary


The passwordfile and the group file areused on all UNIX systems.We’ve looked at the
various functions that read these files. We’ve also talked about shadow passwords,
which can enhance system security.Supplementary group IDs provide a way to
participate in multiple groups at the same time. We also looked at how similar
functions areprovided by most systems to access other system-related data files. We
discussed the POSIX.1 functions that programs can use to identify the system on which
they arerunning. Wefinished the chapter by looking at the time and date functions
provided by ISO C and the Single UNIX Specification.

Exercises


6.1 If the system uses a shadow file and we need to obtain the encrypted password, how do we
do so?
6.2 If you have superuser access and your system uses shadow passwords, implement the
previous exercise.
6.3 Write a program that callsunameand prints all the fields in theutsnamestructure.
Comparethe output to the output from theuname( 1 )command.
6.4 Calculate the latest time that can be represented by thetime_tdata type. After it wraps
around, what happens?
6.5 Write a program to obtain the current time and print it usingstrftime, so that it looks like
the default output fromdate( 1 ).Set theTZenvironment variable to different values and
see what happens.
Free download pdf