test/sun/management/jmxremote/bootstrap/PasswordFilePermissionTest.sh

Print this page




  87 createJavaFile ${TESTCLASSES} Null
  88 createConfigFile ${CONFIG} ${PASSWD}
  89 createPasswordFile ${PASSWD}
  90 
  91 # Compile test 
  92 
  93 ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES} ${TESTCLASSES}/Null.java
  94 
  95 
  96 JAVA=${TESTJAVA}/bin/java
  97 CLASSPATH=${TESTCLASSES}
  98 export CLASSPATH
  99 
 100 failures=0
 101 
 102 mp=-Dcom.sun.management.config.file=${CONFIG}
 103 pp=-Dcom.sun.management.jmxremote.port=4888
 104 
 105 go() {
 106     echo ''
 107     sh -xc "$JAVA ${TESTVMOPTS} $1 $2 $3 $4 $5 $6 $7 $8" 2>&1
 108     if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
 109 }
 110 
 111 # Test 1 - password file is secure - VM should start
 112 chmod 700 ${PASSWD}
 113 sh -xc "$JAVA ${TESTVMOPTS} $mp $pp Null" 2>&1
 114 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
 115 
 116 # Test 2 - password file is not secure - VM should fail to start
 117 chmod o+rx ${PASSWD}
 118 sh -xc "$JAVA ${TESTVMOPTS} $mp $pp Null" 2>&1
 119 if [ $? = 0 ]; then failures=`expr $failures + 1`; fi
 120 
 121 # Reset the file permissions on the generated password file
 122 chmod 777 ${PASSWD}
 123 
 124 #
 125 # Results
 126 #
 127 echo ''
 128 if [ $failures -gt 0 ];
 129   then echo "$failures test(s) failed";
 130   else echo "All test(s) passed"; fi
 131 exit $failures
 132 
 133 
 134 


  87 createJavaFile ${TESTCLASSES} Null
  88 createConfigFile ${CONFIG} ${PASSWD}
  89 createPasswordFile ${PASSWD}
  90 
  91 # Compile test 
  92 
  93 ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES} ${TESTCLASSES}/Null.java
  94 
  95 
  96 JAVA=${TESTJAVA}/bin/java
  97 CLASSPATH=${TESTCLASSES}
  98 export CLASSPATH
  99 
 100 failures=0
 101 
 102 mp=-Dcom.sun.management.config.file=${CONFIG}
 103 pp=-Dcom.sun.management.jmxremote.port=4888
 104 
 105 go() {
 106     echo ''
 107     sh -xc "$JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} $1 $2 $3 $4 $5 $6 $7 $8" 2>&1
 108     if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
 109 }
 110 
 111 # Test 1 - password file is secure - VM should start
 112 chmod 700 ${PASSWD}
 113 sh -xc "$JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} $mp $pp Null" 2>&1
 114 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
 115 
 116 # Test 2 - password file is not secure - VM should fail to start
 117 chmod o+rx ${PASSWD}
 118 sh -xc "$JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} $mp $pp Null" 2>&1
 119 if [ $? = 0 ]; then failures=`expr $failures + 1`; fi
 120 
 121 # Reset the file permissions on the generated password file
 122 chmod 777 ${PASSWD}
 123 
 124 #
 125 # Results
 126 #
 127 echo ''
 128 if [ $failures -gt 0 ];
 129   then echo "$failures test(s) failed";
 130   else echo "All test(s) passed"; fi
 131 exit $failures
 132 
 133 
 134