<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.yoctoproject.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wfan</id>
	<title>Yocto Project - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.yoctoproject.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wfan"/>
	<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/Special:Contributions/Wfan"/>
	<updated>2026-04-15T04:47:24Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2981</id>
		<title>PAM Integration</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2981"/>
		<updated>2011-07-28T02:27:01Z</updated>

		<summary type="html">&lt;p&gt;Wfan: /* at */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Motivation ==&lt;br /&gt;
For Yocto 1.1 we are working to ensure that PAM (Pluggable Authentication Module) support is consistent and enabled in recipes where it is applicable. &lt;br /&gt;
&lt;br /&gt;
== Common configure files ==&lt;br /&gt;
For convenience, list common configure files here:&lt;br /&gt;
&lt;br /&gt;
common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
  auth	requisite			pam_deny.so&lt;br /&gt;
  auth	required			pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-account&lt;br /&gt;
  account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so &lt;br /&gt;
  account requisite                       pam_deny.so&lt;br /&gt;
  account required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so obscure sha512&lt;br /&gt;
  password        requisite                       pam_deny.so&lt;br /&gt;
  password        required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-session&lt;br /&gt;
  session [default=1]                     pam_permit.so&lt;br /&gt;
  session requisite                       pam_deny.so&lt;br /&gt;
  session required                        pam_permit.so&lt;br /&gt;
  session required                        pam_unix.so &lt;br /&gt;
&lt;br /&gt;
common-session-noninteractive&lt;br /&gt;
  session [default=1]                     pam_permit.so&lt;br /&gt;
  session requisite                       pam_deny.so&lt;br /&gt;
  session required                        pam_permit.so&lt;br /&gt;
  session required                        pam_unix.so&lt;br /&gt;
&lt;br /&gt;
== Recipes with PAM support ==&lt;br /&gt;
The following recipes are identified to have PAM support:&lt;br /&gt;
&lt;br /&gt;
=== at === &lt;br /&gt;
* Simple ways to verify &#039;at&#039;:&lt;br /&gt;
 $ at now&lt;br /&gt;
 $ echo &amp;quot;$msg_to_print&amp;quot; &amp;gt;&amp;gt; /tmp/at_test&lt;br /&gt;
 $ &amp;lt; ctrl+D &amp;gt;&lt;br /&gt;
 $ cat /tmp/at_test    # Verify if the message has been there &lt;br /&gt;
&lt;br /&gt;
* /etc/pam.d/atd - not installed by default, copy it from source code and replace &#039;@include&#039; with appropriate &#039;module-type include&#039;:&lt;br /&gt;
&lt;br /&gt;
 auth       required    pam_env.so&lt;br /&gt;
 auth       include     common-auth&lt;br /&gt;
 account    include     common-account&lt;br /&gt;
 session    include     common-session-noninteractive&lt;br /&gt;
 session    required    pam_limits.so&lt;br /&gt;
&lt;br /&gt;
* test pam plugins&lt;br /&gt;
** pam_env.so&lt;br /&gt;
modify /etc/pam.d/atd&lt;br /&gt;
 auth       required    pam_env.so    debug&lt;br /&gt;
modify /etc/security/pam_env.conf, add a test entry such as:&lt;br /&gt;
 MYNAME          DEFAULT=&amp;quot;test-at&amp;quot;&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:41:22 qemux86 atd[678]: pam_env(atd:setcred): pam_putenv(&amp;quot;MYNAME=test-at&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
** pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf &lt;br /&gt;
 root    -       nofile  3&lt;br /&gt;
&#039;at&#039; job failed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:49:42 qemux86 atd[699]: pam_env(atd:setcred): Unable to open config file: /etc/security/pam_env.conf: Too many open files&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
 root    -       nofile  4&lt;br /&gt;
&#039;at&#039; job successed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session opened for user root by (uid=0)                      &lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session closed for user root&lt;br /&gt;
&lt;br /&gt;
=== cronie ===&lt;br /&gt;
* /etc/pam.d/crond:&lt;br /&gt;
 account    required   pam_access.so&lt;br /&gt;
 account    include    common-password&lt;br /&gt;
 session    required   pam_loginuid.so&lt;br /&gt;
 session    include    common-session-noninteractive&lt;br /&gt;
 auth       include    common-auth&lt;br /&gt;
&lt;br /&gt;
* test commands:&lt;br /&gt;
 crontab -e    # establish a crontab jobs and check if it works&lt;br /&gt;
 crontab -l    # list crontab jobs for current user&lt;br /&gt;
&lt;br /&gt;
* test pam plugins&lt;br /&gt;
Verified, test ways and the logs/results please refer to other packages:&lt;br /&gt;
** pam_env.so&lt;br /&gt;
** pam_access.so&lt;br /&gt;
** pam_unix.so&lt;br /&gt;
** pam_permit.so&lt;br /&gt;
** pam_deny.so&lt;br /&gt;
&lt;br /&gt;
** pam_loginuid.so&lt;br /&gt;
 TBD&lt;br /&gt;
&lt;br /&gt;
=== cups ===&lt;br /&gt;
* /etc/pam.d/cups&lt;br /&gt;
 auth	    required	pam_unix.so shadow nodelay&lt;br /&gt;
 account    required	pam_unix.so&lt;br /&gt;
&lt;br /&gt;
* Modify /etc/cups/cupsd.conf:&lt;br /&gt;
 ...&lt;br /&gt;
 - Listen localhost:631&lt;br /&gt;
 + Port 631&lt;br /&gt;
 ...&lt;br /&gt;
 # Restrict access to the server...                               &lt;br /&gt;
 &amp;lt;Location /&amp;gt;                                                     &lt;br /&gt;
   Order allow,deny                                               &lt;br /&gt;
 + allow all                                                      &lt;br /&gt;
 &amp;lt;/Location&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
 # Restrict access to the admin pages...                          &lt;br /&gt;
 &amp;lt;Location /admin&amp;gt;                                                &lt;br /&gt;
   Order allow,deny                                               &lt;br /&gt;
 + allow all                                                      &lt;br /&gt;
 &amp;lt;/Location&amp;gt; &lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
* Test pam plugins&lt;br /&gt;
** pam_unix.so&lt;br /&gt;
Add debug option to &#039;/etc/pam/cups&#039;:&lt;br /&gt;
 auth	    required	pam_unix.so shadow nodelay debug&lt;br /&gt;
 account    required	pam_unix.so debug&lt;br /&gt;
&lt;br /&gt;
Access the cups configure page via web browser:&lt;br /&gt;
 http://&amp;lt;qemu.ip&amp;gt;:631&lt;br /&gt;
Click &#039;Administration&#039; -&amp;gt; &#039;Add Printer&#039;, start the pop-window for user authentication, input correct user and password:&lt;br /&gt;
 user: root&lt;br /&gt;
 pwd: &amp;lt;correct password&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Entry the &#039;Add Printer&#039; configure page successed.&lt;br /&gt;
&lt;br /&gt;
Input error password:&lt;br /&gt;
 user: root&lt;br /&gt;
 pwd: &amp;lt;error password&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check log in &#039;/var/log/cups/error_log&#039;:&lt;br /&gt;
 E [14/Jul/2011:02:41:26 +0800] cupsdAuthorize: pam_authenticate() returned 7 (Authentication failure)!&lt;br /&gt;
&lt;br /&gt;
Modify &#039;/etc/shadow&#039;:&lt;br /&gt;
 -root:$6$yMXdsttU$kT7A.n9bP0w0zzX6Uj1wmypHcq0lSGaC5/4xgNTZRSjNvW0q85ryBz8C6WNCbr22c6RjRKaVhv23ogrmoAo9m.:15168:0:99999:7:::&lt;br /&gt;
 +root:$6$yMXdsttU$kT7A.n9bP0w0zzX6Uj1wmypHcq0lSGaC5/4xgNTZRSjNvW0q85ryBz8C6WNCbr22c6RjRKaVhv23ogrmoAo9m.:15168:0:99999:7::1:&lt;br /&gt;
&lt;br /&gt;
Repeat the user authentication steps, check log in &#039;/var/log/cups/error_log&#039;:&lt;br /&gt;
 E [14/Jul/2011:03:05:00 +0800] cupsdAuthorize: pam_acct_mgmt() returned 13 (User account has expired)!&lt;br /&gt;
&lt;br /&gt;
=== dropbear ===&lt;br /&gt;
* For supporting pam in dropbear, we need two steps:&lt;br /&gt;
* Add configuration &amp;quot;--enable-pam&amp;quot; &lt;br /&gt;
* Add patches to open macro definition for supporting in option.h&lt;br /&gt;
 --- a/ptions.h  2011-07-12 11:32:34.165333202 +0800&lt;br /&gt;
 +++ b/options.h.new     2011-07-12 11:33:25.757332986 +0800&lt;br /&gt;
 @@ -149,9 +149,9 @@&lt;br /&gt;
   * but there&#039;s an interface via a PAM module - don&#039;t bother using it otherwise.&lt;br /&gt;
   * You can&#039;t enable both PASSWORD and PAM. */&lt;br /&gt;
 -#define ENABLE_SVR_PASSWORD_AUTH&lt;br /&gt;
 +//#define ENABLE_SVR_PASSWORD_AUTH&lt;br /&gt;
  /* PAM requires ./configure --enable-pam */&lt;br /&gt;
 -/*#define ENABLE_SVR_PAM_AUTH*/&lt;br /&gt;
 +#define ENABLE_SVR_PAM_AUTH&lt;br /&gt;
  #define ENABLE_SVR_PUBKEY_AUTH&lt;br /&gt;
  /* Wether to ake public key options in authorized_keys file into account */&lt;br /&gt;
&lt;br /&gt;
* Test result(dropbear only support simple authentication, account and auth)&lt;br /&gt;
** &#039;&#039;&#039;Server(account)&#039;&#039;&#039;&lt;br /&gt;
 (server ip:192.168.7.2)&lt;br /&gt;
 $touch /etc/pam.d/sshd&lt;br /&gt;
 #%PAM-1.0&lt;br /&gt;
 account  required     pam_access.so&lt;br /&gt;
 $vi /etc/security/access.conf&lt;br /&gt;
 - : root : ALL&lt;br /&gt;
&lt;br /&gt;
** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow access)&lt;br /&gt;
&lt;br /&gt;
** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 14 07:01:48 qemux86 dropbear[407]: pam_access(sshd:account): access denied for user `root&#039; from `ssh&#039;&lt;br /&gt;
 Jul 14 07:01:48 qemux86 dropbear[407]: pam_acct_mgmt() failed, rc=6, Permission denied &lt;br /&gt;
 Jul 14 07:01:48 qemux86 dropbear[407]: bad PAM password attempt for &#039;root&#039; from 192.168.7.1:33633&lt;br /&gt;
&lt;br /&gt;
** &#039;&#039;&#039;Server(auth)&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/sshd&lt;br /&gt;
  auth include common-auth&lt;br /&gt;
 $vi /etc/pam.d/common-auth&lt;br /&gt;
 #auth   [success=1 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
 auth    [success=0 default=ignore]      pam_unix.so debug&lt;br /&gt;
 $ passwd -d username &amp;lt;blank password&amp;gt;&lt;br /&gt;
&lt;br /&gt;
** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow access)&lt;br /&gt;
&lt;br /&gt;
** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 14 07:06:42 qemux86 dropbear[421]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=  user=yxf&lt;br /&gt;
 Jul 14 07:06:44 qemux86 dropbear[421]: pam_authenticate() failed, rc=7, Authentication failure &lt;br /&gt;
 Jul 14 07:06:44 qemux86 dropbear[421]: bad PAM password attempt for &#039;yxf&#039; from 192.168.7.1:379&lt;br /&gt;
&lt;br /&gt;
=== openssh ===&lt;br /&gt;
* Absent configuration /etc/pam.d/sshd, we need to add patches. After adding this file, it can support pam function through simple test.&lt;br /&gt;
* Test Result&lt;br /&gt;
** &#039;&#039;&#039;Configuration of sshd&#039;&#039;&#039;&lt;br /&gt;
 auth       include      common-auth&lt;br /&gt;
 account    required     pam_nologin.so&lt;br /&gt;
 account    include      common-account&lt;br /&gt;
 password   include      common-password&lt;br /&gt;
 session    optional     pam_keyinit.so force revoke&lt;br /&gt;
 session    include      common-session&lt;br /&gt;
 session    required     pam_loginuid.so&lt;br /&gt;
** &#039;&#039;&#039;auth include common-auth --Server&#039;&#039;&#039;&lt;br /&gt;
 $echo &#039;UsePAM no&#039; &amp;gt;&amp;gt;/etc/ssh/sshd_config&lt;br /&gt;
 $vi /etc/ssh/sshd_config&lt;br /&gt;
  PermitEmptyPasswords yes &lt;br /&gt;
&lt;br /&gt;
 Other is as same as sudo&lt;br /&gt;
** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 12 11:16:21 qemux86 sshd[650]: pam_unix(sshd:session): session opened for user test by (uid=0)&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
** &#039;&#039;&#039;account required pam_nologin.so --Server&#039;&#039;&#039;&lt;br /&gt;
 $touch /etc/nologin&lt;br /&gt;
&lt;br /&gt;
** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow accession)&lt;br /&gt;
** &#039;&#039;&#039;log information --Server&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 01:43:48 qemux86 sshd[672]: Accepted keyboard-interactive/pam for yxf from 192.168.7.1 port 59877 ssh2&lt;br /&gt;
 Jul 13 01:43:48 qemux86 sshd[672]: fatal: PAM: pam_setcred(): Failure setting user credentia&lt;br /&gt;
&lt;br /&gt;
** &#039;&#039;&#039;account include common-account --Server&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/ssh/sshd_config&lt;br /&gt;
  PermitEmptyPasswords no&lt;br /&gt;
 $vi /etc/pam.d/common-account &lt;br /&gt;
  #account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
  account [success=0 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow accession)&lt;br /&gt;
** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 02:11:24 qemux86 sshd[752]: Failed password for root from 192.168.7.1 port 53784 ssh2&lt;br /&gt;
&lt;br /&gt;
** &#039;&#039;&#039;password include common-password&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so obscure sha512 &lt;br /&gt;
&lt;br /&gt;
 It&#039;s no use for sshd, So no test result for this item&lt;br /&gt;
&lt;br /&gt;
** &#039;&#039;&#039;session optional  pam_keyinit.so force revoke --Server&#039;&#039;&#039;&lt;br /&gt;
 No action&lt;br /&gt;
** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 07:28:18 qemux86 sshd[1132]: pam_keyinit(sshd:session): OPEN 1&lt;br /&gt;
 Jul 13 07:28:18 qemux86 sshd[1132]: pam_keyinit(sshd:session): UID:1000 [0]  GID:1000 [0]&lt;br /&gt;
 Jul 13 07:28:18 qemux86 sshd[1132]: pam_keyinit(sshd:session): JOIN = 236576375&lt;br /&gt;
** &#039;&#039;&#039;Client&#039;&#039;&#039;( the same session as the above &amp;quot;client&amp;quot;   )&lt;br /&gt;
 $exit&lt;br /&gt;
** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 07:34:47 qemux86 sshd[1132]: pam_keyinit(sshd:session): CLOSE 1,236576375,1&lt;br /&gt;
 Jul 13 07:34:47 qemux86 sshd[1132]: pam_keyinit(sshd:session): REVOKE 236576375&lt;br /&gt;
 Jul 13 07:34:47 qemux86 sshd[1132]: pam_keyinit(sshd:session): UID:1000 [0]  GID:1000 [0]&lt;br /&gt;
&lt;br /&gt;
** &#039;&#039;&#039;session include common-session --Server&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/common-session&lt;br /&gt;
  #session [default=1] pam_permit.so&lt;br /&gt;
  session [default=0] pam_permit.so&lt;br /&gt;
** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow accession)&lt;br /&gt;
** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 05:53:35 qemux86 sshd[960]: error: PAM: pam_open_session(): Permission denied&lt;br /&gt;
 Jul 13 05:53:35 qemux86 sshd[960]: Received disconnect from 192.168.7.1: 11: disconnected by user&lt;br /&gt;
** &#039;&#039;&#039; session required  pam_loginuid.so --Server&#039;&#039;&#039;(Record user´s login uid to the process attribute)&lt;br /&gt;
 No action&lt;br /&gt;
** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 06:31:32 qemux86 sshd[1028]: pam_warn(sshd:session): function=[pam_sm_open_session] service=[sshd] terminal=[ssh] user=[yxf] ruser= [&amp;lt;unknown&amp;gt;] rhost=[ubuntuwindriver.local] &lt;br /&gt;
 Jul 13 06:31:32 qemux86 sshd[1028]: pam_unix(sshd:session): session opened for user yxf by (uid=0)&lt;br /&gt;
&lt;br /&gt;
=== polkit ===&lt;br /&gt;
Polkit includes four binaries. Only pkexec depends on pam. So I use pkexec to make pam test.&lt;br /&gt;
Pkexec allows an authorized user to execute PROGRAM as another user. If username is not specified, then the program will be executed as the administrative super user, root.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Pam configuration file of polkit &#039;&#039;&#039;&lt;br /&gt;
 %PAM-1.0&lt;br /&gt;
 auth       include      common-auth&lt;br /&gt;
 account    include      common-account&lt;br /&gt;
 password   include      common-password&lt;br /&gt;
 session    include      common-session&lt;br /&gt;
* &#039;&#039;&#039;Test Reult&#039;&#039;&#039;&lt;br /&gt;
** &#039;&#039;&#039;Normally pkexec can call pam modules from the above configuration file&#039;&#039;&#039;&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
  ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
  Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
  Authenticating as: root&lt;br /&gt;
  Password: &amp;lt;---Input root password and press key &amp;quot;Enter&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 Jul 14 22:13:18 emenlow polkitd(authority=local): Registered Authentication Agent for unix-process:2466:778527 (system bus name :1.10 [pkexec  cat /var/log/auth.log], &lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)&lt;br /&gt;
 Jul 14 22:13:18 emenlow polkit-agent-helper-1[2501]: PAM pam_parse: expecting non-zero; [... default=ignore]&lt;br /&gt;
 Jul 14 22:13:18 emenlow polkit-agent-helper-1[2501]: PAM pam_parse: expecting non-zero; [... default=ignore]&lt;br /&gt;
 Jul 14 22:13:21 emenlow polkitd(authority=local): Unregistered Authentication Agent for unix-process:2466:778527 (system bus name :1.10,&lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)&lt;br /&gt;
 Jul 14 22:13:21 emenlow polkitd(authority=local): Operator of unix-process:2466:778527 FAILED to authenticate to gain authorization for action&lt;br /&gt;
 org.freedesktop.policykit.exec for unix-process:2466:778527 [sh] (owned by unix-user:yxf)&lt;br /&gt;
 Jul 14 22:14:37 emenlow polkitd(authority=local): Registered Authentication Agent for unix-process:2466:778527 (system bus name :1.11 [pkexec &lt;br /&gt;
 cat /var/log/auth.log], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)&lt;br /&gt;
 Jul 14 22:16:08 emenlow polkitd(authority=local): Operator of unix-process:2466:778527 successfully authenticated as unix-user:root to gain &lt;br /&gt;
 ONE-SHOT authorization for action org.freedesktop.policykit.exec for unix-process:2466:778527 [sh] (owned by unix-user:yxf)&lt;br /&gt;
 Jul 14 22:16:08 emenlow pkexec: pam_unix(polkit-1:session): session opened for user root by root(uid=500)&lt;br /&gt;
 Jul 14 22:16:08 emenlow pkexec[2507]: yxf: Executing command [USER=root] [TTY=/dev/pts/0] [CWD=/] [COMMAND=/bin/cat /var/log/auth.log]&lt;br /&gt;
 Jul 14 22:16:08 emenlow polkitd(authority=local): Unregistered Authentication Agent for unix-process:2466:778527 (system bus name :1.11, &lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)&lt;br /&gt;
** &#039;&#039;&#039;auth include common-auth&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/common-auth&lt;br /&gt;
  #auth    [success=1 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
  auth    [success=0 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
 ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
 Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
 Authenticating as: root&lt;br /&gt;
 Password: &lt;br /&gt;
 polkit-agent-helper-1: pam_authenticate failed: Permission denied&lt;br /&gt;
 Error: Permission denied&lt;br /&gt;
 ==== AUTHENTICATION FAILED ===&lt;br /&gt;
 Error executing command as another user: Not authorized&lt;br /&gt;
 &lt;br /&gt;
 This incident has been reported.&lt;br /&gt;
&lt;br /&gt;
log information in /var/log/auth.log&lt;br /&gt;
 Jul 14 22:23:24 emenlow pkexec[2515]: yxf: Error executing command as another user: Not authorized [USER=root] [TTY=/dev/pts/0] [CWD=/] [COMMAND=/bin/cat /var/log/auth.log]&lt;br /&gt;
** &#039;&#039;&#039;account include common-account&#039;&#039;&#039;&lt;br /&gt;
 $ vi /etc/pam.d/common-account&lt;br /&gt;
 #account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
 account [success=0 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
 ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
 Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
 Authenticating as: root&lt;br /&gt;
 Password: &lt;br /&gt;
 polkit-agent-helper-1: pam_acct_mgmt failed: Permission denied&lt;br /&gt;
 Error: Permission denied&lt;br /&gt;
 ==== AUTHENTICATION FAILED ===&lt;br /&gt;
 Error executing command as another user: Not authorized&lt;br /&gt;
&lt;br /&gt;
log information in /var/log/auth.log&lt;br /&gt;
 Jul 14 22:29:12 emenlow pkexec[2523]: yxf: Error executing command as another user: Not authorized [USER=root] [TTY=/dev/pts/0] [CWD=/] [COMMAND=/bin/cat /var/log/auth.log]&lt;br /&gt;
&lt;br /&gt;
** &#039;&#039;&#039;password include common-password&#039;&#039;&#039;&lt;br /&gt;
 It is no use for polkit. So I don&#039;t test it&lt;br /&gt;
** &#039;&#039;&#039;session include common-session&#039;&#039;&#039;&lt;br /&gt;
 $ vi /etc/pam.d/common-session&lt;br /&gt;
 #session [default=1]                     pam_permit.so&lt;br /&gt;
 session [default=0]                     pam_permit.so&lt;br /&gt;
&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
 ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
 Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
 Authenticating as: root&lt;br /&gt;
 Password: &lt;br /&gt;
 ==== AUTHENTICATION COMPLETE ===&lt;br /&gt;
 pam_open_session() failed: Permission denied&lt;br /&gt;
&lt;br /&gt;
log information in /var/log/auth.log&lt;br /&gt;
 Jul 14 22:35:51 emenlow polkitd(authority=local): Unregistered Authentication Agent for unix-process:2466:778527 (system bus name :1.17, &lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)&lt;br /&gt;
&lt;br /&gt;
=== screen ===&lt;br /&gt;
screen use pam to authenticate users during unlock terminal. Its configure file screen comes from Fedora and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
&lt;br /&gt;
First start screen:&lt;br /&gt;
  root@qemux86:/etc/pam.d# screen&lt;br /&gt;
it will show some information about screen, just press Space or Enter and it will give a screen terminal:&lt;br /&gt;
  root@qemux86:/etc/pam.d# &lt;br /&gt;
then press &amp;quot;Ctrl+a x&amp;quot; will lock the screen terminal and show:&lt;br /&gt;
    &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
In another root terminal, clear the root&#039;s password:&lt;br /&gt;
  password -d root&lt;br /&gt;
&lt;br /&gt;
modify one line in common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
with&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so debug&lt;br /&gt;
option nullok_secure will allow users who has blank password login, after remove it these users are not allowed to login.&lt;br /&gt;
&lt;br /&gt;
Back to the screen terminal, press &amp;lt;Enter&amp;gt;(because root&#039;s password is blank now) will fail: &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
then modify the line in common-auth with &lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure debug&lt;br /&gt;
&lt;br /&gt;
On the screen terminal press &amp;lt;Enter&amp;gt; again it unlock the terminal.&lt;br /&gt;
&lt;br /&gt;
the log in /var/log/auth.log:&lt;br /&gt;
  Jul 11 14:14:14 qemux86 screen: pam_unix(screen:auth): authentication failure; logname=root uid=0 euid=0 tty= ruser= rhost=  user=root&lt;br /&gt;
&lt;br /&gt;
=== shadow ===&lt;br /&gt;
==== chage ====&lt;br /&gt;
/etc/pam.d/chage: need patch to replace system-auth to common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth		sufficient	pam_rootok.so&lt;br /&gt;
  account	required	pam_permit.so&lt;br /&gt;
  password	include		common-auth&lt;br /&gt;
* test pam_rootok.so&lt;br /&gt;
add the only option for pam_rootok.so&lt;br /&gt;
  auth		sufficient	pam_rootok.so debug&lt;br /&gt;
&lt;br /&gt;
run command chage as root:&lt;br /&gt;
  root@qemux86:/etc/pam.d# chage -m 10  test&lt;br /&gt;
&lt;br /&gt;
log info in /var/log/message shows pam_rootok.so return success:&lt;br /&gt;
  Jul 12 06:55:18 qemux86 authpriv.debug chage[575]: pam_rootok(chage:auth): root check succeeded&lt;br /&gt;
  Jul 12 06:55:18 qemux86 authpriv.info chage[575]: changed password expiry for test&lt;br /&gt;
&lt;br /&gt;
* test pam_unix.so&lt;br /&gt;
the content of common-auth are shown at section &amp;quot;Common configure files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
comment the pam_rootok.so line, because it will make pam return success:&lt;br /&gt;
  #auth		sufficient	pam_rootok.so&lt;br /&gt;
&lt;br /&gt;
and modify the pam_unix.so line in common-auth:&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so debug&lt;br /&gt;
&lt;br /&gt;
run commands:&lt;br /&gt;
  root@qemux86:/etc/pam.d# passwd -d root &lt;br /&gt;
  root@qemux86:/etc/pam.d# chfn -f testself test # test is a unprivileged user&lt;br /&gt;
  Password: &lt;br /&gt;
  chfn: PAM authentication failed&lt;br /&gt;
&lt;br /&gt;
log in /var/log/message:&lt;br /&gt;
  Jul 12 07:53:16 qemux86 authpriv.notice chfn[673]: pam_unix(chfn:auth): authentication failure; logname=root uid=0 euid=0 tty= ruser= rhost=  user=root&lt;br /&gt;
&lt;br /&gt;
==== chfn ====&lt;br /&gt;
/etc/pam.d/chfn&lt;br /&gt;
  auth	    sufficient	pam_rootok.so&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-account&lt;br /&gt;
  session    include      common-session&lt;br /&gt;
add option debug to pam_rootok.so&lt;br /&gt;
  auth	    sufficient	pam_rootok.so debug&lt;br /&gt;
&lt;br /&gt;
* pam_rootok.so&lt;br /&gt;
run command chfn as root:&lt;br /&gt;
  root@qemux86:/etc/pam.d# chfn -f testyayay test&lt;br /&gt;
&lt;br /&gt;
log info in /var/log/message shows pam_rootok.so return success:&lt;br /&gt;
  Jul 12 07:22:59 qemux86 authpriv.debug chfn[638]: pam_rootok(chfn:auth): root check succeeded&lt;br /&gt;
  Jul 12 07:22:59 qemux86 authpriv.info chfn[638]: changed user &#039;test&#039; information&lt;br /&gt;
&lt;br /&gt;
* pam_unix.so&lt;br /&gt;
please refer to chage test steps.&lt;br /&gt;
&lt;br /&gt;
==== chgpasswd ====&lt;br /&gt;
/etc/pam.d/chgpasswd(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth		sufficient	pam_rootok.so&lt;br /&gt;
  account	required	pam_permit.so&lt;br /&gt;
  password	include		system-auth&lt;br /&gt;
&lt;br /&gt;
test pam_rootok.so and pam_unix.so(common-auth) refer to test steps in chage &lt;br /&gt;
&lt;br /&gt;
==== chpasswd ====&lt;br /&gt;
/etc/pam.d/chpasswd&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
common-password are listed before, we change the pam_unix.so option:&lt;br /&gt;
  password	[success=1 default=ignore]	pam_unix.so  audit&lt;br /&gt;
&lt;br /&gt;
commands to test:&lt;br /&gt;
  root@qemux86:/etc/pam.d# chpasswd&lt;br /&gt;
  test:&lt;br /&gt;
  Press Ctrl+d, the follow are terminal output:&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  chpasswd: (user test) pam_chauthtok() failed, error:&lt;br /&gt;
  Authentication token manipulation error&lt;br /&gt;
  chpasswd: (line 1, user test) password not changed&lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 04:53:39 qemux86 authpriv.notice chpasswd[844]: pam_warn(chpasswd:auth): function=[pam_sm_authenticate] service=[chpasswd] terminal=[&amp;lt;unknown&amp;gt;] user=[root] ruser=[&amp;lt;unknown&amp;gt;] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul 15 04:53:39 qemux86 authpriv.notice chpasswd[844]: pam_warn(chpasswd:account): function=[pam_sm_acct_mgmt] service=[chpasswd] terminal=[&amp;lt;unknown&amp;gt;] user=[root] ruser=[&amp;lt;unknown&amp;gt;] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.notice chpasswd[844]: pam_unix(chpasswd:chauthtok): new password not acceptable&lt;br /&gt;
&lt;br /&gt;
==== chsh ====&lt;br /&gt;
/etc/pam.d/chsh&lt;br /&gt;
  auth       required   pam_shells.so&lt;br /&gt;
  auth       sufficient      pam_rootok.so&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-account&lt;br /&gt;
  session    include      common-session&lt;br /&gt;
* pam_shells.so&lt;br /&gt;
pam_shells only allows access to the system if the users shell is listed in /etc/shells.It also checks if /etc/shells is a plain file and not world writable.&lt;br /&gt;
&lt;br /&gt;
check /etc/shells first:&lt;br /&gt;
  qemux86:~$ ls -l /etc/shells &lt;br /&gt;
  -rw-r--r--    1 root     root           109 Jul 12 06:05 /etc/shells&lt;br /&gt;
  qemux86:~$ cat /etc/shells&lt;br /&gt;
  # /etc/shells: valid login shells&lt;br /&gt;
  /bin/sh&lt;br /&gt;
  /bin/ash&lt;br /&gt;
  /bin/bash&lt;br /&gt;
  /bin/dash&lt;br /&gt;
  /bin/ksh&lt;br /&gt;
  /usr/bin/ksh&lt;br /&gt;
  /usr/bin/screen&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
login as a unprivileged user, the correct process is:&lt;br /&gt;
  qemux86:~$ chsh -s /bin/ash&lt;br /&gt;
  Password: &amp;lt;-- Enter password here&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 06:15:18 qemux86 authpriv.debug chsh[1283]: pam_rootok(chsh:auth): root check failed&lt;br /&gt;
  Jul 15 06:15:21 qemux86 authpriv.info chsh[1283]: changed user &#039;test&#039; shell to &#039;/bin/ash&#039;&lt;br /&gt;
&lt;br /&gt;
now remove /bin/ash from /etc/shells, then run the same command:&lt;br /&gt;
  qemux86:~$ chsh -s /bin/ash&lt;br /&gt;
  Password: &amp;lt;-- Enter password here&lt;br /&gt;
  chsh: /bin/ash is an invalid shell.&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
if you make /etc/shells is writable to all people, chsh will fail with syslog info:&lt;br /&gt;
  Jul 15 05:38:38 qemux86 authpriv.err chsh[1091]: pam_shells(chsh:auth): /etc/shells is either world writable or not a normal file&lt;br /&gt;
&lt;br /&gt;
* pam_rootok.so&lt;br /&gt;
modify pam_rootok.so item:&lt;br /&gt;
  auth       required     pam_rootok.so debug&lt;br /&gt;
&lt;br /&gt;
then unprivileged users can&#039;t change their shell.&lt;br /&gt;
  qemux86:~$ chsh -s /bin/ash&lt;br /&gt;
  Password: &lt;br /&gt;
  chsh: PAM authentication failed&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 06:43:14 qemux86 authpriv.debug chsh[1350]: pam_rootok(chsh:auth): root check failed&lt;br /&gt;
&lt;br /&gt;
* pam_unix.so&lt;br /&gt;
**pam_unix in common-auth: please refer to sudo tests&lt;br /&gt;
**pam_unix in common-account and common-password don&#039;t have test point.&lt;br /&gt;
&lt;br /&gt;
==== groupadd ====&lt;br /&gt;
/etc/pam.d/groupadd(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
* pam_rootok&lt;br /&gt;
please refer to chage tests&lt;br /&gt;
&lt;br /&gt;
*pam_unix.so in common-password doesn&#039;t has test point&lt;br /&gt;
&lt;br /&gt;
==== groupdel ====&lt;br /&gt;
/etc/pam.d/groupdel(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
* pam_rootok&lt;br /&gt;
please refer to chage tests&lt;br /&gt;
&lt;br /&gt;
==== groupmems ====&lt;br /&gt;
/etc/pam.d/groupmems&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
*pam_rootok:&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
*pam_unix in common-password doesn&#039;t has test point&lt;br /&gt;
&lt;br /&gt;
==== groupmod ====&lt;br /&gt;
/etc/pam.d/groupmod&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth           sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         common-password&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password&lt;br /&gt;
no test point&lt;br /&gt;
&lt;br /&gt;
==== login ====&lt;br /&gt;
/etc/pam.d/login&lt;br /&gt;
  auth       optional   pam_faildelay.so  delay=3000000&lt;br /&gt;
  auth       [success=ok ignore=ignore user_unknown=ignore default=die]  pam_securetty.so&lt;br /&gt;
  auth       requisite  pam_nologin.so&lt;br /&gt;
  session       required   pam_env.so readenv=1&lt;br /&gt;
  session       required   pam_env.so readenv=1 envfile=/etc/default/locale&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  auth       optional   pam_group.so&lt;br /&gt;
  session    required   pam_limits.so                                      &lt;br /&gt;
  session    optional   pam_lastlog.so                                     &lt;br /&gt;
  session    optional   pam_motd.so                              &lt;br /&gt;
  session    optional   pam_mail.so standard                    &lt;br /&gt;
                                                              &lt;br /&gt;
  account    include      common-account                        &lt;br /&gt;
  password   include      common-password                       &lt;br /&gt;
  session    include      common-session&lt;br /&gt;
&lt;br /&gt;
* pam_faildelay&lt;br /&gt;
this plugin an be used to set the delay on failure per-application. We increase &amp;quot;delay&amp;quot; to make it more obviously&lt;br /&gt;
  auth       optional   pam_faildelay.so  delay=10000000&lt;br /&gt;
&lt;br /&gt;
run login as root:&lt;br /&gt;
  root@qemux86:~# login&lt;br /&gt;
  qemux86 login: &#039;&#039;root&#039;&#039;&lt;br /&gt;
  Password: &#039;&#039;&amp;lt;-- enter a wrong password here, then will wait for 10 seconds to show next &amp;quot;login:&amp;quot;&#039;&#039;&lt;br /&gt;
  &lt;br /&gt;
  Login incorrect&lt;br /&gt;
  qemux86 login: &lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 17 07:22:17 qemux86 authpriv.notice login[2223]: pam_unix(login:auth): authentication failure; logname=root uid=0 euid=0 tty=/dev/pts/2 ruser= rhost=  user=root&lt;br /&gt;
  Jul 17 07:22:26 qemux86 authpriv.notice login[2223]: FAILED LOGIN (1) on &#039;/dev/pts/2&#039; FOR &#039;root&#039;, Authentication failure&lt;br /&gt;
&lt;br /&gt;
* pam_securetty&lt;br /&gt;
pam_securetty allows root logins only if the user is logging in on a &amp;quot;secure&amp;quot; tty, as defined by the listing in /etc/securetty.&lt;br /&gt;
&lt;br /&gt;
test steps:&lt;br /&gt;
  # ssh to yocto linux&lt;br /&gt;
  $ ssh root@192.168.7.2&lt;br /&gt;
  root@qemux86:~# tty &lt;br /&gt;
  /dev/pts/1&lt;br /&gt;
  root@qemux86:~# login&lt;br /&gt;
  qemux86 login: root&lt;br /&gt;
                      &amp;lt;-- don&#039;t ask for password, failed directly &lt;br /&gt;
  Login incorrect&lt;br /&gt;
  qemux86 login: &lt;br /&gt;
&lt;br /&gt;
syslog info&lt;br /&gt;
  Jul 17 07:52:32 qemux86 authpriv.warn login[2341]: pam_securetty(login:auth): access denied: tty &#039;pts/1&#039; is not secure !&lt;br /&gt;
  Jul 17 07:52:35 qemux86 authpriv.notice login[2341]: FAILED LOGIN (1) on &#039;/dev/pts/1&#039; FOR &#039;root&#039;, Authentication failure&lt;br /&gt;
&lt;br /&gt;
Then add &amp;quot;pts/1&amp;quot; to file /etc/securetty, run commonds:&lt;br /&gt;
  root@qemux86:~# login&lt;br /&gt;
  qemux86 login: &#039;&#039;root&#039;&#039;&lt;br /&gt;
  Password: &lt;br /&gt;
  Last login: Sun Jul 17 07:52:21 UTC 2011 from k-desktop.local on pts/1&lt;br /&gt;
  root@qemux86:~# &lt;br /&gt;
&lt;br /&gt;
syslog info&lt;br /&gt;
  Jul 17 07:56:00 qemux86 authpriv.notice login[2348]: ROOT LOGIN  on &#039;/dev/pts/1&#039;&lt;br /&gt;
&lt;br /&gt;
* pam_nologin&lt;br /&gt;
pam_nologin prevents non-root users from logging into the system when /etc/nologin exists. &lt;br /&gt;
&lt;br /&gt;
test steps&lt;br /&gt;
  root@qemux86:~# ls /etc/nologin&lt;br /&gt;
  ls: /etc/nologin: No such file or directory&lt;br /&gt;
  root@qemux86:~# login&lt;br /&gt;
  qemux86 login: test&lt;br /&gt;
  Last login: Sun Jul 17 07:19:24 UTC 2011 on pts/2&lt;br /&gt;
  qemux86:~$ logout&lt;br /&gt;
  root@qemux86:~# touch /etc/nologin&lt;br /&gt;
  root@qemux86:~# login&lt;br /&gt;
  qemux86 login: test&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  Login incorrect&lt;br /&gt;
  qemux86 login: &lt;br /&gt;
&lt;br /&gt;
syslog info&lt;br /&gt;
  Jul 17 08:08:07 qemux86 authpriv.info login[2366]: pam_unix(login:session): session opened for user test by root(uid=0)&lt;br /&gt;
  Jul 17 08:08:08 qemux86 authpriv.info login[2366]: pam_unix(login:session): session closed for user test&lt;br /&gt;
  Jul 17 08:08:51 qemux86 authpriv.notice login[2371]: FAILED LOGIN (1) on &#039;/dev/pts/1&#039; FOR &#039;test&#039;, Authentication failure&lt;br /&gt;
&lt;br /&gt;
* pam_env&lt;br /&gt;
refer to su tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-auth&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_group&lt;br /&gt;
pam_group grants group memberships to the user. Its configure file is /etc/security/group.conf.&lt;br /&gt;
&lt;br /&gt;
First get your current tty by run&lt;br /&gt;
  root@qemux86:/etc/pam.d# tty&lt;br /&gt;
  /dev/pts/2&lt;br /&gt;
  root@qemux86:/etc/pam.d# &lt;br /&gt;
&lt;br /&gt;
then add a item to /etc/security/group.conf&lt;br /&gt;
  login; pts/* ;%root;Al0000-2400;&#039;&#039;&#039;plugdev,test &lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
after that run commands&lt;br /&gt;
  root@qemux86:/etc/pam.d# id&lt;br /&gt;
  uid=0(root) gid=0(root) groups=0(root)&lt;br /&gt;
  root@qemux86:/etc/pam.d# login&lt;br /&gt;
  qemux86 login: root&lt;br /&gt;
  &lt;br /&gt;
  Password: &lt;br /&gt;
  Last login: Mon Jul 18 00:20:47 UTC 2011 on pts/2&lt;br /&gt;
  root@qemux86:~# id&lt;br /&gt;
  uid=0(root) gid=0(root) groups=0(root),&#039;&#039;&#039;46(plugdev),1001(test)&#039;&#039;&#039;&lt;br /&gt;
  root@qemux86:~#&lt;br /&gt;
&lt;br /&gt;
* pam_limits&lt;br /&gt;
pam_limits sets limits on the system resources that can be obtained in a user-session. &lt;br /&gt;
&lt;br /&gt;
Its default configure file is /etc/security/limits.conf, modify it with&lt;br /&gt;
  test        -       maxlogins       1&lt;br /&gt;
&lt;br /&gt;
Login unprivileged user &amp;quot;test&amp;quot;&lt;br /&gt;
  root@qemux86:/etc/pam.d# login&lt;br /&gt;
  qemux86 login: &#039;&#039;&#039;test&#039;&#039;&#039;&lt;br /&gt;
  Last login: Sun Jul 17 08:08:07 UTC 2011 on pts/1&lt;br /&gt;
  qemux86:~$  &lt;br /&gt;
And login in another terminal&lt;br /&gt;
  root@qemux86:~# login&lt;br /&gt;
  qemux86 login: test&lt;br /&gt;
  Too many logins for &#039;test&#039;.&lt;br /&gt;
  Last login: Mon Jul 18 01:21:54 UTC 2011 on pts/2&lt;br /&gt;
  &lt;br /&gt;
  Permission denied&lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 18 01:39:55 qemux86 authpriv.debug login[2668]: pam_limits(login:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul 18 01:39:55 qemux86 authpriv.debug login[2668]: pam_limits(login:session): process_limit: processing - maxlogins 1 for USER&lt;br /&gt;
  Jul 18 01:39:55 qemux86 authpriv.debug login[2668]: pam_limits(login:session): checking logins for &#039;test&#039; (maximum of 1)&lt;br /&gt;
  Jul 18 01:39:55 qemux86 authpriv.warn login[2668]: pam_limits(login:session): Too many logins (max 1) for test&lt;br /&gt;
  Jul 18 01:39:55 qemux86 authpriv.info login[2668]: pam_unix(login:session): session opened for user test by root(uid=0)&lt;br /&gt;
  Jul 18 01:39:55 qemux86 authpriv.err login[2668]: Permission denied&lt;br /&gt;
&lt;br /&gt;
* pam_lastlog&lt;br /&gt;
pam_lastlog is to display date of last login.&lt;br /&gt;
add options to pam_lastlog&lt;br /&gt;
  session    optional   pam_lastlog.so debug nodate&lt;br /&gt;
&lt;br /&gt;
run commands and you can check that no last login date information shows&lt;br /&gt;
  root@qemux86:~# login&lt;br /&gt;
  qemux86 login: test&lt;br /&gt;
  Last login: on pts/2&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
* pam_motd&lt;br /&gt;
pam_motd can be used to display arbitrary motd (message of the day) files after a successful login. By default the /etc/motd file is shown.&lt;br /&gt;
&lt;br /&gt;
test steps:&lt;br /&gt;
  root@qemux86:~# cat /etc/motd&lt;br /&gt;
  root@qemux86:~# echo &amp;quot;Welcome to Yocto&amp;quot; &amp;gt; /etc/motd&lt;br /&gt;
  root@qemux86:~# login&lt;br /&gt;
  qemux86 login: root&lt;br /&gt;
  Password: &lt;br /&gt;
  Last login: on pts/1&lt;br /&gt;
  &#039;&#039;&#039;Welcome to Yocto&#039;&#039;&#039;&lt;br /&gt;
  root@qemux86:~#&lt;br /&gt;
&lt;br /&gt;
* pam_mail&lt;br /&gt;
refer to su tests&lt;br /&gt;
&lt;br /&gt;
==== newusers ====&lt;br /&gt;
/etc/pam.d/newusers&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
&lt;br /&gt;
*pam_unix&lt;br /&gt;
modify the pam_unix item in common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so debug &lt;br /&gt;
&lt;br /&gt;
run command:&lt;br /&gt;
  root@qemux86:~# newusers&lt;br /&gt;
  a::::::&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  newusers: (user a) pam_chauthtok() failed, error:&lt;br /&gt;
  Authentication token manipulation error&lt;br /&gt;
  newusers: (line 1, user a) password not changed&lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): username [a] obtained&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): username [a] obtained&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.notice newusers[1560]: pam_unix(newusers:chauthtok): new password not acceptable&lt;br /&gt;
&lt;br /&gt;
==== passwd ====&lt;br /&gt;
/etc/pam.d/passwd&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password&lt;br /&gt;
modify the item to make password length not less than 4 characters:&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so minlen=4 debug&lt;br /&gt;
&lt;br /&gt;
run test commands:&lt;br /&gt;
  qemux86:~$ passwd&lt;br /&gt;
  Changing password for test.&lt;br /&gt;
  (current) UNIX password: &amp;lt;-- input 123 here&lt;br /&gt;
  Enter new UNIX password: &lt;br /&gt;
  Retype new UNIX password: &lt;br /&gt;
  You must choose a longer password&lt;br /&gt;
  Enter new UNIX password: &amp;lt;-- input 1234 here&lt;br /&gt;
  Retype new UNIX password: &lt;br /&gt;
  passwd: password updated successfully&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
syslog doesn&#039;t has detail informatiaon&lt;br /&gt;
  Jul 17 02:00:39 qemux86 authpriv.debug passwd[1649]: pam_unix(passwd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 17 02:00:41 qemux86 authpriv.debug passwd[1649]: pam_unix(passwd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 17 02:00:49 qemux86 authpriv.notice passwd[1649]: pam_unix(passwd:chauthtok): password changed for test&lt;br /&gt;
&lt;br /&gt;
==== su ====&lt;br /&gt;
/etc/pam.d/su&lt;br /&gt;
  auth       sufficient pam_rootok.so&lt;br /&gt;
  session       required   pam_env.so readenv=1&lt;br /&gt;
  session       required   pam_env.so readenv=1 envfile=/etc/default/locale&lt;br /&gt;
  session    optional   pam_mail.so nopen&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-account&lt;br /&gt;
  session    include      common-session&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_env&lt;br /&gt;
option readenv=1 means read configure file pointed by variable envfile, default is /etc/environment&lt;br /&gt;
&lt;br /&gt;
We will add a variable named YOCTO to /etc/environment.&lt;br /&gt;
First we will check there is no var YOCTO after su&lt;br /&gt;
  root@qemux86:~# su test&lt;br /&gt;
  test@qemux86:/home/root$ echo $YOCTO&lt;br /&gt;
&lt;br /&gt;
  test@qemux86:/home/root$ &lt;br /&gt;
&lt;br /&gt;
after add YOCTO=yoctolinux to /etc/environment, then test again&lt;br /&gt;
  root@qemux86:~# su test&lt;br /&gt;
  test@qemux86:/home/root$ echo $YOCTO&lt;br /&gt;
  yoctolinux&lt;br /&gt;
  test@qemux86:/home/root$ &lt;br /&gt;
&lt;br /&gt;
* pam_mail&lt;br /&gt;
The mailx in Yocto can NOT run correctly, so didn&#039;t test it. &lt;br /&gt;
Test steps should be as follows. &lt;br /&gt;
First remove option nopen which prevents show user mails&lt;br /&gt;
  #session    optional   pam_mail.so nopen&lt;br /&gt;
  session    optional   pam_mail.so &lt;br /&gt;
&lt;br /&gt;
Then mail a user, such as root(run test on Fedora 14)&lt;br /&gt;
  [packager@F14 ~]$ mail root&lt;br /&gt;
  Subject: &#039;&#039;test&#039;&#039;&lt;br /&gt;
  &#039;&#039;test&#039;&#039;&lt;br /&gt;
  EOT&lt;br /&gt;
  [packager@F14 ~]$ export LANG=C&lt;br /&gt;
  [packager@F14 ~]$ su -&lt;br /&gt;
  Password: &lt;br /&gt;
  &#039;&#039;&#039;You have old mail in folder /var/mail/root.&#039;&#039;&#039;&lt;br /&gt;
  [root@F14 ~]#&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-auth&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-account/common-session has no test point&lt;br /&gt;
&lt;br /&gt;
==== useradd ====&lt;br /&gt;
/etc/pam.d/useradd(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password:&lt;br /&gt;
no test point&lt;br /&gt;
&lt;br /&gt;
==== userdel ====&lt;br /&gt;
/etc/pam.d/userdel(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password: &lt;br /&gt;
no test point&lt;br /&gt;
&lt;br /&gt;
==== usermod ==== &lt;br /&gt;
/etc/pam.d/usermod(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password&lt;br /&gt;
no test point&lt;br /&gt;
&lt;br /&gt;
=== sudo ===&lt;br /&gt;
*/etc/pam.d/sudo comes from Fedora, and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-account&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
  session    required     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
and content of common-auth has been show above.&lt;br /&gt;
&lt;br /&gt;
*test pam plugins&lt;br /&gt;
**pam_unix.so&lt;br /&gt;
modify common-auth:&lt;br /&gt;
  auth    [success=1 default=ignore]      pam_unix.so debug&lt;br /&gt;
then unpriviledge user can NOT run sudo with blank password&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 16:39:04 qemux86 sudo: pam_unix(sudo:auth): authentication failure; logname=test-pam uid=0 euid=0 tty=/dev/pts/1 ruser=test-pam rhost=  user=test-pam&lt;br /&gt;
  Jul  8 16:39:14 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
**pam_deny.so&lt;br /&gt;
mv line&lt;br /&gt;
  auth    requisite                       pam_deny.so&lt;br /&gt;
to the head of file, unprivilege user can NOT sudo any more:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 14:03:29 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
**pam_permit.so&lt;br /&gt;
comment this line&lt;br /&gt;
  auth    required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
sudo will fail without ask user to enter password:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 12:43:22 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm -f /test&lt;br /&gt;
&lt;br /&gt;
**pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf&lt;br /&gt;
  *        -       nofile       3&lt;br /&gt;
then sudo will fail:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Inconsistency detected by ld.so: dl-deps.c: 622: _dl_map_object_deps: Assertion `nlist &amp;gt; 1&#039; failed!&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
  *        -       nofile       4&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 3 for DEFAULT&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 4 for DEFAULT&lt;br /&gt;
&lt;br /&gt;
** pam_keyinit&lt;br /&gt;
add option debug&lt;br /&gt;
  session    optional     pam_keyinit.so revoke debug&lt;br /&gt;
&lt;br /&gt;
log shows pam_keyinit was called:&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): OPEN 1&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): UID:0 [0]  GID:0 [1000]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 143761918&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 669161571&lt;br /&gt;
&lt;br /&gt;
according the source code pam_keyinit.c line 102 in function init_keyrings, the module return PAM_SUCCESS&lt;br /&gt;
&lt;br /&gt;
== Identify upstream PAM patches to use ==&lt;br /&gt;
After checking the Fedora develop repository, the following packages may need patches(only libpam need to upgrade, other patches are pam related configure file but they are absent in poky):&lt;br /&gt;
* libpam: need update from current 1.1.3 to 1.1.4 [https://www.redhat.com/archives/pam-list/2011-June/msg00013.html Release Notes]&lt;br /&gt;
* sudo: package sudo in Fedora provides /etc/pam.d/sudo and /etc/pam.d/sudo-i&lt;br /&gt;
** /etc/pam.d/sudo (Yocto use common-auth instead of system-auth)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      system-auth&lt;br /&gt;
  account    include      system-auth&lt;br /&gt;
  password   include      system-auth&lt;br /&gt;
  session    optional     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
&lt;br /&gt;
* screen: check Fedora screen.pam&lt;br /&gt;
&lt;br /&gt;
* util-linux: check Fedora source file util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* at: check Fedora util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* cups: check Fedora cups-1.1.16-system-auth.patch&lt;br /&gt;
&lt;br /&gt;
* openssh: check Fedora sshd.pam&lt;br /&gt;
&lt;br /&gt;
== PAM Unit Tests==&lt;br /&gt;
We use unit test cases provided by libpam itself, a subdirectory with name &amp;quot;xtests&amp;quot; under libpam source code. Right now we spit it as a sub-package libpam-xtests.&lt;br /&gt;
&lt;br /&gt;
All test cases are:&lt;br /&gt;
    tst-pam_dispatch1 tst-pam_dispatch2 tst-pam_dispatch3 \&lt;br /&gt;
    tst-pam_dispatch4 tst-pam_dispatch5 \&lt;br /&gt;
    tst-pam_cracklib1 tst-pam_cracklib2 \&lt;br /&gt;
    tst-pam_unix1 tst-pam_unix2 tst-pam_unix3 tst-pam_unix4 \&lt;br /&gt;
    tst-pam_access1 tst-pam_access2 tst-pam_access3 \&lt;br /&gt;
    tst-pam_access4 tst-pam_limits1 tst-pam_succeed_if1 \&lt;br /&gt;
    tst-pam_group1 tst-pam_authfail tst-pam_authsucceed \&lt;br /&gt;
    tst-pam_pwhistory1 tst-pam_time1&lt;br /&gt;
&lt;br /&gt;
On build machine after install package libpam-xtests, go to the xtexts directory and run tests&lt;br /&gt;
  cd /usr/share/Linux-PAM/xtests&lt;br /&gt;
  ./run-xtests.sh `pwd` ALL_TESTS # replace All_TESTS with the tests listed above&lt;br /&gt;
&lt;br /&gt;
If you want to run sigle test case, just run (take tst-pam_time1 for example)&lt;br /&gt;
  ./run-xtests.sh . tst-pam_time1&lt;br /&gt;
&lt;br /&gt;
Two unit tests may NOT passed, they need some prerequisite:&lt;br /&gt;
* tst-pam_cracklib1&lt;br /&gt;
* tst-pam_cracklib2&lt;br /&gt;
**need /lib/security/pam_cracklib.so, need build cracklib first, and then libpam will check it and create pam-plugin-cracklib&lt;br /&gt;
**need /usr/share/cracklib/pw_dict.pwd file, please run command on host machine:&lt;br /&gt;
  cp /usr/share/cracklib/cracklib-small /tmp&lt;br /&gt;
  gzip /tmp/cracklib-small&lt;br /&gt;
  create-cracklib-dict /tmp/cracklib-small.gz&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
=== image to run tests ===&lt;br /&gt;
We test the packages both on core-image-sato and core-image-lsb&lt;br /&gt;
* on sato, edit the /etc/syslog.conf, set&lt;br /&gt;
  DESTINATION=&amp;quot;file&amp;quot;     &lt;br /&gt;
then you can check the log via /var/log/message&lt;br /&gt;
* on lsb, the log information are send to /var/log/auth.log&lt;br /&gt;
&lt;br /&gt;
=== Packages dropped ===&lt;br /&gt;
At the beginning we got a list of packages that use pam. After more work, some of them are dropped.&lt;br /&gt;
* consolekit provides a pam plugin module pam_ck_connector.so and not the package that use pam. Drop it.&lt;br /&gt;
* gnome-keyring can&#039;t call configuration file like &amp;quot;/etc/pam.d/gnome-keyring&amp;quot; because it is called by other program like &amp;quot;gnome-screensave&amp;quot; and &amp;quot;gdm&amp;quot;. If we want test &amp;quot;pam_gnome_keyring.so&amp;quot;, we need write .bb files to cross-compile gnome-screensave or gdm. So drop it.&lt;br /&gt;
* util-linux: 3 programs chfn chsh and login in util-linux will use libpam. Right now these programs are provided by package shadow. In util-linux.inc, EXTRA_OECONF has option &amp;quot;--disable-login-utils &amp;quot; which will disable to build them. Drop it.&lt;br /&gt;
* mc: mc has remove package mcserv and dropped dependency on PAM already, but didn&#039;t remove checking security/pam_misc.h. Drop it. [http://www.midnight-commander.org/changeset/4816107a02ccbf6331534113e6ec0c8df84e24eb Official change log]&lt;br /&gt;
* libcap: if pam exists, libcap will create a pam plugin pam_cap.so to add a new front end for the authentication function. Because it is not a application, remove it from list.&lt;br /&gt;
* libuser: pam is libuser&#039;s build dependency, so remove it too.&lt;br /&gt;
* The busybox login has a option to use pam, but we use tinylogin&#039;s login right now (tinylogin also provides the su command)&lt;br /&gt;
* gettext only has a example &amp;quot;hello-c++-kde&amp;quot; use pam under source code directory, and it doen&#039;t be compiled and only copied to destination. So omit gettext.&lt;br /&gt;
* sysvinit has a patch contrib/notify-pam-dead.patch for /sbin/init to use pam, but the whole contrib directory didn&#039;t take part in compilation. Drop it.&lt;br /&gt;
* xserver: based on following 2 reason drop it.&lt;br /&gt;
** the code use pam is old. Add xserver to original list to be pam-enabled by &amp;quot;bzgrep&amp;quot;  tar balls. But in xserver the code to use pam only in os/utils.c function CheckUserAuthorization. No configure mechanism is provided to define macro USE_PAM to make the pam codes enabled. According to the comments, pam authentication only done for setuid servers (uid != euid). Our Xorg is not a setuid server, so we don&#039;t need it .&lt;br /&gt;
** Xorg in Fedora doesn&#039;t support pam. Once I check the xorg-x11-server.spec, and it installs a pam related configure file, so I thought it is pam enabled. But I check the executable file /usr/bin/Xorg , that /usr/bin/Xorg even doesn&#039;t link to libpam or libpam_misc. The config file &amp;quot;xserver&amp;quot; is also from Fedora 15,  because it is not supported by Fedora itself we don&#039;t have any reason to support the configure file in oe.&lt;br /&gt;
&lt;br /&gt;
=== Common configure files ===&lt;br /&gt;
When import pam related configure file for each package from Fedora, it may contains &amp;quot;include system-auth&amp;quot;. System-auth is the Fedora common configure file and it is autogenerated by command authconfig. It contain all 4 types(auth, account, session, password) rules. But in Yocto these common rules are seperated according pam type, and they are common-auth, common-account, common-session and common-password.&lt;br /&gt;
&lt;br /&gt;
So if configure files from Fedora contains system-auth, we use the seperated common configure files instead.&lt;/div&gt;</summary>
		<author><name>Wfan</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2804</id>
		<title>PAM Integration</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2804"/>
		<updated>2011-07-14T07:26:47Z</updated>

		<summary type="html">&lt;p&gt;Wfan: /* cronie */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Motivation ==&lt;br /&gt;
For Yocto 1.1 we are working to ensure that PAM (Pluggable Authentication Module) support is consistent and enabled in recipes where it is applicable. &lt;br /&gt;
&lt;br /&gt;
== Common configure files ==&lt;br /&gt;
For convenience, list common configure files here:&lt;br /&gt;
&lt;br /&gt;
common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
  auth	requisite			pam_deny.so&lt;br /&gt;
  auth	required			pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-account&lt;br /&gt;
  account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so &lt;br /&gt;
  account requisite                       pam_deny.so&lt;br /&gt;
  account required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so obscure sha512&lt;br /&gt;
  password        requisite                       pam_deny.so&lt;br /&gt;
  password        required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-session&lt;br /&gt;
  session [default=1]                     pam_permit.so&lt;br /&gt;
  session requisite                       pam_deny.so&lt;br /&gt;
  session required                        pam_permit.so&lt;br /&gt;
  session required        pam_unix.so &lt;br /&gt;
&lt;br /&gt;
common-session-noninteractive&lt;br /&gt;
  session [default=1]                     pam_permit.so&lt;br /&gt;
  session requisite                       pam_deny.so&lt;br /&gt;
  session required                        pam_permit.so&lt;br /&gt;
  session required        pam_unix.so &lt;br /&gt;
&lt;br /&gt;
== Recipes with PAM support ==&lt;br /&gt;
The following recipes were identified to have PAM support (some already implemented) on 2011-06-27:&lt;br /&gt;
&lt;br /&gt;
=== at === &lt;br /&gt;
* Open issue:&lt;br /&gt;
** It can&#039;t be ran by a non-root user, error message is:&lt;br /&gt;
 Can&#039;t signal atd (permission denied)&lt;br /&gt;
&lt;br /&gt;
* Simple ways to verify &#039;at&#039;:&lt;br /&gt;
 $ at now&lt;br /&gt;
 $ echo &amp;quot;$msg_to_print&amp;quot; &amp;gt;&amp;gt; /tmp/at_test&lt;br /&gt;
 $ &amp;lt; ctrl+D &amp;gt;&lt;br /&gt;
 $ cat /tmp/at_test    # Verify if the message has been there &lt;br /&gt;
&lt;br /&gt;
* /etc/pam.d/atd - not installed by default, copy it from source code and replace &#039;@include&#039; with appropriate &#039;module-type include&#039;:&lt;br /&gt;
&lt;br /&gt;
 auth       required    pam_env.so&lt;br /&gt;
 auth       include     common-auth&lt;br /&gt;
 account    include     common-account&lt;br /&gt;
 session    include     common-session-noninteractive&lt;br /&gt;
 session    required    pam_limits.so&lt;br /&gt;
&lt;br /&gt;
* test pam plugins&lt;br /&gt;
** pam_env.so&lt;br /&gt;
modify /etc/pam.d/atd&lt;br /&gt;
 auth       required    pam_env.so    debug&lt;br /&gt;
modify /etc/security/pam_env.conf, add a test entry such as:&lt;br /&gt;
 MYNAME          DEFAULT=&amp;quot;test-at&amp;quot;&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:41:22 qemux86 atd[678]: pam_env(atd:setcred): pam_putenv(&amp;quot;MYNAME=test-at&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
** pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf &lt;br /&gt;
 root    -       nofile  3&lt;br /&gt;
&#039;at&#039; job failed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:49:42 qemux86 atd[699]: pam_env(atd:setcred): Unable to open config file: /etc/security/pam_env.conf: Too many open files&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
 root    -       nofile  4&lt;br /&gt;
&#039;at&#039; job successed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session opened for user root by (uid=0)                      &lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session closed for user root&lt;br /&gt;
&lt;br /&gt;
=== consolekit ===&lt;br /&gt;
Consolekit provides a pam plugin module pam_ck_connector.so and not the package that use pam.&lt;br /&gt;
Drop it.&lt;br /&gt;
&lt;br /&gt;
=== cronie ===&lt;br /&gt;
* /etc/pam.d/crond:&lt;br /&gt;
 account    required   pam_access.so&lt;br /&gt;
 account    include    common-password&lt;br /&gt;
 session    required   pam_loginuid.so&lt;br /&gt;
 session    include    common-session-noninteractive&lt;br /&gt;
 auth       include    common-auth&lt;br /&gt;
&lt;br /&gt;
* test commands:&lt;br /&gt;
 crontab -e    # establish a crontab jobs and check if it works&lt;br /&gt;
 crontab -l    # list crontab jobs for current user&lt;br /&gt;
&lt;br /&gt;
* test pam plugins&lt;br /&gt;
Verified, test ways and the logs/results please refer to other packages:&lt;br /&gt;
** pam_env.so&lt;br /&gt;
** pam_access.so&lt;br /&gt;
** pam_unix.so&lt;br /&gt;
** pam_permit.so&lt;br /&gt;
** pam_deny.so&lt;br /&gt;
&lt;br /&gt;
** pam_loginuid.so&lt;br /&gt;
 TBD&lt;br /&gt;
&lt;br /&gt;
=== cups ===&lt;br /&gt;
* /etc/pam.d/cups&lt;br /&gt;
 auth	    required	pam_unix.so shadow nodelay&lt;br /&gt;
 account    required	pam_unix.so&lt;br /&gt;
&lt;br /&gt;
* Modify /etc/cups/cupsd.conf:&lt;br /&gt;
 ...&lt;br /&gt;
 - Listen localhost:631&lt;br /&gt;
 + Port 631&lt;br /&gt;
 ...&lt;br /&gt;
 # Restrict access to the server...                               &lt;br /&gt;
 &amp;lt;Location /&amp;gt;                                                     &lt;br /&gt;
   Order allow,deny                                               &lt;br /&gt;
 + allow all                                                      &lt;br /&gt;
 &amp;lt;/Location&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
 # Restrict access to the admin pages...                          &lt;br /&gt;
 &amp;lt;Location /admin&amp;gt;                                                &lt;br /&gt;
   Order allow,deny                                               &lt;br /&gt;
 + allow all                                                      &lt;br /&gt;
 &amp;lt;/Location&amp;gt; &lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
* Test pam plugins&lt;br /&gt;
** pam_unix.so&lt;br /&gt;
Add debug option to &#039;/etc/pam/cups&#039;:&lt;br /&gt;
 auth	    required	pam_unix.so shadow nodelay debug&lt;br /&gt;
 account    required	pam_unix.so debug&lt;br /&gt;
&lt;br /&gt;
Access the cups configure page via web browser:&lt;br /&gt;
 http://&amp;lt;qemu.ip&amp;gt;:631&lt;br /&gt;
Click &#039;Administration&#039; -&amp;gt; &#039;Add Printer&#039;, start the pop-window for user authentication, input correct user and password:&lt;br /&gt;
 user: root&lt;br /&gt;
 pwd: &amp;lt;correct password&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Entry the &#039;Add Printer&#039; configure page successed.&lt;br /&gt;
&lt;br /&gt;
Input error password:&lt;br /&gt;
 user: root&lt;br /&gt;
 pwd: &amp;lt;error password&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check log in &#039;/var/log/cups/error_log&#039;:&lt;br /&gt;
 E [14/Jul/2011:02:41:26 +0800] cupsdAuthorize: pam_authenticate() returned 7 (Authentication failure)!&lt;br /&gt;
&lt;br /&gt;
Modify &#039;/etc/shadow&#039;:&lt;br /&gt;
 -root:$6$yMXdsttU$kT7A.n9bP0w0zzX6Uj1wmypHcq0lSGaC5/4xgNTZRSjNvW0q85ryBz8C6WNCbr22c6RjRKaVhv23ogrmoAo9m.:15168:0:99999:7:::&lt;br /&gt;
 +root:$6$yMXdsttU$kT7A.n9bP0w0zzX6Uj1wmypHcq0lSGaC5/4xgNTZRSjNvW0q85ryBz8C6WNCbr22c6RjRKaVhv23ogrmoAo9m.:15168:0:99999:7::1:&lt;br /&gt;
&lt;br /&gt;
Repeat the user authentication steps, check log in &#039;/var/log/cups/error_log&#039;:&lt;br /&gt;
 E [14/Jul/2011:03:05:00 +0800] cupsdAuthorize: pam_acct_mgmt() returned 13 (User account has expired)!&lt;br /&gt;
&lt;br /&gt;
=== dropbear ===&lt;br /&gt;
** For supporting pam in dropbear, we need two steps:&lt;br /&gt;
** Add configuration &amp;quot;--enable-pam&amp;quot; &lt;br /&gt;
** Add patches to open macro definition for supporting in option.h&lt;br /&gt;
 --- a/ptions.h  2011-07-12 11:32:34.165333202 +0800&lt;br /&gt;
 +++ b/options.h.new     2011-07-12 11:33:25.757332986 +0800&lt;br /&gt;
 @@ -149,9 +149,9 @@&lt;br /&gt;
   * but there&#039;s an interface via a PAM module - don&#039;t bother using it otherwise.&lt;br /&gt;
   * You can&#039;t enable both PASSWORD and PAM. */&lt;br /&gt;
 -#define ENABLE_SVR_PASSWORD_AUTH&lt;br /&gt;
 +//#define ENABLE_SVR_PASSWORD_AUTH&lt;br /&gt;
  /* PAM requires ./configure --enable-pam */&lt;br /&gt;
 -/*#define ENABLE_SVR_PAM_AUTH*/&lt;br /&gt;
 +#define ENABLE_SVR_PAM_AUTH&lt;br /&gt;
  #define ENABLE_SVR_PUBKEY_AUTH&lt;br /&gt;
  /* Wether to ake public key options in authorized_keys file into account */&lt;br /&gt;
&lt;br /&gt;
** Test result(dropbeat only support simple authentication, account and auth)&lt;br /&gt;
*** &#039;&#039;&#039;Server(account)&#039;&#039;&#039;&lt;br /&gt;
 (server ip:192.168.7.2)&lt;br /&gt;
 $touch /etc/pam.d/sshd&lt;br /&gt;
 #%PAM-1.0&lt;br /&gt;
 account  required     pam_access.so&lt;br /&gt;
 $vi /etc/security/access.conf&lt;br /&gt;
 - : root : ALL&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow access)&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 14 07:01:48 qemux86 dropbear[407]: pam_access(sshd:account): access denied for user `root&#039; from `ssh&#039;&lt;br /&gt;
 Jul 14 07:01:48 qemux86 dropbear[407]: pam_acct_mgmt() failed, rc=6, Permission denied &lt;br /&gt;
 Jul 14 07:01:48 qemux86 dropbear[407]: bad PAM password attempt for &#039;root&#039; from 192.168.7.1:33633&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;Server(auth)&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/sshd&lt;br /&gt;
  auth include common-auth&lt;br /&gt;
 $vi /etc/pam.d/common-auth&lt;br /&gt;
 #auth   [success=1 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
 auth    [success=0 default=ignore]      pam_unix.so debug&lt;br /&gt;
 $ passwd -d username &amp;lt;blank password&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow access)&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 14 07:06:42 qemux86 dropbear[421]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=  user=yxf&lt;br /&gt;
 Jul 14 07:06:44 qemux86 dropbear[421]: pam_authenticate() failed, rc=7, Authentication failure &lt;br /&gt;
 Jul 14 07:06:44 qemux86 dropbear[421]: bad PAM password attempt for &#039;yxf&#039; from 192.168.7.1:379&lt;br /&gt;
&lt;br /&gt;
=== gnome-keyring ===&lt;br /&gt;
* gnome-keyring can&#039;t call configuration file like &amp;quot;/etc/pam.d/gnome-keyring&amp;quot; because it is called by other program like &amp;quot;gnome-screensave&amp;quot; and &amp;quot;gdm&amp;quot;. If we want test &amp;quot;pam_gnome_keyring.so&amp;quot;, we need write .bb files to cross-compile gnome-screensave or gdm.&lt;br /&gt;
&lt;br /&gt;
=== openssh ===&lt;br /&gt;
** Absent configuration /etc/pam.d/sshd, we need to add patches. After adding this file, it can support pam function through simple test.&lt;br /&gt;
** Test Result&lt;br /&gt;
*** &#039;&#039;&#039;Configuration of sshd&#039;&#039;&#039;&lt;br /&gt;
 auth       include      common-auth&lt;br /&gt;
 account    required     pam_nologin.so&lt;br /&gt;
 account    include      common-account&lt;br /&gt;
 password   include      common-password&lt;br /&gt;
 session    optional     pam_keyinit.so force revoke&lt;br /&gt;
 session    include      common-session&lt;br /&gt;
 session    required     pam_loginuid.so&lt;br /&gt;
*** &#039;&#039;&#039;auth include common-auth --Server&#039;&#039;&#039;&lt;br /&gt;
 $echo &#039;UsePAM no&#039; &amp;gt;&amp;gt;/etc/ssh/sshd_config&lt;br /&gt;
 $vi /etc/ssh/sshd_config&lt;br /&gt;
  PermitEmptyPasswords yes &lt;br /&gt;
&lt;br /&gt;
 Other is as same as sudo&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 12 11:16:21 qemux86 sshd[650]: pam_unix(sshd:session): session opened for user test by (uid=0)&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
*** &#039;&#039;&#039;account required pam_nologin.so --Server&#039;&#039;&#039;&lt;br /&gt;
 $touch /etc/nologin&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow accession)&lt;br /&gt;
*** &#039;&#039;&#039;log information --Server&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 01:43:48 qemux86 sshd[672]: Accepted keyboard-interactive/pam for yxf from 192.168.7.1 port 59877 ssh2&lt;br /&gt;
 Jul 13 01:43:48 qemux86 sshd[672]: fatal: PAM: pam_setcred(): Failure setting user credentia&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;account include common-account --Server&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/ssh/sshd_config&lt;br /&gt;
  PermitEmptyPasswords no&lt;br /&gt;
 $vi /etc/pam.d/common-account &lt;br /&gt;
  #account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
  account [success=0 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow accession)&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 02:11:24 qemux86 sshd[752]: Failed password for root from 192.168.7.1 port 53784 ssh2&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;password include common-password&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so obscure sha512 &lt;br /&gt;
&lt;br /&gt;
 It&#039;s no use for sshd, So no test result for this item&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;session optional  pam_keyinit.so force revoke --Server&#039;&#039;&#039;&lt;br /&gt;
 No action&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 07:28:18 qemux86 sshd[1132]: pam_keyinit(sshd:session): OPEN 1&lt;br /&gt;
 Jul 13 07:28:18 qemux86 sshd[1132]: pam_keyinit(sshd:session): UID:1000 [0]  GID:1000 [0]&lt;br /&gt;
 Jul 13 07:28:18 qemux86 sshd[1132]: pam_keyinit(sshd:session): JOIN = 236576375&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;( the same session as the above &amp;quot;client&amp;quot;   )&lt;br /&gt;
 $exit&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 07:34:47 qemux86 sshd[1132]: pam_keyinit(sshd:session): CLOSE 1,236576375,1&lt;br /&gt;
 Jul 13 07:34:47 qemux86 sshd[1132]: pam_keyinit(sshd:session): REVOKE 236576375&lt;br /&gt;
 Jul 13 07:34:47 qemux86 sshd[1132]: pam_keyinit(sshd:session): UID:1000 [0]  GID:1000 [0]&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;session include common-session --Server&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/common-session&lt;br /&gt;
  #session [default=1] pam_permit.so&lt;br /&gt;
  session [default=0] pam_permit.so&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow accession)&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 05:53:35 qemux86 sshd[960]: error: PAM: pam_open_session(): Permission denied&lt;br /&gt;
 Jul 13 05:53:35 qemux86 sshd[960]: Received disconnect from 192.168.7.1: 11: disconnected by user&lt;br /&gt;
*** &#039;&#039;&#039; session required  pam_loginuid.so --Server&#039;&#039;&#039;(Record user´s login uid to the process attribute)&lt;br /&gt;
 No action&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 06:31:32 qemux86 sshd[1028]: pam_warn(sshd:session): function=[pam_sm_open_session] service=[sshd] terminal=[ssh] user=[yxf] ruser= [&amp;lt;unknown&amp;gt;] rhost=[ubuntuwindriver.local] &lt;br /&gt;
 Jul 13 06:31:32 qemux86 sshd[1028]: pam_unix(sshd:session): session opened for user yxf by (uid=0)&lt;br /&gt;
&lt;br /&gt;
=== polkit ===&lt;br /&gt;
Polkit includes four binaries. Only pkexec depends on pam. So I use pkexec to make pam test.&lt;br /&gt;
Pkexec allows an authorized user to execute PROGRAM as another user. If username is not specified, then the program will be executed as the administrative super user, root.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Pam configuration file of polkit &#039;&#039;&#039;&lt;br /&gt;
 %PAM-1.0&lt;br /&gt;
 auth       include      common-auth&lt;br /&gt;
 account    include      common-account&lt;br /&gt;
 password   include      common-password&lt;br /&gt;
 session    include      common-session&lt;br /&gt;
* &#039;&#039;&#039;Test Reult&#039;&#039;&#039;&lt;br /&gt;
*** &#039;&#039;&#039;Normally pkexec can call pam modules from the above configuration file&#039;&#039;&#039;&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
  ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
  Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
  Authenticating as: root&lt;br /&gt;
  Password: &amp;lt;---Input root password and press key &amp;quot;Enter&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 Jul 14 22:13:18 emenlow polkitd(authority=local): Registered Authentication Agent for unix-process:2466:778527 (system bus name :1.10 [pkexec  cat /var/log/auth.log], &lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)&lt;br /&gt;
 Jul 14 22:13:18 emenlow polkit-agent-helper-1[2501]: PAM pam_parse: expecting non-zero; [... default=ignore]&lt;br /&gt;
 Jul 14 22:13:18 emenlow polkit-agent-helper-1[2501]: PAM pam_parse: expecting non-zero; [... default=ignore]&lt;br /&gt;
 Jul 14 22:13:21 emenlow polkitd(authority=local): Unregistered Authentication Agent for unix-process:2466:778527 (system bus name :1.10,&lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)&lt;br /&gt;
 Jul 14 22:13:21 emenlow polkitd(authority=local): Operator of unix-process:2466:778527 FAILED to authenticate to gain authorization for action&lt;br /&gt;
 org.freedesktop.policykit.exec for unix-process:2466:778527 [sh] (owned by unix-user:yxf)&lt;br /&gt;
 Jul 14 22:14:37 emenlow polkitd(authority=local): Registered Authentication Agent for unix-process:2466:778527 (system bus name :1.11 [pkexec &lt;br /&gt;
 cat /var/log/auth.log], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)&lt;br /&gt;
 Jul 14 22:16:08 emenlow polkitd(authority=local): Operator of unix-process:2466:778527 successfully authenticated as unix-user:root to gain &lt;br /&gt;
 ONE-SHOT authorization for action org.freedesktop.policykit.exec for unix-process:2466:778527 [sh] (owned by unix-user:yxf)&lt;br /&gt;
 Jul 14 22:16:08 emenlow pkexec: pam_unix(polkit-1:session): session opened for user root by root(uid=500)&lt;br /&gt;
 Jul 14 22:16:08 emenlow pkexec[2507]: yxf: Executing command [USER=root] [TTY=/dev/pts/0] [CWD=/] [COMMAND=/bin/cat /var/log/auth.log]&lt;br /&gt;
 Jul 14 22:16:08 emenlow polkitd(authority=local): Unregistered Authentication Agent for unix-process:2466:778527 (system bus name :1.11, &lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)&lt;br /&gt;
*** &#039;&#039;&#039;auth include common-auth&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/common-auth&lt;br /&gt;
  #auth    [success=1 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
  auth    [success=0 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
 ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
 Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
 Authenticating as: root&lt;br /&gt;
 Password: &lt;br /&gt;
 polkit-agent-helper-1: pam_authenticate failed: Permission denied&lt;br /&gt;
 Error: Permission denied&lt;br /&gt;
 ==== AUTHENTICATION FAILED ===&lt;br /&gt;
 Error executing command as another user: Not authorized&lt;br /&gt;
 &lt;br /&gt;
 This incident has been reported.&lt;br /&gt;
&lt;br /&gt;
log information in /var/log/auth.log&lt;br /&gt;
 Jul 14 22:23:24 emenlow pkexec[2515]: yxf: Error executing command as another user: Not authorized [USER=root] [TTY=/dev/pts/0] [CWD=/] [COMMAND=/bin/cat /var/log/auth.log]&lt;br /&gt;
*** &#039;&#039;&#039;account include common-account&#039;&#039;&#039;&lt;br /&gt;
 $ vi /etc/pam.d/common-account&lt;br /&gt;
 #account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
 account [success=0 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
 ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
 Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
 Authenticating as: root&lt;br /&gt;
 Password: &lt;br /&gt;
 polkit-agent-helper-1: pam_acct_mgmt failed: Permission denied&lt;br /&gt;
 Error: Permission denied&lt;br /&gt;
 ==== AUTHENTICATION FAILED ===&lt;br /&gt;
 Error executing command as another user: Not authorized&lt;br /&gt;
&lt;br /&gt;
log information in /var/log/auth.log&lt;br /&gt;
 Jul 14 22:29:12 emenlow pkexec[2523]: yxf: Error executing command as another user: Not authorized [USER=root] [TTY=/dev/pts/0] [CWD=/] [COMMAND=/bin/cat /var/log/auth.log]&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;password include common-password&#039;&#039;&#039;&lt;br /&gt;
 It is no use for polkit. So I don&#039;t test it&lt;br /&gt;
*** &#039;&#039;&#039;session include common-session&#039;&#039;&#039;&lt;br /&gt;
 $ vi /etc/pam.d/common-session&lt;br /&gt;
 #session [default=1]                     pam_permit.so&lt;br /&gt;
 session [default=0]                     pam_permit.so&lt;br /&gt;
&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
 ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
 Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
 Authenticating as: root&lt;br /&gt;
 Password: &lt;br /&gt;
 ==== AUTHENTICATION COMPLETE ===&lt;br /&gt;
 pam_open_session() failed: Permission denied&lt;br /&gt;
&lt;br /&gt;
log information in /var/log/auth.log&lt;br /&gt;
 Jul 14 22:35:51 emenlow polkitd(authority=local): Unregistered Authentication Agent for unix-process:2466:778527 (system bus name :1.17, &lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)&lt;br /&gt;
&lt;br /&gt;
=== screen ===&lt;br /&gt;
screen use pam to authenticate users during unlock terminal. Its configure file screen comes from Fedora and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
&lt;br /&gt;
First start screen:&lt;br /&gt;
  root@qemux86:/etc/pam.d# screen&lt;br /&gt;
it will show some information about screen, just press Space or Enter and it will give a screen terminal:&lt;br /&gt;
  root@qemux86:/etc/pam.d# &lt;br /&gt;
then press &amp;quot;Ctrl+a x&amp;quot; will lock the screen terminal and show:&lt;br /&gt;
    &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
In another root terminal, clear the root&#039;s password:&lt;br /&gt;
  password -d root&lt;br /&gt;
&lt;br /&gt;
modify one line in common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
with&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so debug&lt;br /&gt;
option nullok_secure will allow users who has blank password login, after remove it these users are not allowed to login.&lt;br /&gt;
&lt;br /&gt;
Back to the screen terminal, press &amp;lt;Enter&amp;gt;(because root&#039;s password is blank now) will fail: &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
then modify the line in common-auth with &lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure debug&lt;br /&gt;
&lt;br /&gt;
On the screen terminal press &amp;lt;Enter&amp;gt; again it unlock the terminal.&lt;br /&gt;
&lt;br /&gt;
the log in /var/log/auth.log:&lt;br /&gt;
  Jul 11 14:14:14 qemux86 screen: pam_unix(screen:auth): authentication failure; logname=root uid=0 euid=0 tty= ruser= rhost=  user=root&lt;br /&gt;
&lt;br /&gt;
=== shadow ===&lt;br /&gt;
==== chage ====&lt;br /&gt;
/etc/pam.d/chage: need patch to replace system-auth to common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth		sufficient	pam_rootok.so&lt;br /&gt;
  account	required	pam_permit.so&lt;br /&gt;
  password	include		common-auth&lt;br /&gt;
* test pam_rootok.so&lt;br /&gt;
add the only option for pam_rootok.so&lt;br /&gt;
  auth		sufficient	pam_rootok.so debug&lt;br /&gt;
&lt;br /&gt;
run command chage as root:&lt;br /&gt;
  root@qemux86:/etc/pam.d# chage -m 10  test&lt;br /&gt;
&lt;br /&gt;
log info in /var/log/message shows pam_rootok.so return success:&lt;br /&gt;
  Jul 12 06:55:18 qemux86 authpriv.debug chage[575]: pam_rootok(chage:auth): root check succeeded&lt;br /&gt;
  Jul 12 06:55:18 qemux86 authpriv.info chage[575]: changed password expiry for test&lt;br /&gt;
&lt;br /&gt;
* test pam_unix.so&lt;br /&gt;
the content of common-auth are shown at section &amp;quot;Common configure files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
comment the pam_rootok.so line, because it will make pam return success:&lt;br /&gt;
  #auth		sufficient	pam_rootok.so&lt;br /&gt;
&lt;br /&gt;
and modify the pam_unix.so line in common-auth:&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so debug&lt;br /&gt;
&lt;br /&gt;
run commands:&lt;br /&gt;
  root@qemux86:/etc/pam.d# passwd -d root &lt;br /&gt;
  root@qemux86:/etc/pam.d# chfn -f testself test # test is a unprivileged user&lt;br /&gt;
  Password: &lt;br /&gt;
  chfn: PAM authentication failed&lt;br /&gt;
&lt;br /&gt;
log in /var/log/message:&lt;br /&gt;
  Jul 12 07:53:16 qemux86 authpriv.notice chfn[673]: pam_unix(chfn:auth): authentication failure; logname=root uid=0 euid=0 tty= ruser= rhost=  user=root&lt;br /&gt;
&lt;br /&gt;
==== chfn ====&lt;br /&gt;
/etc/pam.d/chfn&lt;br /&gt;
  auth	    sufficient	pam_rootok.so&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-account&lt;br /&gt;
  session    include      common-session&lt;br /&gt;
add option debug to pam_rootok.so&lt;br /&gt;
  auth	    sufficient	pam_rootok.so debug&lt;br /&gt;
&lt;br /&gt;
* pam_rootok.so&lt;br /&gt;
run command chfn as root:&lt;br /&gt;
  root@qemux86:/etc/pam.d# chfn -f testyayay test&lt;br /&gt;
&lt;br /&gt;
log info in /var/log/message shows pam_rootok.so return success:&lt;br /&gt;
  Jul 12 07:22:59 qemux86 authpriv.debug chfn[638]: pam_rootok(chfn:auth): root check succeeded&lt;br /&gt;
  Jul 12 07:22:59 qemux86 authpriv.info chfn[638]: changed user &#039;test&#039; information&lt;br /&gt;
&lt;br /&gt;
* pam_unix.so&lt;br /&gt;
please refer to chage test steps.&lt;br /&gt;
&lt;br /&gt;
==== chgpasswd ====&lt;br /&gt;
/etc/pam.d/chgpasswd(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth		sufficient	pam_rootok.so&lt;br /&gt;
  account	required	pam_permit.so&lt;br /&gt;
  password	include		system-auth&lt;br /&gt;
&lt;br /&gt;
test pam_rootok.so and pam_unix.so(common-auth) refer to test steps in chage &lt;br /&gt;
&lt;br /&gt;
==== chpasswd ====&lt;br /&gt;
/etc/pam.d/chpasswd&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
common-password are listed before, we change the pam_unix.so option:&lt;br /&gt;
  password	[success=1 default=ignore]	pam_unix.so  audit&lt;br /&gt;
&lt;br /&gt;
commands to test:&lt;br /&gt;
  root@qemux86:/etc/pam.d# chpasswd&lt;br /&gt;
  test:&lt;br /&gt;
  Press Ctrl+d, the follow are terminal output:&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  chpasswd: (user test) pam_chauthtok() failed, error:&lt;br /&gt;
  Authentication token manipulation error&lt;br /&gt;
  chpasswd: (line 1, user test) password not changed&lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 04:53:39 qemux86 authpriv.notice chpasswd[844]: pam_warn(chpasswd:auth): function=[pam_sm_authenticate] service=[chpasswd] terminal=[&amp;lt;unknown&amp;gt;] user=[root] ruser=[&amp;lt;unknown&amp;gt;] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul 15 04:53:39 qemux86 authpriv.notice chpasswd[844]: pam_warn(chpasswd:account): function=[pam_sm_acct_mgmt] service=[chpasswd] terminal=[&amp;lt;unknown&amp;gt;] user=[root] ruser=[&amp;lt;unknown&amp;gt;] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.notice chpasswd[844]: pam_unix(chpasswd:chauthtok): new password not acceptable&lt;br /&gt;
&lt;br /&gt;
==== chsh ====&lt;br /&gt;
/etc/pam.d/chsh&lt;br /&gt;
  auth       required   pam_shells.so&lt;br /&gt;
  auth       sufficient      pam_rootok.so&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-account&lt;br /&gt;
  session    include      common-session&lt;br /&gt;
* pam_shells.so&lt;br /&gt;
pam_shells only allows access to the system if the users shell is listed in /etc/shells.It also checks if /etc/shells is a plain file and not world writable.&lt;br /&gt;
&lt;br /&gt;
check /etc/shells first:&lt;br /&gt;
  qemux86:~$ ls -l /etc/shells &lt;br /&gt;
  -rw-r--r--    1 root     root           109 Jul 12 06:05 /etc/shells&lt;br /&gt;
  qemux86:~$ cat /etc/shells&lt;br /&gt;
  # /etc/shells: valid login shells&lt;br /&gt;
  /bin/sh&lt;br /&gt;
  /bin/ash&lt;br /&gt;
  /bin/bash&lt;br /&gt;
  /bin/dash&lt;br /&gt;
  /bin/ksh&lt;br /&gt;
  /usr/bin/ksh&lt;br /&gt;
  /usr/bin/screen&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
login as a unprivileged user, the correct process is:&lt;br /&gt;
  qemux86:~$ chsh -s /bin/ash&lt;br /&gt;
  Password: &amp;lt;-- Enter password here&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 06:15:18 qemux86 authpriv.debug chsh[1283]: pam_rootok(chsh:auth): root check failed&lt;br /&gt;
  Jul 15 06:15:21 qemux86 authpriv.info chsh[1283]: changed user &#039;test&#039; shell to &#039;/bin/ash&#039;&lt;br /&gt;
&lt;br /&gt;
now remove /bin/ash from /etc/shells, then run the same command:&lt;br /&gt;
  qemux86:~$ chsh -s /bin/ash&lt;br /&gt;
  Password: &amp;lt;-- Enter password here&lt;br /&gt;
  chsh: /bin/ash is an invalid shell.&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
if you make /etc/shells is writable to all people, chsh will fail with syslog info:&lt;br /&gt;
  Jul 15 05:38:38 qemux86 authpriv.err chsh[1091]: pam_shells(chsh:auth): /etc/shells is either world writable or not a normal file&lt;br /&gt;
&lt;br /&gt;
* pam_rootok.so&lt;br /&gt;
modify pam_rootok.so item:&lt;br /&gt;
  auth       required     pam_rootok.so debug&lt;br /&gt;
&lt;br /&gt;
then unprivileged users can&#039;t change their shell.&lt;br /&gt;
  qemux86:~$ chsh -s /bin/ash&lt;br /&gt;
  Password: &lt;br /&gt;
  chsh: PAM authentication failed&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 06:43:14 qemux86 authpriv.debug chsh[1350]: pam_rootok(chsh:auth): root check failed&lt;br /&gt;
&lt;br /&gt;
* pam_unix.so&lt;br /&gt;
**pam_unix in common-auth: please refer to sudo tests&lt;br /&gt;
**pam_unix in common-account and common-password don&#039;t have test point.&lt;br /&gt;
&lt;br /&gt;
==== groupadd ====&lt;br /&gt;
/etc/pam.d/groupadd(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
* pam_rootok&lt;br /&gt;
please refer to chage tests&lt;br /&gt;
&lt;br /&gt;
*pam_unix.so in common-password doesn&#039;t has test point&lt;br /&gt;
&lt;br /&gt;
==== groupdel ====&lt;br /&gt;
/etc/pam.d/groupdel(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
* pam_rootok&lt;br /&gt;
please refer to chage tests&lt;br /&gt;
&lt;br /&gt;
==== groupmems ====&lt;br /&gt;
/etc/pam.d/groupmems&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
*pam_rootok:&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
*pam_unix in common-password doesn&#039;t has test point&lt;br /&gt;
&lt;br /&gt;
==== groupmod ====&lt;br /&gt;
/etc/pam.d/groupmod&lt;br /&gt;
#%PAM-1.0&lt;br /&gt;
auth           sufficient      pam_rootok.so&lt;br /&gt;
account         required        pam_permit.so&lt;br /&gt;
password        include         common-password&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix: FIXME&lt;br /&gt;
&lt;br /&gt;
==== login ====&lt;br /&gt;
/etc/pam.d/login&lt;br /&gt;
  auth       optional   pam_faildelay.so  delay=3000000&lt;br /&gt;
  auth       [success=ok ignore=ignore user_unknown=ignore default=die]  pam_securetty.so&lt;br /&gt;
  auth       requisite  pam_nologin.so&lt;br /&gt;
  session       required   pam_env.so readenv=1&lt;br /&gt;
  session       required   pam_env.so readenv=1 envfile=/etc/default/locale&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  auth       optional   pam_group.so&lt;br /&gt;
  session    required   pam_limits.so                                      &lt;br /&gt;
  session    optional   pam_lastlog.so                                     &lt;br /&gt;
  session    optional   pam_motd.so                              &lt;br /&gt;
  session    optional   pam_mail.so standard                    &lt;br /&gt;
                                                              &lt;br /&gt;
  account    include      common-account                        &lt;br /&gt;
  password   include      common-password                       &lt;br /&gt;
  session    include      common-session&lt;br /&gt;
&lt;br /&gt;
==== newusers ====&lt;br /&gt;
/etc/pam.d/newusers&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
&lt;br /&gt;
*pam_unix&lt;br /&gt;
modify the pam_unix item in common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so debug &lt;br /&gt;
&lt;br /&gt;
run command:&lt;br /&gt;
  root@qemux86:~# newusers&lt;br /&gt;
  a::::::&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  newusers: (user a) pam_chauthtok() failed, error:&lt;br /&gt;
  Authentication token manipulation error&lt;br /&gt;
  newusers: (line 1, user a) password not changed&lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): username [a] obtained&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): username [a] obtained&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.notice newusers[1560]: pam_unix(newusers:chauthtok): new password not acceptable&lt;br /&gt;
&lt;br /&gt;
==== passwd ====&lt;br /&gt;
/etc/pam.d/passwd&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password&lt;br /&gt;
modify the item to make password length not less than 4 characters:&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so minlen=4 debug&lt;br /&gt;
&lt;br /&gt;
run test commands:&lt;br /&gt;
  qemux86:~$ passwd&lt;br /&gt;
  Changing password for test.&lt;br /&gt;
  (current) UNIX password: &amp;lt;-- input 123 here&lt;br /&gt;
  Enter new UNIX password: &lt;br /&gt;
  Retype new UNIX password: &lt;br /&gt;
  You must choose a longer password&lt;br /&gt;
  Enter new UNIX password: &amp;lt;-- input 1234 here&lt;br /&gt;
  Retype new UNIX password: &lt;br /&gt;
  passwd: password updated successfully&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
syslog doesn&#039;t has detail informatiaon&lt;br /&gt;
  Jul 17 02:00:39 qemux86 authpriv.debug passwd[1649]: pam_unix(passwd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 17 02:00:41 qemux86 authpriv.debug passwd[1649]: pam_unix(passwd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 17 02:00:49 qemux86 authpriv.notice passwd[1649]: pam_unix(passwd:chauthtok): password changed for test&lt;br /&gt;
&lt;br /&gt;
==== su ====&lt;br /&gt;
/etc/pam.d/su&lt;br /&gt;
==== useradd ====&lt;br /&gt;
/etc/pam.d/useradd(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password： FIXME&lt;br /&gt;
&lt;br /&gt;
==== userdel ====&lt;br /&gt;
/etc/pam.d/userdel(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password: &lt;br /&gt;
no test point&lt;br /&gt;
&lt;br /&gt;
==== usermod ==== &lt;br /&gt;
/etc/pam.d/usermod(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password： FIXME&lt;br /&gt;
&lt;br /&gt;
=== sudo ===&lt;br /&gt;
*/etc/pam.d/sudo comes from Fedora, and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-account&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
  session    required     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
and content of common-auth has been show above.&lt;br /&gt;
&lt;br /&gt;
*test pam plugins&lt;br /&gt;
**pam_unix.so&lt;br /&gt;
modify common-auth:&lt;br /&gt;
  auth    [success=1 default=ignore]      pam_unix.so debug&lt;br /&gt;
then unpriviledge user can NOT run sudo with blank password&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 16:39:04 qemux86 sudo: pam_unix(sudo:auth): authentication failure; logname=test-pam uid=0 euid=0 tty=/dev/pts/1 ruser=test-pam rhost=  user=test-pam&lt;br /&gt;
  Jul  8 16:39:14 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
**pam_deny.so&lt;br /&gt;
mv line&lt;br /&gt;
  auth    requisite                       pam_deny.so&lt;br /&gt;
to the head of file, unprivilege user can NOT sudo any more:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 14:03:29 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
**pam_permit.so&lt;br /&gt;
comment this line&lt;br /&gt;
  auth    required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
sudo will fail without ask user to enter password:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 12:43:22 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm -f /test&lt;br /&gt;
&lt;br /&gt;
**pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf&lt;br /&gt;
  *        -       nofile       3&lt;br /&gt;
then sudo will fail:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Inconsistency detected by ld.so: dl-deps.c: 622: _dl_map_object_deps: Assertion `nlist &amp;gt; 1&#039; failed!&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
  *        -       nofile       4&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 3 for DEFAULT&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 4 for DEFAULT&lt;br /&gt;
&lt;br /&gt;
** pam_keyinit&lt;br /&gt;
add option debug&lt;br /&gt;
  session    optional     pam_keyinit.so revoke debug&lt;br /&gt;
&lt;br /&gt;
log shows pam_keyinit was called:&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): OPEN 1&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): UID:0 [0]  GID:0 [1000]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 143761918&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 669161571&lt;br /&gt;
&lt;br /&gt;
according the source code pam_keyinit.c line 102 in function init_keyrings, the module return PAM_SUCCESS&lt;br /&gt;
&lt;br /&gt;
=== util-linux ===&lt;br /&gt;
Three programs chfn chsh and login in util-linux will use libpam. Right now these programs are provided by package shadow. In util-linux.inc, EXTRA_OECONF has option &amp;quot;--disable-login-utils &amp;quot; which will disable to build them.&lt;br /&gt;
&lt;br /&gt;
Drop it.&lt;br /&gt;
&lt;br /&gt;
=== xserver-xf86-lite ===&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
&lt;br /&gt;
* mc: mc has remove package mcserv and dropped dependency on PAM already, but didn&#039;t remove checking security/pam_misc.h. Drop it. [http://www.midnight-commander.org/changeset/4816107a02ccbf6331534113e6ec0c8df84e24eb Official change log]&lt;br /&gt;
* libcap: if pam exists, libcap will create a pam plugin pam_cap.so to add a new front end for the authentication function. Because it is not a application, remove it from list.&lt;br /&gt;
* libuser: pam is libuser&#039;s build dependency, so remove it too.&lt;br /&gt;
* The busybox login has a option to use pam, but we use tinylogin&#039;s login right now (tinylogin also provides the su command)&lt;br /&gt;
* gettext only has a example &amp;quot;hello-c++-kde&amp;quot; use pam under source code directory, and it doen&#039;t be compiled and only copied to destination. So omit gettext.&lt;br /&gt;
* sysvinit has a patch contrib/notify-pam-dead.patch for /sbin/init to use pam, but the whole contrib directory didn&#039;t take part in compilation. Drop it.&lt;br /&gt;
&lt;br /&gt;
== Identify upstream PAM patches to use ==&lt;br /&gt;
After checking the Fedora develop repository, the following packages may need patches(only libpam need to upgrade, other patches are pam related configure file but they are absent in poky):&lt;br /&gt;
* libpam: need update from current 1.1.3 to 1.1.4 [https://www.redhat.com/archives/pam-list/2011-June/msg00013.html Release Notes]&lt;br /&gt;
* sudo: package sudo in Fedora provides /etc/pam.d/sudo and /etc/pam.d/sudo-i&lt;br /&gt;
** /etc/pam.d/sudo (Yocto use common-auth instead of system-auth)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      system-auth&lt;br /&gt;
  account    include      system-auth&lt;br /&gt;
  password   include      system-auth&lt;br /&gt;
  session    optional     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
&lt;br /&gt;
* screen: check Fedora screen.pam&lt;br /&gt;
&lt;br /&gt;
* util-linux: check Fedora source file util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* at: check Fedora util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* cups: check Fedora cups-1.1.16-system-auth.patch&lt;br /&gt;
&lt;br /&gt;
* openssh: check Fedora sshd.pam&lt;br /&gt;
&lt;br /&gt;
== PAM Unit Tests==&lt;br /&gt;
We use unit test cases provided by libpam itself, a subdirectory with name &amp;quot;xtests&amp;quot; under libpam source code.&lt;br /&gt;
&lt;br /&gt;
On build machine run &lt;br /&gt;
  bitbake libpam -c patch&lt;br /&gt;
to get the libpam source code Linux-PAM-1.1.4, and scp it to host(target) machine. &lt;br /&gt;
&lt;br /&gt;
On the target machine under Linux-PAM-1.1.4, run&lt;br /&gt;
  ./configure&lt;br /&gt;
  make xtests&lt;br /&gt;
will get the test result of 28 unit test case. If you want to run sigle test case, go to subdirectory xtests and run (take tst-pam_time1 for example)&lt;br /&gt;
  ./run-xtests.sh . tst-pam_time1&lt;br /&gt;
&lt;br /&gt;
Some unit test can NOT pass(15/28), they need some pam plugin libraies:&lt;br /&gt;
* tst-pam_access1&lt;br /&gt;
* tst-pam_access2&lt;br /&gt;
* tst-pam_access3&lt;br /&gt;
* tst-pam_access4&lt;br /&gt;
**the tst-pam_access test cases need pam_access.so, install package pam-plugin-access will make them pass the test&lt;br /&gt;
* tst-pam_authsucceed&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_cracklib1&lt;br /&gt;
* tst-pam_cracklib2&lt;br /&gt;
**need /lib/security/pam_cracklib.so, need build cracklib, and then libpam will check it and create pam-plugin-cracklib&lt;br /&gt;
**need /usr/share/cracklib/pw_dict.pwd file, please run command on host machine:&lt;br /&gt;
    create-cracklib-dict /usr/share/cracklib/cracklib-small&lt;br /&gt;
&lt;br /&gt;
* tst-pam_dispatch1&lt;br /&gt;
* tst-pam_dispatch2&lt;br /&gt;
* tst-pam_dispatch3&lt;br /&gt;
* tst-pam_dispatch4&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_pwhistory1&lt;br /&gt;
**need /lib/security/pam_pwhistory.so, install pam-plugin-pwhistory to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_substack2&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_succeed_if1&lt;br /&gt;
**install pam-plugin-succeed-if to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_time1&lt;br /&gt;
**install pam-plugin-time to make it pass&lt;/div&gt;</summary>
		<author><name>Wfan</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2803</id>
		<title>PAM Integration</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2803"/>
		<updated>2011-07-14T07:19:41Z</updated>

		<summary type="html">&lt;p&gt;Wfan: /* cups */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Motivation ==&lt;br /&gt;
For Yocto 1.1 we are working to ensure that PAM (Pluggable Authentication Module) support is consistent and enabled in recipes where it is applicable. &lt;br /&gt;
&lt;br /&gt;
== Common configure files ==&lt;br /&gt;
For convenience, list common configure files here:&lt;br /&gt;
&lt;br /&gt;
common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
  auth	requisite			pam_deny.so&lt;br /&gt;
  auth	required			pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-account&lt;br /&gt;
  account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so &lt;br /&gt;
  account requisite                       pam_deny.so&lt;br /&gt;
  account required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so obscure sha512&lt;br /&gt;
  password        requisite                       pam_deny.so&lt;br /&gt;
  password        required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-session&lt;br /&gt;
  session [default=1]                     pam_permit.so&lt;br /&gt;
  session requisite                       pam_deny.so&lt;br /&gt;
  session required                        pam_permit.so&lt;br /&gt;
  session required        pam_unix.so &lt;br /&gt;
&lt;br /&gt;
common-session-noninteractive&lt;br /&gt;
  session [default=1]                     pam_permit.so&lt;br /&gt;
  session requisite                       pam_deny.so&lt;br /&gt;
  session required                        pam_permit.so&lt;br /&gt;
  session required        pam_unix.so &lt;br /&gt;
&lt;br /&gt;
== Recipes with PAM support ==&lt;br /&gt;
The following recipes were identified to have PAM support (some already implemented) on 2011-06-27:&lt;br /&gt;
&lt;br /&gt;
=== at === &lt;br /&gt;
* Open issue:&lt;br /&gt;
** It can&#039;t be ran by a non-root user, error message is:&lt;br /&gt;
 Can&#039;t signal atd (permission denied)&lt;br /&gt;
&lt;br /&gt;
* Simple ways to verify &#039;at&#039;:&lt;br /&gt;
 $ at now&lt;br /&gt;
 $ echo &amp;quot;$msg_to_print&amp;quot; &amp;gt;&amp;gt; /tmp/at_test&lt;br /&gt;
 $ &amp;lt; ctrl+D &amp;gt;&lt;br /&gt;
 $ cat /tmp/at_test    # Verify if the message has been there &lt;br /&gt;
&lt;br /&gt;
* /etc/pam.d/atd - not installed by default, copy it from source code and replace &#039;@include&#039; with appropriate &#039;module-type include&#039;:&lt;br /&gt;
&lt;br /&gt;
 auth       required    pam_env.so&lt;br /&gt;
 auth       include     common-auth&lt;br /&gt;
 account    include     common-account&lt;br /&gt;
 session    include     common-session-noninteractive&lt;br /&gt;
 session    required    pam_limits.so&lt;br /&gt;
&lt;br /&gt;
* test pam plugins&lt;br /&gt;
** pam_env.so&lt;br /&gt;
modify /etc/pam.d/atd&lt;br /&gt;
 auth       required    pam_env.so    debug&lt;br /&gt;
modify /etc/security/pam_env.conf, add a test entry such as:&lt;br /&gt;
 MYNAME          DEFAULT=&amp;quot;test-at&amp;quot;&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:41:22 qemux86 atd[678]: pam_env(atd:setcred): pam_putenv(&amp;quot;MYNAME=test-at&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
** pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf &lt;br /&gt;
 root    -       nofile  3&lt;br /&gt;
&#039;at&#039; job failed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:49:42 qemux86 atd[699]: pam_env(atd:setcred): Unable to open config file: /etc/security/pam_env.conf: Too many open files&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
 root    -       nofile  4&lt;br /&gt;
&#039;at&#039; job successed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session opened for user root by (uid=0)                      &lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session closed for user root&lt;br /&gt;
&lt;br /&gt;
=== consolekit ===&lt;br /&gt;
Consolekit provides a pam plugin module pam_ck_connector.so and not the package that use pam.&lt;br /&gt;
Drop it.&lt;br /&gt;
&lt;br /&gt;
=== cronie ===&lt;br /&gt;
* /etc/pam.d/crond:&lt;br /&gt;
 account    required   pam_access.so&lt;br /&gt;
 account    include    password-auth&lt;br /&gt;
 session    required   pam_loginuid.so&lt;br /&gt;
 session    include    password-auth&lt;br /&gt;
 auth       include    password-auth&lt;br /&gt;
&lt;br /&gt;
* /etc/pam.d/password-auth:&lt;br /&gt;
 auth        required      pam_env.so&lt;br /&gt;
 auth        sufficient    pam_unix.so nullok try_first_pass&lt;br /&gt;
 auth        requisite     pam_succeed_if.so uid &amp;gt;= 500 quiet&lt;br /&gt;
 auth        required      pam_deny.so&lt;br /&gt;
 account     required      pam_unix.so&lt;br /&gt;
 account     sufficient    pam_localuser.so&lt;br /&gt;
 account     sufficient    pam_succeed_if.so uid &amp;lt; 500 quiet&lt;br /&gt;
 account     required      pam_permit.so&lt;br /&gt;
 password    requisite     pam_cracklib.so try_first_pass retry=3 type=&lt;br /&gt;
 password    sufficient    pam_unix.so sha512 shadow nullok try_first_pass use_authtok&lt;br /&gt;
 password    required      pam_deny.so&lt;br /&gt;
 session     optional      pam_keyinit.so revoke&lt;br /&gt;
 session     required      pam_limits.so&lt;br /&gt;
 -session     optional      pam_systemd.so&lt;br /&gt;
 session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid&lt;br /&gt;
 session     required      pam_unix.so&lt;br /&gt;
&lt;br /&gt;
* test commands:&lt;br /&gt;
 crontab -e    # establish a crontab jobs and check if it works&lt;br /&gt;
 crontab -l    # list crontab jobs for current user&lt;br /&gt;
&lt;br /&gt;
* test pam plugins&lt;br /&gt;
Verified, test ways and the logs/results please refer to other packages:&lt;br /&gt;
** pam_env.so&lt;br /&gt;
** pam_access.so&lt;br /&gt;
** pam_unix.so&lt;br /&gt;
** pam_permit.so&lt;br /&gt;
** pam_keyinit.so &lt;br /&gt;
&lt;br /&gt;
** pam_localuser.so&lt;br /&gt;
copy &#039;/etc/passwd&#039; to &#039;/tmp/passwd&#039; and delete the entry for &#039;root&#039;;&lt;br /&gt;
modify /etc/pam.d/password-auth:&lt;br /&gt;
 account     requisite    pam_localuser.so file=/tmp/passwd debug&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): set filename to &amp;quot;/tmp/passwd&amp;quot;&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): checking &amp;quot;daemon:x:1:1:daemon:/usr/sbin:/bin/sh &amp;quot;&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): checking &amp;quot;bin:x:2:2:bin:/bin:/bin/sh &amp;quot;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
** pam_succeed_if.so&lt;br /&gt;
account     requisite    pam_succeed_if.so uid &amp;gt; 500 debug&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 12 03:14:14 qemux86 crontab: pam_succeed_if(crond:account): &#039;uid&#039; resolves to &#039;0&#039;&lt;br /&gt;
 Jul 12 03:14:14 qemux86 crontab: pam_succeed_if(crond:account): requirement &amp;quot;uid &amp;gt; 500&amp;quot; not met by user &amp;quot;root&amp;quot;&lt;br /&gt;
&lt;br /&gt;
** pam_loginuid.so&lt;br /&gt;
 TBD&lt;br /&gt;
&lt;br /&gt;
** pam_systemd.so&lt;br /&gt;
 no this module&lt;br /&gt;
&lt;br /&gt;
=== cups ===&lt;br /&gt;
* /etc/pam.d/cups&lt;br /&gt;
 auth	    required	pam_unix.so shadow nodelay&lt;br /&gt;
 account    required	pam_unix.so&lt;br /&gt;
&lt;br /&gt;
* Modify /etc/cups/cupsd.conf:&lt;br /&gt;
 ...&lt;br /&gt;
 - Listen localhost:631&lt;br /&gt;
 + Port 631&lt;br /&gt;
 ...&lt;br /&gt;
 # Restrict access to the server...                               &lt;br /&gt;
 &amp;lt;Location /&amp;gt;                                                     &lt;br /&gt;
   Order allow,deny                                               &lt;br /&gt;
 + allow all                                                      &lt;br /&gt;
 &amp;lt;/Location&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
 # Restrict access to the admin pages...                          &lt;br /&gt;
 &amp;lt;Location /admin&amp;gt;                                                &lt;br /&gt;
   Order allow,deny                                               &lt;br /&gt;
 + allow all                                                      &lt;br /&gt;
 &amp;lt;/Location&amp;gt; &lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
* Test pam plugins&lt;br /&gt;
** pam_unix.so&lt;br /&gt;
Add debug option to &#039;/etc/pam/cups&#039;:&lt;br /&gt;
 auth	    required	pam_unix.so shadow nodelay debug&lt;br /&gt;
 account    required	pam_unix.so debug&lt;br /&gt;
&lt;br /&gt;
Access the cups configure page via web browser:&lt;br /&gt;
 http://&amp;lt;qemu.ip&amp;gt;:631&lt;br /&gt;
Click &#039;Administration&#039; -&amp;gt; &#039;Add Printer&#039;, start the pop-window for user authentication, input correct user and password:&lt;br /&gt;
 user: root&lt;br /&gt;
 pwd: &amp;lt;correct password&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Entry the &#039;Add Printer&#039; configure page successed.&lt;br /&gt;
&lt;br /&gt;
Input error password:&lt;br /&gt;
 user: root&lt;br /&gt;
 pwd: &amp;lt;error password&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check log in &#039;/var/log/cups/error_log&#039;:&lt;br /&gt;
 E [14/Jul/2011:02:41:26 +0800] cupsdAuthorize: pam_authenticate() returned 7 (Authentication failure)!&lt;br /&gt;
&lt;br /&gt;
Modify &#039;/etc/shadow&#039;:&lt;br /&gt;
 -root:$6$yMXdsttU$kT7A.n9bP0w0zzX6Uj1wmypHcq0lSGaC5/4xgNTZRSjNvW0q85ryBz8C6WNCbr22c6RjRKaVhv23ogrmoAo9m.:15168:0:99999:7:::&lt;br /&gt;
 +root:$6$yMXdsttU$kT7A.n9bP0w0zzX6Uj1wmypHcq0lSGaC5/4xgNTZRSjNvW0q85ryBz8C6WNCbr22c6RjRKaVhv23ogrmoAo9m.:15168:0:99999:7::1:&lt;br /&gt;
&lt;br /&gt;
Repeat the user authentication steps, check log in &#039;/var/log/cups/error_log&#039;:&lt;br /&gt;
 E [14/Jul/2011:03:05:00 +0800] cupsdAuthorize: pam_acct_mgmt() returned 13 (User account has expired)!&lt;br /&gt;
&lt;br /&gt;
=== dropbear ===&lt;br /&gt;
** For supporting pam in dropbear, we need two steps:&lt;br /&gt;
** Add configuration &amp;quot;--enable-pam&amp;quot; &lt;br /&gt;
** Add patches to open macro definition for supporting in option.h&lt;br /&gt;
 --- a/ptions.h  2011-07-12 11:32:34.165333202 +0800&lt;br /&gt;
 +++ b/options.h.new     2011-07-12 11:33:25.757332986 +0800&lt;br /&gt;
 @@ -149,9 +149,9 @@&lt;br /&gt;
   * but there&#039;s an interface via a PAM module - don&#039;t bother using it otherwise.&lt;br /&gt;
   * You can&#039;t enable both PASSWORD and PAM. */&lt;br /&gt;
 -#define ENABLE_SVR_PASSWORD_AUTH&lt;br /&gt;
 +//#define ENABLE_SVR_PASSWORD_AUTH&lt;br /&gt;
  /* PAM requires ./configure --enable-pam */&lt;br /&gt;
 -/*#define ENABLE_SVR_PAM_AUTH*/&lt;br /&gt;
 +#define ENABLE_SVR_PAM_AUTH&lt;br /&gt;
  #define ENABLE_SVR_PUBKEY_AUTH&lt;br /&gt;
  /* Wether to ake public key options in authorized_keys file into account */&lt;br /&gt;
&lt;br /&gt;
** Test result(dropbeat only support simple authentication, account and auth)&lt;br /&gt;
*** &#039;&#039;&#039;Server(account)&#039;&#039;&#039;&lt;br /&gt;
 (server ip:192.168.7.2)&lt;br /&gt;
 $touch /etc/pam.d/sshd&lt;br /&gt;
 #%PAM-1.0&lt;br /&gt;
 account  required     pam_access.so&lt;br /&gt;
 $vi /etc/security/access.conf&lt;br /&gt;
 - : root : ALL&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow access)&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 14 07:01:48 qemux86 dropbear[407]: pam_access(sshd:account): access denied for user `root&#039; from `ssh&#039;&lt;br /&gt;
 Jul 14 07:01:48 qemux86 dropbear[407]: pam_acct_mgmt() failed, rc=6, Permission denied &lt;br /&gt;
 Jul 14 07:01:48 qemux86 dropbear[407]: bad PAM password attempt for &#039;root&#039; from 192.168.7.1:33633&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;Server(auth)&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/sshd&lt;br /&gt;
  auth include common-auth&lt;br /&gt;
 $vi /etc/pam.d/common-auth&lt;br /&gt;
 #auth   [success=1 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
 auth    [success=0 default=ignore]      pam_unix.so debug&lt;br /&gt;
 $ passwd -d username &amp;lt;blank password&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow access)&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 14 07:06:42 qemux86 dropbear[421]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=  user=yxf&lt;br /&gt;
 Jul 14 07:06:44 qemux86 dropbear[421]: pam_authenticate() failed, rc=7, Authentication failure &lt;br /&gt;
 Jul 14 07:06:44 qemux86 dropbear[421]: bad PAM password attempt for &#039;yxf&#039; from 192.168.7.1:379&lt;br /&gt;
&lt;br /&gt;
=== gnome-keyring ===&lt;br /&gt;
* gnome-keyring can&#039;t call configuration file like &amp;quot;/etc/pam.d/gnome-keyring&amp;quot; because it is called by other program like &amp;quot;gnome-screensave&amp;quot; and &amp;quot;gdm&amp;quot;. If we want test &amp;quot;pam_gnome_keyring.so&amp;quot;, we need write .bb files to cross-compile gnome-screensave or gdm.&lt;br /&gt;
&lt;br /&gt;
=== openssh ===&lt;br /&gt;
** Absent configuration /etc/pam.d/sshd, we need to add patches. After adding this file, it can support pam function through simple test.&lt;br /&gt;
** Test Result&lt;br /&gt;
*** &#039;&#039;&#039;Configuration of sshd&#039;&#039;&#039;&lt;br /&gt;
 auth       include      common-auth&lt;br /&gt;
 account    required     pam_nologin.so&lt;br /&gt;
 account    include      common-account&lt;br /&gt;
 password   include      common-password&lt;br /&gt;
 session    optional     pam_keyinit.so force revoke&lt;br /&gt;
 session    include      common-session&lt;br /&gt;
 session    required     pam_loginuid.so&lt;br /&gt;
*** &#039;&#039;&#039;auth include common-auth --Server&#039;&#039;&#039;&lt;br /&gt;
 $echo &#039;UsePAM no&#039; &amp;gt;&amp;gt;/etc/ssh/sshd_config&lt;br /&gt;
 $vi /etc/ssh/sshd_config&lt;br /&gt;
  PermitEmptyPasswords yes &lt;br /&gt;
&lt;br /&gt;
 Other is as same as sudo&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 12 11:16:21 qemux86 sshd[650]: pam_unix(sshd:session): session opened for user test by (uid=0)&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
*** &#039;&#039;&#039;account required pam_nologin.so --Server&#039;&#039;&#039;&lt;br /&gt;
 $touch /etc/nologin&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow accession)&lt;br /&gt;
*** &#039;&#039;&#039;log information --Server&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 01:43:48 qemux86 sshd[672]: Accepted keyboard-interactive/pam for yxf from 192.168.7.1 port 59877 ssh2&lt;br /&gt;
 Jul 13 01:43:48 qemux86 sshd[672]: fatal: PAM: pam_setcred(): Failure setting user credentia&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;account include common-account --Server&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/ssh/sshd_config&lt;br /&gt;
  PermitEmptyPasswords no&lt;br /&gt;
 $vi /etc/pam.d/common-account &lt;br /&gt;
  #account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
  account [success=0 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow accession)&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 02:11:24 qemux86 sshd[752]: Failed password for root from 192.168.7.1 port 53784 ssh2&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;password include common-password&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so obscure sha512 &lt;br /&gt;
&lt;br /&gt;
 It&#039;s no use for sshd, So no test result for this item&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;session optional  pam_keyinit.so force revoke --Server&#039;&#039;&#039;&lt;br /&gt;
 No action&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 07:28:18 qemux86 sshd[1132]: pam_keyinit(sshd:session): OPEN 1&lt;br /&gt;
 Jul 13 07:28:18 qemux86 sshd[1132]: pam_keyinit(sshd:session): UID:1000 [0]  GID:1000 [0]&lt;br /&gt;
 Jul 13 07:28:18 qemux86 sshd[1132]: pam_keyinit(sshd:session): JOIN = 236576375&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;( the same session as the above &amp;quot;client&amp;quot;   )&lt;br /&gt;
 $exit&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 07:34:47 qemux86 sshd[1132]: pam_keyinit(sshd:session): CLOSE 1,236576375,1&lt;br /&gt;
 Jul 13 07:34:47 qemux86 sshd[1132]: pam_keyinit(sshd:session): REVOKE 236576375&lt;br /&gt;
 Jul 13 07:34:47 qemux86 sshd[1132]: pam_keyinit(sshd:session): UID:1000 [0]  GID:1000 [0]&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;session include common-session --Server&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/common-session&lt;br /&gt;
  #session [default=1] pam_permit.so&lt;br /&gt;
  session [default=0] pam_permit.so&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow accession)&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 05:53:35 qemux86 sshd[960]: error: PAM: pam_open_session(): Permission denied&lt;br /&gt;
 Jul 13 05:53:35 qemux86 sshd[960]: Received disconnect from 192.168.7.1: 11: disconnected by user&lt;br /&gt;
*** &#039;&#039;&#039; session required  pam_loginuid.so --Server&#039;&#039;&#039;(Record user´s login uid to the process attribute)&lt;br /&gt;
 No action&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 06:31:32 qemux86 sshd[1028]: pam_warn(sshd:session): function=[pam_sm_open_session] service=[sshd] terminal=[ssh] user=[yxf] ruser= [&amp;lt;unknown&amp;gt;] rhost=[ubuntuwindriver.local] &lt;br /&gt;
 Jul 13 06:31:32 qemux86 sshd[1028]: pam_unix(sshd:session): session opened for user yxf by (uid=0)&lt;br /&gt;
&lt;br /&gt;
=== polkit ===&lt;br /&gt;
Polkit includes four binaries. Only pkexec depends on pam. So I use pkexec to make pam test.&lt;br /&gt;
Pkexec allows an authorized user to execute PROGRAM as another user. If username is not specified, then the program will be executed as the administrative super user, root.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Pam configuration file of polkit &#039;&#039;&#039;&lt;br /&gt;
 %PAM-1.0&lt;br /&gt;
 auth       include      common-auth&lt;br /&gt;
 account    include      common-account&lt;br /&gt;
 password   include      common-password&lt;br /&gt;
 session    include      common-session&lt;br /&gt;
* &#039;&#039;&#039;Test Reult&#039;&#039;&#039;&lt;br /&gt;
*** &#039;&#039;&#039;Normally pkexec can call pam modules from the above configuration file&#039;&#039;&#039;&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
  ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
  Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
  Authenticating as: root&lt;br /&gt;
  Password: &amp;lt;---Input root password and press key &amp;quot;Enter&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 Jul 14 22:13:18 emenlow polkitd(authority=local): Registered Authentication Agent for unix-process:2466:778527 (system bus name :1.10 [pkexec  cat /var/log/auth.log], &lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)&lt;br /&gt;
 Jul 14 22:13:18 emenlow polkit-agent-helper-1[2501]: PAM pam_parse: expecting non-zero; [... default=ignore]&lt;br /&gt;
 Jul 14 22:13:18 emenlow polkit-agent-helper-1[2501]: PAM pam_parse: expecting non-zero; [... default=ignore]&lt;br /&gt;
 Jul 14 22:13:21 emenlow polkitd(authority=local): Unregistered Authentication Agent for unix-process:2466:778527 (system bus name :1.10,&lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)&lt;br /&gt;
 Jul 14 22:13:21 emenlow polkitd(authority=local): Operator of unix-process:2466:778527 FAILED to authenticate to gain authorization for action&lt;br /&gt;
 org.freedesktop.policykit.exec for unix-process:2466:778527 [sh] (owned by unix-user:yxf)&lt;br /&gt;
 Jul 14 22:14:37 emenlow polkitd(authority=local): Registered Authentication Agent for unix-process:2466:778527 (system bus name :1.11 [pkexec &lt;br /&gt;
 cat /var/log/auth.log], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)&lt;br /&gt;
 Jul 14 22:16:08 emenlow polkitd(authority=local): Operator of unix-process:2466:778527 successfully authenticated as unix-user:root to gain &lt;br /&gt;
 ONE-SHOT authorization for action org.freedesktop.policykit.exec for unix-process:2466:778527 [sh] (owned by unix-user:yxf)&lt;br /&gt;
 Jul 14 22:16:08 emenlow pkexec: pam_unix(polkit-1:session): session opened for user root by root(uid=500)&lt;br /&gt;
 Jul 14 22:16:08 emenlow pkexec[2507]: yxf: Executing command [USER=root] [TTY=/dev/pts/0] [CWD=/] [COMMAND=/bin/cat /var/log/auth.log]&lt;br /&gt;
 Jul 14 22:16:08 emenlow polkitd(authority=local): Unregistered Authentication Agent for unix-process:2466:778527 (system bus name :1.11, &lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)&lt;br /&gt;
*** &#039;&#039;&#039;auth include common-auth&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/common-auth&lt;br /&gt;
  #auth    [success=1 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
  auth    [success=0 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
 ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
 Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
 Authenticating as: root&lt;br /&gt;
 Password: &lt;br /&gt;
 polkit-agent-helper-1: pam_authenticate failed: Permission denied&lt;br /&gt;
 Error: Permission denied&lt;br /&gt;
 ==== AUTHENTICATION FAILED ===&lt;br /&gt;
 Error executing command as another user: Not authorized&lt;br /&gt;
 &lt;br /&gt;
 This incident has been reported.&lt;br /&gt;
&lt;br /&gt;
log information in /var/log/auth.log&lt;br /&gt;
 Jul 14 22:23:24 emenlow pkexec[2515]: yxf: Error executing command as another user: Not authorized [USER=root] [TTY=/dev/pts/0] [CWD=/] [COMMAND=/bin/cat /var/log/auth.log]&lt;br /&gt;
*** &#039;&#039;&#039;account include common-account&#039;&#039;&#039;&lt;br /&gt;
 $ vi /etc/pam.d/common-account&lt;br /&gt;
 #account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
 account [success=0 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
 ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
 Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
 Authenticating as: root&lt;br /&gt;
 Password: &lt;br /&gt;
 polkit-agent-helper-1: pam_acct_mgmt failed: Permission denied&lt;br /&gt;
 Error: Permission denied&lt;br /&gt;
 ==== AUTHENTICATION FAILED ===&lt;br /&gt;
 Error executing command as another user: Not authorized&lt;br /&gt;
&lt;br /&gt;
log information in /var/log/auth.log&lt;br /&gt;
 Jul 14 22:29:12 emenlow pkexec[2523]: yxf: Error executing command as another user: Not authorized [USER=root] [TTY=/dev/pts/0] [CWD=/] [COMMAND=/bin/cat /var/log/auth.log]&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;password include common-password&#039;&#039;&#039;&lt;br /&gt;
 It is no use for polkit. So I don&#039;t test it&lt;br /&gt;
*** &#039;&#039;&#039;session include common-session&#039;&#039;&#039;&lt;br /&gt;
 $ vi /etc/pam.d/common-session&lt;br /&gt;
 #session [default=1]                     pam_permit.so&lt;br /&gt;
 session [default=0]                     pam_permit.so&lt;br /&gt;
&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
 ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
 Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
 Authenticating as: root&lt;br /&gt;
 Password: &lt;br /&gt;
 ==== AUTHENTICATION COMPLETE ===&lt;br /&gt;
 pam_open_session() failed: Permission denied&lt;br /&gt;
&lt;br /&gt;
log information in /var/log/auth.log&lt;br /&gt;
 Jul 14 22:35:51 emenlow polkitd(authority=local): Unregistered Authentication Agent for unix-process:2466:778527 (system bus name :1.17, &lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)&lt;br /&gt;
&lt;br /&gt;
=== screen ===&lt;br /&gt;
screen use pam to authenticate users during unlock terminal. Its configure file screen comes from Fedora and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
&lt;br /&gt;
First start screen:&lt;br /&gt;
  root@qemux86:/etc/pam.d# screen&lt;br /&gt;
it will show some information about screen, just press Space or Enter and it will give a screen terminal:&lt;br /&gt;
  root@qemux86:/etc/pam.d# &lt;br /&gt;
then press &amp;quot;Ctrl+a x&amp;quot; will lock the screen terminal and show:&lt;br /&gt;
    &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
In another root terminal, clear the root&#039;s password:&lt;br /&gt;
  password -d root&lt;br /&gt;
&lt;br /&gt;
modify one line in common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
with&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so debug&lt;br /&gt;
option nullok_secure will allow users who has blank password login, after remove it these users are not allowed to login.&lt;br /&gt;
&lt;br /&gt;
Back to the screen terminal, press &amp;lt;Enter&amp;gt;(because root&#039;s password is blank now) will fail: &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
then modify the line in common-auth with &lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure debug&lt;br /&gt;
&lt;br /&gt;
On the screen terminal press &amp;lt;Enter&amp;gt; again it unlock the terminal.&lt;br /&gt;
&lt;br /&gt;
the log in /var/log/auth.log:&lt;br /&gt;
  Jul 11 14:14:14 qemux86 screen: pam_unix(screen:auth): authentication failure; logname=root uid=0 euid=0 tty= ruser= rhost=  user=root&lt;br /&gt;
&lt;br /&gt;
=== shadow ===&lt;br /&gt;
==== chage ====&lt;br /&gt;
/etc/pam.d/chage: need patch to replace system-auth to common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth		sufficient	pam_rootok.so&lt;br /&gt;
  account	required	pam_permit.so&lt;br /&gt;
  password	include		common-auth&lt;br /&gt;
* test pam_rootok.so&lt;br /&gt;
add the only option for pam_rootok.so&lt;br /&gt;
  auth		sufficient	pam_rootok.so debug&lt;br /&gt;
&lt;br /&gt;
run command chage as root:&lt;br /&gt;
  root@qemux86:/etc/pam.d# chage -m 10  test&lt;br /&gt;
&lt;br /&gt;
log info in /var/log/message shows pam_rootok.so return success:&lt;br /&gt;
  Jul 12 06:55:18 qemux86 authpriv.debug chage[575]: pam_rootok(chage:auth): root check succeeded&lt;br /&gt;
  Jul 12 06:55:18 qemux86 authpriv.info chage[575]: changed password expiry for test&lt;br /&gt;
&lt;br /&gt;
* test pam_unix.so&lt;br /&gt;
the content of common-auth are shown at section &amp;quot;Common configure files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
comment the pam_rootok.so line, because it will make pam return success:&lt;br /&gt;
  #auth		sufficient	pam_rootok.so&lt;br /&gt;
&lt;br /&gt;
and modify the pam_unix.so line in common-auth:&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so debug&lt;br /&gt;
&lt;br /&gt;
run commands:&lt;br /&gt;
  root@qemux86:/etc/pam.d# passwd -d root &lt;br /&gt;
  root@qemux86:/etc/pam.d# chfn -f testself test # test is a unprivileged user&lt;br /&gt;
  Password: &lt;br /&gt;
  chfn: PAM authentication failed&lt;br /&gt;
&lt;br /&gt;
log in /var/log/message:&lt;br /&gt;
  Jul 12 07:53:16 qemux86 authpriv.notice chfn[673]: pam_unix(chfn:auth): authentication failure; logname=root uid=0 euid=0 tty= ruser= rhost=  user=root&lt;br /&gt;
&lt;br /&gt;
==== chfn ====&lt;br /&gt;
/etc/pam.d/chfn&lt;br /&gt;
  auth	    sufficient	pam_rootok.so&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-account&lt;br /&gt;
  session    include      common-session&lt;br /&gt;
add option debug to pam_rootok.so&lt;br /&gt;
  auth	    sufficient	pam_rootok.so debug&lt;br /&gt;
&lt;br /&gt;
* pam_rootok.so&lt;br /&gt;
run command chfn as root:&lt;br /&gt;
  root@qemux86:/etc/pam.d# chfn -f testyayay test&lt;br /&gt;
&lt;br /&gt;
log info in /var/log/message shows pam_rootok.so return success:&lt;br /&gt;
  Jul 12 07:22:59 qemux86 authpriv.debug chfn[638]: pam_rootok(chfn:auth): root check succeeded&lt;br /&gt;
  Jul 12 07:22:59 qemux86 authpriv.info chfn[638]: changed user &#039;test&#039; information&lt;br /&gt;
&lt;br /&gt;
* pam_unix.so&lt;br /&gt;
please refer to chage test steps.&lt;br /&gt;
&lt;br /&gt;
==== chgpasswd ====&lt;br /&gt;
/etc/pam.d/chgpasswd(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth		sufficient	pam_rootok.so&lt;br /&gt;
  account	required	pam_permit.so&lt;br /&gt;
  password	include		system-auth&lt;br /&gt;
&lt;br /&gt;
test pam_rootok.so and pam_unix.so(common-auth) refer to test steps in chage &lt;br /&gt;
&lt;br /&gt;
==== chpasswd ====&lt;br /&gt;
/etc/pam.d/chpasswd&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
common-password are listed before, we change the pam_unix.so option:&lt;br /&gt;
  password	[success=1 default=ignore]	pam_unix.so  audit&lt;br /&gt;
&lt;br /&gt;
commands to test:&lt;br /&gt;
  root@qemux86:/etc/pam.d# chpasswd&lt;br /&gt;
  test:&lt;br /&gt;
  Press Ctrl+d, the follow are terminal output:&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  chpasswd: (user test) pam_chauthtok() failed, error:&lt;br /&gt;
  Authentication token manipulation error&lt;br /&gt;
  chpasswd: (line 1, user test) password not changed&lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 04:53:39 qemux86 authpriv.notice chpasswd[844]: pam_warn(chpasswd:auth): function=[pam_sm_authenticate] service=[chpasswd] terminal=[&amp;lt;unknown&amp;gt;] user=[root] ruser=[&amp;lt;unknown&amp;gt;] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul 15 04:53:39 qemux86 authpriv.notice chpasswd[844]: pam_warn(chpasswd:account): function=[pam_sm_acct_mgmt] service=[chpasswd] terminal=[&amp;lt;unknown&amp;gt;] user=[root] ruser=[&amp;lt;unknown&amp;gt;] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.notice chpasswd[844]: pam_unix(chpasswd:chauthtok): new password not acceptable&lt;br /&gt;
&lt;br /&gt;
==== chsh ====&lt;br /&gt;
/etc/pam.d/chsh&lt;br /&gt;
  auth       required   pam_shells.so&lt;br /&gt;
  auth       sufficient      pam_rootok.so&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-account&lt;br /&gt;
  session    include      common-session&lt;br /&gt;
* pam_shells.so&lt;br /&gt;
pam_shells only allows access to the system if the users shell is listed in /etc/shells.It also checks if /etc/shells is a plain file and not world writable.&lt;br /&gt;
&lt;br /&gt;
check /etc/shells first:&lt;br /&gt;
  qemux86:~$ ls -l /etc/shells &lt;br /&gt;
  -rw-r--r--    1 root     root           109 Jul 12 06:05 /etc/shells&lt;br /&gt;
  qemux86:~$ cat /etc/shells&lt;br /&gt;
  # /etc/shells: valid login shells&lt;br /&gt;
  /bin/sh&lt;br /&gt;
  /bin/ash&lt;br /&gt;
  /bin/bash&lt;br /&gt;
  /bin/dash&lt;br /&gt;
  /bin/ksh&lt;br /&gt;
  /usr/bin/ksh&lt;br /&gt;
  /usr/bin/screen&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
login as a unprivileged user, the correct process is:&lt;br /&gt;
  qemux86:~$ chsh -s /bin/ash&lt;br /&gt;
  Password: &amp;lt;-- Enter password here&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 06:15:18 qemux86 authpriv.debug chsh[1283]: pam_rootok(chsh:auth): root check failed&lt;br /&gt;
  Jul 15 06:15:21 qemux86 authpriv.info chsh[1283]: changed user &#039;test&#039; shell to &#039;/bin/ash&#039;&lt;br /&gt;
&lt;br /&gt;
now remove /bin/ash from /etc/shells, then run the same command:&lt;br /&gt;
  qemux86:~$ chsh -s /bin/ash&lt;br /&gt;
  Password: &amp;lt;-- Enter password here&lt;br /&gt;
  chsh: /bin/ash is an invalid shell.&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
if you make /etc/shells is writable to all people, chsh will fail with syslog info:&lt;br /&gt;
  Jul 15 05:38:38 qemux86 authpriv.err chsh[1091]: pam_shells(chsh:auth): /etc/shells is either world writable or not a normal file&lt;br /&gt;
&lt;br /&gt;
* pam_rootok.so&lt;br /&gt;
modify pam_rootok.so item:&lt;br /&gt;
  auth       required     pam_rootok.so debug&lt;br /&gt;
&lt;br /&gt;
then unprivileged users can&#039;t change their shell.&lt;br /&gt;
  qemux86:~$ chsh -s /bin/ash&lt;br /&gt;
  Password: &lt;br /&gt;
  chsh: PAM authentication failed&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 06:43:14 qemux86 authpriv.debug chsh[1350]: pam_rootok(chsh:auth): root check failed&lt;br /&gt;
&lt;br /&gt;
* pam_unix.so&lt;br /&gt;
**pam_unix in common-auth: please refer to sudo tests&lt;br /&gt;
**pam_unix in common-account and common-password don&#039;t have test point.&lt;br /&gt;
&lt;br /&gt;
==== groupadd ====&lt;br /&gt;
/etc/pam.d/groupadd(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
* pam_rootok&lt;br /&gt;
please refer to chage tests&lt;br /&gt;
&lt;br /&gt;
*pam_unix.so in common-password doesn&#039;t has test point&lt;br /&gt;
&lt;br /&gt;
==== groupdel ====&lt;br /&gt;
/etc/pam.d/groupdel(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
* pam_rootok&lt;br /&gt;
please refer to chage tests&lt;br /&gt;
&lt;br /&gt;
==== groupmems ====&lt;br /&gt;
/etc/pam.d/groupmems&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
*pam_rootok:&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
*pam_unix in common-password doesn&#039;t has test point&lt;br /&gt;
&lt;br /&gt;
==== groupmod ====&lt;br /&gt;
/etc/pam.d/groupmod&lt;br /&gt;
#%PAM-1.0&lt;br /&gt;
auth           sufficient      pam_rootok.so&lt;br /&gt;
account         required        pam_permit.so&lt;br /&gt;
password        include         common-password&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix: FIXME&lt;br /&gt;
&lt;br /&gt;
==== login ====&lt;br /&gt;
/etc/pam.d/login&lt;br /&gt;
  auth       optional   pam_faildelay.so  delay=3000000&lt;br /&gt;
  auth       [success=ok ignore=ignore user_unknown=ignore default=die]  pam_securetty.so&lt;br /&gt;
  auth       requisite  pam_nologin.so&lt;br /&gt;
  session       required   pam_env.so readenv=1&lt;br /&gt;
  session       required   pam_env.so readenv=1 envfile=/etc/default/locale&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  auth       optional   pam_group.so&lt;br /&gt;
  session    required   pam_limits.so                                      &lt;br /&gt;
  session    optional   pam_lastlog.so                                     &lt;br /&gt;
  session    optional   pam_motd.so                              &lt;br /&gt;
  session    optional   pam_mail.so standard                    &lt;br /&gt;
                                                              &lt;br /&gt;
  account    include      common-account                        &lt;br /&gt;
  password   include      common-password                       &lt;br /&gt;
  session    include      common-session&lt;br /&gt;
&lt;br /&gt;
==== newusers ====&lt;br /&gt;
/etc/pam.d/newusers&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
&lt;br /&gt;
*pam_unix&lt;br /&gt;
modify the pam_unix item in common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so debug &lt;br /&gt;
&lt;br /&gt;
run command:&lt;br /&gt;
  root@qemux86:~# newusers&lt;br /&gt;
  a::::::&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  newusers: (user a) pam_chauthtok() failed, error:&lt;br /&gt;
  Authentication token manipulation error&lt;br /&gt;
  newusers: (line 1, user a) password not changed&lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): username [a] obtained&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): username [a] obtained&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.notice newusers[1560]: pam_unix(newusers:chauthtok): new password not acceptable&lt;br /&gt;
&lt;br /&gt;
==== passwd ====&lt;br /&gt;
/etc/pam.d/passwd&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password&lt;br /&gt;
modify the item to make password length not less than 4 characters:&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so minlen=4 debug&lt;br /&gt;
&lt;br /&gt;
run test commands:&lt;br /&gt;
  qemux86:~$ passwd&lt;br /&gt;
  Changing password for test.&lt;br /&gt;
  (current) UNIX password: &amp;lt;-- input 123 here&lt;br /&gt;
  Enter new UNIX password: &lt;br /&gt;
  Retype new UNIX password: &lt;br /&gt;
  You must choose a longer password&lt;br /&gt;
  Enter new UNIX password: &amp;lt;-- input 1234 here&lt;br /&gt;
  Retype new UNIX password: &lt;br /&gt;
  passwd: password updated successfully&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
syslog doesn&#039;t has detail informatiaon&lt;br /&gt;
  Jul 17 02:00:39 qemux86 authpriv.debug passwd[1649]: pam_unix(passwd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 17 02:00:41 qemux86 authpriv.debug passwd[1649]: pam_unix(passwd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 17 02:00:49 qemux86 authpriv.notice passwd[1649]: pam_unix(passwd:chauthtok): password changed for test&lt;br /&gt;
&lt;br /&gt;
==== su ====&lt;br /&gt;
/etc/pam.d/su&lt;br /&gt;
==== useradd ====&lt;br /&gt;
/etc/pam.d/useradd(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password： FIXME&lt;br /&gt;
&lt;br /&gt;
==== userdel ====&lt;br /&gt;
/etc/pam.d/userdel(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password: &lt;br /&gt;
no test point&lt;br /&gt;
&lt;br /&gt;
==== usermod ==== &lt;br /&gt;
/etc/pam.d/usermod(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password： FIXME&lt;br /&gt;
&lt;br /&gt;
=== sudo ===&lt;br /&gt;
*/etc/pam.d/sudo comes from Fedora, and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-account&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
  session    required     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
and content of common-auth has been show above.&lt;br /&gt;
&lt;br /&gt;
*test pam plugins&lt;br /&gt;
**pam_unix.so&lt;br /&gt;
modify common-auth:&lt;br /&gt;
  auth    [success=1 default=ignore]      pam_unix.so debug&lt;br /&gt;
then unpriviledge user can NOT run sudo with blank password&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 16:39:04 qemux86 sudo: pam_unix(sudo:auth): authentication failure; logname=test-pam uid=0 euid=0 tty=/dev/pts/1 ruser=test-pam rhost=  user=test-pam&lt;br /&gt;
  Jul  8 16:39:14 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
**pam_deny.so&lt;br /&gt;
mv line&lt;br /&gt;
  auth    requisite                       pam_deny.so&lt;br /&gt;
to the head of file, unprivilege user can NOT sudo any more:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 14:03:29 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
**pam_permit.so&lt;br /&gt;
comment this line&lt;br /&gt;
  auth    required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
sudo will fail without ask user to enter password:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 12:43:22 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm -f /test&lt;br /&gt;
&lt;br /&gt;
**pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf&lt;br /&gt;
  *        -       nofile       3&lt;br /&gt;
then sudo will fail:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Inconsistency detected by ld.so: dl-deps.c: 622: _dl_map_object_deps: Assertion `nlist &amp;gt; 1&#039; failed!&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
  *        -       nofile       4&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 3 for DEFAULT&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 4 for DEFAULT&lt;br /&gt;
&lt;br /&gt;
** pam_keyinit&lt;br /&gt;
add option debug&lt;br /&gt;
  session    optional     pam_keyinit.so revoke debug&lt;br /&gt;
&lt;br /&gt;
log shows pam_keyinit was called:&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): OPEN 1&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): UID:0 [0]  GID:0 [1000]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 143761918&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 669161571&lt;br /&gt;
&lt;br /&gt;
according the source code pam_keyinit.c line 102 in function init_keyrings, the module return PAM_SUCCESS&lt;br /&gt;
&lt;br /&gt;
=== util-linux ===&lt;br /&gt;
Three programs chfn chsh and login in util-linux will use libpam. Right now these programs are provided by package shadow. In util-linux.inc, EXTRA_OECONF has option &amp;quot;--disable-login-utils &amp;quot; which will disable to build them.&lt;br /&gt;
&lt;br /&gt;
Drop it.&lt;br /&gt;
&lt;br /&gt;
=== xserver-xf86-lite ===&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
&lt;br /&gt;
* mc: mc has remove package mcserv and dropped dependency on PAM already, but didn&#039;t remove checking security/pam_misc.h. Drop it. [http://www.midnight-commander.org/changeset/4816107a02ccbf6331534113e6ec0c8df84e24eb Official change log]&lt;br /&gt;
* libcap: if pam exists, libcap will create a pam plugin pam_cap.so to add a new front end for the authentication function. Because it is not a application, remove it from list.&lt;br /&gt;
* libuser: pam is libuser&#039;s build dependency, so remove it too.&lt;br /&gt;
* The busybox login has a option to use pam, but we use tinylogin&#039;s login right now (tinylogin also provides the su command)&lt;br /&gt;
* gettext only has a example &amp;quot;hello-c++-kde&amp;quot; use pam under source code directory, and it doen&#039;t be compiled and only copied to destination. So omit gettext.&lt;br /&gt;
* sysvinit has a patch contrib/notify-pam-dead.patch for /sbin/init to use pam, but the whole contrib directory didn&#039;t take part in compilation. Drop it.&lt;br /&gt;
&lt;br /&gt;
== Identify upstream PAM patches to use ==&lt;br /&gt;
After checking the Fedora develop repository, the following packages may need patches(only libpam need to upgrade, other patches are pam related configure file but they are absent in poky):&lt;br /&gt;
* libpam: need update from current 1.1.3 to 1.1.4 [https://www.redhat.com/archives/pam-list/2011-June/msg00013.html Release Notes]&lt;br /&gt;
* sudo: package sudo in Fedora provides /etc/pam.d/sudo and /etc/pam.d/sudo-i&lt;br /&gt;
** /etc/pam.d/sudo (Yocto use common-auth instead of system-auth)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      system-auth&lt;br /&gt;
  account    include      system-auth&lt;br /&gt;
  password   include      system-auth&lt;br /&gt;
  session    optional     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
&lt;br /&gt;
* screen: check Fedora screen.pam&lt;br /&gt;
&lt;br /&gt;
* util-linux: check Fedora source file util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* at: check Fedora util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* cups: check Fedora cups-1.1.16-system-auth.patch&lt;br /&gt;
&lt;br /&gt;
* openssh: check Fedora sshd.pam&lt;br /&gt;
&lt;br /&gt;
== PAM Unit Tests==&lt;br /&gt;
We use unit test cases provided by libpam itself, a subdirectory with name &amp;quot;xtests&amp;quot; under libpam source code.&lt;br /&gt;
&lt;br /&gt;
On build machine run &lt;br /&gt;
  bitbake libpam -c patch&lt;br /&gt;
to get the libpam source code Linux-PAM-1.1.4, and scp it to host(target) machine. &lt;br /&gt;
&lt;br /&gt;
On the target machine under Linux-PAM-1.1.4, run&lt;br /&gt;
  ./configure&lt;br /&gt;
  make xtests&lt;br /&gt;
will get the test result of 28 unit test case. If you want to run sigle test case, go to subdirectory xtests and run (take tst-pam_time1 for example)&lt;br /&gt;
  ./run-xtests.sh . tst-pam_time1&lt;br /&gt;
&lt;br /&gt;
Some unit test can NOT pass(15/28), they need some pam plugin libraies:&lt;br /&gt;
* tst-pam_access1&lt;br /&gt;
* tst-pam_access2&lt;br /&gt;
* tst-pam_access3&lt;br /&gt;
* tst-pam_access4&lt;br /&gt;
**the tst-pam_access test cases need pam_access.so, install package pam-plugin-access will make them pass the test&lt;br /&gt;
* tst-pam_authsucceed&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_cracklib1&lt;br /&gt;
* tst-pam_cracklib2&lt;br /&gt;
**need /lib/security/pam_cracklib.so, need build cracklib, and then libpam will check it and create pam-plugin-cracklib&lt;br /&gt;
**need /usr/share/cracklib/pw_dict.pwd file, please run command on host machine:&lt;br /&gt;
    create-cracklib-dict /usr/share/cracklib/cracklib-small&lt;br /&gt;
&lt;br /&gt;
* tst-pam_dispatch1&lt;br /&gt;
* tst-pam_dispatch2&lt;br /&gt;
* tst-pam_dispatch3&lt;br /&gt;
* tst-pam_dispatch4&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_pwhistory1&lt;br /&gt;
**need /lib/security/pam_pwhistory.so, install pam-plugin-pwhistory to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_substack2&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_succeed_if1&lt;br /&gt;
**install pam-plugin-succeed-if to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_time1&lt;br /&gt;
**install pam-plugin-time to make it pass&lt;/div&gt;</summary>
		<author><name>Wfan</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2802</id>
		<title>PAM Integration</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2802"/>
		<updated>2011-07-14T07:18:06Z</updated>

		<summary type="html">&lt;p&gt;Wfan: /* cups */ Add test results for cups&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Motivation ==&lt;br /&gt;
For Yocto 1.1 we are working to ensure that PAM (Pluggable Authentication Module) support is consistent and enabled in recipes where it is applicable. &lt;br /&gt;
&lt;br /&gt;
== Common configure files ==&lt;br /&gt;
For convenience, list common configure files here:&lt;br /&gt;
&lt;br /&gt;
common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
  auth	requisite			pam_deny.so&lt;br /&gt;
  auth	required			pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-account&lt;br /&gt;
  account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so &lt;br /&gt;
  account requisite                       pam_deny.so&lt;br /&gt;
  account required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so obscure sha512&lt;br /&gt;
  password        requisite                       pam_deny.so&lt;br /&gt;
  password        required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-session&lt;br /&gt;
  session [default=1]                     pam_permit.so&lt;br /&gt;
  session requisite                       pam_deny.so&lt;br /&gt;
  session required                        pam_permit.so&lt;br /&gt;
  session required        pam_unix.so &lt;br /&gt;
&lt;br /&gt;
common-session-noninteractive&lt;br /&gt;
  session [default=1]                     pam_permit.so&lt;br /&gt;
  session requisite                       pam_deny.so&lt;br /&gt;
  session required                        pam_permit.so&lt;br /&gt;
  session required        pam_unix.so &lt;br /&gt;
&lt;br /&gt;
== Recipes with PAM support ==&lt;br /&gt;
The following recipes were identified to have PAM support (some already implemented) on 2011-06-27:&lt;br /&gt;
&lt;br /&gt;
=== at === &lt;br /&gt;
* Open issue:&lt;br /&gt;
** It can&#039;t be ran by a non-root user, error message is:&lt;br /&gt;
 Can&#039;t signal atd (permission denied)&lt;br /&gt;
&lt;br /&gt;
* Simple ways to verify &#039;at&#039;:&lt;br /&gt;
 $ at now&lt;br /&gt;
 $ echo &amp;quot;$msg_to_print&amp;quot; &amp;gt;&amp;gt; /tmp/at_test&lt;br /&gt;
 $ &amp;lt; ctrl+D &amp;gt;&lt;br /&gt;
 $ cat /tmp/at_test    # Verify if the message has been there &lt;br /&gt;
&lt;br /&gt;
* /etc/pam.d/atd - not installed by default, copy it from source code and replace &#039;@include&#039; with appropriate &#039;module-type include&#039;:&lt;br /&gt;
&lt;br /&gt;
 auth       required    pam_env.so&lt;br /&gt;
 auth       include     common-auth&lt;br /&gt;
 account    include     common-account&lt;br /&gt;
 session    include     common-session-noninteractive&lt;br /&gt;
 session    required    pam_limits.so&lt;br /&gt;
&lt;br /&gt;
* test pam plugins&lt;br /&gt;
** pam_env.so&lt;br /&gt;
modify /etc/pam.d/atd&lt;br /&gt;
 auth       required    pam_env.so    debug&lt;br /&gt;
modify /etc/security/pam_env.conf, add a test entry such as:&lt;br /&gt;
 MYNAME          DEFAULT=&amp;quot;test-at&amp;quot;&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:41:22 qemux86 atd[678]: pam_env(atd:setcred): pam_putenv(&amp;quot;MYNAME=test-at&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
** pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf &lt;br /&gt;
 root    -       nofile  3&lt;br /&gt;
&#039;at&#039; job failed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:49:42 qemux86 atd[699]: pam_env(atd:setcred): Unable to open config file: /etc/security/pam_env.conf: Too many open files&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
 root    -       nofile  4&lt;br /&gt;
&#039;at&#039; job successed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session opened for user root by (uid=0)                      &lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session closed for user root&lt;br /&gt;
&lt;br /&gt;
=== consolekit ===&lt;br /&gt;
Consolekit provides a pam plugin module pam_ck_connector.so and not the package that use pam.&lt;br /&gt;
Drop it.&lt;br /&gt;
&lt;br /&gt;
=== cronie ===&lt;br /&gt;
* /etc/pam.d/crond:&lt;br /&gt;
 account    required   pam_access.so&lt;br /&gt;
 account    include    password-auth&lt;br /&gt;
 session    required   pam_loginuid.so&lt;br /&gt;
 session    include    password-auth&lt;br /&gt;
 auth       include    password-auth&lt;br /&gt;
&lt;br /&gt;
* /etc/pam.d/password-auth:&lt;br /&gt;
 auth        required      pam_env.so&lt;br /&gt;
 auth        sufficient    pam_unix.so nullok try_first_pass&lt;br /&gt;
 auth        requisite     pam_succeed_if.so uid &amp;gt;= 500 quiet&lt;br /&gt;
 auth        required      pam_deny.so&lt;br /&gt;
 account     required      pam_unix.so&lt;br /&gt;
 account     sufficient    pam_localuser.so&lt;br /&gt;
 account     sufficient    pam_succeed_if.so uid &amp;lt; 500 quiet&lt;br /&gt;
 account     required      pam_permit.so&lt;br /&gt;
 password    requisite     pam_cracklib.so try_first_pass retry=3 type=&lt;br /&gt;
 password    sufficient    pam_unix.so sha512 shadow nullok try_first_pass use_authtok&lt;br /&gt;
 password    required      pam_deny.so&lt;br /&gt;
 session     optional      pam_keyinit.so revoke&lt;br /&gt;
 session     required      pam_limits.so&lt;br /&gt;
 -session     optional      pam_systemd.so&lt;br /&gt;
 session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid&lt;br /&gt;
 session     required      pam_unix.so&lt;br /&gt;
&lt;br /&gt;
* test commands:&lt;br /&gt;
 crontab -e    # establish a crontab jobs and check if it works&lt;br /&gt;
 crontab -l    # list crontab jobs for current user&lt;br /&gt;
&lt;br /&gt;
* test pam plugins&lt;br /&gt;
Verified, test ways and the logs/results please refer to other packages:&lt;br /&gt;
** pam_env.so&lt;br /&gt;
** pam_access.so&lt;br /&gt;
** pam_unix.so&lt;br /&gt;
** pam_permit.so&lt;br /&gt;
** pam_keyinit.so &lt;br /&gt;
&lt;br /&gt;
** pam_localuser.so&lt;br /&gt;
copy &#039;/etc/passwd&#039; to &#039;/tmp/passwd&#039; and delete the entry for &#039;root&#039;;&lt;br /&gt;
modify /etc/pam.d/password-auth:&lt;br /&gt;
 account     requisite    pam_localuser.so file=/tmp/passwd debug&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): set filename to &amp;quot;/tmp/passwd&amp;quot;&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): checking &amp;quot;daemon:x:1:1:daemon:/usr/sbin:/bin/sh &amp;quot;&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): checking &amp;quot;bin:x:2:2:bin:/bin:/bin/sh &amp;quot;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
** pam_succeed_if.so&lt;br /&gt;
account     requisite    pam_succeed_if.so uid &amp;gt; 500 debug&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 12 03:14:14 qemux86 crontab: pam_succeed_if(crond:account): &#039;uid&#039; resolves to &#039;0&#039;&lt;br /&gt;
 Jul 12 03:14:14 qemux86 crontab: pam_succeed_if(crond:account): requirement &amp;quot;uid &amp;gt; 500&amp;quot; not met by user &amp;quot;root&amp;quot;&lt;br /&gt;
&lt;br /&gt;
** pam_loginuid.so&lt;br /&gt;
 TBD&lt;br /&gt;
&lt;br /&gt;
** pam_systemd.so&lt;br /&gt;
 no this module&lt;br /&gt;
&lt;br /&gt;
=== cups ===&lt;br /&gt;
* /etc/pam.d/cups&lt;br /&gt;
 auth	    required	pam_unix.so shadow nodelay&lt;br /&gt;
 account    required	pam_unix.so&lt;br /&gt;
&lt;br /&gt;
* Modify /etc/cups/cupsd.conf:&lt;br /&gt;
 ...&lt;br /&gt;
 - Listen localhost:631&lt;br /&gt;
 + Port 631&lt;br /&gt;
 ...&lt;br /&gt;
 # Restrict access to the server...                               &lt;br /&gt;
 &amp;lt;Location /&amp;gt;                                                     &lt;br /&gt;
  Order allow,deny                                               &lt;br /&gt;
+  allow all                                                      &lt;br /&gt;
 &amp;lt;/Location&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
 # Restrict access to the admin pages...                          &lt;br /&gt;
 &amp;lt;Location /admin&amp;gt;                                                &lt;br /&gt;
  Order allow,deny                                               &lt;br /&gt;
+  allow all                                                      &lt;br /&gt;
 &amp;lt;/Location&amp;gt; &lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
* Test pam plugins&lt;br /&gt;
** pam_unix.so&lt;br /&gt;
Add debug option to &#039;/etc/pam/cups&#039;:&lt;br /&gt;
 auth	    required	pam_unix.so shadow nodelay debug&lt;br /&gt;
 account    required	pam_unix.so debug&lt;br /&gt;
&lt;br /&gt;
Access the cups configure page via web browser:&lt;br /&gt;
 http://&amp;lt;qemu.ip&amp;gt;:631&lt;br /&gt;
Click &#039;Administration&#039; -&amp;gt; &#039;Add Printer&#039;, start the pop-window for user authentication, input correct user and password:&lt;br /&gt;
 user: root&lt;br /&gt;
 pwd: &amp;lt;correct password&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Entry the &#039;Add Printer&#039; configure page successed.&lt;br /&gt;
&lt;br /&gt;
Input error password:&lt;br /&gt;
 user: root&lt;br /&gt;
 pwd: &amp;lt;error password&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check log in &#039;/var/log/cups/error_log&#039;:&lt;br /&gt;
 E [14/Jul/2011:02:41:26 +0800] cupsdAuthorize: pam_authenticate() returned 7 (Authentication failure)!&lt;br /&gt;
&lt;br /&gt;
Modify &#039;/etc/shadow&#039;:&lt;br /&gt;
 -root:$6$yMXdsttU$kT7A.n9bP0w0zzX6Uj1wmypHcq0lSGaC5/4xgNTZRSjNvW0q85ryBz8C6WNCbr22c6RjRKaVhv23ogrmoAo9m.:15168:0:99999:7:::&lt;br /&gt;
 +root:$6$yMXdsttU$kT7A.n9bP0w0zzX6Uj1wmypHcq0lSGaC5/4xgNTZRSjNvW0q85ryBz8C6WNCbr22c6RjRKaVhv23ogrmoAo9m.:15168:0:99999:7::1:&lt;br /&gt;
&lt;br /&gt;
Repeat the user authentication steps, check log in &#039;/var/log/cups/error_log&#039;:&lt;br /&gt;
 E [14/Jul/2011:03:05:00 +0800] cupsdAuthorize: pam_acct_mgmt() returned 13 (User account has expired)!&lt;br /&gt;
&lt;br /&gt;
=== dropbear ===&lt;br /&gt;
** For supporting pam in dropbear, we need two steps:&lt;br /&gt;
** Add configuration &amp;quot;--enable-pam&amp;quot; &lt;br /&gt;
** Add patches to open macro definition for supporting in option.h&lt;br /&gt;
 --- a/ptions.h  2011-07-12 11:32:34.165333202 +0800&lt;br /&gt;
 +++ b/options.h.new     2011-07-12 11:33:25.757332986 +0800&lt;br /&gt;
 @@ -149,9 +149,9 @@&lt;br /&gt;
   * but there&#039;s an interface via a PAM module - don&#039;t bother using it otherwise.&lt;br /&gt;
   * You can&#039;t enable both PASSWORD and PAM. */&lt;br /&gt;
 -#define ENABLE_SVR_PASSWORD_AUTH&lt;br /&gt;
 +//#define ENABLE_SVR_PASSWORD_AUTH&lt;br /&gt;
  /* PAM requires ./configure --enable-pam */&lt;br /&gt;
 -/*#define ENABLE_SVR_PAM_AUTH*/&lt;br /&gt;
 +#define ENABLE_SVR_PAM_AUTH&lt;br /&gt;
  #define ENABLE_SVR_PUBKEY_AUTH&lt;br /&gt;
  /* Wether to ake public key options in authorized_keys file into account */&lt;br /&gt;
&lt;br /&gt;
** Test result(dropbeat only support simple authentication, account and auth)&lt;br /&gt;
*** &#039;&#039;&#039;Server(account)&#039;&#039;&#039;&lt;br /&gt;
 (server ip:192.168.7.2)&lt;br /&gt;
 $touch /etc/pam.d/sshd&lt;br /&gt;
 #%PAM-1.0&lt;br /&gt;
 account  required     pam_access.so&lt;br /&gt;
 $vi /etc/security/access.conf&lt;br /&gt;
 - : root : ALL&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow access)&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 14 07:01:48 qemux86 dropbear[407]: pam_access(sshd:account): access denied for user `root&#039; from `ssh&#039;&lt;br /&gt;
 Jul 14 07:01:48 qemux86 dropbear[407]: pam_acct_mgmt() failed, rc=6, Permission denied &lt;br /&gt;
 Jul 14 07:01:48 qemux86 dropbear[407]: bad PAM password attempt for &#039;root&#039; from 192.168.7.1:33633&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;Server(auth)&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/sshd&lt;br /&gt;
  auth include common-auth&lt;br /&gt;
 $vi /etc/pam.d/common-auth&lt;br /&gt;
 #auth   [success=1 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
 auth    [success=0 default=ignore]      pam_unix.so debug&lt;br /&gt;
 $ passwd -d username &amp;lt;blank password&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow access)&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 14 07:06:42 qemux86 dropbear[421]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=  user=yxf&lt;br /&gt;
 Jul 14 07:06:44 qemux86 dropbear[421]: pam_authenticate() failed, rc=7, Authentication failure &lt;br /&gt;
 Jul 14 07:06:44 qemux86 dropbear[421]: bad PAM password attempt for &#039;yxf&#039; from 192.168.7.1:379&lt;br /&gt;
&lt;br /&gt;
=== gnome-keyring ===&lt;br /&gt;
* gnome-keyring can&#039;t call configuration file like &amp;quot;/etc/pam.d/gnome-keyring&amp;quot; because it is called by other program like &amp;quot;gnome-screensave&amp;quot; and &amp;quot;gdm&amp;quot;. If we want test &amp;quot;pam_gnome_keyring.so&amp;quot;, we need write .bb files to cross-compile gnome-screensave or gdm.&lt;br /&gt;
&lt;br /&gt;
=== openssh ===&lt;br /&gt;
** Absent configuration /etc/pam.d/sshd, we need to add patches. After adding this file, it can support pam function through simple test.&lt;br /&gt;
** Test Result&lt;br /&gt;
*** &#039;&#039;&#039;Configuration of sshd&#039;&#039;&#039;&lt;br /&gt;
 auth       include      common-auth&lt;br /&gt;
 account    required     pam_nologin.so&lt;br /&gt;
 account    include      common-account&lt;br /&gt;
 password   include      common-password&lt;br /&gt;
 session    optional     pam_keyinit.so force revoke&lt;br /&gt;
 session    include      common-session&lt;br /&gt;
 session    required     pam_loginuid.so&lt;br /&gt;
*** &#039;&#039;&#039;auth include common-auth --Server&#039;&#039;&#039;&lt;br /&gt;
 $echo &#039;UsePAM no&#039; &amp;gt;&amp;gt;/etc/ssh/sshd_config&lt;br /&gt;
 $vi /etc/ssh/sshd_config&lt;br /&gt;
  PermitEmptyPasswords yes &lt;br /&gt;
&lt;br /&gt;
 Other is as same as sudo&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 12 11:16:21 qemux86 sshd[650]: pam_unix(sshd:session): session opened for user test by (uid=0)&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
*** &#039;&#039;&#039;account required pam_nologin.so --Server&#039;&#039;&#039;&lt;br /&gt;
 $touch /etc/nologin&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow accession)&lt;br /&gt;
*** &#039;&#039;&#039;log information --Server&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 01:43:48 qemux86 sshd[672]: Accepted keyboard-interactive/pam for yxf from 192.168.7.1 port 59877 ssh2&lt;br /&gt;
 Jul 13 01:43:48 qemux86 sshd[672]: fatal: PAM: pam_setcred(): Failure setting user credentia&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;account include common-account --Server&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/ssh/sshd_config&lt;br /&gt;
  PermitEmptyPasswords no&lt;br /&gt;
 $vi /etc/pam.d/common-account &lt;br /&gt;
  #account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
  account [success=0 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow accession)&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 02:11:24 qemux86 sshd[752]: Failed password for root from 192.168.7.1 port 53784 ssh2&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;password include common-password&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so obscure sha512 &lt;br /&gt;
&lt;br /&gt;
 It&#039;s no use for sshd, So no test result for this item&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;session optional  pam_keyinit.so force revoke --Server&#039;&#039;&#039;&lt;br /&gt;
 No action&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 07:28:18 qemux86 sshd[1132]: pam_keyinit(sshd:session): OPEN 1&lt;br /&gt;
 Jul 13 07:28:18 qemux86 sshd[1132]: pam_keyinit(sshd:session): UID:1000 [0]  GID:1000 [0]&lt;br /&gt;
 Jul 13 07:28:18 qemux86 sshd[1132]: pam_keyinit(sshd:session): JOIN = 236576375&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;( the same session as the above &amp;quot;client&amp;quot;   )&lt;br /&gt;
 $exit&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 07:34:47 qemux86 sshd[1132]: pam_keyinit(sshd:session): CLOSE 1,236576375,1&lt;br /&gt;
 Jul 13 07:34:47 qemux86 sshd[1132]: pam_keyinit(sshd:session): REVOKE 236576375&lt;br /&gt;
 Jul 13 07:34:47 qemux86 sshd[1132]: pam_keyinit(sshd:session): UID:1000 [0]  GID:1000 [0]&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;session include common-session --Server&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/common-session&lt;br /&gt;
  #session [default=1] pam_permit.so&lt;br /&gt;
  session [default=0] pam_permit.so&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow accession)&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 05:53:35 qemux86 sshd[960]: error: PAM: pam_open_session(): Permission denied&lt;br /&gt;
 Jul 13 05:53:35 qemux86 sshd[960]: Received disconnect from 192.168.7.1: 11: disconnected by user&lt;br /&gt;
*** &#039;&#039;&#039; session required  pam_loginuid.so --Server&#039;&#039;&#039;(Record user´s login uid to the process attribute)&lt;br /&gt;
 No action&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 06:31:32 qemux86 sshd[1028]: pam_warn(sshd:session): function=[pam_sm_open_session] service=[sshd] terminal=[ssh] user=[yxf] ruser= [&amp;lt;unknown&amp;gt;] rhost=[ubuntuwindriver.local] &lt;br /&gt;
 Jul 13 06:31:32 qemux86 sshd[1028]: pam_unix(sshd:session): session opened for user yxf by (uid=0)&lt;br /&gt;
&lt;br /&gt;
=== polkit ===&lt;br /&gt;
Polkit includes four binaries. Only pkexec depends on pam. So I use pkexec to make pam test.&lt;br /&gt;
Pkexec allows an authorized user to execute PROGRAM as another user. If username is not specified, then the program will be executed as the administrative super user, root.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Pam configuration file of polkit &#039;&#039;&#039;&lt;br /&gt;
 %PAM-1.0&lt;br /&gt;
 auth       include      common-auth&lt;br /&gt;
 account    include      common-account&lt;br /&gt;
 password   include      common-password&lt;br /&gt;
 session    include      common-session&lt;br /&gt;
* &#039;&#039;&#039;Test Reult&#039;&#039;&#039;&lt;br /&gt;
*** &#039;&#039;&#039;Normally pkexec can call pam modules from the above configuration file&#039;&#039;&#039;&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
  ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
  Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
  Authenticating as: root&lt;br /&gt;
  Password: &amp;lt;---Input root password and press key &amp;quot;Enter&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 Jul 14 22:13:18 emenlow polkitd(authority=local): Registered Authentication Agent for unix-process:2466:778527 (system bus name :1.10 [pkexec  cat /var/log/auth.log], &lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)&lt;br /&gt;
 Jul 14 22:13:18 emenlow polkit-agent-helper-1[2501]: PAM pam_parse: expecting non-zero; [... default=ignore]&lt;br /&gt;
 Jul 14 22:13:18 emenlow polkit-agent-helper-1[2501]: PAM pam_parse: expecting non-zero; [... default=ignore]&lt;br /&gt;
 Jul 14 22:13:21 emenlow polkitd(authority=local): Unregistered Authentication Agent for unix-process:2466:778527 (system bus name :1.10,&lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)&lt;br /&gt;
 Jul 14 22:13:21 emenlow polkitd(authority=local): Operator of unix-process:2466:778527 FAILED to authenticate to gain authorization for action&lt;br /&gt;
 org.freedesktop.policykit.exec for unix-process:2466:778527 [sh] (owned by unix-user:yxf)&lt;br /&gt;
 Jul 14 22:14:37 emenlow polkitd(authority=local): Registered Authentication Agent for unix-process:2466:778527 (system bus name :1.11 [pkexec &lt;br /&gt;
 cat /var/log/auth.log], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)&lt;br /&gt;
 Jul 14 22:16:08 emenlow polkitd(authority=local): Operator of unix-process:2466:778527 successfully authenticated as unix-user:root to gain &lt;br /&gt;
 ONE-SHOT authorization for action org.freedesktop.policykit.exec for unix-process:2466:778527 [sh] (owned by unix-user:yxf)&lt;br /&gt;
 Jul 14 22:16:08 emenlow pkexec: pam_unix(polkit-1:session): session opened for user root by root(uid=500)&lt;br /&gt;
 Jul 14 22:16:08 emenlow pkexec[2507]: yxf: Executing command [USER=root] [TTY=/dev/pts/0] [CWD=/] [COMMAND=/bin/cat /var/log/auth.log]&lt;br /&gt;
 Jul 14 22:16:08 emenlow polkitd(authority=local): Unregistered Authentication Agent for unix-process:2466:778527 (system bus name :1.11, &lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)&lt;br /&gt;
*** &#039;&#039;&#039;auth include common-auth&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/common-auth&lt;br /&gt;
  #auth    [success=1 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
  auth    [success=0 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
 ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
 Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
 Authenticating as: root&lt;br /&gt;
 Password: &lt;br /&gt;
 polkit-agent-helper-1: pam_authenticate failed: Permission denied&lt;br /&gt;
 Error: Permission denied&lt;br /&gt;
 ==== AUTHENTICATION FAILED ===&lt;br /&gt;
 Error executing command as another user: Not authorized&lt;br /&gt;
 &lt;br /&gt;
 This incident has been reported.&lt;br /&gt;
&lt;br /&gt;
log information in /var/log/auth.log&lt;br /&gt;
 Jul 14 22:23:24 emenlow pkexec[2515]: yxf: Error executing command as another user: Not authorized [USER=root] [TTY=/dev/pts/0] [CWD=/] [COMMAND=/bin/cat /var/log/auth.log]&lt;br /&gt;
*** &#039;&#039;&#039;account include common-account&#039;&#039;&#039;&lt;br /&gt;
 $ vi /etc/pam.d/common-account&lt;br /&gt;
 #account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
 account [success=0 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
 ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
 Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
 Authenticating as: root&lt;br /&gt;
 Password: &lt;br /&gt;
 polkit-agent-helper-1: pam_acct_mgmt failed: Permission denied&lt;br /&gt;
 Error: Permission denied&lt;br /&gt;
 ==== AUTHENTICATION FAILED ===&lt;br /&gt;
 Error executing command as another user: Not authorized&lt;br /&gt;
&lt;br /&gt;
log information in /var/log/auth.log&lt;br /&gt;
 Jul 14 22:29:12 emenlow pkexec[2523]: yxf: Error executing command as another user: Not authorized [USER=root] [TTY=/dev/pts/0] [CWD=/] [COMMAND=/bin/cat /var/log/auth.log]&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;password include common-password&#039;&#039;&#039;&lt;br /&gt;
 It is no use for polkit. So I don&#039;t test it&lt;br /&gt;
*** &#039;&#039;&#039;session include common-session&#039;&#039;&#039;&lt;br /&gt;
 $ vi /etc/pam.d/common-session&lt;br /&gt;
 #session [default=1]                     pam_permit.so&lt;br /&gt;
 session [default=0]                     pam_permit.so&lt;br /&gt;
&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
 ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
 Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
 Authenticating as: root&lt;br /&gt;
 Password: &lt;br /&gt;
 ==== AUTHENTICATION COMPLETE ===&lt;br /&gt;
 pam_open_session() failed: Permission denied&lt;br /&gt;
&lt;br /&gt;
log information in /var/log/auth.log&lt;br /&gt;
 Jul 14 22:35:51 emenlow polkitd(authority=local): Unregistered Authentication Agent for unix-process:2466:778527 (system bus name :1.17, &lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)&lt;br /&gt;
&lt;br /&gt;
=== screen ===&lt;br /&gt;
screen use pam to authenticate users during unlock terminal. Its configure file screen comes from Fedora and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
&lt;br /&gt;
First start screen:&lt;br /&gt;
  root@qemux86:/etc/pam.d# screen&lt;br /&gt;
it will show some information about screen, just press Space or Enter and it will give a screen terminal:&lt;br /&gt;
  root@qemux86:/etc/pam.d# &lt;br /&gt;
then press &amp;quot;Ctrl+a x&amp;quot; will lock the screen terminal and show:&lt;br /&gt;
    &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
In another root terminal, clear the root&#039;s password:&lt;br /&gt;
  password -d root&lt;br /&gt;
&lt;br /&gt;
modify one line in common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
with&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so debug&lt;br /&gt;
option nullok_secure will allow users who has blank password login, after remove it these users are not allowed to login.&lt;br /&gt;
&lt;br /&gt;
Back to the screen terminal, press &amp;lt;Enter&amp;gt;(because root&#039;s password is blank now) will fail: &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
then modify the line in common-auth with &lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure debug&lt;br /&gt;
&lt;br /&gt;
On the screen terminal press &amp;lt;Enter&amp;gt; again it unlock the terminal.&lt;br /&gt;
&lt;br /&gt;
the log in /var/log/auth.log:&lt;br /&gt;
  Jul 11 14:14:14 qemux86 screen: pam_unix(screen:auth): authentication failure; logname=root uid=0 euid=0 tty= ruser= rhost=  user=root&lt;br /&gt;
&lt;br /&gt;
=== shadow ===&lt;br /&gt;
==== chage ====&lt;br /&gt;
/etc/pam.d/chage: need patch to replace system-auth to common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth		sufficient	pam_rootok.so&lt;br /&gt;
  account	required	pam_permit.so&lt;br /&gt;
  password	include		common-auth&lt;br /&gt;
* test pam_rootok.so&lt;br /&gt;
add the only option for pam_rootok.so&lt;br /&gt;
  auth		sufficient	pam_rootok.so debug&lt;br /&gt;
&lt;br /&gt;
run command chage as root:&lt;br /&gt;
  root@qemux86:/etc/pam.d# chage -m 10  test&lt;br /&gt;
&lt;br /&gt;
log info in /var/log/message shows pam_rootok.so return success:&lt;br /&gt;
  Jul 12 06:55:18 qemux86 authpriv.debug chage[575]: pam_rootok(chage:auth): root check succeeded&lt;br /&gt;
  Jul 12 06:55:18 qemux86 authpriv.info chage[575]: changed password expiry for test&lt;br /&gt;
&lt;br /&gt;
* test pam_unix.so&lt;br /&gt;
the content of common-auth are shown at section &amp;quot;Common configure files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
comment the pam_rootok.so line, because it will make pam return success:&lt;br /&gt;
  #auth		sufficient	pam_rootok.so&lt;br /&gt;
&lt;br /&gt;
and modify the pam_unix.so line in common-auth:&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so debug&lt;br /&gt;
&lt;br /&gt;
run commands:&lt;br /&gt;
  root@qemux86:/etc/pam.d# passwd -d root &lt;br /&gt;
  root@qemux86:/etc/pam.d# chfn -f testself test # test is a unprivileged user&lt;br /&gt;
  Password: &lt;br /&gt;
  chfn: PAM authentication failed&lt;br /&gt;
&lt;br /&gt;
log in /var/log/message:&lt;br /&gt;
  Jul 12 07:53:16 qemux86 authpriv.notice chfn[673]: pam_unix(chfn:auth): authentication failure; logname=root uid=0 euid=0 tty= ruser= rhost=  user=root&lt;br /&gt;
&lt;br /&gt;
==== chfn ====&lt;br /&gt;
/etc/pam.d/chfn&lt;br /&gt;
  auth	    sufficient	pam_rootok.so&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-account&lt;br /&gt;
  session    include      common-session&lt;br /&gt;
add option debug to pam_rootok.so&lt;br /&gt;
  auth	    sufficient	pam_rootok.so debug&lt;br /&gt;
&lt;br /&gt;
* pam_rootok.so&lt;br /&gt;
run command chfn as root:&lt;br /&gt;
  root@qemux86:/etc/pam.d# chfn -f testyayay test&lt;br /&gt;
&lt;br /&gt;
log info in /var/log/message shows pam_rootok.so return success:&lt;br /&gt;
  Jul 12 07:22:59 qemux86 authpriv.debug chfn[638]: pam_rootok(chfn:auth): root check succeeded&lt;br /&gt;
  Jul 12 07:22:59 qemux86 authpriv.info chfn[638]: changed user &#039;test&#039; information&lt;br /&gt;
&lt;br /&gt;
* pam_unix.so&lt;br /&gt;
please refer to chage test steps.&lt;br /&gt;
&lt;br /&gt;
==== chgpasswd ====&lt;br /&gt;
/etc/pam.d/chgpasswd(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth		sufficient	pam_rootok.so&lt;br /&gt;
  account	required	pam_permit.so&lt;br /&gt;
  password	include		system-auth&lt;br /&gt;
&lt;br /&gt;
test pam_rootok.so and pam_unix.so(common-auth) refer to test steps in chage &lt;br /&gt;
&lt;br /&gt;
==== chpasswd ====&lt;br /&gt;
/etc/pam.d/chpasswd&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
common-password are listed before, we change the pam_unix.so option:&lt;br /&gt;
  password	[success=1 default=ignore]	pam_unix.so  audit&lt;br /&gt;
&lt;br /&gt;
commands to test:&lt;br /&gt;
  root@qemux86:/etc/pam.d# chpasswd&lt;br /&gt;
  test:&lt;br /&gt;
  Press Ctrl+d, the follow are terminal output:&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  chpasswd: (user test) pam_chauthtok() failed, error:&lt;br /&gt;
  Authentication token manipulation error&lt;br /&gt;
  chpasswd: (line 1, user test) password not changed&lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 04:53:39 qemux86 authpriv.notice chpasswd[844]: pam_warn(chpasswd:auth): function=[pam_sm_authenticate] service=[chpasswd] terminal=[&amp;lt;unknown&amp;gt;] user=[root] ruser=[&amp;lt;unknown&amp;gt;] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul 15 04:53:39 qemux86 authpriv.notice chpasswd[844]: pam_warn(chpasswd:account): function=[pam_sm_acct_mgmt] service=[chpasswd] terminal=[&amp;lt;unknown&amp;gt;] user=[root] ruser=[&amp;lt;unknown&amp;gt;] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.notice chpasswd[844]: pam_unix(chpasswd:chauthtok): new password not acceptable&lt;br /&gt;
&lt;br /&gt;
==== chsh ====&lt;br /&gt;
/etc/pam.d/chsh&lt;br /&gt;
  auth       required   pam_shells.so&lt;br /&gt;
  auth       sufficient      pam_rootok.so&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-account&lt;br /&gt;
  session    include      common-session&lt;br /&gt;
* pam_shells.so&lt;br /&gt;
pam_shells only allows access to the system if the users shell is listed in /etc/shells.It also checks if /etc/shells is a plain file and not world writable.&lt;br /&gt;
&lt;br /&gt;
check /etc/shells first:&lt;br /&gt;
  qemux86:~$ ls -l /etc/shells &lt;br /&gt;
  -rw-r--r--    1 root     root           109 Jul 12 06:05 /etc/shells&lt;br /&gt;
  qemux86:~$ cat /etc/shells&lt;br /&gt;
  # /etc/shells: valid login shells&lt;br /&gt;
  /bin/sh&lt;br /&gt;
  /bin/ash&lt;br /&gt;
  /bin/bash&lt;br /&gt;
  /bin/dash&lt;br /&gt;
  /bin/ksh&lt;br /&gt;
  /usr/bin/ksh&lt;br /&gt;
  /usr/bin/screen&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
login as a unprivileged user, the correct process is:&lt;br /&gt;
  qemux86:~$ chsh -s /bin/ash&lt;br /&gt;
  Password: &amp;lt;-- Enter password here&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 06:15:18 qemux86 authpriv.debug chsh[1283]: pam_rootok(chsh:auth): root check failed&lt;br /&gt;
  Jul 15 06:15:21 qemux86 authpriv.info chsh[1283]: changed user &#039;test&#039; shell to &#039;/bin/ash&#039;&lt;br /&gt;
&lt;br /&gt;
now remove /bin/ash from /etc/shells, then run the same command:&lt;br /&gt;
  qemux86:~$ chsh -s /bin/ash&lt;br /&gt;
  Password: &amp;lt;-- Enter password here&lt;br /&gt;
  chsh: /bin/ash is an invalid shell.&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
if you make /etc/shells is writable to all people, chsh will fail with syslog info:&lt;br /&gt;
  Jul 15 05:38:38 qemux86 authpriv.err chsh[1091]: pam_shells(chsh:auth): /etc/shells is either world writable or not a normal file&lt;br /&gt;
&lt;br /&gt;
* pam_rootok.so&lt;br /&gt;
modify pam_rootok.so item:&lt;br /&gt;
  auth       required     pam_rootok.so debug&lt;br /&gt;
&lt;br /&gt;
then unprivileged users can&#039;t change their shell.&lt;br /&gt;
  qemux86:~$ chsh -s /bin/ash&lt;br /&gt;
  Password: &lt;br /&gt;
  chsh: PAM authentication failed&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 06:43:14 qemux86 authpriv.debug chsh[1350]: pam_rootok(chsh:auth): root check failed&lt;br /&gt;
&lt;br /&gt;
* pam_unix.so&lt;br /&gt;
**pam_unix in common-auth: please refer to sudo tests&lt;br /&gt;
**pam_unix in common-account and common-password don&#039;t have test point.&lt;br /&gt;
&lt;br /&gt;
==== groupadd ====&lt;br /&gt;
/etc/pam.d/groupadd(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
* pam_rootok&lt;br /&gt;
please refer to chage tests&lt;br /&gt;
&lt;br /&gt;
*pam_unix.so in common-password doesn&#039;t has test point&lt;br /&gt;
&lt;br /&gt;
==== groupdel ====&lt;br /&gt;
/etc/pam.d/groupdel(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
* pam_rootok&lt;br /&gt;
please refer to chage tests&lt;br /&gt;
&lt;br /&gt;
==== groupmems ====&lt;br /&gt;
/etc/pam.d/groupmems&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
*pam_rootok:&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
*pam_unix in common-password doesn&#039;t has test point&lt;br /&gt;
&lt;br /&gt;
==== groupmod ====&lt;br /&gt;
/etc/pam.d/groupmod&lt;br /&gt;
#%PAM-1.0&lt;br /&gt;
auth           sufficient      pam_rootok.so&lt;br /&gt;
account         required        pam_permit.so&lt;br /&gt;
password        include         common-password&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix: FIXME&lt;br /&gt;
&lt;br /&gt;
==== login ====&lt;br /&gt;
/etc/pam.d/login&lt;br /&gt;
  auth       optional   pam_faildelay.so  delay=3000000&lt;br /&gt;
  auth       [success=ok ignore=ignore user_unknown=ignore default=die]  pam_securetty.so&lt;br /&gt;
  auth       requisite  pam_nologin.so&lt;br /&gt;
  session       required   pam_env.so readenv=1&lt;br /&gt;
  session       required   pam_env.so readenv=1 envfile=/etc/default/locale&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  auth       optional   pam_group.so&lt;br /&gt;
  session    required   pam_limits.so                                      &lt;br /&gt;
  session    optional   pam_lastlog.so                                     &lt;br /&gt;
  session    optional   pam_motd.so                              &lt;br /&gt;
  session    optional   pam_mail.so standard                    &lt;br /&gt;
                                                              &lt;br /&gt;
  account    include      common-account                        &lt;br /&gt;
  password   include      common-password                       &lt;br /&gt;
  session    include      common-session&lt;br /&gt;
&lt;br /&gt;
==== newusers ====&lt;br /&gt;
/etc/pam.d/newusers&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
&lt;br /&gt;
*pam_unix&lt;br /&gt;
modify the pam_unix item in common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so debug &lt;br /&gt;
&lt;br /&gt;
run command:&lt;br /&gt;
  root@qemux86:~# newusers&lt;br /&gt;
  a::::::&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  newusers: (user a) pam_chauthtok() failed, error:&lt;br /&gt;
  Authentication token manipulation error&lt;br /&gt;
  newusers: (line 1, user a) password not changed&lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): username [a] obtained&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): username [a] obtained&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.notice newusers[1560]: pam_unix(newusers:chauthtok): new password not acceptable&lt;br /&gt;
&lt;br /&gt;
==== passwd ====&lt;br /&gt;
/etc/pam.d/passwd&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password&lt;br /&gt;
modify the item to make password length not less than 4 characters:&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so minlen=4 debug&lt;br /&gt;
&lt;br /&gt;
run test commands:&lt;br /&gt;
  qemux86:~$ passwd&lt;br /&gt;
  Changing password for test.&lt;br /&gt;
  (current) UNIX password: &amp;lt;-- input 123 here&lt;br /&gt;
  Enter new UNIX password: &lt;br /&gt;
  Retype new UNIX password: &lt;br /&gt;
  You must choose a longer password&lt;br /&gt;
  Enter new UNIX password: &amp;lt;-- input 1234 here&lt;br /&gt;
  Retype new UNIX password: &lt;br /&gt;
  passwd: password updated successfully&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
syslog doesn&#039;t has detail informatiaon&lt;br /&gt;
  Jul 17 02:00:39 qemux86 authpriv.debug passwd[1649]: pam_unix(passwd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 17 02:00:41 qemux86 authpriv.debug passwd[1649]: pam_unix(passwd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 17 02:00:49 qemux86 authpriv.notice passwd[1649]: pam_unix(passwd:chauthtok): password changed for test&lt;br /&gt;
&lt;br /&gt;
==== su ====&lt;br /&gt;
/etc/pam.d/su&lt;br /&gt;
==== useradd ====&lt;br /&gt;
/etc/pam.d/useradd(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password： FIXME&lt;br /&gt;
&lt;br /&gt;
==== userdel ====&lt;br /&gt;
/etc/pam.d/userdel(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password: &lt;br /&gt;
no test point&lt;br /&gt;
&lt;br /&gt;
==== usermod ==== &lt;br /&gt;
/etc/pam.d/usermod(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password： FIXME&lt;br /&gt;
&lt;br /&gt;
=== sudo ===&lt;br /&gt;
*/etc/pam.d/sudo comes from Fedora, and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-account&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
  session    required     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
and content of common-auth has been show above.&lt;br /&gt;
&lt;br /&gt;
*test pam plugins&lt;br /&gt;
**pam_unix.so&lt;br /&gt;
modify common-auth:&lt;br /&gt;
  auth    [success=1 default=ignore]      pam_unix.so debug&lt;br /&gt;
then unpriviledge user can NOT run sudo with blank password&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 16:39:04 qemux86 sudo: pam_unix(sudo:auth): authentication failure; logname=test-pam uid=0 euid=0 tty=/dev/pts/1 ruser=test-pam rhost=  user=test-pam&lt;br /&gt;
  Jul  8 16:39:14 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
**pam_deny.so&lt;br /&gt;
mv line&lt;br /&gt;
  auth    requisite                       pam_deny.so&lt;br /&gt;
to the head of file, unprivilege user can NOT sudo any more:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 14:03:29 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
**pam_permit.so&lt;br /&gt;
comment this line&lt;br /&gt;
  auth    required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
sudo will fail without ask user to enter password:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 12:43:22 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm -f /test&lt;br /&gt;
&lt;br /&gt;
**pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf&lt;br /&gt;
  *        -       nofile       3&lt;br /&gt;
then sudo will fail:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Inconsistency detected by ld.so: dl-deps.c: 622: _dl_map_object_deps: Assertion `nlist &amp;gt; 1&#039; failed!&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
  *        -       nofile       4&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 3 for DEFAULT&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 4 for DEFAULT&lt;br /&gt;
&lt;br /&gt;
** pam_keyinit&lt;br /&gt;
add option debug&lt;br /&gt;
  session    optional     pam_keyinit.so revoke debug&lt;br /&gt;
&lt;br /&gt;
log shows pam_keyinit was called:&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): OPEN 1&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): UID:0 [0]  GID:0 [1000]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 143761918&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 669161571&lt;br /&gt;
&lt;br /&gt;
according the source code pam_keyinit.c line 102 in function init_keyrings, the module return PAM_SUCCESS&lt;br /&gt;
&lt;br /&gt;
=== util-linux ===&lt;br /&gt;
Three programs chfn chsh and login in util-linux will use libpam. Right now these programs are provided by package shadow. In util-linux.inc, EXTRA_OECONF has option &amp;quot;--disable-login-utils &amp;quot; which will disable to build them.&lt;br /&gt;
&lt;br /&gt;
Drop it.&lt;br /&gt;
&lt;br /&gt;
=== xserver-xf86-lite ===&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
&lt;br /&gt;
* mc: mc has remove package mcserv and dropped dependency on PAM already, but didn&#039;t remove checking security/pam_misc.h. Drop it. [http://www.midnight-commander.org/changeset/4816107a02ccbf6331534113e6ec0c8df84e24eb Official change log]&lt;br /&gt;
* libcap: if pam exists, libcap will create a pam plugin pam_cap.so to add a new front end for the authentication function. Because it is not a application, remove it from list.&lt;br /&gt;
* libuser: pam is libuser&#039;s build dependency, so remove it too.&lt;br /&gt;
* The busybox login has a option to use pam, but we use tinylogin&#039;s login right now (tinylogin also provides the su command)&lt;br /&gt;
* gettext only has a example &amp;quot;hello-c++-kde&amp;quot; use pam under source code directory, and it doen&#039;t be compiled and only copied to destination. So omit gettext.&lt;br /&gt;
* sysvinit has a patch contrib/notify-pam-dead.patch for /sbin/init to use pam, but the whole contrib directory didn&#039;t take part in compilation. Drop it.&lt;br /&gt;
&lt;br /&gt;
== Identify upstream PAM patches to use ==&lt;br /&gt;
After checking the Fedora develop repository, the following packages may need patches(only libpam need to upgrade, other patches are pam related configure file but they are absent in poky):&lt;br /&gt;
* libpam: need update from current 1.1.3 to 1.1.4 [https://www.redhat.com/archives/pam-list/2011-June/msg00013.html Release Notes]&lt;br /&gt;
* sudo: package sudo in Fedora provides /etc/pam.d/sudo and /etc/pam.d/sudo-i&lt;br /&gt;
** /etc/pam.d/sudo (Yocto use common-auth instead of system-auth)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      system-auth&lt;br /&gt;
  account    include      system-auth&lt;br /&gt;
  password   include      system-auth&lt;br /&gt;
  session    optional     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
&lt;br /&gt;
* screen: check Fedora screen.pam&lt;br /&gt;
&lt;br /&gt;
* util-linux: check Fedora source file util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* at: check Fedora util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* cups: check Fedora cups-1.1.16-system-auth.patch&lt;br /&gt;
&lt;br /&gt;
* openssh: check Fedora sshd.pam&lt;br /&gt;
&lt;br /&gt;
== PAM Unit Tests==&lt;br /&gt;
We use unit test cases provided by libpam itself, a subdirectory with name &amp;quot;xtests&amp;quot; under libpam source code.&lt;br /&gt;
&lt;br /&gt;
On build machine run &lt;br /&gt;
  bitbake libpam -c patch&lt;br /&gt;
to get the libpam source code Linux-PAM-1.1.4, and scp it to host(target) machine. &lt;br /&gt;
&lt;br /&gt;
On the target machine under Linux-PAM-1.1.4, run&lt;br /&gt;
  ./configure&lt;br /&gt;
  make xtests&lt;br /&gt;
will get the test result of 28 unit test case. If you want to run sigle test case, go to subdirectory xtests and run (take tst-pam_time1 for example)&lt;br /&gt;
  ./run-xtests.sh . tst-pam_time1&lt;br /&gt;
&lt;br /&gt;
Some unit test can NOT pass(15/28), they need some pam plugin libraies:&lt;br /&gt;
* tst-pam_access1&lt;br /&gt;
* tst-pam_access2&lt;br /&gt;
* tst-pam_access3&lt;br /&gt;
* tst-pam_access4&lt;br /&gt;
**the tst-pam_access test cases need pam_access.so, install package pam-plugin-access will make them pass the test&lt;br /&gt;
* tst-pam_authsucceed&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_cracklib1&lt;br /&gt;
* tst-pam_cracklib2&lt;br /&gt;
**need /lib/security/pam_cracklib.so, need build cracklib, and then libpam will check it and create pam-plugin-cracklib&lt;br /&gt;
**need /usr/share/cracklib/pw_dict.pwd file, please run command on host machine:&lt;br /&gt;
    create-cracklib-dict /usr/share/cracklib/cracklib-small&lt;br /&gt;
&lt;br /&gt;
* tst-pam_dispatch1&lt;br /&gt;
* tst-pam_dispatch2&lt;br /&gt;
* tst-pam_dispatch3&lt;br /&gt;
* tst-pam_dispatch4&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_pwhistory1&lt;br /&gt;
**need /lib/security/pam_pwhistory.so, install pam-plugin-pwhistory to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_substack2&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_succeed_if1&lt;br /&gt;
**install pam-plugin-succeed-if to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_time1&lt;br /&gt;
**install pam-plugin-time to make it pass&lt;/div&gt;</summary>
		<author><name>Wfan</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2800</id>
		<title>PAM Integration</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2800"/>
		<updated>2011-07-14T06:49:03Z</updated>

		<summary type="html">&lt;p&gt;Wfan: /* cronie */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Motivation ==&lt;br /&gt;
For Yocto 1.1 we are working to ensure that PAM (Pluggable Authentication Module) support is consistent and enabled in recipes where it is applicable. &lt;br /&gt;
&lt;br /&gt;
== Common configure files ==&lt;br /&gt;
For convenience, list common configure files here:&lt;br /&gt;
&lt;br /&gt;
common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
  auth	requisite			pam_deny.so&lt;br /&gt;
  auth	required			pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-account&lt;br /&gt;
  account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so &lt;br /&gt;
  account requisite                       pam_deny.so&lt;br /&gt;
  account required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so obscure sha512&lt;br /&gt;
  password        requisite                       pam_deny.so&lt;br /&gt;
  password        required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-session&lt;br /&gt;
  session [default=1]                     pam_permit.so&lt;br /&gt;
  session requisite                       pam_deny.so&lt;br /&gt;
  session required                        pam_permit.so&lt;br /&gt;
  session required        pam_unix.so &lt;br /&gt;
&lt;br /&gt;
common-session-noninteractive&lt;br /&gt;
  session [default=1]                     pam_permit.so&lt;br /&gt;
  session requisite                       pam_deny.so&lt;br /&gt;
  session required                        pam_permit.so&lt;br /&gt;
  session required        pam_unix.so &lt;br /&gt;
&lt;br /&gt;
== Recipes with PAM support ==&lt;br /&gt;
The following recipes were identified to have PAM support (some already implemented) on 2011-06-27:&lt;br /&gt;
&lt;br /&gt;
=== at === &lt;br /&gt;
* Open issue:&lt;br /&gt;
** It can&#039;t be ran by a non-root user, error message is:&lt;br /&gt;
 Can&#039;t signal atd (permission denied)&lt;br /&gt;
&lt;br /&gt;
* Simple ways to verify &#039;at&#039;:&lt;br /&gt;
 $ at now&lt;br /&gt;
 $ echo &amp;quot;$msg_to_print&amp;quot; &amp;gt;&amp;gt; /tmp/at_test&lt;br /&gt;
 $ &amp;lt; ctrl+D &amp;gt;&lt;br /&gt;
 $ cat /tmp/at_test    # Verify if the message has been there &lt;br /&gt;
&lt;br /&gt;
* /etc/pam.d/atd - not installed by default, copy it from source code and replace &#039;@include&#039; with appropriate &#039;module-type include&#039;:&lt;br /&gt;
&lt;br /&gt;
 auth       required    pam_env.so&lt;br /&gt;
 auth       include     common-auth&lt;br /&gt;
 account    include     common-account&lt;br /&gt;
 session    include     common-session-noninteractive&lt;br /&gt;
 session    required    pam_limits.so&lt;br /&gt;
&lt;br /&gt;
* test pam plugins&lt;br /&gt;
** pam_env.so&lt;br /&gt;
modify /etc/pam.d/atd&lt;br /&gt;
 auth       required    pam_env.so    debug&lt;br /&gt;
modify /etc/security/pam_env.conf, add a test entry such as:&lt;br /&gt;
 MYNAME          DEFAULT=&amp;quot;test-at&amp;quot;&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:41:22 qemux86 atd[678]: pam_env(atd:setcred): pam_putenv(&amp;quot;MYNAME=test-at&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
** pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf &lt;br /&gt;
 root    -       nofile  3&lt;br /&gt;
&#039;at&#039; job failed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:49:42 qemux86 atd[699]: pam_env(atd:setcred): Unable to open config file: /etc/security/pam_env.conf: Too many open files&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
 root    -       nofile  4&lt;br /&gt;
&#039;at&#039; job successed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session opened for user root by (uid=0)                      &lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session closed for user root&lt;br /&gt;
&lt;br /&gt;
=== consolekit ===&lt;br /&gt;
Consolekit provides a pam plugin module pam_ck_connector.so and not the package that use pam.&lt;br /&gt;
Drop it.&lt;br /&gt;
&lt;br /&gt;
=== cronie ===&lt;br /&gt;
* /etc/pam.d/crond:&lt;br /&gt;
 account    required   pam_access.so&lt;br /&gt;
 account    include    password-auth&lt;br /&gt;
 session    required   pam_loginuid.so&lt;br /&gt;
 session    include    password-auth&lt;br /&gt;
 auth       include    password-auth&lt;br /&gt;
&lt;br /&gt;
* /etc/pam.d/password-auth:&lt;br /&gt;
 auth        required      pam_env.so&lt;br /&gt;
 auth        sufficient    pam_unix.so nullok try_first_pass&lt;br /&gt;
 auth        requisite     pam_succeed_if.so uid &amp;gt;= 500 quiet&lt;br /&gt;
 auth        required      pam_deny.so&lt;br /&gt;
 account     required      pam_unix.so&lt;br /&gt;
 account     sufficient    pam_localuser.so&lt;br /&gt;
 account     sufficient    pam_succeed_if.so uid &amp;lt; 500 quiet&lt;br /&gt;
 account     required      pam_permit.so&lt;br /&gt;
 password    requisite     pam_cracklib.so try_first_pass retry=3 type=&lt;br /&gt;
 password    sufficient    pam_unix.so sha512 shadow nullok try_first_pass use_authtok&lt;br /&gt;
 password    required      pam_deny.so&lt;br /&gt;
 session     optional      pam_keyinit.so revoke&lt;br /&gt;
 session     required      pam_limits.so&lt;br /&gt;
 -session     optional      pam_systemd.so&lt;br /&gt;
 session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid&lt;br /&gt;
 session     required      pam_unix.so&lt;br /&gt;
&lt;br /&gt;
* test commands:&lt;br /&gt;
 crontab -e    # establish a crontab jobs and check if it works&lt;br /&gt;
 crontab -l    # list crontab jobs for current user&lt;br /&gt;
&lt;br /&gt;
* test pam plugins&lt;br /&gt;
Verified, test ways and the logs/results please refer to other packages:&lt;br /&gt;
** pam_env.so&lt;br /&gt;
** pam_access.so&lt;br /&gt;
** pam_unix.so&lt;br /&gt;
** pam_permit.so&lt;br /&gt;
** pam_keyinit.so &lt;br /&gt;
&lt;br /&gt;
** pam_localuser.so&lt;br /&gt;
copy &#039;/etc/passwd&#039; to &#039;/tmp/passwd&#039; and delete the entry for &#039;root&#039;;&lt;br /&gt;
modify /etc/pam.d/password-auth:&lt;br /&gt;
 account     requisite    pam_localuser.so file=/tmp/passwd debug&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): set filename to &amp;quot;/tmp/passwd&amp;quot;&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): checking &amp;quot;daemon:x:1:1:daemon:/usr/sbin:/bin/sh &amp;quot;&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): checking &amp;quot;bin:x:2:2:bin:/bin:/bin/sh &amp;quot;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
** pam_succeed_if.so&lt;br /&gt;
account     requisite    pam_succeed_if.so uid &amp;gt; 500 debug&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 12 03:14:14 qemux86 crontab: pam_succeed_if(crond:account): &#039;uid&#039; resolves to &#039;0&#039;&lt;br /&gt;
 Jul 12 03:14:14 qemux86 crontab: pam_succeed_if(crond:account): requirement &amp;quot;uid &amp;gt; 500&amp;quot; not met by user &amp;quot;root&amp;quot;&lt;br /&gt;
&lt;br /&gt;
** pam_loginuid.so&lt;br /&gt;
 TBD&lt;br /&gt;
&lt;br /&gt;
** pam_systemd.so&lt;br /&gt;
 no this module&lt;br /&gt;
&lt;br /&gt;
=== cups ===&lt;br /&gt;
&lt;br /&gt;
=== dropbear ===&lt;br /&gt;
** For supporting pam in dropbear, we need two steps:&lt;br /&gt;
** Add configuration &amp;quot;--enable-pam&amp;quot; &lt;br /&gt;
** Add patches to open macro definition for supporting in option.h&lt;br /&gt;
 --- a/ptions.h  2011-07-12 11:32:34.165333202 +0800&lt;br /&gt;
 +++ b/options.h.new     2011-07-12 11:33:25.757332986 +0800&lt;br /&gt;
 @@ -149,9 +149,9 @@&lt;br /&gt;
   * but there&#039;s an interface via a PAM module - don&#039;t bother using it otherwise.&lt;br /&gt;
   * You can&#039;t enable both PASSWORD and PAM. */&lt;br /&gt;
 -#define ENABLE_SVR_PASSWORD_AUTH&lt;br /&gt;
 +//#define ENABLE_SVR_PASSWORD_AUTH&lt;br /&gt;
  /* PAM requires ./configure --enable-pam */&lt;br /&gt;
 -/*#define ENABLE_SVR_PAM_AUTH*/&lt;br /&gt;
 +#define ENABLE_SVR_PAM_AUTH&lt;br /&gt;
  #define ENABLE_SVR_PUBKEY_AUTH&lt;br /&gt;
  /* Wether to ake public key options in authorized_keys file into account */&lt;br /&gt;
&lt;br /&gt;
** Test result(dropbeat only support simple authentication, account and auth)&lt;br /&gt;
*** &#039;&#039;&#039;Server(account)&#039;&#039;&#039;&lt;br /&gt;
 (server ip:192.168.7.2)&lt;br /&gt;
 $touch /etc/pam.d/sshd&lt;br /&gt;
 account  required     pam_access.so&lt;br /&gt;
 $vi /etc/security/access.conf&lt;br /&gt;
 - : root : ALL&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow access)&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;Server(auth)&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/sshd&lt;br /&gt;
  auth include common-auth&lt;br /&gt;
 $vi /etc/pam.d/common-auth&lt;br /&gt;
 #auth   [success=1 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
 auth    [success=0 default=ignore]      pam_unix.so debug&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow access)&lt;br /&gt;
&lt;br /&gt;
=== gnome-keyring ===&lt;br /&gt;
* gnome-keyring can&#039;t call configuration file like &amp;quot;/etc/pam.d/gnome-keyring&amp;quot; because it is called by other program like &amp;quot;gnome-screensave&amp;quot; and &amp;quot;gdm&amp;quot;. If we want test &amp;quot;pam_gnome_keyring.so&amp;quot;, we need write .bb files to cross-compile gnome-screensave or gdm.&lt;br /&gt;
&lt;br /&gt;
=== openssh ===&lt;br /&gt;
** Absent configuration /etc/pam.d/sshd, we need to add patches. After adding this file, it can support pam function through simple test.&lt;br /&gt;
** Test Result&lt;br /&gt;
*** &#039;&#039;&#039;Configuration of sshd&#039;&#039;&#039;&lt;br /&gt;
 auth       include      common-auth&lt;br /&gt;
 account    required     pam_nologin.so&lt;br /&gt;
 account    include      common-account&lt;br /&gt;
 password   include      common-password&lt;br /&gt;
 session    optional     pam_keyinit.so force revoke&lt;br /&gt;
 session    include      common-session&lt;br /&gt;
 session    required     pam_loginuid.so&lt;br /&gt;
*** &#039;&#039;&#039;auth include common-auth --Server&#039;&#039;&#039;&lt;br /&gt;
 $echo &#039;UsePAM no&#039; &amp;gt;&amp;gt;/etc/ssh/sshd_config&lt;br /&gt;
 $vi /etc/ssh/sshd_config&lt;br /&gt;
  PermitEmptyPasswords yes &lt;br /&gt;
&lt;br /&gt;
 Other is as same as sudo&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 12 11:16:21 qemux86 sshd[650]: pam_unix(sshd:session): session opened for user test by (uid=0)&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
*** &#039;&#039;&#039;account required pam_nologin.so --Server&#039;&#039;&#039;&lt;br /&gt;
 $touch /etc/nologin&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow accession)&lt;br /&gt;
*** &#039;&#039;&#039;log information --Server&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 01:43:48 qemux86 sshd[672]: Accepted keyboard-interactive/pam for yxf from 192.168.7.1 port 59877 ssh2&lt;br /&gt;
 Jul 13 01:43:48 qemux86 sshd[672]: fatal: PAM: pam_setcred(): Failure setting user credentia&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;account include common-account --Server&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/ssh/sshd_config&lt;br /&gt;
  PermitEmptyPasswords no&lt;br /&gt;
 $vi /etc/pam.d/common-account &lt;br /&gt;
  #account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
  account [success=0 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow accession)&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 02:11:24 qemux86 sshd[752]: Failed password for root from 192.168.7.1 port 53784 ssh2&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;password include common-password&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so obscure sha512 &lt;br /&gt;
&lt;br /&gt;
 It&#039;s no use for sshd, So no test result for this item&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;session optional  pam_keyinit.so force revoke --Server&#039;&#039;&#039;&lt;br /&gt;
 No action&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 07:28:18 qemux86 sshd[1132]: pam_keyinit(sshd:session): OPEN 1&lt;br /&gt;
 Jul 13 07:28:18 qemux86 sshd[1132]: pam_keyinit(sshd:session): UID:1000 [0]  GID:1000 [0]&lt;br /&gt;
 Jul 13 07:28:18 qemux86 sshd[1132]: pam_keyinit(sshd:session): JOIN = 236576375&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;( the same session as the above &amp;quot;client&amp;quot;   )&lt;br /&gt;
 $exit&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 07:34:47 qemux86 sshd[1132]: pam_keyinit(sshd:session): CLOSE 1,236576375,1&lt;br /&gt;
 Jul 13 07:34:47 qemux86 sshd[1132]: pam_keyinit(sshd:session): REVOKE 236576375&lt;br /&gt;
 Jul 13 07:34:47 qemux86 sshd[1132]: pam_keyinit(sshd:session): UID:1000 [0]  GID:1000 [0]&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;session include common-session --Server&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/common-session&lt;br /&gt;
  #session [default=1] pam_permit.so&lt;br /&gt;
  session [default=0] pam_permit.so&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (Disallow accession)&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 05:53:35 qemux86 sshd[960]: error: PAM: pam_open_session(): Permission denied&lt;br /&gt;
 Jul 13 05:53:35 qemux86 sshd[960]: Received disconnect from 192.168.7.1: 11: disconnected by user&lt;br /&gt;
*** &#039;&#039;&#039; session required  pam_loginuid.so --Server&#039;&#039;&#039;(Record user´s login uid to the process attribute)&lt;br /&gt;
 No action&lt;br /&gt;
*** &#039;&#039;&#039;Client&#039;&#039;&#039;&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
*** &#039;&#039;&#039;log information&#039;&#039;&#039;&lt;br /&gt;
 Jul 13 06:31:32 qemux86 sshd[1028]: pam_warn(sshd:session): function=[pam_sm_open_session] service=[sshd] terminal=[ssh] user=[yxf] ruser= [&amp;lt;unknown&amp;gt;] rhost=[ubuntuwindriver.local] &lt;br /&gt;
 Jul 13 06:31:32 qemux86 sshd[1028]: pam_unix(sshd:session): session opened for user yxf by (uid=0)&lt;br /&gt;
&lt;br /&gt;
=== polkit ===&lt;br /&gt;
Polkit includes four binaries. Only pkexec depends on pam. So I use pkexec to make pam test.&lt;br /&gt;
Pkexec allows an authorized user to execute PROGRAM as another user. If username is not specified, then the program will be executed as the administrative super user, root.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Pam configuration file of polkit &#039;&#039;&#039;&lt;br /&gt;
 %PAM-1.0&lt;br /&gt;
 auth       include      common-auth&lt;br /&gt;
 account    include      common-account&lt;br /&gt;
 password   include      common-password&lt;br /&gt;
 session    include      common-session&lt;br /&gt;
* &#039;&#039;&#039;Test Reult&#039;&#039;&#039;&lt;br /&gt;
*** &#039;&#039;&#039;Normally pkexec can call pam modules from the above configuration file&#039;&#039;&#039;&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
  ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
  Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
  Authenticating as: root&lt;br /&gt;
  Password: &amp;lt;---Input root password and press key &amp;quot;Enter&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 Jul 14 22:13:18 emenlow polkitd(authority=local): Registered Authentication Agent for unix-process:2466:778527 (system bus name :1.10 [pkexec  cat /var/log/auth.log], &lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)&lt;br /&gt;
 Jul 14 22:13:18 emenlow polkit-agent-helper-1[2501]: PAM pam_parse: expecting non-zero; [... default=ignore]&lt;br /&gt;
 Jul 14 22:13:18 emenlow polkit-agent-helper-1[2501]: PAM pam_parse: expecting non-zero; [... default=ignore]&lt;br /&gt;
 Jul 14 22:13:21 emenlow polkitd(authority=local): Unregistered Authentication Agent for unix-process:2466:778527 (system bus name :1.10,&lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)&lt;br /&gt;
 Jul 14 22:13:21 emenlow polkitd(authority=local): Operator of unix-process:2466:778527 FAILED to authenticate to gain authorization for action&lt;br /&gt;
 org.freedesktop.policykit.exec for unix-process:2466:778527 [sh] (owned by unix-user:yxf)&lt;br /&gt;
 Jul 14 22:14:37 emenlow polkitd(authority=local): Registered Authentication Agent for unix-process:2466:778527 (system bus name :1.11 [pkexec &lt;br /&gt;
 cat /var/log/auth.log], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)&lt;br /&gt;
 Jul 14 22:16:08 emenlow polkitd(authority=local): Operator of unix-process:2466:778527 successfully authenticated as unix-user:root to gain &lt;br /&gt;
 ONE-SHOT authorization for action org.freedesktop.policykit.exec for unix-process:2466:778527 [sh] (owned by unix-user:yxf)&lt;br /&gt;
 Jul 14 22:16:08 emenlow pkexec: pam_unix(polkit-1:session): session opened for user root by root(uid=500)&lt;br /&gt;
 Jul 14 22:16:08 emenlow pkexec[2507]: yxf: Executing command [USER=root] [TTY=/dev/pts/0] [CWD=/] [COMMAND=/bin/cat /var/log/auth.log]&lt;br /&gt;
 Jul 14 22:16:08 emenlow polkitd(authority=local): Unregistered Authentication Agent for unix-process:2466:778527 (system bus name :1.11, &lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)&lt;br /&gt;
*** &#039;&#039;&#039;auth include common-auth&#039;&#039;&#039;&lt;br /&gt;
 $vi /etc/pam.d/common-auth&lt;br /&gt;
  #auth    [success=1 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
  auth    [success=0 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
 ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
 Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
 Authenticating as: root&lt;br /&gt;
 Password: &lt;br /&gt;
 polkit-agent-helper-1: pam_authenticate failed: Permission denied&lt;br /&gt;
 Error: Permission denied&lt;br /&gt;
 ==== AUTHENTICATION FAILED ===&lt;br /&gt;
 Error executing command as another user: Not authorized&lt;br /&gt;
 &lt;br /&gt;
 This incident has been reported.&lt;br /&gt;
&lt;br /&gt;
log information in /var/log/auth.log&lt;br /&gt;
 Jul 14 22:23:24 emenlow pkexec[2515]: yxf: Error executing command as another user: Not authorized [USER=root] [TTY=/dev/pts/0] [CWD=/] [COMMAND=/bin/cat /var/log/auth.log]&lt;br /&gt;
*** &#039;&#039;&#039;account include common-account&#039;&#039;&#039;&lt;br /&gt;
 $ vi /etc/pam.d/common-account&lt;br /&gt;
 #account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
 account [success=0 new_authtok_reqd=done default=ignore]        pam_unix.so&lt;br /&gt;
&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
 ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
 Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
 Authenticating as: root&lt;br /&gt;
 Password: &lt;br /&gt;
 polkit-agent-helper-1: pam_acct_mgmt failed: Permission denied&lt;br /&gt;
 Error: Permission denied&lt;br /&gt;
 ==== AUTHENTICATION FAILED ===&lt;br /&gt;
 Error executing command as another user: Not authorized&lt;br /&gt;
&lt;br /&gt;
log information in /var/log/auth.log&lt;br /&gt;
 Jul 14 22:29:12 emenlow pkexec[2523]: yxf: Error executing command as another user: Not authorized [USER=root] [TTY=/dev/pts/0] [CWD=/] [COMMAND=/bin/cat /var/log/auth.log]&lt;br /&gt;
&lt;br /&gt;
*** &#039;&#039;&#039;password include common-password&#039;&#039;&#039;&lt;br /&gt;
 It is no use for polkit. So I don&#039;t test it&lt;br /&gt;
*** &#039;&#039;&#039;session include common-session&#039;&#039;&#039;&lt;br /&gt;
 $ vi /etc/pam.d/common-session&lt;br /&gt;
 #session [default=1]                     pam_permit.so&lt;br /&gt;
 session [default=0]                     pam_permit.so&lt;br /&gt;
&lt;br /&gt;
 $ pkexec cat /var/log/auth.log &lt;br /&gt;
 ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===&lt;br /&gt;
 Authentication is needed to run `/bin/cat&#039; as the super user&lt;br /&gt;
 Authenticating as: root&lt;br /&gt;
 Password: &lt;br /&gt;
 ==== AUTHENTICATION COMPLETE ===&lt;br /&gt;
 pam_open_session() failed: Permission denied&lt;br /&gt;
&lt;br /&gt;
log information in /var/log/auth.log&lt;br /&gt;
 Jul 14 22:35:51 emenlow polkitd(authority=local): Unregistered Authentication Agent for unix-process:2466:778527 (system bus name :1.17, &lt;br /&gt;
 object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)&lt;br /&gt;
&lt;br /&gt;
=== screen ===&lt;br /&gt;
screen use pam to authenticate users during unlock terminal. Its configure file screen comes from Fedora and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
&lt;br /&gt;
First start screen:&lt;br /&gt;
  root@qemux86:/etc/pam.d# screen&lt;br /&gt;
it will show some information about screen, just press Space or Enter and it will give a screen terminal:&lt;br /&gt;
  root@qemux86:/etc/pam.d# &lt;br /&gt;
then press &amp;quot;Ctrl+a x&amp;quot; will lock the screen terminal and show:&lt;br /&gt;
    &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
In another root terminal, clear the root&#039;s password:&lt;br /&gt;
  password -d root&lt;br /&gt;
&lt;br /&gt;
modify one line in common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
with&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so debug&lt;br /&gt;
option nullok_secure will allow users who has blank password login, after remove it these users are not allowed to login.&lt;br /&gt;
&lt;br /&gt;
Back to the screen terminal, press &amp;lt;Enter&amp;gt;(because root&#039;s password is blank now) will fail: &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
then modify the line in common-auth with &lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure debug&lt;br /&gt;
&lt;br /&gt;
On the screen terminal press &amp;lt;Enter&amp;gt; again it unlock the terminal.&lt;br /&gt;
&lt;br /&gt;
the log in /var/log/auth.log:&lt;br /&gt;
  Jul 11 14:14:14 qemux86 screen: pam_unix(screen:auth): authentication failure; logname=root uid=0 euid=0 tty= ruser= rhost=  user=root&lt;br /&gt;
&lt;br /&gt;
=== shadow ===&lt;br /&gt;
==== chage ====&lt;br /&gt;
/etc/pam.d/chage: need patch to replace system-auth to common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth		sufficient	pam_rootok.so&lt;br /&gt;
  account	required	pam_permit.so&lt;br /&gt;
  password	include		common-auth&lt;br /&gt;
* test pam_rootok.so&lt;br /&gt;
add the only option for pam_rootok.so&lt;br /&gt;
  auth		sufficient	pam_rootok.so debug&lt;br /&gt;
&lt;br /&gt;
run command chage as root:&lt;br /&gt;
  root@qemux86:/etc/pam.d# chage -m 10  test&lt;br /&gt;
&lt;br /&gt;
log info in /var/log/message shows pam_rootok.so return success:&lt;br /&gt;
  Jul 12 06:55:18 qemux86 authpriv.debug chage[575]: pam_rootok(chage:auth): root check succeeded&lt;br /&gt;
  Jul 12 06:55:18 qemux86 authpriv.info chage[575]: changed password expiry for test&lt;br /&gt;
&lt;br /&gt;
* test pam_unix.so&lt;br /&gt;
the content of common-auth are shown at section &amp;quot;Common configure files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
comment the pam_rootok.so line, because it will make pam return success:&lt;br /&gt;
  #auth		sufficient	pam_rootok.so&lt;br /&gt;
&lt;br /&gt;
and modify the pam_unix.so line in common-auth:&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so debug&lt;br /&gt;
&lt;br /&gt;
run commands:&lt;br /&gt;
  root@qemux86:/etc/pam.d# passwd -d root &lt;br /&gt;
  root@qemux86:/etc/pam.d# chfn -f testself test # test is a unprivileged user&lt;br /&gt;
  Password: &lt;br /&gt;
  chfn: PAM authentication failed&lt;br /&gt;
&lt;br /&gt;
log in /var/log/message:&lt;br /&gt;
  Jul 12 07:53:16 qemux86 authpriv.notice chfn[673]: pam_unix(chfn:auth): authentication failure; logname=root uid=0 euid=0 tty= ruser= rhost=  user=root&lt;br /&gt;
&lt;br /&gt;
==== chfn ====&lt;br /&gt;
/etc/pam.d/chfn&lt;br /&gt;
  auth	    sufficient	pam_rootok.so&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-account&lt;br /&gt;
  session    include      common-session&lt;br /&gt;
add option debug to pam_rootok.so&lt;br /&gt;
  auth	    sufficient	pam_rootok.so debug&lt;br /&gt;
&lt;br /&gt;
* pam_rootok.so&lt;br /&gt;
run command chfn as root:&lt;br /&gt;
  root@qemux86:/etc/pam.d# chfn -f testyayay test&lt;br /&gt;
&lt;br /&gt;
log info in /var/log/message shows pam_rootok.so return success:&lt;br /&gt;
  Jul 12 07:22:59 qemux86 authpriv.debug chfn[638]: pam_rootok(chfn:auth): root check succeeded&lt;br /&gt;
  Jul 12 07:22:59 qemux86 authpriv.info chfn[638]: changed user &#039;test&#039; information&lt;br /&gt;
&lt;br /&gt;
* pam_unix.so&lt;br /&gt;
please refer to chage test steps.&lt;br /&gt;
&lt;br /&gt;
==== chgpasswd ====&lt;br /&gt;
/etc/pam.d/chgpasswd(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth		sufficient	pam_rootok.so&lt;br /&gt;
  account	required	pam_permit.so&lt;br /&gt;
  password	include		system-auth&lt;br /&gt;
&lt;br /&gt;
test pam_rootok.so and pam_unix.so(common-auth) refer to test steps in chage &lt;br /&gt;
&lt;br /&gt;
==== chpasswd ====&lt;br /&gt;
/etc/pam.d/chpasswd&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
common-password are listed before, we change the pam_unix.so option:&lt;br /&gt;
  password	[success=1 default=ignore]	pam_unix.so  audit&lt;br /&gt;
&lt;br /&gt;
commands to test:&lt;br /&gt;
  root@qemux86:/etc/pam.d# chpasswd&lt;br /&gt;
  test:&lt;br /&gt;
  Press Ctrl+d, the follow are terminal output:&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  chpasswd: (user test) pam_chauthtok() failed, error:&lt;br /&gt;
  Authentication token manipulation error&lt;br /&gt;
  chpasswd: (line 1, user test) password not changed&lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 04:53:39 qemux86 authpriv.notice chpasswd[844]: pam_warn(chpasswd:auth): function=[pam_sm_authenticate] service=[chpasswd] terminal=[&amp;lt;unknown&amp;gt;] user=[root] ruser=[&amp;lt;unknown&amp;gt;] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul 15 04:53:39 qemux86 authpriv.notice chpasswd[844]: pam_warn(chpasswd:account): function=[pam_sm_acct_mgmt] service=[chpasswd] terminal=[&amp;lt;unknown&amp;gt;] user=[root] ruser=[&amp;lt;unknown&amp;gt;] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.debug chpasswd[844]: pam_unix(chpasswd:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 04:53:41 qemux86 authpriv.notice chpasswd[844]: pam_unix(chpasswd:chauthtok): new password not acceptable&lt;br /&gt;
&lt;br /&gt;
==== chsh ====&lt;br /&gt;
/etc/pam.d/chsh&lt;br /&gt;
  auth       required   pam_shells.so&lt;br /&gt;
  auth       sufficient      pam_rootok.so&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-account&lt;br /&gt;
  session    include      common-session&lt;br /&gt;
* pam_shells.so&lt;br /&gt;
pam_shells only allows access to the system if the users shell is listed in /etc/shells.It also checks if /etc/shells is a plain file and not world writable.&lt;br /&gt;
&lt;br /&gt;
check /etc/shells first:&lt;br /&gt;
  qemux86:~$ ls -l /etc/shells &lt;br /&gt;
  -rw-r--r--    1 root     root           109 Jul 12 06:05 /etc/shells&lt;br /&gt;
  qemux86:~$ cat /etc/shells&lt;br /&gt;
  # /etc/shells: valid login shells&lt;br /&gt;
  /bin/sh&lt;br /&gt;
  /bin/ash&lt;br /&gt;
  /bin/bash&lt;br /&gt;
  /bin/dash&lt;br /&gt;
  /bin/ksh&lt;br /&gt;
  /usr/bin/ksh&lt;br /&gt;
  /usr/bin/screen&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
login as a unprivileged user, the correct process is:&lt;br /&gt;
  qemux86:~$ chsh -s /bin/ash&lt;br /&gt;
  Password: &amp;lt;-- Enter password here&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 06:15:18 qemux86 authpriv.debug chsh[1283]: pam_rootok(chsh:auth): root check failed&lt;br /&gt;
  Jul 15 06:15:21 qemux86 authpriv.info chsh[1283]: changed user &#039;test&#039; shell to &#039;/bin/ash&#039;&lt;br /&gt;
&lt;br /&gt;
now remove /bin/ash from /etc/shells, then run the same command:&lt;br /&gt;
  qemux86:~$ chsh -s /bin/ash&lt;br /&gt;
  Password: &amp;lt;-- Enter password here&lt;br /&gt;
  chsh: /bin/ash is an invalid shell.&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
if you make /etc/shells is writable to all people, chsh will fail with syslog info:&lt;br /&gt;
  Jul 15 05:38:38 qemux86 authpriv.err chsh[1091]: pam_shells(chsh:auth): /etc/shells is either world writable or not a normal file&lt;br /&gt;
&lt;br /&gt;
* pam_rootok.so&lt;br /&gt;
modify pam_rootok.so item:&lt;br /&gt;
  auth       required     pam_rootok.so debug&lt;br /&gt;
&lt;br /&gt;
then unprivileged users can&#039;t change their shell.&lt;br /&gt;
  qemux86:~$ chsh -s /bin/ash&lt;br /&gt;
  Password: &lt;br /&gt;
  chsh: PAM authentication failed&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 06:43:14 qemux86 authpriv.debug chsh[1350]: pam_rootok(chsh:auth): root check failed&lt;br /&gt;
&lt;br /&gt;
* pam_unix.so&lt;br /&gt;
**pam_unix in common-auth: please refer to sudo tests&lt;br /&gt;
**pam_unix in common-account and common-password don&#039;t have test point.&lt;br /&gt;
&lt;br /&gt;
==== groupadd ====&lt;br /&gt;
/etc/pam.d/groupadd(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
* pam_rootok&lt;br /&gt;
please refer to chage tests&lt;br /&gt;
&lt;br /&gt;
*pam_unix.so in common-password doesn&#039;t has test point&lt;br /&gt;
&lt;br /&gt;
==== groupdel ====&lt;br /&gt;
/etc/pam.d/groupdel(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
* pam_rootok&lt;br /&gt;
please refer to chage tests&lt;br /&gt;
&lt;br /&gt;
==== groupmems ====&lt;br /&gt;
/etc/pam.d/groupmems&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
*pam_rootok:&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
*pam_unix in common-password doesn&#039;t has test point&lt;br /&gt;
&lt;br /&gt;
==== groupmod ====&lt;br /&gt;
/etc/pam.d/groupmod&lt;br /&gt;
#%PAM-1.0&lt;br /&gt;
auth           sufficient      pam_rootok.so&lt;br /&gt;
account         required        pam_permit.so&lt;br /&gt;
password        include         common-password&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix: FIXME&lt;br /&gt;
&lt;br /&gt;
==== login ====&lt;br /&gt;
/etc/pam.d/login&lt;br /&gt;
  auth       optional   pam_faildelay.so  delay=3000000&lt;br /&gt;
  auth       [success=ok ignore=ignore user_unknown=ignore default=die]  pam_securetty.so&lt;br /&gt;
  auth       requisite  pam_nologin.so&lt;br /&gt;
  session       required   pam_env.so readenv=1&lt;br /&gt;
  session       required   pam_env.so readenv=1 envfile=/etc/default/locale&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  auth       optional   pam_group.so&lt;br /&gt;
  session    required   pam_limits.so                                      &lt;br /&gt;
  session    optional   pam_lastlog.so                                     &lt;br /&gt;
  session    optional   pam_motd.so                              &lt;br /&gt;
  session    optional   pam_mail.so standard                    &lt;br /&gt;
                                                              &lt;br /&gt;
  account    include      common-account                        &lt;br /&gt;
  password   include      common-password                       &lt;br /&gt;
  session    include      common-session&lt;br /&gt;
&lt;br /&gt;
==== newusers ====&lt;br /&gt;
/etc/pam.d/newusers&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
&lt;br /&gt;
*pam_unix&lt;br /&gt;
modify the pam_unix item in common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so debug &lt;br /&gt;
&lt;br /&gt;
run command:&lt;br /&gt;
  root@qemux86:~# newusers&lt;br /&gt;
  a::::::&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  No password supplied&lt;br /&gt;
  newusers: (user a) pam_chauthtok() failed, error:&lt;br /&gt;
  Authentication token manipulation error&lt;br /&gt;
  newusers: (line 1, user a) password not changed&lt;br /&gt;
&lt;br /&gt;
syslog info:&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): username [a] obtained&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): username [a] obtained&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.debug newusers[1560]: pam_unix(newusers:chauthtok): bad authentication token&lt;br /&gt;
  Jul 15 09:50:17 qemux86 authpriv.notice newusers[1560]: pam_unix(newusers:chauthtok): new password not acceptable&lt;br /&gt;
&lt;br /&gt;
==== passwd ====&lt;br /&gt;
/etc/pam.d/passwd&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password&lt;br /&gt;
modify the item to make password length not less than 4 characters:&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so minlen=4 debug&lt;br /&gt;
&lt;br /&gt;
run test commands:&lt;br /&gt;
  qemux86:~$ passwd&lt;br /&gt;
  Changing password for test.&lt;br /&gt;
  (current) UNIX password: &amp;lt;-- input 123 here&lt;br /&gt;
  Enter new UNIX password: &lt;br /&gt;
  Retype new UNIX password: &lt;br /&gt;
  You must choose a longer password&lt;br /&gt;
  Enter new UNIX password: &amp;lt;-- input 1234 here&lt;br /&gt;
  Retype new UNIX password: &lt;br /&gt;
  passwd: password updated successfully&lt;br /&gt;
  qemux86:~$ &lt;br /&gt;
&lt;br /&gt;
syslog doesn&#039;t has detail informatiaon&lt;br /&gt;
  Jul 17 02:00:39 qemux86 authpriv.debug passwd[1649]: pam_unix(passwd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 17 02:00:41 qemux86 authpriv.debug passwd[1649]: pam_unix(passwd:chauthtok): username [test] obtained&lt;br /&gt;
  Jul 17 02:00:49 qemux86 authpriv.notice passwd[1649]: pam_unix(passwd:chauthtok): password changed for test&lt;br /&gt;
&lt;br /&gt;
==== su ====&lt;br /&gt;
/etc/pam.d/su&lt;br /&gt;
==== useradd ====&lt;br /&gt;
/etc/pam.d/useradd(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password： FIXME&lt;br /&gt;
&lt;br /&gt;
==== userdel ====&lt;br /&gt;
/etc/pam.d/userdel(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password: &lt;br /&gt;
no test point&lt;br /&gt;
&lt;br /&gt;
==== usermod ==== &lt;br /&gt;
/etc/pam.d/usermod(need patch)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth            sufficient      pam_rootok.so&lt;br /&gt;
  account         required        pam_permit.so&lt;br /&gt;
  password        include         system-auth(common-password)&lt;br /&gt;
&lt;br /&gt;
* pam_rootok&lt;br /&gt;
refer to chage tests&lt;br /&gt;
&lt;br /&gt;
* pam_unix in common-password： FIXME&lt;br /&gt;
&lt;br /&gt;
=== sudo ===&lt;br /&gt;
*/etc/pam.d/sudo comes from Fedora, and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-account&lt;br /&gt;
  password   include      common-password&lt;br /&gt;
  session    required     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
and content of common-auth has been show above.&lt;br /&gt;
&lt;br /&gt;
*test pam plugins&lt;br /&gt;
**pam_unix.so&lt;br /&gt;
modify common-auth:&lt;br /&gt;
  auth    [success=1 default=ignore]      pam_unix.so debug&lt;br /&gt;
then unpriviledge user can NOT run sudo with blank password&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 16:39:04 qemux86 sudo: pam_unix(sudo:auth): authentication failure; logname=test-pam uid=0 euid=0 tty=/dev/pts/1 ruser=test-pam rhost=  user=test-pam&lt;br /&gt;
  Jul  8 16:39:14 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
**pam_deny.so&lt;br /&gt;
mv line&lt;br /&gt;
  auth    requisite                       pam_deny.so&lt;br /&gt;
to the head of file, unprivilege user can NOT sudo any more:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 14:03:29 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
**pam_permit.so&lt;br /&gt;
comment this line&lt;br /&gt;
  auth    required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
sudo will fail without ask user to enter password:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 12:43:22 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm -f /test&lt;br /&gt;
&lt;br /&gt;
**pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf&lt;br /&gt;
  *        -       nofile       3&lt;br /&gt;
then sudo will fail:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Inconsistency detected by ld.so: dl-deps.c: 622: _dl_map_object_deps: Assertion `nlist &amp;gt; 1&#039; failed!&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
  *        -       nofile       4&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 3 for DEFAULT&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 4 for DEFAULT&lt;br /&gt;
&lt;br /&gt;
** pam_keyinit&lt;br /&gt;
add option debug&lt;br /&gt;
  session    optional     pam_keyinit.so revoke debug&lt;br /&gt;
&lt;br /&gt;
log shows pam_keyinit was called:&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): OPEN 1&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): UID:0 [0]  GID:0 [1000]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 143761918&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 669161571&lt;br /&gt;
&lt;br /&gt;
according the source code pam_keyinit.c line 102 in function init_keyrings, the module return PAM_SUCCESS&lt;br /&gt;
&lt;br /&gt;
=== util-linux ===&lt;br /&gt;
Three programs chfn chsh and login in util-linux will use libpam. Right now these programs are provided by package shadow. In util-linux.inc, EXTRA_OECONF has option &amp;quot;--disable-login-utils &amp;quot; which will disable to build them.&lt;br /&gt;
&lt;br /&gt;
Drop it.&lt;br /&gt;
&lt;br /&gt;
=== xserver-xf86-lite ===&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
&lt;br /&gt;
* mc: mc has remove package mcserv and dropped dependency on PAM already, but didn&#039;t remove checking security/pam_misc.h. Drop it. [http://www.midnight-commander.org/changeset/4816107a02ccbf6331534113e6ec0c8df84e24eb Official change log]&lt;br /&gt;
* libcap: if pam exists, libcap will create a pam plugin pam_cap.so to add a new front end for the authentication function. Because it is not a application, remove it from list.&lt;br /&gt;
* libuser: pam is libuser&#039;s build dependency, so remove it too.&lt;br /&gt;
* The busybox login has a option to use pam, but we use tinylogin&#039;s login right now (tinylogin also provides the su command)&lt;br /&gt;
* gettext only has a example &amp;quot;hello-c++-kde&amp;quot; use pam under source code directory, and it doen&#039;t be compiled and only copied to destination. So omit gettext.&lt;br /&gt;
* sysvinit has a patch contrib/notify-pam-dead.patch for /sbin/init to use pam, but the whole contrib directory didn&#039;t take part in compilation. Drop it.&lt;br /&gt;
&lt;br /&gt;
== Identify upstream PAM patches to use ==&lt;br /&gt;
After checking the Fedora develop repository, the following packages may need patches(only libpam need to upgrade, other patches are pam related configure file but they are absent in poky):&lt;br /&gt;
* libpam: need update from current 1.1.3 to 1.1.4 [https://www.redhat.com/archives/pam-list/2011-June/msg00013.html Release Notes]&lt;br /&gt;
* sudo: package sudo in Fedora provides /etc/pam.d/sudo and /etc/pam.d/sudo-i&lt;br /&gt;
** /etc/pam.d/sudo (Yocto use common-auth instead of system-auth)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      system-auth&lt;br /&gt;
  account    include      system-auth&lt;br /&gt;
  password   include      system-auth&lt;br /&gt;
  session    optional     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
&lt;br /&gt;
* screen: check Fedora screen.pam&lt;br /&gt;
&lt;br /&gt;
* util-linux: check Fedora source file util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* at: check Fedora util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* cups: check Fedora cups-1.1.16-system-auth.patch&lt;br /&gt;
&lt;br /&gt;
* openssh: check Fedora sshd.pam&lt;br /&gt;
&lt;br /&gt;
== PAM Unit Tests==&lt;br /&gt;
We use unit test cases provided by libpam itself, a subdirectory with name &amp;quot;xtests&amp;quot; under libpam source code.&lt;br /&gt;
&lt;br /&gt;
On build machine run &lt;br /&gt;
  bitbake libpam -c patch&lt;br /&gt;
to get the libpam source code Linux-PAM-1.1.4, and scp it to host(target) machine. &lt;br /&gt;
&lt;br /&gt;
On the target machine under Linux-PAM-1.1.4, run&lt;br /&gt;
  ./configure&lt;br /&gt;
  make xtests&lt;br /&gt;
will get the test result of 28 unit test case. If you want to run sigle test case, go to subdirectory xtests and run (take tst-pam_time1 for example)&lt;br /&gt;
  ./run-xtests.sh . tst-pam_time1&lt;br /&gt;
&lt;br /&gt;
Some unit test can NOT pass(15/28), they need some pam plugin libraies:&lt;br /&gt;
* tst-pam_access1&lt;br /&gt;
* tst-pam_access2&lt;br /&gt;
* tst-pam_access3&lt;br /&gt;
* tst-pam_access4&lt;br /&gt;
**the tst-pam_access test cases need pam_access.so, install package pam-plugin-access will make them pass the test&lt;br /&gt;
* tst-pam_authsucceed&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_cracklib1&lt;br /&gt;
* tst-pam_cracklib2&lt;br /&gt;
**need /lib/security/pam_cracklib.so, need build cracklib, and then libpam will check it and create pam-plugin-cracklib&lt;br /&gt;
**need /usr/share/cracklib/pw_dict.pwd file, please run command on host machine:&lt;br /&gt;
    create-cracklib-dict /usr/share/cracklib/cracklib-small&lt;br /&gt;
&lt;br /&gt;
* tst-pam_dispatch1&lt;br /&gt;
* tst-pam_dispatch2&lt;br /&gt;
* tst-pam_dispatch3&lt;br /&gt;
* tst-pam_dispatch4&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_pwhistory1&lt;br /&gt;
**need /lib/security/pam_pwhistory.so, install pam-plugin-pwhistory to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_substack2&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_succeed_if1&lt;br /&gt;
**install pam-plugin-succeed-if to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_time1&lt;br /&gt;
**install pam-plugin-time to make it pass&lt;/div&gt;</summary>
		<author><name>Wfan</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2742</id>
		<title>PAM Integration</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2742"/>
		<updated>2011-07-12T09:24:13Z</updated>

		<summary type="html">&lt;p&gt;Wfan: /* cronie */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Motivation ==&lt;br /&gt;
For Yocto 1.1 we are working to ensure that PAM (Pluggable Authentication Module) support is consistent and enabled in recipes where it is applicable. &lt;br /&gt;
&lt;br /&gt;
== Common configure files ==&lt;br /&gt;
For convenience, list common configure files here:&lt;br /&gt;
&lt;br /&gt;
common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
  auth	requisite			pam_deny.so&lt;br /&gt;
  auth	required			pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-account&lt;br /&gt;
  account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so &lt;br /&gt;
  account requisite                       pam_deny.so&lt;br /&gt;
  account required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so obscure sha512&lt;br /&gt;
  password        requisite                       pam_deny.so&lt;br /&gt;
  password        required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-session&lt;br /&gt;
  session [default=1]                     pam_permit.so&lt;br /&gt;
  session requisite                       pam_deny.so&lt;br /&gt;
  session required                        pam_permit.so&lt;br /&gt;
  session required        pam_unix.so &lt;br /&gt;
&lt;br /&gt;
common-session-noninteractive&lt;br /&gt;
  session [default=1]                     pam_permit.so&lt;br /&gt;
  session requisite                       pam_deny.so&lt;br /&gt;
  session required                        pam_permit.so&lt;br /&gt;
  session required        pam_unix.so &lt;br /&gt;
&lt;br /&gt;
== Recipes with PAM support ==&lt;br /&gt;
The following recipes were identified to have PAM support (some already implemented) on 2011-06-27:&lt;br /&gt;
&lt;br /&gt;
=== at === &lt;br /&gt;
* Open issue:&lt;br /&gt;
** It can&#039;t be ran by a non-root user, error message is:&lt;br /&gt;
 Can&#039;t signal atd (permission denied)&lt;br /&gt;
&lt;br /&gt;
* Simple ways to verify &#039;at&#039;:&lt;br /&gt;
 $ at now&lt;br /&gt;
 $ echo &amp;quot;$msg_to_print&amp;quot; &amp;gt;&amp;gt; /tmp/at_test&lt;br /&gt;
 $ &amp;lt; ctrl+D &amp;gt;&lt;br /&gt;
 $ cat /tmp/at_test    # Verify if the message has been there &lt;br /&gt;
&lt;br /&gt;
* /etc/pam.d/atd - not installed by default, copy it from source code and replace &#039;@include&#039; with appropriate &#039;module-type include&#039;:&lt;br /&gt;
&lt;br /&gt;
 auth       required    pam_env.so&lt;br /&gt;
 auth       include     common-auth&lt;br /&gt;
 account    include     common-account&lt;br /&gt;
 session    include     common-session-noninteractive&lt;br /&gt;
 session    required    pam_limits.so&lt;br /&gt;
&lt;br /&gt;
* test pam plugins&lt;br /&gt;
** pam_env.so&lt;br /&gt;
modify /etc/pam.d/atd&lt;br /&gt;
 auth       required    pam_env.so    debug&lt;br /&gt;
modify /etc/security/pam_env.conf, add a test entry such as:&lt;br /&gt;
 MYNAME          DEFAULT=&amp;quot;test-at&amp;quot;&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:41:22 qemux86 atd[678]: pam_env(atd:setcred): pam_putenv(&amp;quot;MYNAME=test-at&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
** pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf &lt;br /&gt;
 root    -       nofile  3&lt;br /&gt;
&#039;at&#039; job failed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:49:42 qemux86 atd[699]: pam_env(atd:setcred): Unable to open config file: /etc/security/pam_env.conf: Too many open files&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
 root    -       nofile  4&lt;br /&gt;
&#039;at&#039; job successed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session opened for user root by (uid=0)                      &lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session closed for user root&lt;br /&gt;
&lt;br /&gt;
=== consolekit ===&lt;br /&gt;
&lt;br /&gt;
=== cronie ===&lt;br /&gt;
* Open issue:&lt;br /&gt;
** Can&#039;t run &#039;crontab&#039; command with non-root user, error message is:&lt;br /&gt;
 You (test-pam) are not allowed to access to (crontab) because of pam configuration.&lt;br /&gt;
 Jul 12 02:36:14 qemux86 unix_chkpwd[768]: could not obtain user info (test-pam)&lt;br /&gt;
&lt;br /&gt;
* /etc/pam.d/crond:&lt;br /&gt;
 account    required   pam_access.so&lt;br /&gt;
 account    include    password-auth&lt;br /&gt;
 session    required   pam_loginuid.so&lt;br /&gt;
 session    include    password-auth&lt;br /&gt;
 auth       include    password-auth&lt;br /&gt;
&lt;br /&gt;
* /etc/pam.d/password-auth:&lt;br /&gt;
 auth        required      pam_env.so&lt;br /&gt;
 auth        sufficient    pam_unix.so nullok try_first_pass&lt;br /&gt;
 auth        requisite     pam_succeed_if.so uid &amp;gt;= 500 quiet&lt;br /&gt;
 auth        required      pam_deny.so&lt;br /&gt;
 account     required      pam_unix.so&lt;br /&gt;
 account     sufficient    pam_localuser.so&lt;br /&gt;
 account     sufficient    pam_succeed_if.so uid &amp;lt; 500 quiet&lt;br /&gt;
 account     required      pam_permit.so&lt;br /&gt;
 password    requisite     pam_cracklib.so try_first_pass retry=3 type=&lt;br /&gt;
 password    sufficient    pam_unix.so sha512 shadow nullok try_first_pass use_authtok&lt;br /&gt;
 password    required      pam_deny.so&lt;br /&gt;
 session     optional      pam_keyinit.so revoke&lt;br /&gt;
 session     required      pam_limits.so&lt;br /&gt;
 -session     optional      pam_systemd.so&lt;br /&gt;
 session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid&lt;br /&gt;
 session     required      pam_unix.so&lt;br /&gt;
&lt;br /&gt;
* test commands:&lt;br /&gt;
 crontab -e    # establish a crontab jobs and check if it works&lt;br /&gt;
 crontab -l    # list crontab jobs for current user&lt;br /&gt;
&lt;br /&gt;
* test pam plugins&lt;br /&gt;
Verified, test ways and the logs/results please refer to other packages:&lt;br /&gt;
** pam_env.so&lt;br /&gt;
** pam_access.so&lt;br /&gt;
** pam_unix.so&lt;br /&gt;
** pam_permit.so&lt;br /&gt;
** pam_keyinit.so &lt;br /&gt;
&lt;br /&gt;
** pam_localuser.so&lt;br /&gt;
copy &#039;/etc/passwd&#039; to &#039;/tmp/passwd&#039; and delete the entry for &#039;root&#039;;&lt;br /&gt;
modify /etc/pam.d/password-auth:&lt;br /&gt;
 account     requisite    pam_localuser.so file=/tmp/passwd debug&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): set filename to &amp;quot;/tmp/passwd&amp;quot;&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): checking &amp;quot;daemon:x:1:1:daemon:/usr/sbin:/bin/sh &amp;quot;&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): checking &amp;quot;bin:x:2:2:bin:/bin:/bin/sh &amp;quot;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
** pam_succeed_if.so&lt;br /&gt;
account     requisite    pam_succeed_if.so uid &amp;gt; 500 debug&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 12 03:14:14 qemux86 crontab: pam_succeed_if(crond:account): &#039;uid&#039; resolves to &#039;0&#039;&lt;br /&gt;
 Jul 12 03:14:14 qemux86 crontab: pam_succeed_if(crond:account): requirement &amp;quot;uid &amp;gt; 500&amp;quot; not met by user &amp;quot;root&amp;quot;&lt;br /&gt;
&lt;br /&gt;
** pam_loginuid.so&lt;br /&gt;
 TBD&lt;br /&gt;
&lt;br /&gt;
** pam_systemd.so&lt;br /&gt;
 no this module&lt;br /&gt;
&lt;br /&gt;
=== cups ===&lt;br /&gt;
&lt;br /&gt;
=== dropbear ===&lt;br /&gt;
** For supporting pam in dropbear, we need two steps:&lt;br /&gt;
** Add configuration &amp;quot;--enable-pam&amp;quot; &lt;br /&gt;
** Add patches to open macro definition for supporting in option.h&lt;br /&gt;
 --- a/ptions.h  2011-07-12 11:32:34.165333202 +0800&lt;br /&gt;
 +++ b/options.h.new     2011-07-12 11:33:25.757332986 +0800&lt;br /&gt;
 @@ -149,9 +149,9 @@&lt;br /&gt;
   * but there&#039;s an interface via a PAM module - don&#039;t bother using it otherwise.&lt;br /&gt;
   * You can&#039;t enable both PASSWORD and PAM. */&lt;br /&gt;
 -#define ENABLE_SVR_PASSWORD_AUTH&lt;br /&gt;
 +//#define ENABLE_SVR_PASSWORD_AUTH&lt;br /&gt;
  /* PAM requires ./configure --enable-pam */&lt;br /&gt;
 -/*#define ENABLE_SVR_PAM_AUTH*/&lt;br /&gt;
 +#define ENABLE_SVR_PAM_AUTH&lt;br /&gt;
  #define ENABLE_SVR_PUBKEY_AUTH&lt;br /&gt;
  /* Wether to ake public key options in authorized_keys file into account */&lt;br /&gt;
&lt;br /&gt;
** Test result(dropbeat only support simple authentication, account and auth)&lt;br /&gt;
*** Server(account)&lt;br /&gt;
 (server ip:192.168.7.2)&lt;br /&gt;
 $touch /etc/pam.d/sshd&lt;br /&gt;
 account  required     pam_access.so&lt;br /&gt;
 $vi /etc/security/access.conf&lt;br /&gt;
 - : root : ALL&lt;br /&gt;
&lt;br /&gt;
*** Client&lt;br /&gt;
 $ssh root@192.168.7.2&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied, please try again.&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied, please try again.&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied (publickey,password).&lt;br /&gt;
&lt;br /&gt;
*** Server(auth)&lt;br /&gt;
 $vi /etc/pam.d/sshd&lt;br /&gt;
  auth include common-auth&lt;br /&gt;
 $vi /etc/pam.d/common-auth&lt;br /&gt;
 #auth   [success=1 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
 auth    [success=0 default=ignore]      pam_unix.so debug&lt;br /&gt;
&lt;br /&gt;
*** Client&lt;br /&gt;
 $ssh root@192.168.7.2&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied, please try again.&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied, please try again.&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied (publickey,password).&lt;br /&gt;
&lt;br /&gt;
=== gnome-keyring ===&lt;br /&gt;
* gnome-keyring can&#039;t call configuration file like &amp;quot;/etc/pam.d/gnome-keyring&amp;quot; because it is called by other program like &amp;quot;gnome-screensave&amp;quot; and &amp;quot;gdm&amp;quot;. If we want test &amp;quot;pam_gnome_keyring.so&amp;quot;, we need write .bb files to cross-compile gnome-screensave or gdm.&lt;br /&gt;
&lt;br /&gt;
=== openssh ===&lt;br /&gt;
** Absent configuration /etc/pam.d/sshd, we need to add patches. After adding this file, it can support pam function through simple test.&lt;br /&gt;
** Test Result&lt;br /&gt;
*** Configuration of sshd&lt;br /&gt;
auth       include      common-auth&lt;br /&gt;
account    required     pam_nologin.so&lt;br /&gt;
account    include      common-auth&lt;br /&gt;
password   include      common-auth&lt;br /&gt;
session    optional     pam_keyinit.so force revoke&lt;br /&gt;
session    include      common-auth&lt;br /&gt;
session    required     pam_loginuid.so&lt;br /&gt;
*** auth include common-auth&lt;br /&gt;
 It is as same as dropbear&lt;br /&gt;
  &lt;br /&gt;
*** account required pam_nologin.so --Server&lt;br /&gt;
 $touch /etc/nologin&lt;br /&gt;
&lt;br /&gt;
*** Client&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (can&#039;t log in)&lt;br /&gt;
*** log information --Server&lt;br /&gt;
 Jul 12 08:34:08 qemux86 login[373]: FAILED LOGIN (1) on &#039;/dev/tty1&#039; FOR &#039;root&#039;, Permission denied&lt;br /&gt;
&lt;br /&gt;
=== polkit ===&lt;br /&gt;
&lt;br /&gt;
=== screen ===&lt;br /&gt;
screen use pam to authenticate users during unlock terminal. Its configure file screen comes from Fedora and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
&lt;br /&gt;
First start screen:&lt;br /&gt;
  root@qemux86:/etc/pam.d# screen&lt;br /&gt;
it will show some information about screen, just press Space or Enter and it will give a screen terminal:&lt;br /&gt;
  root@qemux86:/etc/pam.d# &lt;br /&gt;
then press &amp;quot;Ctrl+a x&amp;quot; will lock the screen terminal and show:&lt;br /&gt;
    &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
In another root terminal, clear the root&#039;s password:&lt;br /&gt;
  password -d root&lt;br /&gt;
&lt;br /&gt;
modify one line in common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
with&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so debug&lt;br /&gt;
option nullok_secure will allow users who has blank password login, after remove it these users are not allowed to login.&lt;br /&gt;
&lt;br /&gt;
Back to the screen terminal, press &amp;lt;Enter&amp;gt;(because root&#039;s password is blank now) will fail: &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
then modify the line in common-auth with &lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure debug&lt;br /&gt;
&lt;br /&gt;
On the screen terminal press &amp;lt;Enter&amp;gt; again it unlock the terminal.&lt;br /&gt;
&lt;br /&gt;
the log in /var/log/auth.log:&lt;br /&gt;
  Jul 11 14:14:14 qemux86 screen: pam_unix(screen:auth): authentication failure; logname=root uid=0 euid=0 tty= ruser= rhost=  user=root&lt;br /&gt;
&lt;br /&gt;
=== shadow ===&lt;br /&gt;
&lt;br /&gt;
=== sudo ===&lt;br /&gt;
*/etc/pam.d/sudo comes from Fedora, and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-auth&lt;br /&gt;
  password   include      common-auth&lt;br /&gt;
  session    required     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
and content of common-auth has been show above.&lt;br /&gt;
&lt;br /&gt;
*test pam plugins&lt;br /&gt;
**pam_unix.so&lt;br /&gt;
modify common-auth:&lt;br /&gt;
  auth    [success=1 default=ignore]      pam_unix.so debug&lt;br /&gt;
then unpriviledge user can NOT run sudo with blank password&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 16:39:04 qemux86 sudo: pam_unix(sudo:auth): authentication failure; logname=test-pam uid=0 euid=0 tty=/dev/pts/1 ruser=test-pam rhost=  user=test-pam&lt;br /&gt;
  Jul  8 16:39:14 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
**pam_deny.so&lt;br /&gt;
mv line&lt;br /&gt;
  auth    requisite                       pam_deny.so&lt;br /&gt;
to the head of file, unprivilege user can NOT sudo any more:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 14:03:29 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
**pam_permit.so&lt;br /&gt;
comment this line&lt;br /&gt;
  auth    required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
sudo will fail without ask user to enter password:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 12:43:22 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm -f /test&lt;br /&gt;
&lt;br /&gt;
**pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf&lt;br /&gt;
  *        -       nofile       3&lt;br /&gt;
then sudo will fail:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Inconsistency detected by ld.so: dl-deps.c: 622: _dl_map_object_deps: Assertion `nlist &amp;gt; 1&#039; failed!&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
  *        -       nofile       4&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 3 for DEFAULT&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 4 for DEFAULT&lt;br /&gt;
&lt;br /&gt;
** pam_keyinit&lt;br /&gt;
add option debug&lt;br /&gt;
  session    optional     pam_keyinit.so revoke debug&lt;br /&gt;
&lt;br /&gt;
log shows pam_keyinit was called:&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): OPEN 1&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): UID:0 [0]  GID:0 [1000]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 143761918&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 669161571&lt;br /&gt;
&lt;br /&gt;
according the source code pam_keyinit.c line 102 in function init_keyrings, the module return PAM_SUCCESS&lt;br /&gt;
&lt;br /&gt;
=== util-linux ===&lt;br /&gt;
Three programs chfn chsh and login in util-linux will use libpam. But in util-linux.inc, EXTRA_OECONF has option &amp;quot;--disable-login-utils &amp;quot; so these programs will not be built.&lt;br /&gt;
&lt;br /&gt;
Drop it.&lt;br /&gt;
&lt;br /&gt;
=== xserver-xf86-lite ===&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* mc: mc has remove package mcserv and dropped dependency on PAM already, but didn&#039;t remove checking security/pam_misc.h. Drop it. [http://www.midnight-commander.org/changeset/4816107a02ccbf6331534113e6ec0c8df84e24eb Official change log]&lt;br /&gt;
* libcap: if pam exists, libcap will create a pam plugin pam_cap.so to add a new front end for the authentication function. Because it is not a application, remove it from list.&lt;br /&gt;
* libuser: pam is libuser&#039;s build dependency, so remove it too.&lt;br /&gt;
* The busybox login has a option to use pam, but we use tinylogin&#039;s login right now (tinylogin also provides the su command)&lt;br /&gt;
* gettext only has a example &amp;quot;hello-c++-kde&amp;quot; use pam under source code directory, and it doen&#039;t be compiled and only copied to destination. So omit gettext.&lt;br /&gt;
* sysvinit has a patch contrib/notify-pam-dead.patch for /sbin/init to use pam, but the whole contrib directory didn&#039;t take part in compilation. Drop it.&lt;br /&gt;
&lt;br /&gt;
== Identify upstream PAM patches to use ==&lt;br /&gt;
After checking the Fedora develop repository, the following packages may need patches(only libpam need to upgrade, other patches are pam related configure file but they are absent in poky):&lt;br /&gt;
* libpam: need update from current 1.1.3 to 1.1.4 [https://www.redhat.com/archives/pam-list/2011-June/msg00013.html Release Notes]&lt;br /&gt;
* sudo: package sudo in Fedora provides /etc/pam.d/sudo and /etc/pam.d/sudo-i&lt;br /&gt;
** /etc/pam.d/sudo (Yocto use common-auth instead of system-auth)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      system-auth&lt;br /&gt;
  account    include      system-auth&lt;br /&gt;
  password   include      system-auth&lt;br /&gt;
  session    optional     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
&lt;br /&gt;
* screen: check Fedora screen.pam&lt;br /&gt;
&lt;br /&gt;
* util-linux: check Fedora source file util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* at: check Fedora util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* cups: check Fedora cups-1.1.16-system-auth.patch&lt;br /&gt;
&lt;br /&gt;
* openssh: check Fedora sshd.pam&lt;br /&gt;
&lt;br /&gt;
== PAM Unit Tests==&lt;br /&gt;
We use unit test cases provided by libpam itself, a subdirectory with name &amp;quot;xtests&amp;quot; under libpam source code.&lt;br /&gt;
&lt;br /&gt;
On build machine run &lt;br /&gt;
  bitbake libpam -c patch&lt;br /&gt;
to get the libpam source code Linux-PAM-1.1.4, and scp it to host(target) machine. &lt;br /&gt;
&lt;br /&gt;
On the target machine under Linux-PAM-1.1.4, run&lt;br /&gt;
  ./configure&lt;br /&gt;
  make xtests&lt;br /&gt;
will get the test result of 28 unit test case. If you want to run sigle test case, go to subdirectory xtests and run (take tst-pam_time1 for example)&lt;br /&gt;
  ./run-xtests.sh . tst-pam_time1&lt;br /&gt;
&lt;br /&gt;
Some unit test can NOT pass(15/28), they need some pam plugin libraies:&lt;br /&gt;
* tst-pam_access1&lt;br /&gt;
* tst-pam_access2&lt;br /&gt;
* tst-pam_access3&lt;br /&gt;
* tst-pam_access4&lt;br /&gt;
**the tst-pam_access test cases need pam_access.so, install package pam-plugin-access will make them pass the test&lt;br /&gt;
* tst-pam_authsucceed&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_cracklib1&lt;br /&gt;
* tst-pam_cracklib2&lt;br /&gt;
**need /lib/security/pam_cracklib.so, need build cracklib, and then libpam will check it and create pam-plugin-cracklib&lt;br /&gt;
**need /usr/share/cracklib/pw_dict.pwd file, please run command on host machine:&lt;br /&gt;
    create-cracklib-dict /usr/share/cracklib/cracklib-small&lt;br /&gt;
&lt;br /&gt;
* tst-pam_dispatch1&lt;br /&gt;
* tst-pam_dispatch2&lt;br /&gt;
* tst-pam_dispatch3&lt;br /&gt;
* tst-pam_dispatch4&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_pwhistory1&lt;br /&gt;
**need /lib/security/pam_pwhistory.so, install pam-plugin-pwhistory to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_substack2&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_succeed_if1&lt;br /&gt;
**install pam-plugin-succeed-if to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_time1&lt;br /&gt;
**install pam-plugin-time to make it pass&lt;/div&gt;</summary>
		<author><name>Wfan</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2741</id>
		<title>PAM Integration</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2741"/>
		<updated>2011-07-12T09:23:38Z</updated>

		<summary type="html">&lt;p&gt;Wfan: /* at */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Motivation ==&lt;br /&gt;
For Yocto 1.1 we are working to ensure that PAM (Pluggable Authentication Module) support is consistent and enabled in recipes where it is applicable. &lt;br /&gt;
&lt;br /&gt;
== Common configure files ==&lt;br /&gt;
For convenience, list common configure files here:&lt;br /&gt;
&lt;br /&gt;
common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
  auth	requisite			pam_deny.so&lt;br /&gt;
  auth	required			pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-account&lt;br /&gt;
  account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so &lt;br /&gt;
  account requisite                       pam_deny.so&lt;br /&gt;
  account required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so obscure sha512&lt;br /&gt;
  password        requisite                       pam_deny.so&lt;br /&gt;
  password        required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-session&lt;br /&gt;
  session [default=1]                     pam_permit.so&lt;br /&gt;
  session requisite                       pam_deny.so&lt;br /&gt;
  session required                        pam_permit.so&lt;br /&gt;
  session required        pam_unix.so &lt;br /&gt;
&lt;br /&gt;
common-session-noninteractive&lt;br /&gt;
  session [default=1]                     pam_permit.so&lt;br /&gt;
  session requisite                       pam_deny.so&lt;br /&gt;
  session required                        pam_permit.so&lt;br /&gt;
  session required        pam_unix.so &lt;br /&gt;
&lt;br /&gt;
== Recipes with PAM support ==&lt;br /&gt;
The following recipes were identified to have PAM support (some already implemented) on 2011-06-27:&lt;br /&gt;
&lt;br /&gt;
=== at === &lt;br /&gt;
* Open issue:&lt;br /&gt;
** It can&#039;t be ran by a non-root user, error message is:&lt;br /&gt;
 Can&#039;t signal atd (permission denied)&lt;br /&gt;
&lt;br /&gt;
* Simple ways to verify &#039;at&#039;:&lt;br /&gt;
 $ at now&lt;br /&gt;
 $ echo &amp;quot;$msg_to_print&amp;quot; &amp;gt;&amp;gt; /tmp/at_test&lt;br /&gt;
 $ &amp;lt; ctrl+D &amp;gt;&lt;br /&gt;
 $ cat /tmp/at_test    # Verify if the message has been there &lt;br /&gt;
&lt;br /&gt;
* /etc/pam.d/atd - not installed by default, copy it from source code and replace &#039;@include&#039; with appropriate &#039;module-type include&#039;:&lt;br /&gt;
&lt;br /&gt;
 auth       required    pam_env.so&lt;br /&gt;
 auth       include     common-auth&lt;br /&gt;
 account    include     common-account&lt;br /&gt;
 session    include     common-session-noninteractive&lt;br /&gt;
 session    required    pam_limits.so&lt;br /&gt;
&lt;br /&gt;
* test pam plugins&lt;br /&gt;
** pam_env.so&lt;br /&gt;
modify /etc/pam.d/atd&lt;br /&gt;
 auth       required    pam_env.so    debug&lt;br /&gt;
modify /etc/security/pam_env.conf, add a test entry such as:&lt;br /&gt;
 MYNAME          DEFAULT=&amp;quot;test-at&amp;quot;&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:41:22 qemux86 atd[678]: pam_env(atd:setcred): pam_putenv(&amp;quot;MYNAME=test-at&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
** pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf &lt;br /&gt;
 root    -       nofile  3&lt;br /&gt;
&#039;at&#039; job failed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:49:42 qemux86 atd[699]: pam_env(atd:setcred): Unable to open config file: /etc/security/pam_env.conf: Too many open files&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
 root    -       nofile  4&lt;br /&gt;
&#039;at&#039; job successed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session opened for user root by (uid=0)                      &lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session closed for user root&lt;br /&gt;
&lt;br /&gt;
=== consolekit ===&lt;br /&gt;
&lt;br /&gt;
=== cronie ===&lt;br /&gt;
** Open issue:&lt;br /&gt;
** Can&#039;t run &#039;crontab&#039; command with non-root user, error message is:&lt;br /&gt;
 You (test-pam) are not allowed to access to (crontab) because of pam configuration.&lt;br /&gt;
 Jul 12 02:36:14 qemux86 unix_chkpwd[768]: could not obtain user info (test-pam)&lt;br /&gt;
&lt;br /&gt;
** /etc/pam.d/crond:&lt;br /&gt;
 account    required   pam_access.so&lt;br /&gt;
 account    include    password-auth&lt;br /&gt;
 session    required   pam_loginuid.so&lt;br /&gt;
 session    include    password-auth&lt;br /&gt;
 auth       include    password-auth&lt;br /&gt;
&lt;br /&gt;
** /etc/pam.d/password-auth:&lt;br /&gt;
 auth        required      pam_env.so&lt;br /&gt;
 auth        sufficient    pam_unix.so nullok try_first_pass&lt;br /&gt;
 auth        requisite     pam_succeed_if.so uid &amp;gt;= 500 quiet&lt;br /&gt;
 auth        required      pam_deny.so&lt;br /&gt;
 account     required      pam_unix.so&lt;br /&gt;
 account     sufficient    pam_localuser.so&lt;br /&gt;
 account     sufficient    pam_succeed_if.so uid &amp;lt; 500 quiet&lt;br /&gt;
 account     required      pam_permit.so&lt;br /&gt;
 password    requisite     pam_cracklib.so try_first_pass retry=3 type=&lt;br /&gt;
 password    sufficient    pam_unix.so sha512 shadow nullok try_first_pass use_authtok&lt;br /&gt;
 password    required      pam_deny.so&lt;br /&gt;
 session     optional      pam_keyinit.so revoke&lt;br /&gt;
 session     required      pam_limits.so&lt;br /&gt;
 -session     optional      pam_systemd.so&lt;br /&gt;
 session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid&lt;br /&gt;
 session     required      pam_unix.so&lt;br /&gt;
&lt;br /&gt;
** test commands:&lt;br /&gt;
 crontab -e    # establish a crontab jobs and check if it works&lt;br /&gt;
 crontab -l    # list crontab jobs for current user&lt;br /&gt;
&lt;br /&gt;
** test pam plugins&lt;br /&gt;
Verified, test ways and the logs/results please refer to other packages:&lt;br /&gt;
*** pam_env.so&lt;br /&gt;
*** pam_access.so&lt;br /&gt;
*** pam_unix.so&lt;br /&gt;
*** pam_permit.so&lt;br /&gt;
*** pam_keyinit.so &lt;br /&gt;
&lt;br /&gt;
*** pam_localuser.so&lt;br /&gt;
copy &#039;/etc/passwd&#039; to &#039;/tmp/passwd&#039; and delete the entry for &#039;root&#039;;&lt;br /&gt;
modify /etc/pam.d/password-auth:&lt;br /&gt;
 account     requisite    pam_localuser.so file=/tmp/passwd debug&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): set filename to &amp;quot;/tmp/passwd&amp;quot;&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): checking &amp;quot;daemon:x:1:1:daemon:/usr/sbin:/bin/sh &amp;quot;&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): checking &amp;quot;bin:x:2:2:bin:/bin:/bin/sh &amp;quot;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
*** pam_succeed_if.so&lt;br /&gt;
account     requisite    pam_succeed_if.so uid &amp;gt; 500 debug&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 12 03:14:14 qemux86 crontab: pam_succeed_if(crond:account): &#039;uid&#039; resolves to &#039;0&#039;&lt;br /&gt;
 Jul 12 03:14:14 qemux86 crontab: pam_succeed_if(crond:account): requirement &amp;quot;uid &amp;gt; 500&amp;quot; not met by user &amp;quot;root&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*** pam_loginuid.so&lt;br /&gt;
 TBD&lt;br /&gt;
&lt;br /&gt;
*** pam_systemd.so&lt;br /&gt;
 no this module&lt;br /&gt;
&lt;br /&gt;
=== cups ===&lt;br /&gt;
&lt;br /&gt;
=== dropbear ===&lt;br /&gt;
** For supporting pam in dropbear, we need two steps:&lt;br /&gt;
** Add configuration &amp;quot;--enable-pam&amp;quot; &lt;br /&gt;
** Add patches to open macro definition for supporting in option.h&lt;br /&gt;
 --- a/ptions.h  2011-07-12 11:32:34.165333202 +0800&lt;br /&gt;
 +++ b/options.h.new     2011-07-12 11:33:25.757332986 +0800&lt;br /&gt;
 @@ -149,9 +149,9 @@&lt;br /&gt;
   * but there&#039;s an interface via a PAM module - don&#039;t bother using it otherwise.&lt;br /&gt;
   * You can&#039;t enable both PASSWORD and PAM. */&lt;br /&gt;
 -#define ENABLE_SVR_PASSWORD_AUTH&lt;br /&gt;
 +//#define ENABLE_SVR_PASSWORD_AUTH&lt;br /&gt;
  /* PAM requires ./configure --enable-pam */&lt;br /&gt;
 -/*#define ENABLE_SVR_PAM_AUTH*/&lt;br /&gt;
 +#define ENABLE_SVR_PAM_AUTH&lt;br /&gt;
  #define ENABLE_SVR_PUBKEY_AUTH&lt;br /&gt;
  /* Wether to ake public key options in authorized_keys file into account */&lt;br /&gt;
&lt;br /&gt;
** Test result(dropbeat only support simple authentication, account and auth)&lt;br /&gt;
*** Server(account)&lt;br /&gt;
 (server ip:192.168.7.2)&lt;br /&gt;
 $touch /etc/pam.d/sshd&lt;br /&gt;
 account  required     pam_access.so&lt;br /&gt;
 $vi /etc/security/access.conf&lt;br /&gt;
 - : root : ALL&lt;br /&gt;
&lt;br /&gt;
*** Client&lt;br /&gt;
 $ssh root@192.168.7.2&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied, please try again.&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied, please try again.&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied (publickey,password).&lt;br /&gt;
&lt;br /&gt;
*** Server(auth)&lt;br /&gt;
 $vi /etc/pam.d/sshd&lt;br /&gt;
  auth include common-auth&lt;br /&gt;
 $vi /etc/pam.d/common-auth&lt;br /&gt;
 #auth   [success=1 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
 auth    [success=0 default=ignore]      pam_unix.so debug&lt;br /&gt;
&lt;br /&gt;
*** Client&lt;br /&gt;
 $ssh root@192.168.7.2&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied, please try again.&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied, please try again.&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied (publickey,password).&lt;br /&gt;
&lt;br /&gt;
=== gnome-keyring ===&lt;br /&gt;
* gnome-keyring can&#039;t call configuration file like &amp;quot;/etc/pam.d/gnome-keyring&amp;quot; because it is called by other program like &amp;quot;gnome-screensave&amp;quot; and &amp;quot;gdm&amp;quot;. If we want test &amp;quot;pam_gnome_keyring.so&amp;quot;, we need write .bb files to cross-compile gnome-screensave or gdm.&lt;br /&gt;
&lt;br /&gt;
=== openssh ===&lt;br /&gt;
** Absent configuration /etc/pam.d/sshd, we need to add patches. After adding this file, it can support pam function through simple test.&lt;br /&gt;
** Test Result&lt;br /&gt;
*** Configuration of sshd&lt;br /&gt;
auth       include      common-auth&lt;br /&gt;
account    required     pam_nologin.so&lt;br /&gt;
account    include      common-auth&lt;br /&gt;
password   include      common-auth&lt;br /&gt;
session    optional     pam_keyinit.so force revoke&lt;br /&gt;
session    include      common-auth&lt;br /&gt;
session    required     pam_loginuid.so&lt;br /&gt;
*** auth include common-auth&lt;br /&gt;
 It is as same as dropbear&lt;br /&gt;
  &lt;br /&gt;
*** account required pam_nologin.so --Server&lt;br /&gt;
 $touch /etc/nologin&lt;br /&gt;
&lt;br /&gt;
*** Client&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (can&#039;t log in)&lt;br /&gt;
*** log information --Server&lt;br /&gt;
 Jul 12 08:34:08 qemux86 login[373]: FAILED LOGIN (1) on &#039;/dev/tty1&#039; FOR &#039;root&#039;, Permission denied&lt;br /&gt;
&lt;br /&gt;
=== polkit ===&lt;br /&gt;
&lt;br /&gt;
=== screen ===&lt;br /&gt;
screen use pam to authenticate users during unlock terminal. Its configure file screen comes from Fedora and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
&lt;br /&gt;
First start screen:&lt;br /&gt;
  root@qemux86:/etc/pam.d# screen&lt;br /&gt;
it will show some information about screen, just press Space or Enter and it will give a screen terminal:&lt;br /&gt;
  root@qemux86:/etc/pam.d# &lt;br /&gt;
then press &amp;quot;Ctrl+a x&amp;quot; will lock the screen terminal and show:&lt;br /&gt;
    &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
In another root terminal, clear the root&#039;s password:&lt;br /&gt;
  password -d root&lt;br /&gt;
&lt;br /&gt;
modify one line in common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
with&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so debug&lt;br /&gt;
option nullok_secure will allow users who has blank password login, after remove it these users are not allowed to login.&lt;br /&gt;
&lt;br /&gt;
Back to the screen terminal, press &amp;lt;Enter&amp;gt;(because root&#039;s password is blank now) will fail: &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
then modify the line in common-auth with &lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure debug&lt;br /&gt;
&lt;br /&gt;
On the screen terminal press &amp;lt;Enter&amp;gt; again it unlock the terminal.&lt;br /&gt;
&lt;br /&gt;
the log in /var/log/auth.log:&lt;br /&gt;
  Jul 11 14:14:14 qemux86 screen: pam_unix(screen:auth): authentication failure; logname=root uid=0 euid=0 tty= ruser= rhost=  user=root&lt;br /&gt;
&lt;br /&gt;
=== shadow ===&lt;br /&gt;
&lt;br /&gt;
=== sudo ===&lt;br /&gt;
*/etc/pam.d/sudo comes from Fedora, and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-auth&lt;br /&gt;
  password   include      common-auth&lt;br /&gt;
  session    required     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
and content of common-auth has been show above.&lt;br /&gt;
&lt;br /&gt;
*test pam plugins&lt;br /&gt;
**pam_unix.so&lt;br /&gt;
modify common-auth:&lt;br /&gt;
  auth    [success=1 default=ignore]      pam_unix.so debug&lt;br /&gt;
then unpriviledge user can NOT run sudo with blank password&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 16:39:04 qemux86 sudo: pam_unix(sudo:auth): authentication failure; logname=test-pam uid=0 euid=0 tty=/dev/pts/1 ruser=test-pam rhost=  user=test-pam&lt;br /&gt;
  Jul  8 16:39:14 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
**pam_deny.so&lt;br /&gt;
mv line&lt;br /&gt;
  auth    requisite                       pam_deny.so&lt;br /&gt;
to the head of file, unprivilege user can NOT sudo any more:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 14:03:29 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
**pam_permit.so&lt;br /&gt;
comment this line&lt;br /&gt;
  auth    required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
sudo will fail without ask user to enter password:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 12:43:22 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm -f /test&lt;br /&gt;
&lt;br /&gt;
**pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf&lt;br /&gt;
  *        -       nofile       3&lt;br /&gt;
then sudo will fail:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Inconsistency detected by ld.so: dl-deps.c: 622: _dl_map_object_deps: Assertion `nlist &amp;gt; 1&#039; failed!&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
  *        -       nofile       4&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 3 for DEFAULT&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 4 for DEFAULT&lt;br /&gt;
&lt;br /&gt;
** pam_keyinit&lt;br /&gt;
add option debug&lt;br /&gt;
  session    optional     pam_keyinit.so revoke debug&lt;br /&gt;
&lt;br /&gt;
log shows pam_keyinit was called:&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): OPEN 1&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): UID:0 [0]  GID:0 [1000]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 143761918&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 669161571&lt;br /&gt;
&lt;br /&gt;
according the source code pam_keyinit.c line 102 in function init_keyrings, the module return PAM_SUCCESS&lt;br /&gt;
&lt;br /&gt;
=== util-linux ===&lt;br /&gt;
Three programs chfn chsh and login in util-linux will use libpam. But in util-linux.inc, EXTRA_OECONF has option &amp;quot;--disable-login-utils &amp;quot; so these programs will not be built.&lt;br /&gt;
&lt;br /&gt;
Drop it.&lt;br /&gt;
&lt;br /&gt;
=== xserver-xf86-lite ===&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* mc: mc has remove package mcserv and dropped dependency on PAM already, but didn&#039;t remove checking security/pam_misc.h. Drop it. [http://www.midnight-commander.org/changeset/4816107a02ccbf6331534113e6ec0c8df84e24eb Official change log]&lt;br /&gt;
* libcap: if pam exists, libcap will create a pam plugin pam_cap.so to add a new front end for the authentication function. Because it is not a application, remove it from list.&lt;br /&gt;
* libuser: pam is libuser&#039;s build dependency, so remove it too.&lt;br /&gt;
* The busybox login has a option to use pam, but we use tinylogin&#039;s login right now (tinylogin also provides the su command)&lt;br /&gt;
* gettext only has a example &amp;quot;hello-c++-kde&amp;quot; use pam under source code directory, and it doen&#039;t be compiled and only copied to destination. So omit gettext.&lt;br /&gt;
* sysvinit has a patch contrib/notify-pam-dead.patch for /sbin/init to use pam, but the whole contrib directory didn&#039;t take part in compilation. Drop it.&lt;br /&gt;
&lt;br /&gt;
== Identify upstream PAM patches to use ==&lt;br /&gt;
After checking the Fedora develop repository, the following packages may need patches(only libpam need to upgrade, other patches are pam related configure file but they are absent in poky):&lt;br /&gt;
* libpam: need update from current 1.1.3 to 1.1.4 [https://www.redhat.com/archives/pam-list/2011-June/msg00013.html Release Notes]&lt;br /&gt;
* sudo: package sudo in Fedora provides /etc/pam.d/sudo and /etc/pam.d/sudo-i&lt;br /&gt;
** /etc/pam.d/sudo (Yocto use common-auth instead of system-auth)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      system-auth&lt;br /&gt;
  account    include      system-auth&lt;br /&gt;
  password   include      system-auth&lt;br /&gt;
  session    optional     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
&lt;br /&gt;
* screen: check Fedora screen.pam&lt;br /&gt;
&lt;br /&gt;
* util-linux: check Fedora source file util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* at: check Fedora util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* cups: check Fedora cups-1.1.16-system-auth.patch&lt;br /&gt;
&lt;br /&gt;
* openssh: check Fedora sshd.pam&lt;br /&gt;
&lt;br /&gt;
== PAM Unit Tests==&lt;br /&gt;
We use unit test cases provided by libpam itself, a subdirectory with name &amp;quot;xtests&amp;quot; under libpam source code.&lt;br /&gt;
&lt;br /&gt;
On build machine run &lt;br /&gt;
  bitbake libpam -c patch&lt;br /&gt;
to get the libpam source code Linux-PAM-1.1.4, and scp it to host(target) machine. &lt;br /&gt;
&lt;br /&gt;
On the target machine under Linux-PAM-1.1.4, run&lt;br /&gt;
  ./configure&lt;br /&gt;
  make xtests&lt;br /&gt;
will get the test result of 28 unit test case. If you want to run sigle test case, go to subdirectory xtests and run (take tst-pam_time1 for example)&lt;br /&gt;
  ./run-xtests.sh . tst-pam_time1&lt;br /&gt;
&lt;br /&gt;
Some unit test can NOT pass(15/28), they need some pam plugin libraies:&lt;br /&gt;
* tst-pam_access1&lt;br /&gt;
* tst-pam_access2&lt;br /&gt;
* tst-pam_access3&lt;br /&gt;
* tst-pam_access4&lt;br /&gt;
**the tst-pam_access test cases need pam_access.so, install package pam-plugin-access will make them pass the test&lt;br /&gt;
* tst-pam_authsucceed&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_cracklib1&lt;br /&gt;
* tst-pam_cracklib2&lt;br /&gt;
**need /lib/security/pam_cracklib.so, need build cracklib, and then libpam will check it and create pam-plugin-cracklib&lt;br /&gt;
**need /usr/share/cracklib/pw_dict.pwd file, please run command on host machine:&lt;br /&gt;
    create-cracklib-dict /usr/share/cracklib/cracklib-small&lt;br /&gt;
&lt;br /&gt;
* tst-pam_dispatch1&lt;br /&gt;
* tst-pam_dispatch2&lt;br /&gt;
* tst-pam_dispatch3&lt;br /&gt;
* tst-pam_dispatch4&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_pwhistory1&lt;br /&gt;
**need /lib/security/pam_pwhistory.so, install pam-plugin-pwhistory to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_substack2&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_succeed_if1&lt;br /&gt;
**install pam-plugin-succeed-if to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_time1&lt;br /&gt;
**install pam-plugin-time to make it pass&lt;/div&gt;</summary>
		<author><name>Wfan</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2740</id>
		<title>PAM Integration</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2740"/>
		<updated>2011-07-12T09:19:51Z</updated>

		<summary type="html">&lt;p&gt;Wfan: /* cronie */ Add test results for crond&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Motivation ==&lt;br /&gt;
For Yocto 1.1 we are working to ensure that PAM (Pluggable Authentication Module) support is consistent and enabled in recipes where it is applicable. &lt;br /&gt;
&lt;br /&gt;
== Common configure files ==&lt;br /&gt;
For convenience, list common configure files here:&lt;br /&gt;
&lt;br /&gt;
common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
  auth	requisite			pam_deny.so&lt;br /&gt;
  auth	required			pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-account&lt;br /&gt;
  account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so &lt;br /&gt;
  account requisite                       pam_deny.so&lt;br /&gt;
  account required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-password&lt;br /&gt;
  password        [success=1 default=ignore]      pam_unix.so obscure sha512&lt;br /&gt;
  password        requisite                       pam_deny.so&lt;br /&gt;
  password        required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
common-session&lt;br /&gt;
  session [default=1]                     pam_permit.so&lt;br /&gt;
  session requisite                       pam_deny.so&lt;br /&gt;
  session required                        pam_permit.so&lt;br /&gt;
  session required        pam_unix.so &lt;br /&gt;
&lt;br /&gt;
common-session-noninteractive&lt;br /&gt;
  session [default=1]                     pam_permit.so&lt;br /&gt;
  session requisite                       pam_deny.so&lt;br /&gt;
  session required                        pam_permit.so&lt;br /&gt;
  session required        pam_unix.so &lt;br /&gt;
&lt;br /&gt;
== Recipes with PAM support ==&lt;br /&gt;
The following recipes were identified to have PAM support (some already implemented) on 2011-06-27:&lt;br /&gt;
&lt;br /&gt;
=== at === &lt;br /&gt;
** Open issue:&lt;br /&gt;
** It can&#039;t be ran by a non-root user, error message is:&lt;br /&gt;
 Can&#039;t signal atd (permission denied)&lt;br /&gt;
&lt;br /&gt;
** Simple ways to verify &#039;at&#039;:&lt;br /&gt;
 $ at now&lt;br /&gt;
 $ echo &amp;quot;$msg_to_print&amp;quot; &amp;gt;&amp;gt; /tmp/at_test&lt;br /&gt;
 $ &amp;lt; ctrl+D &amp;gt;&lt;br /&gt;
 $ cat /tmp/at_test    # Verify if the message has been there &lt;br /&gt;
&lt;br /&gt;
** /etc/pam.d/atd - not installed by default, copy it from source code and replace &#039;@include&#039; with appropriate &#039;module-type include&#039;:&lt;br /&gt;
&lt;br /&gt;
 auth       required    pam_env.so&lt;br /&gt;
 auth       include     common-auth&lt;br /&gt;
 account    include     common-account&lt;br /&gt;
 session    include     common-session-noninteractive&lt;br /&gt;
 session    required    pam_limits.so&lt;br /&gt;
&lt;br /&gt;
** test pam plugins&lt;br /&gt;
*** pam_env.so&lt;br /&gt;
modify /etc/pam.d/atd&lt;br /&gt;
 auth       required    pam_env.so    debug&lt;br /&gt;
modify /etc/security/pam_env.conf, add a test entry such as:&lt;br /&gt;
 MYNAME          DEFAULT=&amp;quot;test-at&amp;quot;&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:41:22 qemux86 atd[678]: pam_env(atd:setcred): pam_putenv(&amp;quot;MYNAME=test-at&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
*** pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf &lt;br /&gt;
 root    -       nofile  3&lt;br /&gt;
&#039;at&#039; job failed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:49:42 qemux86 atd[699]: pam_env(atd:setcred): Unable to open config file: /etc/security/pam_env.conf: Too many open files&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
 root    -       nofile  4&lt;br /&gt;
&#039;at&#039; job successed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session opened for user root by (uid=0)                      &lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session closed for user root&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== consolekit ===&lt;br /&gt;
&lt;br /&gt;
=== cronie ===&lt;br /&gt;
** Open issue:&lt;br /&gt;
** Can&#039;t run &#039;crontab&#039; command with non-root user, error message is:&lt;br /&gt;
 You (test-pam) are not allowed to access to (crontab) because of pam configuration.&lt;br /&gt;
 Jul 12 02:36:14 qemux86 unix_chkpwd[768]: could not obtain user info (test-pam)&lt;br /&gt;
&lt;br /&gt;
** /etc/pam.d/crond:&lt;br /&gt;
 account    required   pam_access.so&lt;br /&gt;
 account    include    password-auth&lt;br /&gt;
 session    required   pam_loginuid.so&lt;br /&gt;
 session    include    password-auth&lt;br /&gt;
 auth       include    password-auth&lt;br /&gt;
&lt;br /&gt;
** /etc/pam.d/password-auth:&lt;br /&gt;
 auth        required      pam_env.so&lt;br /&gt;
 auth        sufficient    pam_unix.so nullok try_first_pass&lt;br /&gt;
 auth        requisite     pam_succeed_if.so uid &amp;gt;= 500 quiet&lt;br /&gt;
 auth        required      pam_deny.so&lt;br /&gt;
 account     required      pam_unix.so&lt;br /&gt;
 account     sufficient    pam_localuser.so&lt;br /&gt;
 account     sufficient    pam_succeed_if.so uid &amp;lt; 500 quiet&lt;br /&gt;
 account     required      pam_permit.so&lt;br /&gt;
 password    requisite     pam_cracklib.so try_first_pass retry=3 type=&lt;br /&gt;
 password    sufficient    pam_unix.so sha512 shadow nullok try_first_pass use_authtok&lt;br /&gt;
 password    required      pam_deny.so&lt;br /&gt;
 session     optional      pam_keyinit.so revoke&lt;br /&gt;
 session     required      pam_limits.so&lt;br /&gt;
 -session     optional      pam_systemd.so&lt;br /&gt;
 session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid&lt;br /&gt;
 session     required      pam_unix.so&lt;br /&gt;
&lt;br /&gt;
** test commands:&lt;br /&gt;
 crontab -e    # establish a crontab jobs and check if it works&lt;br /&gt;
 crontab -l    # list crontab jobs for current user&lt;br /&gt;
&lt;br /&gt;
** test pam plugins&lt;br /&gt;
Verified, test ways and the logs/results please refer to other packages:&lt;br /&gt;
*** pam_env.so&lt;br /&gt;
*** pam_access.so&lt;br /&gt;
*** pam_unix.so&lt;br /&gt;
*** pam_permit.so&lt;br /&gt;
*** pam_keyinit.so &lt;br /&gt;
&lt;br /&gt;
*** pam_localuser.so&lt;br /&gt;
copy &#039;/etc/passwd&#039; to &#039;/tmp/passwd&#039; and delete the entry for &#039;root&#039;;&lt;br /&gt;
modify /etc/pam.d/password-auth:&lt;br /&gt;
 account     requisite    pam_localuser.so file=/tmp/passwd debug&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): set filename to &amp;quot;/tmp/passwd&amp;quot;&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): checking &amp;quot;daemon:x:1:1:daemon:/usr/sbin:/bin/sh &amp;quot;&lt;br /&gt;
 Jul 12 02:58:51 qemux86 crontab: pam_localuser(crond:account): checking &amp;quot;bin:x:2:2:bin:/bin:/bin/sh &amp;quot;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
*** pam_succeed_if.so&lt;br /&gt;
account     requisite    pam_succeed_if.so uid &amp;gt; 500 debug&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 12 03:14:14 qemux86 crontab: pam_succeed_if(crond:account): &#039;uid&#039; resolves to &#039;0&#039;&lt;br /&gt;
 Jul 12 03:14:14 qemux86 crontab: pam_succeed_if(crond:account): requirement &amp;quot;uid &amp;gt; 500&amp;quot; not met by user &amp;quot;root&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*** pam_loginuid.so&lt;br /&gt;
 TBD&lt;br /&gt;
&lt;br /&gt;
*** pam_systemd.so&lt;br /&gt;
 no this module&lt;br /&gt;
&lt;br /&gt;
=== cups ===&lt;br /&gt;
&lt;br /&gt;
=== dropbear ===&lt;br /&gt;
** For supporting pam in dropbear, we need two steps:&lt;br /&gt;
** Add configuration &amp;quot;--enable-pam&amp;quot; &lt;br /&gt;
** Add patches to open macro definition for supporting in option.h&lt;br /&gt;
 --- a/ptions.h  2011-07-12 11:32:34.165333202 +0800&lt;br /&gt;
 +++ b/options.h.new     2011-07-12 11:33:25.757332986 +0800&lt;br /&gt;
 @@ -149,9 +149,9 @@&lt;br /&gt;
   * but there&#039;s an interface via a PAM module - don&#039;t bother using it otherwise.&lt;br /&gt;
   * You can&#039;t enable both PASSWORD and PAM. */&lt;br /&gt;
 -#define ENABLE_SVR_PASSWORD_AUTH&lt;br /&gt;
 +//#define ENABLE_SVR_PASSWORD_AUTH&lt;br /&gt;
  /* PAM requires ./configure --enable-pam */&lt;br /&gt;
 -/*#define ENABLE_SVR_PAM_AUTH*/&lt;br /&gt;
 +#define ENABLE_SVR_PAM_AUTH&lt;br /&gt;
  #define ENABLE_SVR_PUBKEY_AUTH&lt;br /&gt;
  /* Wether to ake public key options in authorized_keys file into account */&lt;br /&gt;
&lt;br /&gt;
** Test result(dropbeat only support simple authentication, account and auth)&lt;br /&gt;
*** Server(account)&lt;br /&gt;
 (server ip:192.168.7.2)&lt;br /&gt;
 $touch /etc/pam.d/sshd&lt;br /&gt;
 account  required     pam_access.so&lt;br /&gt;
 $vi /etc/security/access.conf&lt;br /&gt;
 - : root : ALL&lt;br /&gt;
&lt;br /&gt;
*** Client&lt;br /&gt;
 $ssh root@192.168.7.2&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied, please try again.&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied, please try again.&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied (publickey,password).&lt;br /&gt;
&lt;br /&gt;
*** Server(auth)&lt;br /&gt;
 $vi /etc/pam.d/sshd&lt;br /&gt;
  auth include common-auth&lt;br /&gt;
 $vi /etc/pam.d/common-auth&lt;br /&gt;
 #auth   [success=1 default=ignore]      pam_unix.so nullok_secure&lt;br /&gt;
 auth    [success=0 default=ignore]      pam_unix.so debug&lt;br /&gt;
&lt;br /&gt;
*** Client&lt;br /&gt;
 $ssh root@192.168.7.2&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied, please try again.&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied, please try again.&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied (publickey,password).&lt;br /&gt;
&lt;br /&gt;
=== gnome-keyring ===&lt;br /&gt;
* gnome-keyring can&#039;t call configuration file like &amp;quot;/etc/pam.d/gnome-keyring&amp;quot; because it is called by other program like &amp;quot;gnome-screensave&amp;quot; and &amp;quot;gdm&amp;quot;. If we want test &amp;quot;pam_gnome_keyring.so&amp;quot;, we need write .bb files to cross-compile gnome-screensave or gdm.&lt;br /&gt;
&lt;br /&gt;
=== openssh ===&lt;br /&gt;
** Absent configuration /etc/pam.d/sshd, we need to add patches. After adding this file, it can support pam function through simple test.&lt;br /&gt;
** Test Result&lt;br /&gt;
*** Configuration of sshd&lt;br /&gt;
auth       include      common-auth&lt;br /&gt;
account    required     pam_nologin.so&lt;br /&gt;
account    include      common-auth&lt;br /&gt;
password   include      common-auth&lt;br /&gt;
session    optional     pam_keyinit.so force revoke&lt;br /&gt;
session    include      common-auth&lt;br /&gt;
session    required     pam_loginuid.so&lt;br /&gt;
*** auth include common-auth&lt;br /&gt;
 It is as same as dropbear&lt;br /&gt;
  &lt;br /&gt;
*** account required pam_nologin.so --Server&lt;br /&gt;
 $touch /etc/nologin&lt;br /&gt;
&lt;br /&gt;
*** Client&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (can&#039;t log in)&lt;br /&gt;
*** log information --Server&lt;br /&gt;
 Jul 12 08:34:08 qemux86 login[373]: FAILED LOGIN (1) on &#039;/dev/tty1&#039; FOR &#039;root&#039;, Permission denied&lt;br /&gt;
&lt;br /&gt;
=== polkit ===&lt;br /&gt;
&lt;br /&gt;
=== screen ===&lt;br /&gt;
screen use pam to authenticate users during unlock terminal. Its configure file screen comes from Fedora and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
&lt;br /&gt;
First start screen:&lt;br /&gt;
  root@qemux86:/etc/pam.d# screen&lt;br /&gt;
it will show some information about screen, just press Space or Enter and it will give a screen terminal:&lt;br /&gt;
  root@qemux86:/etc/pam.d# &lt;br /&gt;
then press &amp;quot;Ctrl+a x&amp;quot; will lock the screen terminal and show:&lt;br /&gt;
    &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
In another root terminal, clear the root&#039;s password:&lt;br /&gt;
  password -d root&lt;br /&gt;
&lt;br /&gt;
modify one line in common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
with&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so debug&lt;br /&gt;
option nullok_secure will allow users who has blank password login, after remove it these users are not allowed to login.&lt;br /&gt;
&lt;br /&gt;
Back to the screen terminal, press &amp;lt;Enter&amp;gt;(because root&#039;s password is blank now) will fail: &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
then modify the line in common-auth with &lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure debug&lt;br /&gt;
&lt;br /&gt;
On the screen terminal press &amp;lt;Enter&amp;gt; again it unlock the terminal.&lt;br /&gt;
&lt;br /&gt;
the log in /var/log/auth.log:&lt;br /&gt;
  Jul 11 14:14:14 qemux86 screen: pam_unix(screen:auth): authentication failure; logname=root uid=0 euid=0 tty= ruser= rhost=  user=root&lt;br /&gt;
&lt;br /&gt;
=== shadow ===&lt;br /&gt;
&lt;br /&gt;
=== sudo ===&lt;br /&gt;
*/etc/pam.d/sudo comes from Fedora, and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-auth&lt;br /&gt;
  password   include      common-auth&lt;br /&gt;
  session    required     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
and content of common-auth has been show above.&lt;br /&gt;
&lt;br /&gt;
*test pam plugins&lt;br /&gt;
**pam_unix.so&lt;br /&gt;
modify common-auth:&lt;br /&gt;
  auth    [success=1 default=ignore]      pam_unix.so debug&lt;br /&gt;
then unpriviledge user can NOT run sudo with blank password&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 16:39:04 qemux86 sudo: pam_unix(sudo:auth): authentication failure; logname=test-pam uid=0 euid=0 tty=/dev/pts/1 ruser=test-pam rhost=  user=test-pam&lt;br /&gt;
  Jul  8 16:39:14 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
**pam_deny.so&lt;br /&gt;
mv line&lt;br /&gt;
  auth    requisite                       pam_deny.so&lt;br /&gt;
to the head of file, unprivilege user can NOT sudo any more:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 14:03:29 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
**pam_permit.so&lt;br /&gt;
comment this line&lt;br /&gt;
  auth    required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
sudo will fail without ask user to enter password:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 12:43:22 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm -f /test&lt;br /&gt;
&lt;br /&gt;
**pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf&lt;br /&gt;
  *        -       nofile       3&lt;br /&gt;
then sudo will fail:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Inconsistency detected by ld.so: dl-deps.c: 622: _dl_map_object_deps: Assertion `nlist &amp;gt; 1&#039; failed!&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
  *        -       nofile       4&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 3 for DEFAULT&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 4 for DEFAULT&lt;br /&gt;
&lt;br /&gt;
** pam_keyinit&lt;br /&gt;
add option debug&lt;br /&gt;
  session    optional     pam_keyinit.so revoke debug&lt;br /&gt;
&lt;br /&gt;
log shows pam_keyinit was called:&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): OPEN 1&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): UID:0 [0]  GID:0 [1000]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 143761918&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 669161571&lt;br /&gt;
&lt;br /&gt;
according the source code pam_keyinit.c line 102 in function init_keyrings, the module return PAM_SUCCESS&lt;br /&gt;
&lt;br /&gt;
=== util-linux ===&lt;br /&gt;
Three programs chfn chsh and login in util-linux will use libpam. But in util-linux.inc, EXTRA_OECONF has option &amp;quot;--disable-login-utils &amp;quot; so these programs will not be built.&lt;br /&gt;
&lt;br /&gt;
Drop it.&lt;br /&gt;
&lt;br /&gt;
=== xserver-xf86-lite ===&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* mc: mc has remove package mcserv and dropped dependency on PAM already, but didn&#039;t remove checking security/pam_misc.h. Drop it. [http://www.midnight-commander.org/changeset/4816107a02ccbf6331534113e6ec0c8df84e24eb Official change log]&lt;br /&gt;
* libcap: if pam exists, libcap will create a pam plugin pam_cap.so to add a new front end for the authentication function. Because it is not a application, remove it from list.&lt;br /&gt;
* libuser: pam is libuser&#039;s build dependency, so remove it too.&lt;br /&gt;
* The busybox login has a option to use pam, but we use tinylogin&#039;s login right now (tinylogin also provides the su command)&lt;br /&gt;
* gettext only has a example &amp;quot;hello-c++-kde&amp;quot; use pam under source code directory, and it doen&#039;t be compiled and only copied to destination. So omit gettext.&lt;br /&gt;
* sysvinit has a patch contrib/notify-pam-dead.patch for /sbin/init to use pam, but the whole contrib directory didn&#039;t take part in compilation. Drop it.&lt;br /&gt;
&lt;br /&gt;
== Identify upstream PAM patches to use ==&lt;br /&gt;
After checking the Fedora develop repository, the following packages may need patches(only libpam need to upgrade, other patches are pam related configure file but they are absent in poky):&lt;br /&gt;
* libpam: need update from current 1.1.3 to 1.1.4 [https://www.redhat.com/archives/pam-list/2011-June/msg00013.html Release Notes]&lt;br /&gt;
* sudo: package sudo in Fedora provides /etc/pam.d/sudo and /etc/pam.d/sudo-i&lt;br /&gt;
** /etc/pam.d/sudo (Yocto use common-auth instead of system-auth)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      system-auth&lt;br /&gt;
  account    include      system-auth&lt;br /&gt;
  password   include      system-auth&lt;br /&gt;
  session    optional     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
&lt;br /&gt;
* screen: check Fedora screen.pam&lt;br /&gt;
&lt;br /&gt;
* util-linux: check Fedora source file util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* at: check Fedora util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* cups: check Fedora cups-1.1.16-system-auth.patch&lt;br /&gt;
&lt;br /&gt;
* openssh: check Fedora sshd.pam&lt;br /&gt;
&lt;br /&gt;
== PAM Unit Tests==&lt;br /&gt;
We use unit test cases provided by libpam itself, a subdirectory with name &amp;quot;xtests&amp;quot; under libpam source code.&lt;br /&gt;
&lt;br /&gt;
On build machine run &lt;br /&gt;
  bitbake libpam -c patch&lt;br /&gt;
to get the libpam source code Linux-PAM-1.1.4, and scp it to host(target) machine. &lt;br /&gt;
&lt;br /&gt;
On the target machine under Linux-PAM-1.1.4, run&lt;br /&gt;
  ./configure&lt;br /&gt;
  make xtests&lt;br /&gt;
will get the test result of 28 unit test case. If you want to run sigle test case, go to subdirectory xtests and run (take tst-pam_time1 for example)&lt;br /&gt;
  ./run-xtests.sh . tst-pam_time1&lt;br /&gt;
&lt;br /&gt;
Some unit test can NOT pass(15/28), they need some pam plugin libraies:&lt;br /&gt;
* tst-pam_access1&lt;br /&gt;
* tst-pam_access2&lt;br /&gt;
* tst-pam_access3&lt;br /&gt;
* tst-pam_access4&lt;br /&gt;
**the tst-pam_access test cases need pam_access.so, install package pam-plugin-access will make them pass the test&lt;br /&gt;
* tst-pam_authsucceed&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_cracklib1&lt;br /&gt;
* tst-pam_cracklib2&lt;br /&gt;
**need /lib/security/pam_cracklib.so, need build cracklib, and then libpam will check it and create pam-plugin-cracklib&lt;br /&gt;
**need /usr/share/cracklib/pw_dict.pwd file, please run command on host machine:&lt;br /&gt;
    create-cracklib-dict /usr/share/cracklib/cracklib-small&lt;br /&gt;
&lt;br /&gt;
* tst-pam_dispatch1&lt;br /&gt;
* tst-pam_dispatch2&lt;br /&gt;
* tst-pam_dispatch3&lt;br /&gt;
* tst-pam_dispatch4&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_pwhistory1&lt;br /&gt;
**need /lib/security/pam_pwhistory.so, install pam-plugin-pwhistory to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_substack2&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_succeed_if1&lt;br /&gt;
**install pam-plugin-succeed-if to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_time1&lt;br /&gt;
**install pam-plugin-time to make it pass&lt;/div&gt;</summary>
		<author><name>Wfan</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2715</id>
		<title>PAM Integration</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2715"/>
		<updated>2011-07-11T09:12:30Z</updated>

		<summary type="html">&lt;p&gt;Wfan: /* at */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Motivation ==&lt;br /&gt;
For Yocto 1.1 we are working to ensure that PAM (Pluggable Authentication Module) support is consistent and enabled in recipes where it is applicable. &lt;br /&gt;
&lt;br /&gt;
== Recipes with PAM support ==&lt;br /&gt;
The following recipes were identified to have PAM support (some already implemented) on 2011-06-27:&lt;br /&gt;
&lt;br /&gt;
=== at === &lt;br /&gt;
** Open issue:&lt;br /&gt;
** It can&#039;t be ran by a non-root user, error message is:&lt;br /&gt;
 Can&#039;t signal atd (permission denied)&lt;br /&gt;
&lt;br /&gt;
** Simple ways to verify &#039;at&#039;:&lt;br /&gt;
 $ at now&lt;br /&gt;
 $ echo &amp;quot;$msg_to_print&amp;quot; &amp;gt;&amp;gt; /tmp/at_test&lt;br /&gt;
 $ &amp;lt; ctrl+D &amp;gt;&lt;br /&gt;
 $ cat /tmp/at_test    # Verify if the message has been there &lt;br /&gt;
&lt;br /&gt;
** /etc/pam.d/atd - not installed by default, copy it from source code and replace &#039;@include&#039; with appropriate &#039;module-type include&#039;:&lt;br /&gt;
&lt;br /&gt;
 auth       required    pam_env.so&lt;br /&gt;
 auth       include     common-auth&lt;br /&gt;
 account    include     common-account&lt;br /&gt;
 session    include     common-session-noninteractive&lt;br /&gt;
 session    required    pam_limits.so&lt;br /&gt;
&lt;br /&gt;
** test pam plugins&lt;br /&gt;
*** pam_env.so&lt;br /&gt;
modify /etc/pam.d/atd&lt;br /&gt;
 auth       required    pam_env.so    debug&lt;br /&gt;
modify /etc/security/pam_env.conf, add a test entry such as:&lt;br /&gt;
 MYNAME          DEFAULT=&amp;quot;test-at&amp;quot;&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:41:22 qemux86 atd[678]: pam_env(atd:setcred): pam_putenv(&amp;quot;MYNAME=test-at&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
*** pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf &lt;br /&gt;
 root    -       nofile  3&lt;br /&gt;
&#039;at&#039; job failed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:49:42 qemux86 atd[699]: pam_env(atd:setcred): Unable to open config file: /etc/security/pam_env.conf: Too many open files&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
 root    -       nofile  4&lt;br /&gt;
&#039;at&#039; job successed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session opened for user root by (uid=0)                      &lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session closed for user root&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* consolekit&lt;br /&gt;
&lt;br /&gt;
* cronie&lt;br /&gt;
&lt;br /&gt;
* cups&lt;br /&gt;
&lt;br /&gt;
* dropbear&lt;br /&gt;
** For supporting pam in dropbear, we need two steps:&lt;br /&gt;
** Add configuration &amp;quot;--enable-pam&amp;quot; &lt;br /&gt;
** Add patches to open macro definition for supporting in option.h&lt;br /&gt;
** Test result&lt;br /&gt;
*** Server&lt;br /&gt;
 (server ip:192.168.7.2)&lt;br /&gt;
 $touch /etc/pam.d/sshd&lt;br /&gt;
 account  required     pam_access.so&lt;br /&gt;
 $vi /etc/security/access.conf&lt;br /&gt;
 - : root : ALL&lt;br /&gt;
&lt;br /&gt;
*** Client&lt;br /&gt;
 $ssh root@192.168.7.2&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied, please try again.&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied, please try again.&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied (publickey,password).&lt;br /&gt;
&lt;br /&gt;
* gnome-keyring&lt;br /&gt;
&lt;br /&gt;
* openssh&lt;br /&gt;
** Absent configuration /etc/pam.d/sshd, we need to add patches. After adding this file, it can support pam function through simple test.&lt;br /&gt;
** Test Result&lt;br /&gt;
*** Server&lt;br /&gt;
 $touch /etc/nologin&lt;br /&gt;
&lt;br /&gt;
*** Client&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (can&#039;t log in)&lt;br /&gt;
* polkit&lt;br /&gt;
&lt;br /&gt;
* screen&lt;br /&gt;
screen use pam to authenticate users during unlock terminal. Its configure file screen comes from Fedora and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
&lt;br /&gt;
First start screen:&lt;br /&gt;
  root@qemux86:/etc/pam.d# screen&lt;br /&gt;
it will show some information about screen, just press Space or Enter and it will give a screen terminal:&lt;br /&gt;
  root@qemux86:/etc/pam.d# &lt;br /&gt;
then press &amp;quot;Ctrl+a x&amp;quot; will lock the screen terminal and show:&lt;br /&gt;
    &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
In another root terminal, clear the root&#039;s password:&lt;br /&gt;
  password -d root&lt;br /&gt;
&lt;br /&gt;
modify one line in common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
with&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so debug&lt;br /&gt;
option nullok_secure will allow users who has blank password login, after remove it these users are not allowed to login.&lt;br /&gt;
&lt;br /&gt;
Back to the screen terminal, press &amp;lt;Enter&amp;gt;(because root&#039;s password is blank now) will fail: &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
then modify the line in common-auth with &lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure debug&lt;br /&gt;
&lt;br /&gt;
On the screen terminal press &amp;lt;Enter&amp;gt; again it unlock the terminal.&lt;br /&gt;
&lt;br /&gt;
the log in /var/log/auth.log:&lt;br /&gt;
  Jul 11 14:14:14 qemux86 screen: pam_unix(screen:auth): authentication failure; logname=root uid=0 euid=0 tty= ruser= rhost=  user=root&lt;br /&gt;
&lt;br /&gt;
* shadow&lt;br /&gt;
&lt;br /&gt;
* sudo&lt;br /&gt;
**/etc/pam.d/sudo comes from Fedora, and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-auth&lt;br /&gt;
  password   include      common-auth&lt;br /&gt;
  session    required     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
and content of common-auth:&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
  auth	requisite			pam_deny.so&lt;br /&gt;
  auth	required			pam_permit.so&lt;br /&gt;
**test pam plugins&lt;br /&gt;
***pam_unix.so&lt;br /&gt;
modify common-auth:&lt;br /&gt;
  auth    [success=1 default=ignore]      pam_unix.so debug&lt;br /&gt;
then unpriviledge user can NOT run sudo with blank password&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 16:39:04 qemux86 sudo: pam_unix(sudo:auth): authentication failure; logname=test-pam uid=0 euid=0 tty=/dev/pts/1 ruser=test-pam rhost=  user=test-pam&lt;br /&gt;
  Jul  8 16:39:14 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
***pam_deny.so&lt;br /&gt;
mv line&lt;br /&gt;
  auth    requisite                       pam_deny.so&lt;br /&gt;
to the head of file, unprivilege user can NOT sudo any more:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 14:03:29 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
***pam_permit.so&lt;br /&gt;
comment this line&lt;br /&gt;
  auth    required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
sudo will fail without ask user to enter password:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 12:43:22 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm -f /test&lt;br /&gt;
&lt;br /&gt;
***pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf&lt;br /&gt;
  *        -       nofile       3&lt;br /&gt;
then sudo will fail:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Inconsistency detected by ld.so: dl-deps.c: 622: _dl_map_object_deps: Assertion `nlist &amp;gt; 1&#039; failed!&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
  *        -       nofile       4&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 3 for DEFAULT&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 4 for DEFAULT&lt;br /&gt;
&lt;br /&gt;
*** pam_keyinit&lt;br /&gt;
add option debug&lt;br /&gt;
  session    optional     pam_keyinit.so revoke debug&lt;br /&gt;
&lt;br /&gt;
log shows pam_keyinit was called:&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): OPEN 1&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): UID:0 [0]  GID:0 [1000]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 143761918&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 669161571&lt;br /&gt;
&lt;br /&gt;
according the source code pam_keyinit.c line 102 in function init_keyrings, the module return PAM_SUCCESS&lt;br /&gt;
&lt;br /&gt;
* util-linux&lt;br /&gt;
&lt;br /&gt;
* xserver-xf86-lite&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* mc: mc has remove package mcserv and dropped dependency on PAM already, but didn&#039;t remove checking security/pam_misc.h. Drop it. [http://www.midnight-commander.org/changeset/4816107a02ccbf6331534113e6ec0c8df84e24eb Official change log]&lt;br /&gt;
* libcap: if pam exists, libcap will create a pam plugin pam_cap.so to add a new front end for the authentication function. Because it is not a application, remove it from list.&lt;br /&gt;
* libuser: pam is libuser&#039;s build dependency, so remove it too.&lt;br /&gt;
* The busybox login has a option to use pam, but we use tinylogin&#039;s login right now (tinylogin also provides the su command)&lt;br /&gt;
* gettext only has a example &amp;quot;hello-c++-kde&amp;quot; use pam under source code directory, and it doen&#039;t be compiled and only copied to destination. So omit gettext.&lt;br /&gt;
* sysvinit has a patch contrib/notify-pam-dead.patch for /sbin/init to use pam, but the whole contrib directory didn&#039;t take part in compilation. Drop it.&lt;br /&gt;
&lt;br /&gt;
== Identify upstream PAM patches to use ==&lt;br /&gt;
After checking the Fedora develop repository, the following packages may need patches(only libpam need to upgrade, other patches are pam related configure file but they are absent in poky):&lt;br /&gt;
* libpam: need update from current 1.1.3 to 1.1.4 [https://www.redhat.com/archives/pam-list/2011-June/msg00013.html Release Notes]&lt;br /&gt;
* sudo: package sudo in Fedora provides /etc/pam.d/sudo and /etc/pam.d/sudo-i&lt;br /&gt;
** /etc/pam.d/sudo (Yocto use common-auth instead of system-auth)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      system-auth&lt;br /&gt;
  account    include      system-auth&lt;br /&gt;
  password   include      system-auth&lt;br /&gt;
  session    optional     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
&lt;br /&gt;
* screen: check Fedora screen.pam&lt;br /&gt;
&lt;br /&gt;
* util-linux: check Fedora source file util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* at: check Fedora util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* cups: check Fedora cups-1.1.16-system-auth.patch&lt;br /&gt;
&lt;br /&gt;
* openssh: check Fedora sshd.pam&lt;br /&gt;
&lt;br /&gt;
== PAM Unit Tests==&lt;br /&gt;
We use unit test cases provided by libpam itself, a subdirectory with name &amp;quot;xtests&amp;quot; under libpam source code.&lt;br /&gt;
&lt;br /&gt;
On build machine run &lt;br /&gt;
  bitbake libpam -c patch&lt;br /&gt;
to get the libpam source code Linux-PAM-1.1.4, and scp it to host(target) machine. &lt;br /&gt;
&lt;br /&gt;
On the target machine under Linux-PAM-1.1.4, run&lt;br /&gt;
  ./configure&lt;br /&gt;
  make xtests&lt;br /&gt;
will get the test result of 28 unit test case. If you want to run sigle test case, go to subdirectory xtests and run (take tst-pam_time1 for example)&lt;br /&gt;
  ./run-xtests.sh . tst-pam_time1&lt;br /&gt;
&lt;br /&gt;
Some unit test can NOT pass(15/28), they need some pam plugin libraies:&lt;br /&gt;
* tst-pam_access1&lt;br /&gt;
* tst-pam_access2&lt;br /&gt;
* tst-pam_access3&lt;br /&gt;
* tst-pam_access4&lt;br /&gt;
**the tst-pam_access test cases need pam_access.so, install package pam-plugin-access will make them pass the test&lt;br /&gt;
* tst-pam_authsucceed&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_cracklib1&lt;br /&gt;
* tst-pam_cracklib2&lt;br /&gt;
**need /lib/security/pam_cracklib.so, need build cracklib, and then libpam will check it and create pam-plugin-cracklib&lt;br /&gt;
**need /usr/share/cracklib/pw_dict.pwd file, please run command on host machine:&lt;br /&gt;
    create-cracklib-dict /usr/share/cracklib/cracklib-small&lt;br /&gt;
&lt;br /&gt;
* tst-pam_dispatch1&lt;br /&gt;
* tst-pam_dispatch2&lt;br /&gt;
* tst-pam_dispatch3&lt;br /&gt;
* tst-pam_dispatch4&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_pwhistory1&lt;br /&gt;
**need /lib/security/pam_pwhistory.so, install pam-plugin-pwhistory to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_substack2&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_succeed_if1&lt;br /&gt;
**install pam-plugin-succeed-if to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_time1&lt;br /&gt;
**install pam-plugin-time to make it pass&lt;br /&gt;
&lt;br /&gt;
=== position ===&lt;/div&gt;</summary>
		<author><name>Wfan</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2714</id>
		<title>PAM Integration</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=PAM_Integration&amp;diff=2714"/>
		<updated>2011-07-11T09:04:23Z</updated>

		<summary type="html">&lt;p&gt;Wfan: /* Recipes with PAM support */ Add test results for at&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Motivation ==&lt;br /&gt;
For Yocto 1.1 we are working to ensure that PAM (Pluggable Authentication Module) support is consistent and enabled in recipes where it is applicable. &lt;br /&gt;
&lt;br /&gt;
== Recipes with PAM support ==&lt;br /&gt;
The following recipes were identified to have PAM support (some already implemented) on 2011-06-27:&lt;br /&gt;
&lt;br /&gt;
=== at === &lt;br /&gt;
** Open issue:&lt;br /&gt;
** It can&#039;t be ran by a non-root user, error message is:&lt;br /&gt;
 Can&#039;t signal atd (permission denied)&lt;br /&gt;
&lt;br /&gt;
** /etc/pam.d/atd - not installed by default, copy it from source code and replace &#039;@include&#039; with appropriate &#039;module-type include&#039;:&lt;br /&gt;
&lt;br /&gt;
 auth       required    pam_env.so&lt;br /&gt;
 auth       include     common-auth&lt;br /&gt;
 account    include     common-account&lt;br /&gt;
 session    include     common-session-noninteractive&lt;br /&gt;
 session    required    pam_limits.so&lt;br /&gt;
&lt;br /&gt;
** test pam plugins&lt;br /&gt;
*** pam_env.so&lt;br /&gt;
modify /etc/pam.d/atd&lt;br /&gt;
 auth       required    pam_env.so    debug&lt;br /&gt;
modify /etc/security/pam_env.conf, add a test entry such as:&lt;br /&gt;
 MYNAME          DEFAULT=&amp;quot;test-at&amp;quot;&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:41:22 qemux86 atd[678]: pam_env(atd:setcred): pam_putenv(&amp;quot;MYNAME=test-at&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
*** pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf &lt;br /&gt;
 root    -       nofile  3&lt;br /&gt;
at task failed, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:49:42 qemux86 atd[699]: pam_env(atd:setcred): Unable to open config file: /etc/security/pam_env.conf: Too many open files&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
 root    -       nofile  4&lt;br /&gt;
at task success, log in /var/log/auth.log:&lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session opened for user root by (uid=0)                      &lt;br /&gt;
 Jul 11 08:59:59 qemux86 atd[738]: pam_unix(atd:session): session closed for user root&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* consolekit&lt;br /&gt;
&lt;br /&gt;
* cronie&lt;br /&gt;
&lt;br /&gt;
* cups&lt;br /&gt;
&lt;br /&gt;
* dropbear&lt;br /&gt;
** For supporting pam in dropbear, we need two steps:&lt;br /&gt;
** Add configuration &amp;quot;--enable-pam&amp;quot; &lt;br /&gt;
** Add patches to open macro definition for supporting in option.h&lt;br /&gt;
** Test result&lt;br /&gt;
*** Server&lt;br /&gt;
 (server ip:192.168.7.2)&lt;br /&gt;
 $touch /etc/pam.d/sshd&lt;br /&gt;
 account  required     pam_access.so&lt;br /&gt;
 $vi /etc/security/access.conf&lt;br /&gt;
 - : root : ALL&lt;br /&gt;
&lt;br /&gt;
*** Client&lt;br /&gt;
 $ssh root@192.168.7.2&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied, please try again.&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied, please try again.&lt;br /&gt;
 root@192.168.7.2&#039;s password: &lt;br /&gt;
 Permission denied (publickey,password).&lt;br /&gt;
&lt;br /&gt;
* gnome-keyring&lt;br /&gt;
&lt;br /&gt;
* openssh&lt;br /&gt;
** Absent configuration /etc/pam.d/sshd, we need to add patches. After adding this file, it can support pam function through simple test.&lt;br /&gt;
** Test Result&lt;br /&gt;
*** Server&lt;br /&gt;
 $touch /etc/nologin&lt;br /&gt;
&lt;br /&gt;
*** Client&lt;br /&gt;
 $ssh username@server-ip&lt;br /&gt;
 (can&#039;t log in)&lt;br /&gt;
* polkit&lt;br /&gt;
&lt;br /&gt;
* screen&lt;br /&gt;
screen use pam to authenticate users during unlock terminal. Its configure file screen comes from Fedora and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
&lt;br /&gt;
First start screen:&lt;br /&gt;
  root@qemux86:/etc/pam.d# screen&lt;br /&gt;
it will show some information about screen, just press Space or Enter and it will give a screen terminal:&lt;br /&gt;
  root@qemux86:/etc/pam.d# &lt;br /&gt;
then press &amp;quot;Ctrl+a x&amp;quot; will lock the screen terminal and show:&lt;br /&gt;
    &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
In another root terminal, clear the root&#039;s password:&lt;br /&gt;
  password -d root&lt;br /&gt;
&lt;br /&gt;
modify one line in common-auth&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
with&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so debug&lt;br /&gt;
option nullok_secure will allow users who has blank password login, after remove it these users are not allowed to login.&lt;br /&gt;
&lt;br /&gt;
Back to the screen terminal, press &amp;lt;Enter&amp;gt;(because root&#039;s password is blank now) will fail: &lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
  Screen used by root &amp;lt;root&amp;gt;.&lt;br /&gt;
  Password:&lt;br /&gt;
&lt;br /&gt;
then modify the line in common-auth with &lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure debug&lt;br /&gt;
&lt;br /&gt;
On the screen terminal press &amp;lt;Enter&amp;gt; again it unlock the terminal.&lt;br /&gt;
&lt;br /&gt;
the log in /var/log/auth.log:&lt;br /&gt;
  Jul 11 14:14:14 qemux86 screen: pam_unix(screen:auth): authentication failure; logname=root uid=0 euid=0 tty= ruser= rhost=  user=root&lt;br /&gt;
&lt;br /&gt;
* shadow&lt;br /&gt;
&lt;br /&gt;
* sudo&lt;br /&gt;
**/etc/pam.d/sudo comes from Fedora, and replace system-auth with common-auth&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      common-auth&lt;br /&gt;
  account    include      common-auth&lt;br /&gt;
  password   include      common-auth&lt;br /&gt;
  session    required     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
and content of common-auth:&lt;br /&gt;
  auth	[success=1 default=ignore]	pam_unix.so nullok_secure&lt;br /&gt;
  auth	requisite			pam_deny.so&lt;br /&gt;
  auth	required			pam_permit.so&lt;br /&gt;
**test pam plugins&lt;br /&gt;
***pam_unix.so&lt;br /&gt;
modify common-auth:&lt;br /&gt;
  auth    [success=1 default=ignore]      pam_unix.so debug&lt;br /&gt;
then unpriviledge user can NOT run sudo with blank password&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Password:&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 16:39:04 qemux86 sudo: pam_unix(sudo:auth): authentication failure; logname=test-pam uid=0 euid=0 tty=/dev/pts/1 ruser=test-pam rhost=  user=test-pam&lt;br /&gt;
  Jul  8 16:39:14 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 16:39:31 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
***pam_deny.so&lt;br /&gt;
mv line&lt;br /&gt;
  auth    requisite                       pam_deny.so&lt;br /&gt;
to the head of file, unprivilege user can NOT sudo any more:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 14:03:29 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
&lt;br /&gt;
***pam_permit.so&lt;br /&gt;
comment this line&lt;br /&gt;
  auth    required                        pam_permit.so&lt;br /&gt;
&lt;br /&gt;
sudo will fail without ask user to enter password:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  Sorry, try again.&lt;br /&gt;
  sudo: 3 incorrect password attempts&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  7 12:43:22 qemux86 sudo: test-pam : 3 incorrect password attempts ; TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm -f /test&lt;br /&gt;
&lt;br /&gt;
***pam_limits.so&lt;br /&gt;
add line to /etc/security/limits.conf&lt;br /&gt;
  *        -       nofile       3&lt;br /&gt;
then sudo will fail:&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  Inconsistency detected by ld.so: dl-deps.c: 622: _dl_map_object_deps: Assertion `nlist &amp;gt; 1&#039; failed!&lt;br /&gt;
&lt;br /&gt;
modify the line:&lt;br /&gt;
  *        -       nofile       4&lt;br /&gt;
  qemux86:~$ sudo rm /test&lt;br /&gt;
  qemux86:~$&lt;br /&gt;
&lt;br /&gt;
log in /var/log/auth.log:&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:41 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 3 for DEFAULT&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): reading settings from &#039;/etc/security/limits.conf&#039;&lt;br /&gt;
  Jul  8 14:24:50 qemux86 sudo: pam_limits(sudo:session): process_limit: processing - nofile 4 for DEFAULT&lt;br /&gt;
&lt;br /&gt;
*** pam_keyinit&lt;br /&gt;
add option debug&lt;br /&gt;
  session    optional     pam_keyinit.so revoke debug&lt;br /&gt;
&lt;br /&gt;
log shows pam_keyinit was called:&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_warn(sudo:account): function=[pam_sm_acct_mgmt] service=[sudo] terminal=[/dev/pts/1] user=[test-pam] ruser=[test-pam] rhost=[&amp;lt;unknown&amp;gt;]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: test-pam : TTY=pts/1 ; PWD=/home/test-pam ; USER=root ; COMMAND=/bin/rm /test&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): OPEN 1&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): UID:0 [0]  GID:0 [1000]&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 143761918&lt;br /&gt;
  Jul  7 14:13:39 qemux86 sudo: pam_keyinit(sudo:session): GET SESSION = 669161571&lt;br /&gt;
&lt;br /&gt;
according the source code pam_keyinit.c line 102 in function init_keyrings, the module return PAM_SUCCESS&lt;br /&gt;
&lt;br /&gt;
* util-linux&lt;br /&gt;
&lt;br /&gt;
* xserver-xf86-lite&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* mc: mc has remove package mcserv and dropped dependency on PAM already, but didn&#039;t remove checking security/pam_misc.h. Drop it. [http://www.midnight-commander.org/changeset/4816107a02ccbf6331534113e6ec0c8df84e24eb Official change log]&lt;br /&gt;
* libcap: if pam exists, libcap will create a pam plugin pam_cap.so to add a new front end for the authentication function. Because it is not a application, remove it from list.&lt;br /&gt;
* libuser: pam is libuser&#039;s build dependency, so remove it too.&lt;br /&gt;
* The busybox login has a option to use pam, but we use tinylogin&#039;s login right now (tinylogin also provides the su command)&lt;br /&gt;
* gettext only has a example &amp;quot;hello-c++-kde&amp;quot; use pam under source code directory, and it doen&#039;t be compiled and only copied to destination. So omit gettext.&lt;br /&gt;
* sysvinit has a patch contrib/notify-pam-dead.patch for /sbin/init to use pam, but the whole contrib directory didn&#039;t take part in compilation. Drop it.&lt;br /&gt;
&lt;br /&gt;
== Identify upstream PAM patches to use ==&lt;br /&gt;
After checking the Fedora develop repository, the following packages may need patches(only libpam need to upgrade, other patches are pam related configure file but they are absent in poky):&lt;br /&gt;
* libpam: need update from current 1.1.3 to 1.1.4 [https://www.redhat.com/archives/pam-list/2011-June/msg00013.html Release Notes]&lt;br /&gt;
* sudo: package sudo in Fedora provides /etc/pam.d/sudo and /etc/pam.d/sudo-i&lt;br /&gt;
** /etc/pam.d/sudo (Yocto use common-auth instead of system-auth)&lt;br /&gt;
  #%PAM-1.0&lt;br /&gt;
  auth       include      system-auth&lt;br /&gt;
  account    include      system-auth&lt;br /&gt;
  password   include      system-auth&lt;br /&gt;
  session    optional     pam_keyinit.so revoke&lt;br /&gt;
  session    required     pam_limits.so&lt;br /&gt;
&lt;br /&gt;
* screen: check Fedora screen.pam&lt;br /&gt;
&lt;br /&gt;
* util-linux: check Fedora source file util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* at: check Fedora util-linux-remote.pamd&lt;br /&gt;
&lt;br /&gt;
* cups: check Fedora cups-1.1.16-system-auth.patch&lt;br /&gt;
&lt;br /&gt;
* openssh: check Fedora sshd.pam&lt;br /&gt;
&lt;br /&gt;
== PAM Unit Tests==&lt;br /&gt;
We use unit test cases provided by libpam itself, a subdirectory with name &amp;quot;xtests&amp;quot; under libpam source code.&lt;br /&gt;
&lt;br /&gt;
On build machine run &lt;br /&gt;
  bitbake libpam -c patch&lt;br /&gt;
to get the libpam source code Linux-PAM-1.1.4, and scp it to host(target) machine. &lt;br /&gt;
&lt;br /&gt;
On the target machine under Linux-PAM-1.1.4, run&lt;br /&gt;
  ./configure&lt;br /&gt;
  make xtests&lt;br /&gt;
will get the test result of 28 unit test case. If you want to run sigle test case, go to subdirectory xtests and run (take tst-pam_time1 for example)&lt;br /&gt;
  ./run-xtests.sh . tst-pam_time1&lt;br /&gt;
&lt;br /&gt;
Some unit test can NOT pass(15/28), they need some pam plugin libraies:&lt;br /&gt;
* tst-pam_access1&lt;br /&gt;
* tst-pam_access2&lt;br /&gt;
* tst-pam_access3&lt;br /&gt;
* tst-pam_access4&lt;br /&gt;
**the tst-pam_access test cases need pam_access.so, install package pam-plugin-access will make them pass the test&lt;br /&gt;
* tst-pam_authsucceed&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_cracklib1&lt;br /&gt;
* tst-pam_cracklib2&lt;br /&gt;
**need /lib/security/pam_cracklib.so, need build cracklib, and then libpam will check it and create pam-plugin-cracklib&lt;br /&gt;
**need /usr/share/cracklib/pw_dict.pwd file, please run command on host machine:&lt;br /&gt;
    create-cracklib-dict /usr/share/cracklib/cracklib-small&lt;br /&gt;
&lt;br /&gt;
* tst-pam_dispatch1&lt;br /&gt;
* tst-pam_dispatch2&lt;br /&gt;
* tst-pam_dispatch3&lt;br /&gt;
* tst-pam_dispatch4&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_pwhistory1&lt;br /&gt;
**need /lib/security/pam_pwhistory.so, install pam-plugin-pwhistory to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_substack2&lt;br /&gt;
**need pam_debug.so, install pam-plugin-debug to make tst-pam_dispatch pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_succeed_if1&lt;br /&gt;
**install pam-plugin-succeed-if to make it pass&lt;br /&gt;
&lt;br /&gt;
* tst-pam_time1&lt;br /&gt;
**install pam-plugin-time to make it pass&lt;br /&gt;
&lt;br /&gt;
=== position ===&lt;/div&gt;</summary>
		<author><name>Wfan</name></author>
	</entry>
</feed>