touch -m
このファイルがグループ書き込み可能でファイルに正しく書き込まれるにもかかわらず、このファイルを実行すると権限が拒否される理由を誰かが説明できますか?
~/test1-> id
uid=1000(plyons) gid=1000(plyons) groups=1000(plyons),4(adm),20(dialout),24(cdrom),46(plugdev),109(lpadmin),110(sambashare),111(admin),1002(webadmin)
~/test1-> ls -ld .; ls -l
drwxrwxr-x 2 plyons plyons 4096 Feb 14 21:20 .
total 4
-r--rw---- 1 www-data webadmin 24 Feb 14 21:29 foo
~/test1-> echo the file is writable >> foo
~/test1-> touch -m foo
touch: setting times of `foo': Operation not permitted
~/test1-> lsattr foo
-------------e- foo
~/test1-> newgrp - webadmin
~/test1-> id
uid=1000(plyons) gid=1002(webadmin) groups=1000(plyons),4(adm),20(dialout),24(cdrom),46(plugdev),109(lpadmin),110(sambashare),111(admin),1002(webadmin)
~/test1-> touch -m foo
touch: setting times of `foo': Operation not permitted
~/test1-> echo the file is writable >> foo
~/test1->
ベストアンサー1
からman utime
:
The utime() system call changes the access and modification times of
the inode specified by filename to the actime and modtime fields of
times respectively.
If times is NULL, then the access and modification times of the file
are set to the current time.
Changing timestamps is permitted when: either the process has appropri‐
ate privileges, or the effective user ID equals the user ID of the
file, or times is NULL and the process has write permission for the
file.
したがって、ファイル()の変更時間のみを変更するには、そのファイルの所有者である必要がtouch -m foo
あります。root
ファイルに書き込むことができる場合は、変更時刻とアクセス時刻を現在時刻に更新する権限のみが付与され、個別に更新したり、別の時刻に設定したりすることはできません。