jdk/test/sun/management/jmxremote/bootstrap/GeneratePropertyPassword.sh
author simonis
Fri, 17 Jan 2014 21:54:30 +0100
changeset 22602 0d9a07b0d7e9
parent 12047 320a714614e9
child 22607 ba232b417248
permissions -rw-r--r--
8028537: PPC64: Updated the JDK regression tests to run on AIX Reviewed-by: alanb Contributed-by: luchsh@linux.vnet.ibm.com, spoole@linux.vnet.ibm.com, volker.simonis@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
#
11988
eeee0e3f1e91 7073626: RmiBootstrapTest.sh and RmiSslBootstrapTest.sh fail under Cygwin
sla
parents: 7668
diff changeset
     2
# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
# published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
# This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
# version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
# accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
# You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
# 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4659
diff changeset
    19
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4659
diff changeset
    20
# or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4659
diff changeset
    21
# questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
# Utility Shell Script for generating .properties files or .password files
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
# or .access files from a list of input .in files.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
# Source in this GeneratePropertyPassword.sh and call the function
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
    29
# generatePropertyPasswordFiles.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
# Call restoreFilePermissions to restore file permissions after the test completes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
OS=`uname -s`
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
UMASK=`umask`
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
11988
eeee0e3f1e91 7073626: RmiBootstrapTest.sh and RmiSslBootstrapTest.sh fail under Cygwin
sla
parents: 7668
diff changeset
    37
if [[ $OS == CYGWIN_NT* ]] ; then
eeee0e3f1e91 7073626: RmiBootstrapTest.sh and RmiSslBootstrapTest.sh fail under Cygwin
sla
parents: 7668
diff changeset
    38
    OS="Windows_NT"
eeee0e3f1e91 7073626: RmiBootstrapTest.sh and RmiSslBootstrapTest.sh fail under Cygwin
sla
parents: 7668
diff changeset
    39
    if [ -z "$SystemRoot" ] ;  then
eeee0e3f1e91 7073626: RmiBootstrapTest.sh and RmiSslBootstrapTest.sh fail under Cygwin
sla
parents: 7668
diff changeset
    40
	SystemRoot=$SYSTEMROOT
eeee0e3f1e91 7073626: RmiBootstrapTest.sh and RmiSslBootstrapTest.sh fail under Cygwin
sla
parents: 7668
diff changeset
    41
    fi
eeee0e3f1e91 7073626: RmiBootstrapTest.sh and RmiSslBootstrapTest.sh fail under Cygwin
sla
parents: 7668
diff changeset
    42
fi
eeee0e3f1e91 7073626: RmiBootstrapTest.sh and RmiSslBootstrapTest.sh fail under Cygwin
sla
parents: 7668
diff changeset
    43
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
case $OS in
22602
0d9a07b0d7e9 8028537: PPC64: Updated the JDK regression tests to run on AIX
simonis
parents: 12047
diff changeset
    45
SunOS | Linux | Darwin | AIX )
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    PATHSEP=":"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    FILESEP="/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    DFILESEP=$FILESEP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    TMP_FILE=${TESTCLASSES}${FILESEP}${TESTCLASS}.sed.tmpfile
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
cat <<EOF > ${TMP_FILE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
s^@TEST-SRC@/^${TESTCLASSES}${DFILESEP}^g
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
EOF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    ;;
4659
3ef31fe2879b 6911131: Test does not work with CYGWIN: sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh
ohair
parents: 2
diff changeset
    55
Windows_95 | Windows_98 | Windows_NT | Windows_ME | CYGWIN*)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    PATHSEP=";"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    FILESEP="\\"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    DFILESEP=$FILESEP$FILESEP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    TMP_FILE=${TESTCLASSES}${FILESEP}${TESTCLASS}.sed.tmpfile
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
cat <<EOF > ${TMP_FILE}0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
s^@TEST-SRC@/^${TESTCLASSES}${DFILESEP}^g
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
EOF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    # Need to put double backslash in the .properties files
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    cat ${TMP_FILE}0 | sed -e 's^\\\\^ZZZZ^g' | \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        sed -e 's^\\^ZZZZ^g' | \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        sed -e 's^ZZZZ^\\\\\\\\^g' > ${TMP_FILE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    if [ "$OS" = "Windows_NT" ]; then
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
    70
        USER=`id -u -n`
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
    71
        CACLS="$SystemRoot/system32/cacls.exe"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
    72
        REVOKEALL="${TESTSRC}/../../windows/revokeall.exe"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
    73
        if [ ! -f "$REVOKEALL" ] ; then
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
    74
            echo "$REVOKEALL missing"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
    75
            exit 1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
*)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    echo "Unrecognized system!"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
esac
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
    87
generatePropertyPasswordFiles()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
   for f in $@
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
   do
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        echo processing $f
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
    92
        suffix=`basename $f .in`
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
    93
        f2="${TESTCLASSES}${FILESEP}${suffix}"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
    95
        if [ -f "$f2" ] ; then
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
    96
            rm -f $f2 || echo WARNING: $f2 already exits - unable to remove old copy
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
    97
        fi
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
    99
        echo creating $f2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        sed -f $TMP_FILE $f > $f2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
   102
        if [ "$OS" = "Windows_NT" ]; then
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
   103
            chown $USER $f2
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
   104
            # Grant this user full access
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
   105
            echo Y|$CACLS $f2 \/E \/G $USER:F
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
   106
            # Revoke everyone else
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
   107
            $REVOKEALL $f2
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
   108
            # Display ACLs
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
   109
            $CACLS $f2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        else
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
   111
            chmod 600 $f2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
   done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
   116
restoreFilePermissions()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    for f in $@
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    do
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
   120
        suffix=`basename $f .in`
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
   121
        f2="${TESTCLASSES}${FILESEP}${suffix}"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
   123
        if [ "$OS" = "Windows_NT" ]; then
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
   124
            # Grant everyone full control
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
   125
            $CACLS $f2 \/E \/G Everyone:F
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
   126
        else
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11988
diff changeset
   127
            chmod 777 $f2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132