[問題] proftp設定-將家目錄設在別人目錄底下

作者: Elfiend (小孩)   2014-03-31 14:40:42
[系統]
Red Hat Enterprise Linux Server release 6.5 (Santiago)
是Amazon的機器。
[背景環境]
帳號abc,是用來啟動apache的系統用途帳號。
擁有家目錄/home/abc/,
內有/home/abc/www/,為apache的根目錄。
[需求]
帳號efg,是用來上傳ftp用的帳號,
希望使用efg帳號登入ftp後,
ftp的根目錄會是/home/abc/www/ftp/upload。
同時ftp帳號無法離開upload/資料夾,
只能在upload下,任意新增上傳刪除檔案、資料夾。
[設定]
/etc/proftpd.conf
ServerType standalone
(原本要設inetd,但是在安裝xinetd時,
出現其他異常,因趕時間就跳過)
DefaultRoot /home/abc/www/upload/ efgGroup
DefaultRoot ~
<Directory /home/abc/www/upload/>
Umask 002
AllowOverwrite yes
<Limit ALL>
AllowAll
</Limit>
</Directory>
/etc/passwd
efg:x:9999:9999::/home/abc/www/upload/:/bin/bash
[錯誤訊息]
/var/log/message
amazon proftpd - FTP session opened.
amazon proftpd - notice: unable to use '/home/abc/www/upload/'
[resolved to '/home/abc/www/upload/']
: Permission denied
amazon proftpd - Preparing to chroot to directory
'/home/abc/www/upload/'
amazon proftpd - chroot to '/home/abc/www/upload/' failed for user 'efg':
Operation not permitted
amazon proftpd - error: unable to set default root directory
amazon proftpd - FTP session closed.
[暫時應對]
/etc/proftpd.conf
DefaultRoot ~
/etc/passwd
efg:x:9999:9999::/home/efg/upload/:/bin/bash
cd /home/abc/www/
ln -s /home/efg/upload
[錯誤訊息]
/var/log/message無異常。
用FileZilla登入,在取得檔案清單時,會出現550 permission denied錯誤。
[暫時應對]
setenforce 0
關掉SELinux,就正常了。
參考:http://kb.parallels.com/en/11142
[問題整理]
1. 希望有設定能滿足原先需求,讓ftp登入時,
可以直接進入指定的目錄,並只能在該目錄下進行各種操作。
2. 若無法滿足1,希望能知道SELinux應如何設定,
感覺關掉不是正確作法。
註:提供內容,部份已手動處理過,若有前後資訊不符,
應為手動輸入錯誤,並非真的異常。
作者: aeolus0829 (阿洽)   2014-03-31 21:27:00
efg 是否有 cd 到abc/www/upload 的權限?su - efg 測看看
作者: Elfiend (小孩)   2014-04-01 12:43:00
謝謝提供建議,之前沒想到測試這個。剛剛測試,可以cd過去,請問這樣還有哪些可能呢?
作者: danny8376 (釣到一隻猴子@_@)   2014-04-01 12:53:00
SELinux要多加label

Links booklink

Contact Us: admin [ a t ] ucptt.com