以下说明了 policy.conf 文件中的缺省算法配置:
# … # crypt(3c) Algorithms Configuration # # CRYPT_ALGORITHMS_ALLOW specifies the algorithms that are allowed to # be used for new passwords. This is enforced only in crypt_gensalt(3c). # CRYPT_ALGORITHMS_ALLOW=1,2a,md5 # To deprecate use of the traditional unix algorithm, uncomment below # and change CRYPT_DEFAULT= to another algorithm. For example, # CRYPT_DEFAULT=1 for BSD/Linux MD5. # #CRYPT_ALGORITHMS_DEPRECATE=__unix__ # The Solaris default is the traditional UNIX algorithm. This is not # listed in crypt.conf(4) since it is internal to libc. The reserved # name __unix__ is used to refer to it. # CRYPT_DEFAULT=__unix__ … |
更改 CRYPT_DEFAULT 的值之后,将使用与新值关联的算法对新用户的口令进行加密。当前用户更改其口令之后,其旧口令的加密方式会影响加密新口令所用的算法。
例如,假设 CRYPT_ALGORITHMS_ALLOW=1,2a,md5,CRYPT_DEFAULT=1。下表说明了将使用何种算法来生成加密口令。
标识符=口令算法 |
说明 |
|
---|---|---|
初始口令 |
更改后的口令 |
|
1 = crypt_bsdmd5 |
使用同一算法 |
1 标识符也是 CRYPT_DEFAULT 的值。继续使用 crypt_bsdmd5 算法对用户口令进行加密。 |
2a = crypt_bsdbf |
使用同一算法 |
2a 标识符位于 CRYPT_ALGORITHMS_ALLOW 列表中。因此,使用 crypt_bsbdf 算法对新口令进行加密。 |
md5 = crypt_md5 |
使用同一算法 |
md5 标识符位于 CRYPT_ALGORITHMS_ALLOW 列表中。因此,使用 crypt_md5 算法对新口令进行加密。 |
__unix__ = crypt_unix |
使用 crypt_bsdmd5 算法 |
__unix__ 标识符不在 CRYPT_ALGORITHMS_ALLOW 列表中。因此,不能使用 crypt_unix 算法。将使用 CRYPT_DEFAULT 算法对新口令进行加密。 |
有关配置算法选择的更多信息,请参见 policy.conf(4) 手册页。要指定口令加密算法,请参见更改口令算法(任务列表)。