![无法在目录中创建文件,即使它具有组权限](https://linux22.com/image/1526431/%E6%97%A0%E6%B3%95%E5%9C%A8%E7%9B%AE%E5%BD%95%E4%B8%AD%E5%88%9B%E5%BB%BA%E6%96%87%E4%BB%B6%EF%BC%8C%E5%8D%B3%E4%BD%BF%E5%AE%83%E5%85%B7%E6%9C%89%E7%BB%84%E6%9D%83%E9%99%90.png)
我创建了一个名为“perm”的组,其中有用户 apache 和 ruey。
[root@xxx ~]# groups apache
apache : apache perm
[root@xxx ~]# groups ruey
ruey : ruey perm
我已将组“perm”设置到我的网络文件夹中,
sudo chgrp -R perm /var/www
&为文件夹及其子文件夹添加了组权限
sudo chmod -R g+w /var/www
[root@xxx ~]# ls -l /var/www
total 12
drwxrwsrwx+ 4 apache perm 4096 Mar 31 09:23 mydomain.com
drwxrwsrwx+ 2 apache perm 4096 Nov 14 18:05 cgi-bin
drwxrwsrwx+ 2 apache perm 4096 Mar 18 02:52 html
当我使用 ruey 登录 ftp 时,我无法在 www 文件夹中创建文件。我收到错误响应
Response: 553 Could not create file.
我的 ftp 当前所有者/组
48/1002
48 is apache
1002 is perm
顺便说一下,我的 SELinux 已被禁用。
[root@xxxx ~]# sestatus
SELinux status: disabled
在此处添加了 vsftpd 配置设置
# Uncomment this to allow local users to log in.
# When SELinux is enforcing check for SE bool ftp_home_dir
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
在 ftp 中添加文件后的审计日志
[root@xxxx ~]# sudo tail /var/log/audit/audit.log
type=USER_START msg=audit(1490967934.517:16331): pid=9646 uid=0 auid=0 ses=1961 msg='op=PAM:session_open grantors=pam_selinux,pam_loginuid,pam_selinux,pam_namespace,pam_keyinit,pam_keyinit,pam_limits,pam_systemd,pam_unix,pam_lastlog acct="root" exe="/usr/sbin/sshd" hostname=183.171.64.24 addr=183.171.64.24 terminal=ssh res=success'
type=CRYPTO_KEY_USER msg=audit(1490967934.601:16332): pid=9648 uid=0 auid=0 ses=1961 msg='op=destroy kind=server fp=b1:31:92:fa:c9:2e:82:06:47:26:16:13:39:de:3a:ee direction=? spid=9648 suid=0 exe="/usr/sbin/sshd" hostname=? addr=183.171.64.24 terminal=pts/1 res=success'
type=CRYPTO_KEY_USER msg=audit(1490967934.601:16333): pid=9648 uid=0 auid=0 ses=1961 msg='op=destroy kind=server fp=97:89:0d:ba:49:ee:57:0b:a5:16:4a:1e:00:8c:81:7c direction=? spid=9648 suid=0 exe="/usr/sbin/sshd" hostname=? addr=183.171.64.24 terminal=pts/1 res=success'
type=CRYPTO_KEY_USER msg=audit(1490967934.601:16334): pid=9648 uid=0 auid=0 ses=1961 msg='op=destroy kind=server fp=32:fe:47:34:7c:8c:0f:e4:33:58:2b:4d:ac:69:e3:1c direction=? spid=9648 suid=0 exe="/usr/sbin/sshd" hostname=? addr=183.171.64.24 terminal=pts/1 res=success'
type=USER_LOGIN msg=audit(1490967934.601:16335): pid=9648 uid=0 auid=0 ses=1961 msg='op=login id=0 exe="/usr/sbin/sshd" hostname=183.171.64.24 addr=183.171.64.24 terminal=/dev/pts/1 res=success'
type=USER_START msg=audit(1490967934.601:16336): pid=9648 uid=0 auid=0 ses=1961 msg='op=login id=0 exe="/usr/sbin/sshd" hostname=183.171.64.24 addr=183.171.64.24 terminal=/dev/pts/1 res=success'
type=CRED_REFR msg=audit(1490967934.601:16337): pid=9648 uid=0 auid=0 ses=1961 msg='op=PAM:setcred grantors=pam_unix acct="root" exe="/usr/sbin/sshd" hostname=183.171.64.24 addr=183.171.64.24 terminal=ssh res=success'
type=USER_CMD msg=audit(1490967986.453:16338): pid=9665 uid=0 auid=0 ses=1961 msg='cwd="/root" cmd=7461696C202F7661722F6C6F672F61756469742F61756469742E6C6F67 terminal=pts/1 res=success'
type=CRED_ACQ msg=audit(1490967986.453:16339): pid=9665 uid=0 auid=0 ses=1961 msg='op=PAM:setcred grantors=pam_env,pam_unix acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/1 res=success'
type=USER_START msg=audit(1490967986.453:16340): pid=9665 uid=0 auid=0 ses=1961 msg='op=PAM:session_open grantors=pam_keyinit,pam_limits acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/1 res=success'
[root@xxxxx ~]# sudo tail /var/log/audit/audit.log
type=CRED_ACQ msg=audit(1490967986.453:16339): pid=9665 uid=0 auid=0 ses=1961 msg='op=PAM:setcred grantors=pam_env,pam_unix acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/1 res=success'
type=USER_START msg=audit(1490967986.453:16340): pid=9665 uid=0 auid=0 ses=1961 msg='op=PAM:session_open grantors=pam_keyinit,pam_limits acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/1 res=success'
type=USER_END msg=audit(1490967986.453:16341): pid=9665 uid=0 auid=0 ses=1961 msg='op=PAM:session_close grantors=pam_keyinit,pam_limits acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/1 res=success'
type=CRED_DISP msg=audit(1490967986.453:16342): pid=9665 uid=0 auid=0 ses=1961 msg='op=PAM:setcred grantors=pam_env,pam_unix acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/1 res=success'
type=USER_AUTH msg=audit(1490967997.906:16343): pid=9668 uid=0 auid=4294967295 ses=4294967295 msg='op=PAM:authentication grantors=pam_listfile,pam_shells,pam_unix acct="ruey" exe="/usr/sbin/vsftpd" hostname=::ffff:183.171.64.24 addr=::ffff:183.171.64.24 terminal=ftp res=success'
type=USER_ACCT msg=audit(1490967997.906:16344): pid=9668 uid=0 auid=4294967295 ses=4294967295 msg='op=PAM:accounting grantors=pam_unix,pam_localuser acct="ruey" exe="/usr/sbin/vsftpd" hostname=::ffff:183.171.64.24 addr=::ffff:183.171.64.24 terminal=ftp res=success'
type=CRED_ACQ msg=audit(1490967997.906:16345): pid=9668 uid=0 auid=4294967295 ses=4294967295 msg='op=PAM:setcred grantors=pam_listfile,pam_shells,pam_unix acct="ruey" exe="/usr/sbin/vsftpd" hostname=::ffff:183.171.64.24 addr=::ffff:183.171.64.24 terminal=ftp res=success'
type=USER_CMD msg=audit(1490968000.632:16346): pid=9671 uid=0 auid=0 ses=1961 msg='cwd="/root" cmd=7461696C202F7661722F6C6F672F61756469742F61756469742E6C6F67 terminal=pts/1 res=success'
type=CRED_ACQ msg=audit(1490968000.632:16347): pid=9671 uid=0 auid=0 ses=1961 msg='op=PAM:setcred grantors=pam_env,pam_unix acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/1 res=success'
type=USER_START msg=audit(1490968000.632:16348): pid=9671 uid=0 auid=0 ses=1961 msg='op=PAM:session_open grantors=pam_keyinit,pam_limits acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/1 res=success'
添加尾部 xferlog
Fri Mar 31 11:42:48 2017 1 ::ffff:118.100.67.46 0 /var/www/example.com/new1.html a _ i r ruey ftp 0 * i
Fri Mar 31 11:50:02 2017 1 ::ffff:118.100.67.46 0 /var/www/new1.html a _ i r ruey ftp 0 * i
Fri Mar 31 13:32:23 2017 1 ::ffff:183.171.64.24 0 /var/www/new1.html a _ i r ruey ftp 0 * i
Fri Mar 31 13:33:38 2017 1 ::ffff:183.171.64.24 0 /var/www/google.txt b _ i r ruey ftp 0 * i
Fri Mar 31 13:46:38 2017 1 ::ffff:183.171.64.24 0 /var/www/lol.php b _ i r ruey ftp 0 * i
Fri Mar 31 14:57:34 2017 1 ::ffff:183.171.76.20 0 /var/www/example.com/new1.html a _ i r ruey ftp 0 * i
Fri Mar 31 14:57:48 2017 1 ::ffff:183.171.76.20 0 /var/www/new1.html a _ i r ruey ftp 0 * i
Fri Mar 31 15:39:06 2017 1 ::ffff:183.171.76.20 0 /var/www/example.com/new1.html a _ i r ruey ftp 0 * i
Fri Mar 31 15:45:12 2017 1 ::ffff:183.171.76.20 0 /var/www/example.com/htdocs/new1.html a _ i r ruey ftp 0 * i
Fri Mar 31 15:46:01 2017 1 ::ffff:183.171.76.20 0 /var/new1.html a _ i r ruey ftp 0 * i
它们全部返回响应:553 无法创建文件。
帮助........