nosuidをsuidパーティションにバインドマウントできますか?

nosuidをsuidパーティションにバインドマウントできますか?

/targetを使用してマウントsuidしてから/ boundにマウントをバインドすると、mount -o bind,nosuid /target /boundnosuidは/ boundに適用されますか?

(動作しなければならないと思いますが、まだ明確な答えを望んでおり、ここには誰も質問していないので、そうです)

ベストアンサー1

はい、ターゲットにsuidがある場合でも、バインディングはnosuidを適用できます。私が実行したテストは次のとおりです。

a.outのCソースコード:

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main(){
uid_t uid=getuid(), euid=geteuid();
printf("uid: %u, euid: %u\n",uid,euid);
return 0;
}

それから

root@ratma:/# mount -o bind,nosuid /target /bound
root@ratma:/# su hans
hans@ratma:/$ stat /target/a.out
  File: /target/a.out
  Size: 16712           Blocks: 40         IO Block: 4096   regular file
Device: 18h/24d Inode: 194454      Links: 1
Access: (6755/-rwsr-sr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-12-12 07:52:45.132465174 +0000
Modify: 2019-12-12 07:52:45.132465174 +0000
Change: 2019-12-12 07:53:24.720322010 +0000
 Birth: -
hans@ratma:/$ stat /bound/a.out
  File: /bound/a.out
  Size: 16712           Blocks: 40         IO Block: 4096   regular file
Device: 18h/24d Inode: 194454      Links: 1
Access: (6755/-rwsr-sr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-12-12 07:52:45.132465174 +0000
Modify: 2019-12-12 07:52:45.132465174 +0000
Change: 2019-12-12 07:53:24.720322010 +0000
 Birth: -
hans@ratma:/$ id
uid=1000(hans) gid=1000(hans) groups=1000(hans),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),109(netdev)
hans@ratma:/$ /target/a.out
uid: 1000, euid: 0
hans@ratma:/$ /bound/a.out
uid: 1000, euid: 1000

成功。うまくいかない場合は、/bound/a.outに "euid:0"が表示されます:)

おすすめ記事