All pastes #558449 Raw Edit

Patch a OS Plugin

public text v1 · immutable
·published 2007-06-11 12:01 UTC
rendered paste body
Index: /Users/andreac/Documents/workspace/enginframe/plugins/certified/os/trunk/etc/antinstall/antinstall-config-component.xml
===================================================================
--- /Users/andreac/Documents/workspace/enginframe/plugins/certified/os/trunk/etc/antinstall/antinstall-config-component.xml	(revision 7032)
+++ /Users/andreac/Documents/workspace/enginframe/plugins/certified/os/trunk/etc/antinstall/antinstall-config-component.xml	(working copy)
@@ -66,7 +66,7 @@
 
   <page
       ifTarget="component_os"
-      ifProperty="(${default.auth.mgr}==os) AND (${java.path.separator}==:)"
+      ifProperty="(${default.auth.mgr}==os) AND (${java.path.separator}==:) AND (${ef.user}==root)"
       type="input"
       name="properties_os_user"
       title="Authentication Manager Configuration"
@@ -89,7 +89,7 @@
     <ext-validated displayText="Username"
                    defaultValue=""
                    property="os.user"
-                   validationClass="com.enginframe.install.antinstaller.validator.UserValidator"/>    
+                   validationClass="com.enginframe.install.antinstaller.validator.UserValidator"/>
     <password property="os.userpw" displayText="Password" textMask="true" regex="^.*$" defaultValue=""/>
   </page>
 
Index: /Users/andreac/Documents/workspace/enginframe/plugins/certified/os/trunk/etc/antinstall/build-component.xml
===================================================================
--- /Users/andreac/Documents/workspace/enginframe/plugins/certified/os/trunk/etc/antinstall/build-component.xml	(revision 7032)
+++ /Users/andreac/Documents/workspace/enginframe/plugins/certified/os/trunk/etc/antinstall/build-component.xml	(working copy)
@@ -4,59 +4,61 @@
 -->
 
 <project name="OS Plug-in Installer"  default=""  basedir=".">
-  <!-- this is required to pick up the properties generated during the install pages -->
-  <property file="${basedir}/efinstall.config"/>
+	<!-- this is required to pick up the properties generated during the install pages -->
+	<property file="${basedir}/efinstall.config"/>
 
-  <target name="init">
-    <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+	<target name="init">
+		<taskdef resource="net/sf/antcontrib/antlib.xml"/>
 
-    <if>
-            <available file="${ef.root.dir}/conf/server.conf"/>
-            <then>
-              <property name="configuration.file" value="${ef.root.dir}/conf/server.conf"/>
-            </then>
-      <elseif>
-              <available file="${ef.root.dir}/conf/agent.conf"/>
-        <then>
-                <property name="configuration.file" value="${ef.root.dir}/conf/agent.conf"/>
-        </then>
-      </elseif>
-      <else>
-        <fail message="Unable to find a valid configuration file looking in ${ef.root.dir}/conf/server.conf and ${ef.root.dir}/conf/agent.conf"/>
-      </else>
-        </if>
-    <if>
-      <not><available file="${nice.root.dir}/conf/enginframe.conf"/></not>
-            <then>
-        <fail message="Unable to find a valid configuration file looking in ${nice.root.dir}/conf/enginframe.conf"/>
-            </then>
-        </if>
+		<if>
+			<available file="${ef.root.dir}/conf/server.conf"/>
+			<then>
+				<property name="configuration.file" value="${ef.root.dir}/conf/server.conf"/>
+			</then>
+			<elseif>
+				<available file="${ef.root.dir}/conf/agent.conf"/>
+				<then>
+					<property name="configuration.file" value="${ef.root.dir}/conf/agent.conf"/>
+				</then>
+			</elseif>
+			<else>
+				<fail message="Unable to find a valid configuration file looking in ${ef.root.dir}/conf/server.conf and ${ef.root.dir}/conf/agent.conf"/>
+			</else>
+		</if>
+		<if>
+			<not>
+				<available file="${nice.root.dir}/conf/enginframe.conf"/>
+			</not>
+			<then>
+				<fail message="Unable to find a valid configuration file looking in ${nice.root.dir}/conf/enginframe.conf"/>
+			</then>
+		</if>
 
