SetUIDビットが設定されている実行可能ファイルは所有者として実行する必要があると思いますが、実際に再現することはできません。私は次を試しました。
$catprep.sh cp /bin/bash 。 chownルート。ルートbash chmod 4770 bash #確認済み $ sudo sh prepare.sh $ ./バッシュ $id-u 1000 $ 終了 $
$cattest.c #include<stdio.h> #include<unistd.h> 整数メイン(){ printf("%d,%d\n", getuid(), geteuid()); 0を返します。 } $gcc -o testtest.c $ chmod 4770テスト#確認済み $sudo chown root.root テスト $ ./テスト 1000,1000 $#なぜですか? ? ?
しかし、
$ su # ./bash #id-u 0 #。 /試験 0,0 #出口 #出口 $
注:マウントポイントは設定されてnosuid
いませんnoexec
。
Ubuntu 16.04 LTSで機能しない理由を説明できる人はいますか?
ベストアンサー1
コンパイルされた実行可能ファイルの場合man 2 chown
:
When the owner or group of an executable file are changed by an
unprivileged user the S_ISUID and S_ISGID mode bits are cleared. POSIX
does not specify whether this also should happen when root does the
chown(); the Linux behavior depends on the kernel version.
リバースchown
とchmod
注文は私にとって効果的です。
$ sudo chmod 4770 foo
$ sudo chown root:root foo
$ stat foo
File: 'foo'
Size: 8712 Blocks: 24 IO Block: 4096 regular file
Device: 801h/2049d Inode: 967977 Links: 1
Access: (0770/-rwxrwx---) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2017-04-18 15:15:15.074425000 +0900
Modify: 2017-04-18 15:15:15.074425000 +0900
Change: 2017-04-18 15:15:33.683725000 +0900
Birth: -
$ sudo chmod 4777 foo
$ ./foo
1000,0