Docsity

Identity - Operating Systems - Lecture Notes, Study notes of Operating Systems

Toggle sidebar
bg1
We began the course by considering the system
programmer's point of view.
Mid-course, we switched to studying how to write the
operating system itself.
Finally, we take a look at programming again,
knowing what's "under the hood."
Thesis, antithesis, synthesis
Before: how to do things?
After: what can we get away with?
And things look very different now...
Thesis, antithesis, synthesis
Thursday, December 01, 2011
Identity Page 1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25

Partial preview of the text

Download Identity - Operating Systems - Lecture Notes and more Study notes Operating Systems in PDF only on Docsity!

We began the course by considering the system

programmer's point of view.

Mid-course, we switched to studying how to write the

operating system itself.

Finally, we take a look at programming again,

knowing what's "under the hood."

Thesis, antithesis, synthesis

Before: how to do things?

After: what can we get away with?

And things look very different now...

Thesis, antithesis, synthesis

Thursday, December 01, 2011 4:00 PM Docsity.com

drivers live.

processes are executed.

scheduling is accomplished.

everything is a number.

So far, we've concentrated on the kernel, where:

Assume that the filesystem works.

Utilize the filesystem to do useful things.

Consider parts of the operating system outside the

kernel.

Now, we shift gears yet another time:

Beyond the kernel

Wednesday, November 30, 2011 4:35 PM Docsity.com

stat - read an inode.

opendir, readdir, closedir - manipulate directories.

Manipulating the filesystem

Manipulating the filesystem

Thursday, December 01, 2011 7:36 AM Docsity.com

Purpose of stat: read most of an inode

dev_t st_dev; /* ID of device containing file / ino_t st_ino; / inode number / mode_t st_mode; / protection / nlink_t st_nlink; / number of hard links / uid_t st_uid; / user ID of owner / gid_t st_gid; / group ID of owner / dev_t st_rdev; / device ID (if special file) / off_t st_size; / total size, in bytes / blksize_t st_blksize; / blocksize for filesystem I/O / blkcnt_t st_blocks; / number of blocks allocated / time_t st_atime; / time of last access / time_t st_mtime; / time of last modification / time_t st_ctime; / time of last status change */ struct stat { }; int stat(const char *path, struct stat *buf); int fstat(int filedes, struct stat *buf); int lstat(const char *path, struct stat *buf);

stat

stat: reads inode information from a path.

fstat: reads from open file descriptor.

lstat: reads the stat for a symlink, rather than following the link.

Three different forms:

stat

Thursday, December 01, 2011 7:36 AM Docsity.com

#include #include #include #include DIR *d = opendir ("."); struct stat s; e->d_name, s.st_mode, s.st_uid, s.st_gid); printf("%s mode=0%o uid=%d gid=%d\n", if ( stat(e->d_name, &s) ==0) { perror("ls"); } else { } struct dirent *e; while (( e=readdir(d) ) != NULL) { } if (d) { perror("ls"); } else { // protection failure } closedir(d); main() { } Pasted from Example: how to write 'ls' Thursday, December 01, 2011 7:50 AM Docsity.com

Owner, group

pretty-printed mode

We don't have most of what normal 'ls' provides us

These are not in the inode!

Info is contained elsewhere!

Why?

Oops!

Oops!

Thursday, December 01, 2011 8:06 AM Docsity.com

The filesystem contains everything the operating

system needs to run.

That part of the filesystem that determines OS

function is called the configuration of the operating

system.

A configuration is a set of files.

Configuration management is the process of

controlling the configuration to create desired

behaviors in the OS.

The configuration mostly resides in /etc.

The "configuration":

The "configuration"

Wednesday, November 30, 2011 4:38 PM Docsity.com

Who can login?

What can someone who logs in actually do?

Our first configuration concept: identity

The concept of identity

Wednesday, November 30, 2011 4:40 PM Docsity.com

name

password (hashed)

user id (UID)

primary group id (GID)

list of groups for which the user is a member.

quotas for filesystems

User attributes:

login name: /etc/passwd

password (hashed) /etc/shadow

user id (UID) /etc/passwd

primary group id (GID) /etc/passwd

list of groups for which the user is a member.

/etc/group

quotas for filesystems

This is not in one file:

User attributes

Wednesday, November 30, 2011 4:59 PM Docsity.com

Again by number: group identifier (GID).

A group is a set of users that share access to things

group name

GID

list of login names that are members.

Defined in /etc/group, which contains

The concept of a group

Wednesday, November 30, 2011 5:03 PM Docsity.com

ldapsearch - x uid=couch # user couch

ldapsearch - x cn=grade111 # group

grade

Exploring LDAP

Exploring LDAP

Thursday, November 29, 2012 11:27 AM Docsity.com

Never read a configuration file directly.

Instead, utilize library functions (man 3) to access it.

Basic principle of configuration

Read the files.

Cache information for repeated use.

Eliminate excess reads.

Understand federation semantics.

These functions

Basic principle of configuration

Thursday, December 01, 2011 8:08 AM Docsity.com

char gr_name; / group name */ char gr_passwd; / group password / gid_t gr_gid; / group ID */ char *gr_mem; / group members */ struct group { }; #include #include struct group *getgrnam(const char *name); struct group *getgrgid(gid_t gid);

Reading groups: getgrnam, getgrgid

Reading groups

Thursday, December 01, 2011 8:17 AM Docsity.com

Read /etc/nsswitch.conf to determine data sources.

Cache it in memory.

Read data sources, cache them.

Return a result that is a pointer into a data source.

What getgr, getpw do:

Returned pointer is not persistent : content can

change at next call of getgr, getpw.

Caveats:

What getgr, getpw do

Thursday, December 01, 2011 8:20 AM Docsity.com