使用 (rw-r--r--) 打开 ( ) 文件
open( ) file with (rw-r--r--)
对于文件所有者 00700,系统调用 open ()
只允许为所有者 rwx
将模式设置为 S_IRWXU
(根据我的手册页)。我想删除所有者通过我的 C 程序执行这个新制作的文件的权利。
不幸的是,chmod
无法更改所有者的权利(据我正确理解手册页)所以我认为有一种方法可以通过一些参数魔术直接指定所需的行为.
int out;
out = open(cmd->outFile, O_WRONLY | O_TRUNC | O_CREAT, /*set the rights correctly to (rw-r--r--)*/
For the file-owner 00700 the system call open ()
only allows to set mode to S_IRWXU
(according to my man page) for the owner which is rwx
.
那将是一个奇怪的手册页;参见 man open
- the description of O_CREAT points to <sys/stat.h>,其中 S_IRWXU 只是访问权限位宏列表的第一个。
I want to delete the owners right to execute this newly made file via my C program.
如果您在创建文件时就指定了所需的权限,则以后无需删除其中任何一项。
要使用 rw-r--r--
创建文件,open
调用可以是:
out = open(cmd->outFile, O_WRONLY|O_TRUNC|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
对于文件所有者 00700,系统调用 open ()
只允许为所有者 rwx
将模式设置为 S_IRWXU
(根据我的手册页)。我想删除所有者通过我的 C 程序执行这个新制作的文件的权利。
不幸的是,chmod
无法更改所有者的权利(据我正确理解手册页)所以我认为有一种方法可以通过一些参数魔术直接指定所需的行为.
int out;
out = open(cmd->outFile, O_WRONLY | O_TRUNC | O_CREAT, /*set the rights correctly to (rw-r--r--)*/
For the file-owner 00700 the system call
open ()
only allows to set mode toS_IRWXU
(according to my man page) for the owner which isrwx
.
那将是一个奇怪的手册页;参见 man open
- the description of O_CREAT points to <sys/stat.h>,其中 S_IRWXU 只是访问权限位宏列表的第一个。
I want to delete the owners right to execute this newly made file via my C program.
如果您在创建文件时就指定了所需的权限,则以后无需删除其中任何一项。
要使用 rw-r--r--
创建文件,open
调用可以是:
out = open(cmd->outFile, O_WRONLY|O_TRUNC|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);