Solaris 9 9/04 安裝指南

使用結束程序檔設定系統的超級使用者密碼

安裝 Solaris 軟體之後,系統會重新啟動。 在啟動程序完成前,系統會提示您輸入超級使用者密碼。 除非鍵入密碼,否則系統無法完成啟動。

名為 set_root_pw 的結束程序檔儲存在 auto_install_sample 目錄中。 結束程序檔顯示如何在不進行提示的情況下,自動設定超級使用者密碼。 set_root_pw 顯示於範例 27–5


註解 –

如果您使用結束程序檔來設定系統的超級使用者密碼,使用者可能會嘗試在結束程序檔的加密密碼中找出超級使用者密碼。 請確保您可以防止使用者嘗試確定超級使用者密碼。



範例 27–5 使用結束程序檔設定系統的超級使用者密碼

	 #!/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 file
 cp /a/etc/shadow /a/etc/shadow.orig
 
	 mv /a/etc/shadow /a/etc/shadow.orig
 	nawk -F: '{
         if ( $1 == "root" )
           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.orig
 # set the flag so sysidroot won't prompt for the root password
 sed -e 's/0 # root/1 # root/' ${SI_SYS_STATE} > /tmp/state.$$
  mv /tmp/state.$$ ${SI_SYS_STATE}

下面將描述此範例中的一些指令。