IDs associated with each process and file’s mode word

原创 2006年05月17日 21:54:00

IDs associated with each process and file’s mode word

 

IDs associated with each process

Every process has seven or more IDs associated with it. The basic seven IDs are: process ID, real IDs (real user ID, real group ID), effective IDs (effective user ID, effective group ID), saved IDs (saved set-user-ID, saved set-group-ID). The most important ID is process ID (read Process ID and special processes.doc).

 

These IDs are used for:

Process ID: distinguish one process from another

Real IDs:     identify who we really are

Effective IDs:    used for file access permission checks

Saved IDs:

 

There are corresponding get functions to get these IDs except saved IDs.

Process ID: getpid, getppid

Real IDs:     getuid, getgid

Effective IDs:    geteuid, getegid

"Note that none of these functions has an error return."

 

The other six IDs are initialized as follows:

Real IDs:     "taken from our entry in the password file when we log in."

Effective IDs:    "Normally, the effective user ID equals the real user ID, and the effective group ID equals the real group ID."

Saved IDs: "contain copies of the effective user ID and the effective group ID when a program is executed."

 

File's mode word

Position:

File's mode word is the i_mode member of the ext3_inode structure and can be copied to the st_mode member of the stat structure using one of the stat functions. It is called word because the i_mode member is 16 bits.

 

Bits:

15-12: file type bits

11: set-user-ID bit

10: set-group-ID bit

9: sticky bit

8-0: access permission bits

           8 7 6: owner access permission

           5 4 3: group access permission

           2 1 0: other access permission

 

Associated command(s) & function(s)

chmod(1), chmod(2), fchmod(2)

NOTE: These can only change low 12 bits of file's mode word.

 

[important]Relationship between set-user-ID bit, set-group-ID bit in a file's mode word and effective IDs associated with the process executing this file.

If the set-user-ID bit in a file's mode word is set to 1, the effective user ID associated with the process executing this file will change to the user ID of the file's owner. Same with the set-group-ID bit.

Example

下面是文件A对应的struct ext3_inode中的i_mode member,也就是文件A的文件模式字:

1000110110110100

"4-3-9"分段看

1000 100 110110100

a) regular file

b) 执行该文件的进程的effective user ID会改变,而effective group ID不会。

c) rw-rw-r--

mode > type

JAVA,OpenLDAP使用心得(1)

如何安装已经在官方文档有了,一步步的照着做就可以/usr/local/etc/openldap/slapd.conf中可以找到schema,pid以及数据库文件存放的路径我修改了/usr/local/...
  • njchenyi
  • njchenyi
  • 2008年01月09日 12:20
  • 5023

What are various IDs associated with a process?

pid, ppid, uid.
  • donhao
  • donhao
  • 2011年08月20日 17:23
  • 441

Leetcode: Word Frequency

QuestionWrite a bash script to calculate the frequency of each word in a text file words.txt.For sim...
  • ayst123
  • ayst123
  • 2015年05月10日 21:50
  • 641

Codeforces 598B Queries on a String 【水题】

B. Queries on a String time limit per test 2 seconds memory limit per test 256 megabytes input...
  • chenzhenyu123456
  • chenzhenyu123456
  • 2015年11月15日 18:27
  • 679

VC编译时,提示no compile tool is associated with the file extension错误 .

VC编译时,提示no compile tool is associated with the file extension错误: 原因是你目前打开的是.h文件,而C++程序中,.h的头文件是...
  • qachenzude
  • qachenzude
  • 2011年11月27日 20:04
  • 13638

VC编译时,提示no compile tool is associated with the file extension错误

VC编译时,提示no compile tool is associated with the file extension错误:原因是你目前打开的是.h文件,而C++程序中,.h的头文件是不参与编译的...
  • suxinpingtao51
  • suxinpingtao51
  • 2011年07月25日 17:07
  • 7252

Django 中The 'image' attribute has no file associated with it.出错问题的解决

这种情况一般是我们上传的图片出错了,所以才会出现的,解决办法很简单,就是在model下添加: @property def image_url(self): if self.image and...
  • grs294845170
  • grs294845170
  • 2017年05月23日 15:28
  • 420

VC++6.0出现no compile tool is associated with the extension.解决方法

对于刚解除VC++6.0的小白,在编译时候经常出现
  • u013018721
  • u013018721
  • 2014年06月29日 14:19
  • 5831

String 共通方法定义

package com.*.util.string; import java.lang.reflect.Method; import java.text.SimpleDateFormat; impo...
  • brian_9988
  • brian_9988
  • 2014年02月12日 09:55
  • 1275

he Struts dispatcher cannot be found. This is usually caused by using Struts tags without the assoc

he Struts dispatcher cannot be found. This is usually caused by using Struts tags without the assoc...
  • lgx06
  • lgx06
  • 2013年10月23日 12:47
  • 2725
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:IDs associated with each process and file’s mode word
举报原因:
原因补充:

(最多只允许输入30个字)