rhel6 上 smb 共享的 pam_mount,主目录不可用于登录 - 可能是 SELinux?

rhel6 上 smb 共享的 pam_mount,主目录不可用于登录 - 可能是 SELinux?

我在 RHEL 6 x86_64 系统上使用 Fedora 12 pam_mount / libHX RPM,从配置了 NTFS 安全性的 NetApp 系统自动挂载主目录

AD 绑定登录工作正常 - 我在让它自动挂载和映射用户主目录共享方面遇到了问题。它最初抱怨权限被拒绝,但后来我可以正常进入主目录。

$ ssh username@hostname

NOTE: This system is for the use of authorized users only

username@hostname's password: 
Last login: Mon Feb 27 10:54:09 2012 from another.hostname
Could not chdir to home directory /home/AD/username: Permission denied
-bash-4.1$ cd
-bash-4.1$ pwd
/home/AD/username

这是 /etc/security/pam_mount.conf.xml:

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE pam_mount SYSTEM "pam_mount.conf.xml.dtd">
<pam_mount>
  <mntoptions allow="nosuid,nodev,loop,encryption,fsck,nonempty,allow_root,allow_other,workgroup,nosetuids,noexec,nosuid,noserverino" />
  <mntoptions require="nosuid,nodev" />
  <logout wait="2" hup="0" term="yes" kill="0" />
  <mkmountpoint enable="1" remove="true" />
  <debug enable="0" />
  <volume fstype="cifs" server="home.ad" path="%(USER)" mountpoint="/home/AD/%(USER)" options="workgroup=ad,uid=%(USER),dir_mode=0700,file_mode=0700,nosuid,nodev,noserverino" />
</pam_mount>

这是 /etc/pam.d/password-auth:

# cat /etc/pam.d/password-auth
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth        required      pam_env.so
auth        required      pam_mount.so
auth        sufficient    pam_unix.so nullok try_first_pass
auth        requisite     pam_succeed_if.so uid >= 500 quiet
auth        sufficient    pam_krb5.so use_first_pass
auth        sufficient    pam_winbind.so use_first_pass
auth        required      pam_deny.so

account     required      pam_access.so
account     required      pam_unix.so broken_shadow
account     sufficient    pam_localuser.so
account     sufficient    pam_succeed_if.so uid < 500 quiet
account     [default=bad success=ok user_unknown=ignore] pam_krb5.so
account     [default=bad success=ok user_unknown=ignore] pam_winbind.so
account     required      pam_permit.so

password    requisite     pam_cracklib.so try_first_pass retry=3 type=
password    sufficient    pam_unix.so sha512 shadow nullok try_first_pass use_authtok
password    sufficient    pam_krb5.so use_authtok
password    sufficient    pam_winbind.so use_authtok
password    required      pam_deny.so

session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
session     optional      pam_oddjob_mkhomedir.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so
session     optional      pam_mount.so
session     optional      pam_krb5.so

在登录时,我在 /var/log/messages 中看到以下错误:

Feb 27 14:28:49 hostname kernel: type=1400 audit(1330381729.009:4304): avc:  denied  { search } for  pid=3855 comm="sshd" name="/" dev=cifs ino=143 scontext=system_u:system_r:sshd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:cifs_t:s0 tclass=dir

仅仅关闭 SELinux 不是一个选择 - 我想弄清楚如何修复它,因为我认为这是根本原因。有人能给我一些指点吗?

答案1

似乎没有任何相关策略默认允许这样做。这是因为 pam 正在 sshd_t 上下文中加载模块,并试图执行一些通常与 sshd_t 类型应该执行的操作无关的奇怪操作。

为了修复此问题,请将以下内容粘贴到文件中,可能将其命名为 mysshd.te;

policy_module(mysshd, 0.0.1)

gen_require(`
    type cifs_t;
    type sshd_t;
')

read_files_pattern(sshd_t, cifs_t, cifs_t, { file, dir})
# If that doesnt work, try this
#manage_files_pattern(sshd_t, cifs_t, cifs_t {file, dir})

通过运行以下命令来编译它:

make -f /usr/share/selinux/devel/Makefile

制作并加载它:

make -f /usr/share/selinux/devel/Makefile load

然后,再试一次。

相关内容