-      <property name="enginframe.configuration.file" value="${nice.root.dir}/conf/enginframe.conf"/>
+		<property name="enginframe.configuration.file" value="${nice.root.dir}/conf/enginframe.conf"/>
 
-    <echo message="Reading configuration from ${enginframe.configuration.file}"/>
-        <property file="${enginframe.configuration.file}" prefix="ef.current.configuration.enginframe"/>
+		<echo message="Reading configuration from ${enginframe.configuration.file}"/>
+		<property file="${enginframe.configuration.file}" prefix="ef.current.configuration.enginframe"/>
 
-    <echo message="Reading configuration from ${configuration.file}"/>
-        <property file="${configuration.file}" prefix="ef.current.configuration.server-agent"/>
+		<echo message="Reading configuration from ${configuration.file}"/>
+		<property file="${configuration.file}" prefix="ef.current.configuration.server-agent"/>
 
-    <echoproperties prefix="ef.current.configuration." description="Properties list"/>
+		<echoproperties prefix="ef.current.configuration." description="Properties list"/>
 
-    <!-- Setting properties from server.conf/agent.conf -->
-    <property name="ef.admin" value="${ef.current.configuration.server-agent.EF_ADMIN}"/>
+		<!-- Setting properties from server.conf/agent.conf -->
+		<property name="ef.admin" value="${ef.current.configuration.server-agent.EF_ADMIN}"/>
 
-    <!-- Setting properties from enginframe.conf (not a real property file but a shell script) -->
-    <propertyregex input="${ef.current.configuration.enginframe.TOMCAT_USER}" property="ef.tomcat.user" regexp='"(.*)"' replace="\1"/>
+		<!-- Setting properties from enginframe.conf (not a real property file but a shell script) -->
+		<propertyregex input="${ef.current.configuration.enginframe.TOMCAT_USER}" property="ef.tomcat.user" regexp='"(.*)"' replace="\1"/>
 
-    <echo message="Setting ef.admin         to ${ef.admin}" level="info"/>
-    <echo message="Setting ef.tomcat.user   to ${ef.tomcat.user}" level="info"/>
-  </target>
+		<echo message="Setting ef.admin         to ${ef.admin}" level="info"/>
+		<echo message="Setting ef.tomcat.user   to ${ef.tomcat.user}" level="info"/>
+	</target>
 
-  <!-- post display target used to get the root dir -->
-  <target name="antinstaller_set_root_dir">
-    <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+	<!-- post display target used to get the root dir -->
+	<target name="antinstaller_set_root_dir">
+		<taskdef resource="net/sf/antcontrib/antlib.xml"/>
 
-     <propertyregex
+		<propertyregex
       property="nice.root.dir.tmp"
       input="${nice.root.dir.ui}"
       regexp="\\"
@@ -65,129 +67,164 @@
        defaultValue="${nice.root.dir.ui}"
     />
 
-    <!-- set globals needed by the install -->
-    <antinstaller-property name="nice.root.dir" value="${nice.root.dir.tmp}"/>
-    <antinstaller-property name="ef.root.dir" value="${nice.root.dir.tmp}/enginframe"/>
-  </target>
+		<!-- set globals needed by the install -->
+		<antinstaller-property name="nice.root.dir" value="${nice.root.dir.tmp}"/>
+		<antinstaller-property name="ef.root.dir" value="${nice.root.dir.tmp}/enginframe"/>
+	</target>
 
-    <target name="component_os_enable">
-        <taskdef resource="net/sf/antcontrib/antlib.xml"/>
-        <if>
-            <and>
-                <equals arg1="${default.auth.mgr}" arg2="os"/>
-                <available file="${ef.root.dir}/conf/server.conf"/>
-            </and>
-            <then>
-                <replace file="${ef.root.dir}/conf/server.conf" token="_EF_ef_defaultauthority" value="os"/>
-            </then>
-        </if>
-    </target>
+	<target name="component_os_enable">
+		<taskdef resource="net/sf/antcontrib/antlib.xml"/>
+		<if>
+			<and>
+				<equals arg1="${default.auth.mgr}" arg2="os"/>
+				<available file="${ef.root.dir}/conf/server.conf"/>
+			</and>
+			<then>
+				<replace file="${ef.root.dir}/conf/server.conf" token="_EF_ef_defaultauthority" value="os"/>
+			</then>
+		</if>
+	</target>
 
-  <target name="component_os" depends="init,component_os_enable">
-    <!-- A simple copy of os/ef_root to ${ef.root.dir} -->
-    <unzip src="${antinstaller.jar}" dest="${ef.root.dir}">
-      <patternset>
-        <include name="os/ef_root/**/*"/>
-      </patternset>
-      <globmapper from="os/ef_root/*" to="*" handledirsep="true"/>
-    </unzip>
-    <chmod perm="755">
-      <fileset dir="${ef.root.dir}/plugins/os">
-        <include name="bin/"/>
-      </fileset>
-      <dirset dir="${ef.root.dir}/plugins/os">
-        <include name="conf"/>
-        <include name="etc"/>
-      </dirset>
-    </chmod>
-    <chmod perm="644">
-      <fileset dir="${ef.root.dir}/plugins/os">
-        <include name="conf/*"/>
-        <include name="etc/*"/>
-      </fileset>
-    </chmod>
-    <chmod perm="4755">
-      <fileset dir="${ef.root.dir}/plugins/os/etc">
-        <include name="checkpassword*"/>
-        <exclude name="checkpassword*tar.gz"/>
-      </fileset>
-    </chmod>
-  </target>
+	<target name="component_os" depends="init,component_os_enable">
+		<!-- A simple copy of os/ef_root to ${ef.root.dir} -->
+		<unzip src="${antinstaller.jar}" dest="${ef.root.dir}">
+			<patternset>
+				<include name="os/ef_root/**/*"/>
+			</patternset>
+			<globmapper from="os/ef_root/*" to="*" handledirsep="true"/>
+		</unzip>
+		<chmod perm="755">
+			<fileset dir="${ef.root.dir}/plugins/os">
+				<include name="bin/"/>
+			</fileset>
+			<dirset dir="${ef.root.dir}/plugins/os">
+				<include name="conf"/>
+				<include name="etc"/>
+			</dirset>
+		</chmod>
+		<chmod perm="644">
+			<fileset dir="${ef.root.dir}/plugins/os">
+				<include name="conf/*"/>
+				<include name="etc/*"/>
+			</fileset>
+		</chmod>
+		<chmod perm="4755">
+			<fileset dir="${ef.root.dir}/plugins/os/etc">
+				<include name="checkpassword*"/>
+				<exclude name="checkpassword*tar.gz"/>
+			</fileset>
+		</chmod>
+	</target>
 
-  <!-- post display target used to validate user login -->
-  <target name="component_os_post_check_user" depends="init">
-    <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+	<!-- post display target used to validate user login -->
+	<target name="component_os_post_check_user" depends="init">
+		<taskdef resource="net/sf/antcontrib/antlib.xml"/>
 
