簡體   English   中英

NFS rootfs上的Busybox SUID

[英]Busybox SUID on NFS rootfs

我正在從底部為Beagle Bone板構建一個Linux系統。 我編譯了vanilla內核並使用busybox構建了一個基本的根文件系統。 系統使用U-boot啟動,而rootfs位於Linux PC上並通過NFS導出:

/path/to/rootfs  10.42.0.17(rw,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)

U-boot bootargs是:

bootargs console=ttyO0,115200n8 root=/dev/nfs rw nfsroot=${serverip}:/path/to/rootfs,v3,tcp ip=dhcp

我一直試圖讓時遇到問題而su工作的非root用戶。 為了解決這個問題,互聯網上的人們建議為busybox二進制文件設置suid位。 這樣做之后:

$ sudo chmod u+s busybox 

並驗證:

$ ls -la
...
-rwsr-xr-x  1 myuser myuser 1882976 Jan 13 21:47 busybox
...

$ stat -c "%a %n" busybox 
4755 busybox

出問題了。 內核正在啟動並顯示所有常用消息,但它最后會卡住,並且不會顯示任何login行。 以下是啟動順序的最后幾行:

[    3.776185] IP-Config: Complete:
[    3.779656]      device=eth0, hwaddr=c8:a0:30:c5:80:e9, ipaddr=10.42.0.17, mask=255.255.255.0, gw=10.42.0.1
[    3.789877]      host=10.42.0.17, domain=, nis-domain=(none)
[    3.795822]      bootserver=10.42.0.1, rootserver=10.42.0.1, rootpath=
[    3.802492]      nameserver0=10.42.0.1
[    3.871575] VFS: Mounted root (nfs filesystem) on device 0:15.
[    3.879903] devtmpfs: mounted
[    3.883713] Freeing unused kernel memory: 380K (c07ef000 - c084e000)

如果刪除標志,事情將恢復正常:

....
[    3.862291] Freeing unused kernel memory: 380K (c07ef000 - c084e000)

10.42.0.17 login: 

如果在Beagle Bone板本身的運行shell中設置標志,則shell在執行chmod后立即停止響應。 我懷疑這與NFS導出rootfs的方式有關,但這只是猜測,所以合格的解釋和可能的解決方案會有所幫助。

經過一番研究后,我會自己回答我的問題。 答案很簡單。 為了使上述工作正常, busybox二進制文件應由root:root擁有。 最簡單的解決方案就是改變所有權。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM