Solaris 9 安装指南

使用结束脚本设置系统的超级用户口令

Solaris 软件安装在系统上之后,系统重新引导。在引导过程完成前,系统提示输入超级用户口令。除非有人键入口令,否则系统无法完成引导。

名为 set_root_pw 的结束脚本保存在 auto_install_sample 目录中。结束脚本显示如何自动设置超级用户口令,而无需提示。set_root_pw 显示在 实例 24–4 中。


实例 24–4 使用结束脚本设置系统的超级用户口令

	 #!/bin/sh

	 #

	 #       @(#)set_root_pw 1.4 93/12/23 SMI

	 #

	 # This is an example Bourne shell script to be run after installation.

	 # It sets the system's root password to the entry defined in PASSWD.

	 # The encrypted password is obtained from an existing root password entry

	 # in /etc/shadow from an installed machine.

 

	 echo "setting password for root"

 

	 # set the root password

 PASSWD=dKO5IBkSF42lw

	 #create a temporary input file1

 cp /a/etc/shadow /a/etc/shadow.orig2

 

	 mv /a/etc/shadow /a/etc/shadow.orig

 	nawk -F: '{

         if ( $1 == "root" )3

           printf"%s:%s:%s:%s:%s:%s:%s:%s:%s\n",$1,passwd,$3,$4,$5,$6,$7,$8,$9

      else

		        printf"%s:%s:%s:%s:%s:%s:%s:%s:%s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9

      }' passwd="$PASSWD" /a/etc/shadow.orig> /a/etc/shadow

 #remove the temporary file

 rm -f /a/etc/shadow.orig4

 # set the flag so sysidroot won't prompt for the root password

 sed -e 's/0 # root/1 # root/' ${SI_SYS_STATE}> /tmp/state.$$5

  mv /tmp/state.$$ ${SI_SYS_STATE}
  1. 将变量 PASSWD 设置为从系统 /etc/shadow 文件中的现有项获取的加密超级用户口令。

  2. 创建 /a/etc/shadow 的临时输入文件。

  3. /etc/shadow 文件中更改新安装的系统的超级用户项,使用 $PASSWD 作为口令字段。

  4. 删除临时 /a/etc/shadow 文件。

  5. 在状态文件中将项从 0 更改为 1,这样将不提示用户输入超级用户口令。状态文件通过变量 SI_SYS_STATE 访问,该变量的当前值为 /a/etc/.sysIDtool.state。为了避免在此值更改时脚本出现问题,请使用 $SI_SYS_STATE 以便始终引用此文件。此处显示的 sed 命令在 0 之后和 1 之后包含一个制表符。



注意:

如果使用结束脚本设置系统的超级用户口令,则用户可能会尝试通过结束脚本中的加密口令来发现超级用户口令。确保有相应的措施防止用户试图确定超级用户口令。