开发者

Linux user access and mount

In my embedded system I mound a uSD card in /mnt which is a folder residing on a NAND flash. A problem arises in the cases where uSD card fails to mount (missing or HW error).

Copying files to /mnt will in this case fill up the nand flash which has limited size. My first idea was to just restrict the access to the /mnt folder so that when it fails to mount no write is allowed. As a test scenario I did (as root user) mkdir /test chmod 000 /test

d--------- 2 root root 160 Jan 3 10:58 test /#

From a Ubuntu PC I then tries a to copy a file using scp scp myFile root@192.168.1.100:/test

The idea was that as long as this directory had now acces rights this copy should b开发者_Python百科e denied. This is not the case, the file is myFile is copied to folder /test

Why is this so? My idea was as long as I revoked all access to this folder copying files would be rejected.

Where am I going wrong here?


root (or any user with uid 0 [zero] for that matter) is able to read and write to any file regardless of permission and ownership.

You might want to try out the immutable flag on that directory, though:

~# mkdir test
~# chmod 0000 test
~# touch test/foo      # no error here

~# chattr +i test
~# touch test/foo2
touch: cannot touch 'test/foo2': Permission denied


Why does mnt reside on a nand flash ? You an also put it in a tmpfs file system, and limit the size of the tmpfs file system, using the size options

mkdir /media
mount -t tmpfs tmpfs -o size=4M /media
mkdir /media/mmc

Mount whatever you want in /media/mmc

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