-      <if>
-        <os family="unix"/>
-          <then>
-          <!-- extract the script and executables in tmp to execute it -->
-        <property name="os.tmpdir" value="/tmp/osplugin"/>
-        <property name="os.checkpwscript" value="${os.tmpdir}/efcheckpassword"/>
-        <unzip src="${antinstaller.jar}" dest="${os.tmpdir}">
-          <patternset>
-            <include name="os/resources/scripts/efcheckpassword"/>
-          </patternset>
-          <globmapper from="os/resources/scripts/*" to="*" handledirsep="true"/>
-        </unzip>
-        <unzip src="${antinstaller.jar}" dest="${os.tmpdir}">
-          <patternset>
-            <include name="os/ef_root/plugins/os/etc/checkpassword*"/>
-            <exclude name="os/ef_root/plugins/os/etc/checkpassword*tar.gz"/>
-          </patternset>
-          <globmapper from="os/ef_root/plugins/os/etc/*" to="*" handledirsep="true"/>
-        </unzip>
+		<if>
+			<!-- Skip test if os.user is empty or null -->
+			<not>
+				<or>
+					<equals arg1="${os.user}" arg2=""/>
+					<equals arg1="${os.user}" arg2="$${os.user}"/>
+				</or>
+			</not>
+			<then>
+				<if>
+					<os family="unix"/>
+					<then>
+						<!-- extract the script and executables in tmp to execute it -->
+						<property name="os.tmpdir" value="/tmp/osplugin"/>
+						<property name="os.checkpwscript" value="${os.tmpdir}/efcheckpassword"/>
+						<unzip src="${antinstaller.jar}" dest="${os.tmpdir}">
+							<patternset>
+								<include name="os/resources/scripts/efcheckpassword"/>
+							</patternset>
+							<globmapper from="os/resources/scripts/*" to="*" handledirsep="true"/>
+						</unzip>
+						<unzip src="${antinstaller.jar}" dest="${os.tmpdir}">
+							<patternset>
+								<include name="os/ef_root/plugins/os/etc/checkpassword*"/>
+								<exclude name="os/ef_root/plugins/os/etc/checkpassword*tar.gz"/>
+							</patternset>
+							<globmapper from="os/ef_root/plugins/os/etc/*" to="*" handledirsep="true"/>
+						</unzip>
 
-        <chmod file="${os.checkpwscript}" perm="755"/>
-        <chmod perm="4755">
-          <fileset dir="${os.tmpdir}" includes="checkpassword*"/>
-        </chmod>
+						<chmod file="${os.checkpwscript}" perm="755"/>
+						<chmod perm="4755">
+							<fileset dir="${os.tmpdir}" includes="checkpassword*"/>
+						</chmod>
 
-            <antinstaller-log message="Calling ${os.checkpwscript} with args:"/>
-            <antinstaller-log message=" ${os.tmpdir}/checkpassword"/>
-            <antinstaller-log message=" ${os.user}"/>
-            <antinstaller-log message=" xxxxxxxx"/>
-            <antinstaller-log message=" ${ef.admin}"/>
+						<antinstaller-log message="Calling ${os.checkpwscript} with args:"/>
+						<antinstaller-log message=" ${os.tmpdir}/checkpassword"/>
+						<antinstaller-log message=" ${os.user}"/>
+						<antinstaller-log message=" xxxxxxxx"/>
+						<antinstaller-log message=" ${ef.admin}"/>
 
-        <exec executable="${os.checkpwscript}" resultproperty="os.checkpassword.res">
-          <arg value="${os.tmpdir}/checkpassword"/>
-          <arg value="${os.user}"/>
-          <arg value="${os.userpw}"/>
-          <arg value="${ef.admin}"/>
-        </exec>
+					    <taskdef classname="com.enginframe.ant.CheckPasswordTask" name="checkpassword">
+					        <classpath>
+					          <pathelement path="${antinstaller.jar}"/>
+					        </classpath>
+					    </taskdef>
 
-            <antinstaller-log message="Result ${os.checkpassword.res}"/>
+					  	<checkpassword
+							efadmin="${ef.admin}"
+							username="${os.user}"
+							password="${os.userpw}"
+							checkPassword="${os.tmpdir}/checkpassword"
+							wrapperScript="${os.checkpwscript}"
+							property="os.checkpassword.res"/>
+<!--
+						<exec executable="${os.checkpwscript}" resultproperty="os.checkpassword.res" inputstring="${os.user}\\0${os.userpw}\\0">
+							<arg value="${os.tmpdir}/checkpassword"/>
+							<arg value="${ef.admin}"/>
+						</exec>
+-->
+						<antinstaller-log message="Result ${os.checkpassword.res}"/>
 
-        <!-- cleanup -->
-        <delete verbose="true" dir="${os.tmpdir}"/>
+						<!-- cleanup -->
+						<delete verbose="true" dir="${os.tmpdir}"/>
 
