System Data and Information - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

System Data and Information

Description:

System Data and Information systems files include password, group, hosts, services, etc. traditionally, systems files are in ASCII text format portable – PowerPoint PPT presentation

Number of Views:79
Avg rating:3.0/5.0
Slides: 19
Provided by: RichardE57
Category:

less

Transcript and Presenter's Notes

Title: System Data and Information


1
System Data and Information
  • systems files include password, group, hosts,
    services, etc.
  • traditionally, systems files are in ASCII text
    format
  • portable
  • human readable
  • contemporary usage calls for cleanly structured,
    possibly binary files for optimum performance,
    security

2
passwd File
  • structure defined in pwd.h
  • traditionally contains seven elements
  • username
  • encrypted password
  • user ID
  • group ID
  • comment (GECOS)
  • home directory
  • default shell

3
passwd File Entries
  • contains root (UID 0)
  • one-way encrypted password
  • can be reverse engineered if visible
  • fields may be empty
  • some systems support structured comment field

4
passwd functions
  • five basic functions
  • getpwuid() - fetch entry from uid
  • getpwnam() - fetch entry from login name
  • getpwent() - get next entry
  • setpwent() - rewinds stream(s)
  • endpwent() - closes stream(s)

5
passwd function details
  • getpwuid, getpwnam, and getpwent all return
    pointers to passwd entry structures
  • passwd entry structures are usually static within
    the function, and are overwritten by subsequent
    calls
  • getpwent opens files automatically, but endpwent
    must be called to close.

6
Shadow Passwords
  • encrypted passwords can be exploited for access
    to systems
  • scan dictionary for common matches
  • encrypt and compare
  • shadow password files hide encrypted passwords
    from world
  • only limited number of system programs need
    access to encrypted passwords in shadow file

7
Group File
  • group file structures contain four elements
  • group name
  • encrypted password (almost never used)
  • group ID
  • array of ptrs to user names

8
group file functions
  • like passwd, five basic file functions
  • getgrgid() - fetch entry from gid
  • getgrnam() - fetch entry from login name
  • getgrent() - get next entry
  • setgrent() - rewind stream(s)
  • endgrent() - close streams(s)

9
Supplementary Group IDs
  • originally, all users had one (login) group
  • newgrp command used to change effective GID
  • today, users can belong to as many as 16
    supplementary groups
  • file permissions are checked against both login
    group, and supplementary groups

10
Supplementary GID functions
  • there are three primary supplementary GID
    functions
  • getgroups() - get supplementary GIDs for user
  • setgroups() - set supplementary GIDs for user
    (superuser only)
  • initgroups() - read group file and set groups
    including login group (superuser only)

11
Accessing Other System Data Files
  • other files use same access function types
  • two keyed search functions (if supported)
  • three file walking functions
  • get next entry
  • set to first entry (rewind)
  • end (close all files)

12
Other Data Files
  • some data files common to almost all
    installations
  • hosts - list of hostnames matched to network
    addresses
  • networks - list of networks supported
  • protocols - list of protocols supported
  • services - list of services supported

13
uname() details
  • uname returns five element structure
  • sysname - name of OS
  • nodename - name of node
  • release - current release of OS
  • version - current version of release
  • machine - hardware type

14
Login Accounting
  • two primary login accounting files
  • utmp - currently logged in users
  • wtmp - all logins and logouts
  • structures vary from machine to machine
  • not all machines have low level functions for
    access
  • those that do have functions that generally
    mirror the other file access functions, a get,
    a set, and an end

15
System Identification
  • two primary functions for access to system ID
    information
  • uname() - returns structure with host information
  • gethostbyname() - returns network hostname

16
Time and Date
  • basic time service returns number of seconds
    since epoch (1/1/70).
  • time_t times are referred to as calendar times
  • break down functions convert time_t to tm
    structure
  • formatting functions produce user friendly
    output

17
Time tm structure functions
  • three main functions
  • break down functions
  • gmtime() - universal time
  • localtime() - local time
  • build up function
  • mktime() - convert tm to time_t

18
time formatting functions
  • three main formatting functions
  • asctime() - default time string from tm
  • ctime() - default time string from time_t
  • strftime() - programmer definable format from tm
Write a Comment
User Comments (0)
About PowerShow.com