首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >获取avc: AOSP 6.0.1中的拒绝错误

获取avc: AOSP 6.0.1中的拒绝错误
EN

Stack Overflow用户
提问于 2021-06-10 16:10:37
回答 1查看 138关注 0票数 1

获取avc:拒绝错误(从sdcard目录复制到高速缓存/SH_DIR时出现SEpolicy。

错误:

type=1400审核(1623259119.150:7):avc:拒绝{搜索pid=2780 comm="xyz“name="default”dev="tmpfs“ino=7420 scontext=u:r:aaa_bbb:s0

代码逻辑:

代码语言:javascript
运行
复制
    FILE *sourceFile; 
    FILE *destFile;
    char sourcePath[100]= "/storage/emulated/0/test.txt";
    char destPath[100]="/cache/SH_DIR/";
    char ch;


    printf("Enter source file path: %s",sourcePath);

    printf("Enter destination file path:%s ",destPath);


    sourceFile  = fopen(sourcePath, "r");
    destFile    = fopen(destPath,   "w");
 
    if (sourceFile == NULL || destFile == NULL)
        {
    
    printf("\nUnable to open file.\n");
    printf("Please check if file exists and you have read/write privilege.\n");


    exit(EXIT_FAILURE);
        }
ch = fgetc(sourceFile);
while (ch != EOF)
{
    /* Write to destination file */
    fputc(ch, destFile);

    /* Read next character from source file */
    ch = fgetc(sourceFile);
}


printf("\nFiles copied successfully.\n");



/* Finally close files to release resources */
fclose(sourceFile);
fclose(destFile);

SEPOLICY中的注册站文件:

AOSP/供应商/.../sepolicy/file_context:

代码语言:javascript
运行
复制
 /cache/SH_DIR(/.*)? u:object_r:ccc_downloaded_sw_file:s0

filename.te:

代码语言:javascript
运行
复制
allow filename ccc_downloaded_sw_file:dir { open search read write getattr add_name remove_name };
allow filename ccc_downloaded_sw_file:file { open read create write unlink append getattr setattr };

你能帮我解释一下,为什么我无法将文件从源复制到目标吗?

EN

回答 1

Stack Overflow用户

发布于 2021-06-10 23:40:38

如果/cache分区挂载为tmpfs,则需要添加:

代码语言:javascript
运行
复制
allow filename tmpfs_t:dir { open search read write getattr add_name remove_name };

allow filename tmpfs_t:file {  open read create write unlink append getattr setattr }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67920120

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档