-        <if>
-          <equals arg1="${os.checkpassword.res}" arg2="0"/>
-          <then>
-            <antinstaller-log message="${os.user} successfully checked"/>
-          </then>
-            <elseif>
-            <equals arg1="${os.checkpassword.res}" arg2="1"/>
-            <then>
-              <antinstaller-message message="Only root can check password. Skipping check."/>
-            </then>
-            </elseif>
-            <elseif>
-            <equals arg1="${os.checkpassword.res}" arg2="2"/>
-            <then>
-              <antinstaller-message message="Platform not supported"/>
-              <fail message="Platform not supported"/>
-            </then>
-          </elseif>
-          <else>
-            <antinstaller-message message="Login failed"/>
-            <fail message="Login failed"/>
-          </else>
-        </if>
-          </then>
-      </if>
-  </target>
+						<if>
+							<equals arg1="${os.checkpassword.res}" arg2="0"/>
+							<then>
+								<!-- Check is ok -->
+								<antinstaller-log message="Credentials of ${os.user} successfully checked."/>
+							</then>
+							<else>
+								<!-- Check failed -->
+								<if>
+									<equals arg1="${os.checkpassword.res}" arg2="1"/>
+									<then>
+										<property name="error.message" value="User ${ef.user} cannot check passsword."/>
+									</then>
+									<elseif>
+										<equals arg1="${os.checkpassword.res}" arg2="2"/>
+										<then>
+											<property name="error.message" value="Platform not supported."/>
+										</then>
+									</elseif>
+									<else>
+										<property name="error.message" value="Login failed."/>
+									</else>
+								</if>
+								<antinstaller-prompt message="${error.message} Do you want to skip this check and continue the installation?" property="continue"/>
+								<if>
+									<equals arg1="${continue}" arg2="yes"/>
+									<then>
+										<antinstaller-log message="Skipping OS credentials check."/>
+									</then>
+									<else>
+										<fail message="User ${ef.user} cannot check passsword."/>
+									</else>
+								</if>
+							</else>
+						</if>
+					</then>
+				</if>
+			</then>
+		</if>
+	</target>
 
-  <target name="cleanuptarget" depends="">
-  </target>
+	<target name="cleanuptarget" depends="">
+	</target>
 </project>
Index: /Users/andreac/Documents/workspace/enginframe/plugins/certified/os/trunk/etc/antinstall/resources/scripts/efcheckpassword
===================================================================
--- /Users/andreac/Documents/workspace/enginframe/plugins/certified/os/trunk/etc/antinstall/resources/scripts/efcheckpassword	(revision 7032)
+++ /Users/andreac/Documents/workspace/enginframe/plugins/certified/os/trunk/etc/antinstall/resources/scripts/efcheckpassword	(working copy)
@@ -16,9 +16,7 @@
 #-----------------------------------------------------------------------
 # Try to check the password of a user.
 #   $1: ${EF_ROOT}/etc/checkpassword
-#   $2: user
-#   $3: passwd
-#   $4: efadmin
+#   $2: efadmin
 #
 # returns:
 #   0: success
@@ -34,9 +32,7 @@
 fi
 
 _checkpasswdpath=$1
-_user=$2
-_passwd=$3
-_efadmin=$4
+_efadmin=$2
 
 # try to find the approriate checkpassword. $0 is the path
 _my_checkpassword="${_checkpasswdpath}.`uname`.`uname -m`"
@@ -47,8 +43,7 @@
     exit 2
 fi
 
-su - "${_efadmin}" -c "/bin/sh -c \"printf '%s\0%s\0' '${_user}' '${_passwd}' \
-| ${_my_checkpassword} /bin/sleep 0 3<&0\"" <"/dev/null" >"/dev/null" 2>&1
+cat - | su - "${_efadmin}" -c "/bin/sh -c \"${_my_checkpassword} /bin/sleep 0 3<&0\"" >"/dev/null" 2>&1
 
 _ret="$?"