在pam_cracklib.so的參數中,測試minlen的時候老是發現不能按本身實際設置的需求來限制密碼長度。
求解過程以下
關鍵在於dcredit=N、ucredit=N、lcredit=N、ocredit=N 這4個參數
百度來的結果(摘其中一個地址,其實不少都是這個解釋 http://my.oschina.net/guol/blog/39901)
dcredit=N:當N>=0時,N表明新密碼最多能夠有多少個阿拉伯數字。當N<0時,N表明新密碼最少要有多少個阿拉伯數字。
教學視頻中講的是:當N>0時,計算密碼長度時,此類字符的長度(數量)將會翻倍。
最後,man查詢的結果是
dcredit=N
(N >= 0) This is the maximum credit for having digits in the new password. If you have less than or N digits, each digit will count +1 towards meeting the current minlen value. The default for dcredit is 1 which is the recommended value for minlen less than 10.
(N < 0) This is the minimum number of digits that must be met for a new password.
其餘3個也與此相似
呃…這彷佛解釋了爲何我設置了minlen=10,可是輸入8位密碼仍然能經過的緣由 --- 數字、大小寫、怪字符的默認credit值都是1。
視頻裏面講的算還不算太離譜,可是百度到的結果嘛…
--------------------------------------------
還有一個長度限制,長度4位是硬性限制,6位是limit定義的限制,可是這個limit在哪定義的還沒搞清楚
html
minlen=Ngit
The minimum acceptable size for the new password (plus one if credits are not disabled which is the default). In addition to the number of characters in thenew password, credit (of +1 in length) is given for each different kind of character (other, upper, lower and digit). The defaultfor this parameter is 9 which is good for a old style UNIX password all of the same type of character but may be too low to exploit the added securityof a md5 system. Note that there is a pair of length limits in Cracklib itself, a "way too short" limit of 4 which is hard coded in and a defined limit(6) that will be checked without reference to minlen. If you want to allow passwords as short as 5 characters you should not use this module.less
這個能夠解釋,爲何當minlen=8的時候,設置相似aA1@的密碼不能生效的緣由,雖然按credit值計算出來已經知足minlen爲8的要求,可是不知足limit和hardcoded的限制,還須要再增長兩位才行。
-----------------------------------------------
http://tech.ddvip.com/2012-08/1344351162179538.html
這個算講的比較細緻了,可是仍然講錯了
當某類credit爲正數N的時候,表示密碼中該類字符一個能夠加N分;當某類credit爲負數N的時候,表示密碼中某類字符必須具有N個。
後面爲負數的時候,是正確的。當N爲正數的時候,不是1個加N分(這個和視頻教程講的內容類似,但又略有區別)。
測試 dcredit=5,minlen=12,其餘設置爲0以免干擾計算 lcredit=0 ucredit=0 ocredit=0,分別統計三種計算方法得出的密碼長度值,並嘗試設置到系統中。
----------------------------------------------
另外提一下,pam_cracklib要對root賬戶生效,須要設置 enforce_for_root參數,不然,root賬戶設置密碼時能夠無視pam_cracklib給出的任何限制。
ide