16.05.2015 Views

Working with the Unix OS

Working with the Unix OS

Working with the Unix OS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Processes I<br />

dev_t st_rdev; /* device ID, for character or block special files */<br />

off_t st_size; /* file size in bytes */<br />

time_t st_atime; /* time of last file access */<br />

time_t st_mtime; /* time of last file mod */<br />

time_t st_ctime; /* time of last file status */<br />

};<br />

st_mode<br />

#define S_IFMT 0170000 /* type of file */<br />

#define S_IFREG 0100000 /* regular */<br />

#define S_IFDIR 0040000 /* directory */<br />

#define S_IFCHR 0020000 /* character special */<br />

#define S_IFBLK 0060000 /* block special */<br />

#define S_IFLNK 0120000 /* symbolic link */<br />

#define S_IFSOCK 0140000 /* socket - BSD only */<br />

#define S_IFIFO 0010000 /* fifo - System V only */<br />

! File Access Permissions<br />

Every process has four IDs associated <strong>with</strong> it<br />

- real user ID<br />

- real group ID<br />

- effective user ID<br />

- effective group ID<br />

Every file has <strong>the</strong> following attributes<br />

- owners user ID (16 bit integer)<br />

- owners group ID (16 bit integer)<br />

- user read, write, execute permission (3 bits)<br />

- group read, write, execute permission (3 bits)<br />

- o<strong>the</strong>r read, write, execute permission (3 bits)<br />

- set user ID (1 bit)<br />

- set group ID (1 bit)<br />

- see file fstatus.c<br />

Test to determine if process can access a file:<br />

- if <strong>the</strong> effective user ID of process is zero (superuser)<br />

- if <strong>the</strong> effective user ID of process matches <strong>the</strong> user ID of <strong>the</strong> file and <strong>the</strong> appropriate access permission bits are<br />

set<br />

- if <strong>the</strong> effective user ID of process does NOT match <strong>the</strong> user ID of <strong>the</strong> file and if <strong>the</strong> effective group ID of<br />

process matches <strong>the</strong> group ID of <strong>the</strong> file and <strong>the</strong> appropriate access permission bits are set<br />

- if <strong>the</strong> o<strong>the</strong>r access permission bits for <strong>the</strong> file are set <strong>the</strong>n access is allowed<br />

! File Access Mode Word<br />

system calls: {access, chmod, creat, mknod, msgctl, open,<br />

semctl, shmctl, stat, fstat & umask}<br />

04000 set user ID on execution<br />

02000 set group ID on execution<br />

01000 save text image after execution "sticky bit"<br />

00400 read by user<br />

00100 write by user<br />

00200 execute by user<br />

00040 read by group<br />

00020 write by group<br />

00010 execute by group<br />

00004 read by o<strong>the</strong>r<br />

00002 write by o<strong>the</strong>r<br />

00001 execute by o<strong>the</strong>r<br />

113

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!