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