【问题标题】:Create a read-only file in yocto在 yocto 中创建一个只读文件
【发布时间】:2018-12-07 00:31:14
【问题描述】:

如何在 yocto 中创建只读文件。

我只授予 bbappend 文件中所有组的读取权限

do_install_append() {
    install -m 0444 os-release ${D}${sysconfdir}/
}

ls -al /etc/os-release 正确列出了权限,但我可以在 root 用户中修改文件。

如何避免这种行为并将其设为只读

【问题讨论】:

  • 你必须创建一个只读的rootfs,unix系统上的root用户是特殊的,它可以对文件做任何事情,除非你使用只读的rootfs启动。
  • 但是我在 Ubuntu 上看不到类似的行为,一旦我为所有组设置了读取权限,root 用户也无法在 Ubuntu 中修改文件

标签: linux embedded-linux yocto


【解决方案1】:

我在 ubuntu 18.04 上对此进行了测试:

erni@Sally:~$ date >> test.txt
erni@Sally:~$ echo test >> test.txt
erni@Sally:~$ chmod 444 test.txt 
erni@Sally:~$ echo test2 >> test.txt
bash: test.txt: Permission denied
erni@Sally:~$ sudo sh -c 'echo test3 >> test.txt'
erni@Sally:~$ cat test.txt 
gio  6 dic 2018, 17.28.42, CET
test
test3

如您所见,您仍然可以在 ubuntu 中修改受保护的文件

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-04
    • 2016-01-06
    • 2017-12-21
    • 1970-01-01
    • 2015-05-21
    • 1970-01-01
    相关资源
    最近更新 更多