linux检查磁盘是否支持acl,如何在Linux中检查ACL中是否存在UID?

如果我误解我道歉的问题,但希望你会有所帮助:某些

Exceprt:

以下功能检索和操纵ACL条目:

acl_copy_entry()

acl_create_entry()

acl_delete_entry()

acl_first_entry()

acl_get_entry()

以下函数用于检索和处理ACL条目中的字段:

acl_add_perm()

acl_clear_perm()

alc_delete_perm()

acl_get_permset()

acl_get_qualifier()

acl_get_tag_type()

acl_set_permset()

acl_set_qualifier()

acl_set_tag_type()

...

ACL条目

ACL条目由以下字段组成:

标签类型(在acl.h头文件中定义):

ACL_USER_OBJ - 拥有用户条目。

ACL_GROUP_OBJ - 拥有组条目。

ACL_USER - 其他用户的条目。

ACL_GROUP - 其他组的条目。

ACL_OTHER_OBJ - 未包含在其他条目中的所有用户和组的条目。

标记限定符 - ACL_USER条目的限定符值是用户标识。

ACL_GROUP条目的限定符值是组ID。 任何* _OBJ条目的限定符值都是NULL。

/*

Find the the ACL entry in 'acl' corresponding to the tag type and

qualifier in 'tag' and 'id'. Return the matching entry, or NULL

if no entry was found. */

static acl_entry_t

findEntry(acl_t acl, acl_tag_t tag, id_t qaul)

{

acl_entry_t entry;

acl_tag_t entryTag;

uid_t *uidp;

gid_t *gidp;

int ent, s;

for (ent = ACL_FIRST_ENTRY; ; ent = ACL_NEXT_ENTRY) {

s = acl_get_entry(acl, ent, &entry);

if (s == -1)

errExit("acl_get_entry");

if (s == 0)

return NULL;

if (acl_get_tag_type(entry, &entryTag) == -1)

errExit("acl_get_tag_type");

if (tag == entryTag) {

if (tag == ACL_USER) {

uidp = acl_get_qualifier(entry);

if (uidp == NULL)

errExit("acl_get_qualifier");

if (qaul == *uidp) {

if (acl_free(uidp) == -1)

errExit("acl_free");

return entry;

} else {

if (acl_free(uidp) == -1)

errExit("acl_free");

}

} else if (tag == ACL_GROUP) {

gidp = acl_get_qualifier(entry);

if (gidp == NULL)

errExit("acl_get_qualifier");

if (qaul == *gidp) {

if (acl_free(gidp) == -1)

errExit("acl_free");

return entry;

} else {

if (acl_free(gidp) == -1)

errExit("acl_free");

}

} else {

return entry;

}

}

}

}

我不觉得你需要检查一个特定的文件的ACL,但如果我错了,这里是一些信息可以这样做:

$ getfacl myFile

# file: myFile

# owner: jon

# group: people

user::rwx

user:foo:rwx

group::rwx

mask::rwx

other::---

然后从名称中得到一个uid(未经测试但应该关闭): 个

$ grep /etc/passwd `getfacl myFile | grep owner | split -d":" -f2` | egrep -o "[0-9]+"

一些更多的资源:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值