config/glibcversion.sh

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rwxr-xr-x

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 #!/bin/sh
     2 #
     3 # This Source Code Form is subject to the terms of the Mozilla Public
     4 # License, v. 2.0. If a copy of the MPL was not distributed with this
     5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     7 ##############################################################################
     8 ##
     9 ## Name:		glibcversion.sh - Print __GLIBC__ version if gnu libc 2 is 
    10 ##              found.
    11 ##
    12 ## Description:	This script is needed by the mozilla build system.  It needs
    13 ##              to determine whether the current platform (mostly the 
    14 ##              various linux "platforms") are based on the gnu libc2.  This
    15 ##              information is later used in mozilla to determine whether 
    16 ##              gnu libc 2 specific "features" need to be handled, such
    17 ##              as broken locales.
    18 ##
    19 ## Author:		Ramiro Estrugo <ramiro@netscape.com>
    20 ##
    21 ##############################################################################
    23 ##
    24 ## Command Line Flags Supported:
    25 ##
    26 ##  -g  | --is-glibc2:				Print True/False if detected __GLIBC__.
    27 ##
    28 ##  -v  | --print-version:			Print value of __GLIBC__ if found, or none.
    29 ##
    30 ##  -o  | --set-object-name:		Set object name for current system.
    31 ##  -cc | --set-compiler:			Set compiler for building test program.
    32 ##
    35 ##
    36 ## Constants
    37 ##
    38 GLIBC_PROG_PREFIX=./get_glibc_info
    40 ##
    41 ## Defaults
    42 ##
    43 GLIBC_PRINT_IS_GLIBC2=False
    45 GLIBC_PRINT_VERSION=False
    47 GLIBC_OBJECT_NAME=`uname`-`uname -r`
    48 GLIBC_CC=cc
    50 function glibc_usage()
    51 {
    52 echo
    53 echo "Usage:   `basename $0` [options]"
    54 echo
    55 echo "  -g,  --is-glibc2:          Print True/False if detected __GLIBC__."
    56 echo
    57 echo "  -v,  --print-version:      Print value of __GLIBC__ if found, or none."
    58 echo
    59 echo "  -o,  --set-object-name:    Set object name for current system."
    60 echo "  -cc, --set-compiler:       Set compiler for building test program."
    61 echo
    62 echo "  -h,  --help:               Print this blurb."
    63 echo
    64 echo "The default is '-v' if no options are given."
    65 echo
    66 }
    68 ##
    69 ## Parse the command line
    70 ##
    71 while [ "$*" ]; do
    72     case $1 in
    73         -h | --help)
    74             shift
    75             glibc_usage
    76 			exit 0
    77             ;;
    79         -g | --is-glibc2)
    80             shift
    81             GLIBC_PRINT_IS_GLIBC2=True
    82             ;;
    84         -v | --print-version)
    85             shift
    86             GLIBC_PRINT_VERSION=True
    87             ;;
    89         -o | --set-object-name)
    90             shift
    91             GLIBC_OBJECT_NAME="$1"
    92             shift
    93             ;;
    95         -cc | --set-compiler)
    96             shift
    97             GLIBC_CC="$1"
    98             shift
    99             ;;
   101         -*)
   102             echo "`basename $0`: invalid option '$1'"
   103             shift
   104             glibc_usage
   105 			exit 0
   106             ;;
   107     esac
   108 done
   110 ##
   111 ## Motif info program name
   112 ##
   113 GLIBC_PROG="$GLIBC_PROG_PREFIX"_"$GLIBC_OBJECT_NAME"
   114 GLIBC_SRC="$GLIBC_PROG_PREFIX"_"$GLIBC_OBJECT_NAME.c"
   116 ##
   117 ## Cleanup the dummy test source/program
   118 ##
   119 function glibc_cleanup()
   120 {
   121 	true
   123 #	rm -f $GLIBC_PROG
   124 #	rm -f $GLIBC_SRC
   126 }
   128 glibc_cleanup
   130 if [ ! -f $GLIBC_SRC ]
   131 then
   132 cat << EOF > $GLIBC_SRC
   133 #include <stdio.h>
   135 int main(int argc,char ** argv) 
   136 {
   137 #ifdef 	__GLIBC__
   138 	fprintf(stdout,"%d\n",__GLIBC__);
   139 #else
   140 	fprintf(stdout,"none\n");
   141 #endif
   143 	return 0;
   144 }
   145 EOF
   146 fi
   148 if [ ! -f $GLIBC_SRC ]
   149 then
   150 	echo
   151 	echo "Could not create test program source $GLIBC_SRC."
   152 	echo
   154 	glibc_cleanup
   156 	exit
   157 fi
   159 ##
   160 ## Compile the dummy test program if needed
   161 ##
   162 if [ ! -x $GLIBC_PROG ]
   163 then
   164 	$GLIBC_CC -o $GLIBC_PROG $GLIBC_SRC
   165 fi
   167 if [ ! -x $GLIBC_PROG ]
   168 then
   169 	echo
   170 	echo "Could not create test program $GLIBC_PROG."
   171 	echo
   173 	glibc_cleanup
   175 	exit
   176 fi
   178 ##
   179 ## Execute the dummy test program
   180 ##
   181 GLIBC_PROG_OUTPUT=`$GLIBC_PROG`
   183 ##
   184 ## -g | --is-glibc2
   185 ##
   186 if [ "$GLIBC_PRINT_IS_GLIBC2" = "True" ]
   187 then
   188 	if [ "$GLIBC_PROG_OUTPUT" = "2" ]
   189 	then
   190 		echo True
   191 	else
   192 		echo False
   193 	fi
   195 	glibc_cleanup
   197 	exit 0
   198 fi
   200 echo $GLIBC_PROG_OUTPUT
   202 glibc_cleanup

mercurial