这个问题是为了一般的应用,但我可以用一些具体的例子来说明我的问题的性质。 当某些Linuxauthentication软件包如krb5,sssd或pam_pkcs11被安装时,会进入PAMconfiguration目录下的文件(如/etc/pam.d/system-auth和/etc/pam.d/password-auth ),添加或修改一行以指向已安装的新.so文件,如pam_krb5.so , pam_sssd.so或pam_pkcs11.so以供使用。
这似乎是自动发生的某些软件包,无需用户干预,只需安装rpm软件包(使用yum或直接使用rpm工具),就像我观察到的那样,安装sssd软件包(至less在RHEL 7上)将会将对pam_sssd.so的引用添加到* -auth PAM文件中。 我想这是唯一可能的方法是通过rpms可以拥有的内部脚本,所以我查了一下如何在rpm的SPEC中列出内部脚本,安装了一个RHEL 7映像以便与源代码包对等,在Packages目录下运行:
sudo rpm –scripts -qpl sssd- * | grep -i pam
然而,我没有返回任何行,表明任何东西都触及/etc/pam.d目录中的文件,即使如果我删除grep,我会看到if / then脚本逻辑做其他事情的结果,所以–scripts参数正在工作。
我也很好奇,在一个非常特殊的例子中,把这一行添加到我的/etc/pam.d/system-auth文件中:
auth [成功=完成authinfo_unavail =忽略忽略=忽略默认=死亡] pam_pkcs11.so nodebug
如果它不是RPM的内部脚本,我想知道它是否可能是最初运行的新安装文件中的某个二进制文件,这是什么负责添加这些更改,但没有看到任何证据那。
此外,我实际上已经在RPM脚本中使用了authconfig行,因为我知道authconfig可以做到这一点,但没有find任何东西。 然而,它似乎必须运行authconfig或在背景等效的东西来做到这一点。
有没有人对这些改变有什么看法?
相当有趣的问题,我承认这一点。
RedHat是一个庞大的组织,它可以改写它在发行版中提供的任何开源软件(RHEL,CentOS)。 它做到了。
我决定在CentOS7.3机器上安装samba时做一个strace ,这里是我看到的(部分输出):
open("/etc/pam.d/samba;593a8da8", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 47 fcntl(47, F_SETFD, FD_CLOEXEC) = 0 umask(022) = 0777 write(47, "#%PAM-1.0\nauth required\tpa"..., 177) = 177 close(47) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 lstat("/etc/pam.d/samba", 0x7ffeed35d250) = -1 ENOENT (No such file or directory) rename("/etc/pam.d/samba;593a8da8", "/etc/pam.d/samba") = 0 getuid() = 0 getuid() = 0 chown("/etc/pam.d/samba", 0, 0) = 0 chmod("/etc/pam.d/samba", 0644) = 0 utime("/etc/pam.d/samba", [2017/05/25-07:33:05, 2017/05/25-07:33:05]) = 0 getuid()
它使用以下内容创build/etc/pam.d/samba文件:
#%PAM-1.0 auth required pam_nologin.so auth include password-auth account include password-auth session include password-auth password include password-auth
另外,还有一个可以自动更新的工具,可以用来备份和/或恢复pam.dconfiguration文件 – 这就是authconfig 。 我的猜测是,它可能会在安装某些软件包以更新PAMconfiguration文件时使用。 例如,RedHatconfigurationSSSD进行系统authentication(包括configurationPAM )的过程的一部分是:
Use authconfig to enable SSSD for system authentication. # authconfig --update --enablesssd --enablesssdauth This automatically updates the PAM configuration to reference all of the
这里是rpm --scripts -qpl samba-4* | grep -i pam 在我的testing服务器上运行rpm --scripts -qpl samba-4* | grep -i pam : /etc/pam.d/samba – 这是在samba安装过程中创build的新文件。