在centos6.X和redhat enterprise 中安装chrome,我找了很久都不行,今天终于找到了可以用下脚本那安装:
#! /bin/bash # Google Chrome Installer/Uninstaller for CentOS 6 or 7 # (C) Richard K. Lloyd 2014 <rklloyd@gmail.com> # See http://chrome.richardlloyd.org.uk/ for further details. # This script is in the public domain and has no warranty. # It needs to be run as root because it installs/uninstalls RPMs. # Minimum system requirements: # - 32-bit or 64-bit CentOS 6.5 or later (you will be asked to # upgrade the OS and reboot if you're running 6.4 or earlier) or # any 64-bit CentOS 7 version (including pre-releases) # - At least 250MB free in each of the temporary directory, /opt and /root # - A working yum system (including http proxy configured if needed) # - http_proxy env var set if you are using an http proxy # - Google Chrome should not be running at the same time as this script show_syntax() # Show syntax of script { cat <<@EOF Syntax: ./install_chrome.sh [-b] [-d] [-f [-f [-f]]] [-h] [-n] [-q] [-s] [-t tmpdir] [-u] [-U] -b (or --beta) will switch to beta versions (google-chrome-beta). -d (or --delete) will delete the temporary directory used for downloads if an installation was successful. -f (or --force) forces an automatic "y" for any interactive prompting except for OS mismatch/OS upgrade/reboot prompts. Specify -f twice to force it for OS mismatches or OS upgrades as well and three times for reboots on top of that. -h (or -? or --help) will display this syntax message. -n (or --dryrun) will show what actions the script will take, but it won't actually perform those actions. -q (or --quiet) will switch to "quiet mode" where minimal info is displayed. Specify -q twice to go completely silent except for errors. -s (or --stable) will switch to stable versions (google-chrome-stable), which is the default if -b or -U haven't previously been specified. -t tmpdir (or --tmpdir tmpdir) will use tmpdir as the temporary directory parent tree rather than $TMPDIR (if set) or /tmp. -u performs an uninstallation of Google Chrome and chrome-deps rather the default action of an installation. -U (or --unstable) will switch to unstable versions (google-chrome-unstable). @EOF } # Current version of this script version="5.01" # This script will download/install the following for an installation: # These CentOS 6 RPMs and their (many!) deps that aren't already installed: # redhat-lsb, wget, xdg-utils, GConf2, libXSCrnSaver, libX11, # gcc, glibc-devel, nss, rpm-build and rpmdevtools. # These CentOS 7 RPMs and their (many!) deps that aren't already installed: # redhat-lsb, wget, xdg-utils, GConf2, libXSCrnSaver. libX11 and nss. # The latest Google Chrome RPM if not already downloaded (or out-of-date). # CentOS 6 only: 5 RPM packages from Fedora 15 if not already fully downloaded. # CentOS 6 only: 1 RPM package from Fedora 17 if not already fully downloaded. # For CentOS 6 only: # It then copies 11 libraries from the F15/F17 packages into # /opt/google/chrome/lib. # It also changes ld library references in four F15 libraries to end # in .so.0 instead of .so.2 so that they avoid the system ld library. # It sets SELinux context user/type for the F15/F17 libraries as well if # SELinux is enabled on the system. # Next, it C-compiles an LD_PRELOAD library that's installed as # /opt/google/chrome/lib/unset_var.so, which saves/unsets LD_LIBRARY_PATH # and LD_PRELOAD before calling exec*() routines and then restores the # environmental variables afterwards. # /opt/google/chrome/google-chrome is also modified to point LD_PRELOAD # to the installed library. This is avoids having LD_LIBRARY_PATH and # LD_PRELOAD set when sub-processes are run. # Finally, it creates and installs a chrome-deps RPM which includes the # F15/F17 libraries, unset_var.so and code to modify the google-chrome wrapper. # (End of CentOS 6 only actions) # Note that you can't run Google Chrome as root - it stops you from doing so. # Revision history: # 5.01 - 26th June 2014 # - Fix for latest CentOS 7 pre-release repo detection, because the latest # pre-release bizarrely includes placeholder .repo files that don't do # anything. # 5.00 - 21st June 2014 # - Added support for pre-release CentOS 7, which mainly means no RPM building # and also the installation of missing dependencies. If no CentOS 7 repos are # detected - which is the current case with pre-release CentOS 7 versions - # in /etc/yum.repos.d, a "chrome-deps-updates" repo will be created (this # will be removed on later runs if any other .repo files are created, on the # assumption that the user has added their own repos for installing/updating # RPMs instead or the final CentOS 7 repos are already present). # - Minimum CentOS 6 release supported is now 6.5, which has been out for over # 6 months at the time of writing. This means libX11 and nss should be # up-to-date versions, avoiding run-time problems with older versions of # those packages. # - Tidied up final messages e.g. it now says the latest version was already # installed if that was the case. # # 4.70 - 17th May 2014 # - Added -f option to auto-force a "y" answer to any interactive prompt # without bothering to actually prompt you (thanks to Steve Cleveland for the # idea). The only exceptions to this are the prompts for an OS mismatch, OS # upgrade or reboot, but even those can be forced by specifying -f twice (or # three times for reboots). # - Fixed the 2-hourly bash segfault recorded in syslog. It was caused by the # chrome binary self-calling the google-chrome bash script to get its version, # which is bizarre since surely it could just call one of its own functions # to get that? By unsetting LD_LIBRARY_PATH on the self-call, the segfault # was avoided. Bumped chrome-deps to version 1.21 because of this. # 4.60 - 12th April 2014 # - The latest Google Chrome releases kept prompting me for a keyring # password when starting up. It turns out they were using the # gnome_keyring_attribute_list_new function, which didn't exist until Fedora # 17's libgnome-keyring.so.0 library! Luckily, the F17 library works in # CentOS 6, so that's been added and the chrome-deps RPM has been bumped # to version 1.20. # - Added nss to the list of possible CentOS 6 RPMs that are installed (thanks # to Ravi Saive at tecmint.com for this, though no-one told me directly...). # - Check the size and cksum of downloaded RPMs and delete them (and quit) if # they are bad. # 4.50 - 11th December 2013 # - A user reported that file-roller wouldn't work when opening downloaded # .tar.gz files inside Google Chrome. It turns out LD_PRELOAD was still set # when file-roller tried to exec() sub-processes like gzip, so I now unset # LD_PRELOAD (as well as LD_LIBRARY_PATH) when exec'ing from within Google # Chrome, which fixes the issue. chrome-deps version was bumped to 1.10 # because of this change. Another user suggested checking previously # downloaded F15 RPMs have the right checksum/size (and a fresh download is # forced if they don't), which has been implemented. # 4.41 - 9th December 2013 # - Added glibc-devel to the list of dependencies because a user reported # that it wasn't dragged in by gcc. With the imminent release of Fedora 20, # Fedora 15 has been archived and the code has been changed to reflect that. # Removed SELinux warning at end of install - the last few releases of # Google Chrome don't seem to have a problem with enforcing mode w.r.t. # nacl_helper. Future releases of this script may remove all SELinux-related # code if enforcing mode remains OK. Google Chrome 31 is displaying a # manifestTypes error to the console in some setups, but this doesn't seem # to affect the running of Google Chrome. # 4.40 - 5th October 2013 # - A similar issue to the 4.30 release cropped up again (reported by # the same user!) that I still can't reproduce. This time it was a missing # gdk_pixbuf_format_get_type symbol in F15's libgtk-x11-2.0. This was fixed # by additonally downloading F15's gdk-pixbuf2 RPM and extracting # libgdk_pixbuf-2.0 from it. This prompted a bump of the chrome-deps RPM to # version 1.03. # 4.30 - 4th October 2013 # - The g_desktop_app_info_get_filename symbol in the F15 libgdk-x11-2.0 # library is present in the F15 libgio-2.0 library (but not in CentOS's). # The script used the former library, but not the latter and a user reported # a missing symbol crash due to this, despite my testing not showing the # issue. This release is therefore purely to add libgio-2.0 and its # libgobject-2.0 dependency to the set of extracted F15 libraries and has # also been tested against Google Chrome 30 and Google Talk Plugin 4.7.0.0. # The chrome-deps RPM is now at version 1.02 because of the two extra # libraries. # 4.20 - 22nd August 2013 # - If the Google Chrome repo is enabled and a Google Chrome RPM is already # installed, use "yum check-update google-chrome-stable" to determine if # there is a newer version available and then fallback to using the # OmahaProxy site if there isn't. # - Any newer version than what's been previously downloaded or installed # can now be downloaded/installed, rather than being exactly the version # displayed on the OmahaProxy site (which was out of date for a full day when # Chrome 29 was released, stopping this script from updating to version 29). # - Removed terminal messages warning because this is fixed with Google Chrome # 29. # - Used extra parameters in the OmahaProxy request to narrow the data down to # the exact channel and platform (linux). # 4.10 - 8th August 2013 # - Fixed Google Talk (Hangouts) plugin crash - it was because, unlike Google # Chrome itself, the plugin hasn't been built with later libraries, so it # needs LD_LIBRARY_PATH to be unset. There still appears to be other # library issues with the Hangouts plugin, mainly because the older libraries # don't implement certain calls it uses. Google need to update the plugin! # Bumped chrome-deps version to 1.01 because of the unset_var.c change. # - Catered for non-standard i686 RPM build trees on 32-bit systems. I couldn't # reproduce this myself (it uses i386 for me all the time in CentOS and # Scientific Linux 32-bit VMs) but the code is in place anyway for the users # that reported the issue. # - modify_wrapper (now bumped to version 1.01) no longer echoes anything to # stdout after a successful update of /opt/google/chrome/google-chrome. # 4.01 - 30th July 2013 # - Emergency 2-char change fix due to a terrible spec parsing bug in rpmbuild. # It appears that it tries to parse % directives in comment lines. # Strangely, three different build envs of mine didn't have the bug, but # a fourth one I tried did. # # 4.00 - 30th July 2013 # - Creates a new chrome-deps RPM that it installs alongside the # google-chrome-stable RPM. It contains the Fedora libraries, the # built unset_var.so library and a script which is run post-install # to add code to /etc/default/google-chrome to modify google-chrome if # its LD_PRELOAD addition isn't present. This gets sourced daily by # /etc/cron.daily/google-chrome and is a way to auto-modify google-chrome # within a day of a Google Chrome update (this is because google-chrome # isn't marked as a config file by Google Chrome's spec file, so updates # will overwrite any changes made to it). The new code will also enable the # Google Chrome repo of course. Many thanks to Marcus Sandberg # for his spec file at https://github.com/adamel/chrome-deps which # I used as the initial basis for the spec file I create. # - Adjusted unset_var code to not unset LD_LIBRARY_PATH if a full file # path (i.e. one containing a slash) is supplied to exec*() routines. # - Download/installation of google-chrome-stable/chrome-deps dependencies # is now prompted for (if you decline, the script aborts). # - Moved out-of-date OS check right to the end of the script and it also # now offers to reboot the machine after a successful OS update. Warn user # not to run Google Chrome if either the OS update or reboot are declined # until they complete the OS update and reboot. # - Don't remove /etc/cron.daily/google-chrome or # /etc/yum.conf.d/google-chrome.repo any more because we actually want # people to use those (they won't be happy cron'ing this script or having # to regularly run it manually to check for updates). # - Added -t option to specify the temporary directory parent tree. # - Added -s (stable), -b (beta) and -U (unstable) options to switch # release channels. Yes, it remembers the switch, so you only have to # specify once time. # - Added libdl.so.2 to the Fedora library list (for unset_var.so). # 3.20 - 27th July 2013 # - Initial attempt to stop helper apps crashing by wrapping exec*() routines # with LD_PRELOAD functions that save/blank LD_LIBRARY_PATH, call the # original routines and, if they return, restore LD_LIBRARY_PATH. Seems to # stop crashes previously logged to syslog on startup at least, but does # require gcc and its dependencies to be installed now of course. # 3.11 - 25th July 2013 # - If SELinux is enabled, set appropriate SELinux contexts on Fedora libraries # in /opt/google/chrome/lib and that directory itself. Investigation shows # that if you enable SELinux and set it to enforcing, nacl_helper appears to # fail to start correctly, possibly disabling sandboxing. The script warns # about this and suggests a temporary workaround of setting # SELINUX=permissive in /etc/selinux/config and rebooting. It's hoped to fix # this SELinux issue more permanently in a future release soon (any help is # most welcome!). # 3.10 - 24th July 2013 # - Use .so.0 extension (instead of .so.3) for renamed Fedora ld-linux library # and change ld-linux*.so.2 references to ld-linux*.so.0 in ld-linux, libc # and libstdc++. Thanks to Marcus Sundberg for this suggestion. # - Dependency list for Google Chrome RPM is now redhat-lsb, wget, xdg-utils, # GConf2, libXSCrnSaver and libX11 (not 1.3* or 1.4* though). # - If OS version ("lsb_release -rs") is less than 6.4 then # offer to "yum update" and refuse to continue if the user declines. # If you don't update to at least 6.4, bad things can # happen (I got a hang and a memory allocation error when starting Google # Chrome on a CentOS 6.0 VM for example). # 3.00 - 21st July 2013 # - Command-line options now supported including -d (delete temp dir), # -h (syntax help), -n (dry run), -q (quiet) and -u (uninstall). # - Abort if Google Chrome is running when the script is started. # - Display any non-zero disk space figures for /opt/google/chrome and the # temporary download directory at the start and end of the script. # 2.10 - 20th July 2013 # - Can now detect if Fedora 15 RPMs have been archived and will download # them from the archive site if they're found there instead. # - Fixed lsb package check, so lsb deps will actually be downloaded now. # - Follow Fedora 15 library soft-links to determine the actual filenames # that need to be copied. # - Removed /etc/cron.daily/google-chrome and # /etc/yum.repos.d/google-chrome.repo straight after the Google Chrome RPM # is installed to avoid any potential conflict with old releases. # - Simplistic check for RHEL 6 derivatives (initially a prompt if the # script thinks you aren't running one, but a future release will block # non-derivatives). # - Early exits due to errors or an interrupt (CTRL-C) will now properly # tidy up files in the temporary directory and uninstall the Google Chrome # RPM if it was installed. # - All downloads now go via a common function, which saves any pre-existing # file as a .old version and renames it back if the download fails. # 2.00 - 14th July 2013 # - Installed a 32-bit CentOS 6.4 VM and this enabled me to add initial 32-bit # support, though there is an nacl_helper issue that I display a warning for. # Thanks to Seva Epsteyn for a 32-bit patch that got the ball rolling. # - Check for version number of latest Google Chrome and download/install it # if it hasn't been already. # - Use updated Fedora 15 RPMs rather than the original ISO versions. # - Warn if an enabled Google Chrome repo is detected (we don't want it). # - Tidied main code into separate functions. # - Added blank lines before/after messages and prefixed them with three stars. # - Displayed more messages now they're easier to read. # 1.10 - 13th July 2013 # - Added an update check for a new version of this script. # It will always download/install the new version, but will ask # if you want to run the new version or exit in case you want to # code inspect it first. # - Always force-install a downloaded Google RPM, even if a version # is already installed. Yes, very obvious it should do this but it # didn't (slaps forehead). # 1.02 - 13th July 2013 # - Second emergency fix today as someone spotted that wget needed # "--no-check-certificate" to talk to Google's https download site. # I didn't need it for the two machines I tested it on though! # - Added in a check for wget as well while I was at it and it will # yum install wget if it's not found. # 1.01 - 13th July 2013 # - Bad variable fix if you've not downloaded Google Chrome's RPM yet. # Serves me right for making a last minute change and not testing it :-( # 1.00 - 13th July 2013 # - Tested on 64-bit CentOS 6.4 using Fedora 15 libraries. Code is there # for 32-bit but has not been tested at all because I have no such systems. message_blank_line() # $1 != "n" (and no quiet mode) to display blank line { if [ $quiet -eq 0 -a "$1" != "n" ] then echo fi } message_output() # Display $1 depending on the quiet mode { case "$quiet" in 0) echo "*** $1 ..." ;; 1) echo "$1" ;; esac } message() # Display a message (passed in $1) prominently # $2 = "n" to avoid displaying blank lines before or after the message { if [ $quiet -eq 2 ] then return fi if [ $dry_run -eq 1 ] then echo "Would display the following message:" message_output "$1" echo return fi message_blank_line "$2" message_output "$1" message_blank_line "$2" } warning() # $1 = Warning message to display to stderr # $2 = "n" to avoid displaying blank lines before or after the message { message "WARNING: $1" "$2" >&2 } show_space_used() # Calculate disk space and number of files in install and temp dirs # and display it if there actually any installed files { for each_tree in "$inst_tree" "$tmp_tree" do if [ -d "$each_tree" ] then num_files="`find "$each_tree/." -type f | wc -l`" if [ $num_files -gt 0 ] then size_files="`du -s "$each_tree/." | awk '{ printf("%d",$1/1024); }'`" message "$each_tree tree contains $num_files files totalling $size_files MB" "n" fi fi done } clean_up() # Remove the stuff we don't want to keep once script finishes { # Make sure we don't trash system directories! if [ "$tmp_tree" != "" -a "$tmp_tree" != "/" -a "$tmp_tree" != "/tmp" ] then if [ $delete_tmp -eq 1 ] then if [ -d "$tmp_tree" ] then if [ $dry_run -eq 1 ] then echo "Would delete temporary dir $tmp_tree" echo else cd / rm -rf "$tmp_tree" if [ -d "$tmp_tree" ] then warning "Failed to delete temporary directory $tmp_tree" else message "Deleted temporary directory $tmp_tree" fi fi fi else rm_dir_list="etc lib lib64 usr sbin usr var" if [ $dry_run -eq 1 ] then echo "Would delete these directories from inside of $tmp_tree:" echo "$rm_dir_list" else # We delete specific directories so that RPM downloads/builds # remain and can be re-used if the script is run again for each_dir in $rm_dir_list do rm -rf "$tmp_tree/$each_dir" done fi fi show_space_used fi } is_installed() # See if $1 package is installed (returns non-null string if it is) { rpm -q "$1" | egrep "($rpmarch|$arch|noarch)" | grep "^$1" } uninstall_rpms() # Uninstall $* RPMs if they are installed { uninstall_list="" for each_pack in $* do if [ "`is_installed $each_pack`" != "" ] then uninstall_list="$uninstall_list $each_pack" fi done if [ "$uninstall_list" != "" ] then if [ $dry_run -eq 1 ] then echo "Would uninstall $uninstall_list using "yum remove"" echo else message "Uninstalling $uninstall_list" yum $yum_options remove $uninstall_list fi fi } uninstall_google_chrome() # Uninstall the Google Chrome and chrome-deps RPMs if they are installed { uninstall_rpms $rpm_name $deps_name # Do a final cleanup if /opt/google/chrome persists if [ "$inst_tree" != "" -a "$inst_tree" != "/" -a "$inst_tree" != "/tmp" ] then if [ -d "$inst_tree" -a $dry_run -eq 0 ] then warning "$inst_tree install tree still present - deleting it" "n" cd / rm -rf "$inst_tree" if [ -d "$inst_tree" ] then warning "Failed to delete $inst_tree install tree" "n" fi fi fi } error() # $1 = Error message # Exit script after displaying error message { if [ $dry_run -eq 1 ] then echo "Would display this error message to stderr:" echo "ERROR: $1 - aborted" else echo >&2 echo "ERROR: $1 - aborted" >&2 echo >&2 fi # A failure means we have to uninstall Google Chrome # if it got on the system and we were installing, but only # if we got past the check that it was running if [ $do_install -eq 1 -a $past_run_check -eq 1 ] then uninstall_google_chrome fi clean_up exit 1 } interrupt() # Interrupt received (usually CTRL-C) { error "Interrupt (usually CTRL-C) received" } set_tmp_tree() # Set tmp_tree variable to $1/chrome_install { if [ "$1" = "" -o "$1" = "/" -o "`echo "x$1" | grep ^x-`" != "" ] then error "Invalid temporary directory parent specified ($1)" fi if [ ! -d "$1" ] then warning "Temporary directory parent $1 doesn't exist - will be created" fi tmp_tree="$1/chrome_install" unsetsrc="$tmp_tree/unset_var.c" } check_binary_not_running() # See if the Google Chrome binary is running and abort if it is { if [ $dry_run -eq 1 ] then echo "Would check to see if $chrome_name is running and abort if it is." echo else if [ "`ps -ef | grep "$inst_tree/chrome" | grep -v grep`" != "" ] then error "$chrome_name is running - exit it then re-run this script" fi fi past_run_check=1 } yesno() # $1 = Message prompt # $2 = Minimal force level required (1 if not stated) # Returns ans=0 for no, ans=1 for yes { ans=1 if [ $dry_run -eq 1 ] then echo "Would be asked here if you wanted to" echo "$1 (y/n - y is assumed)" else if [ "$2" = "" ] then minforce=1 else minforce=$2 fi if [ $force -lt $minforce ] then ans=2 fi fi while [ $ans -eq 2 ] do echo -n "Do you want to $1 (y/n) ?" ; read reply case "$reply" in Y*|y*) ans=1 ;; N*|n*) ans=0 ;; *) echo "Please answer y or n" ;; esac done } set_rpm_type() # Set RPM type to $1 # $1 = stable, beta or unstable { if [ $do_install -eq 1 -a "$1" != "$old_rpm_type" ] then case "$1" in stable|beta|unstable) if [ $dry_run -eq 1 ] then echo "Would prompt to confirm switch to $1 channel" echo "(assuming y is input)" echo else warning "You have requested to switch to the $1 channel" if [ $quiet -eq 0 ] then echo "This script will uninstall all previously installed $chrome_name" echo "packages that originated from non-$1 channels." echo fi yesno "install the $1 release (and uninstall all non-$1s)" if [ $ans -eq 0 ] then error "Did not switch to the $1 channel" fi fi ;; *) error "Invalid $chrome_name channel ($1)" ;; esac check_binary_not_running uninstall_rpms `echo google-chrome-stable google-chrome-beta google-chrome-unstable | sed -e "s/google-chrome-$1//g"` fi case "$1" in stable|beta|unstable) rpm_type="$1" case "$1" in unstable) csv_type="dev" ;; *) csv_type="$1" ;; esac rpm_name="google-chrome-$1" chrome_csv="http://omahaproxy.appspot.com/all?os=linux&channel=$csv_type" chrome_rpm="${rpm_name}_current_$rpmarch.rpm" ;; *) error "Invalid $chrome_name type ($1)" ;; esac } init_vars() # Initialise variables # $1 = Original $0 (i.e. script name) { # Set option variables to temporary values so that errors prior to the # actual option parsing behave sensibly dry_run=0 ; do_install=0 ; delete_tmp=0 past_run_check=0 ; force=0 # Avoid picking up the Fedora libs for any binaries # run by this script unset LD_LIBRARY_PATH if [ "$TMPDIR" = "" ] then set_tmp_tree "/tmp" else set_tmp_tree "$TMPDIR" fi arch="`uname -m`" case "$arch" in x86_64) rellib="lib64" ; ld_linux="ld-linux-x86-64" ; rpmarch="$arch" ;; i686) rellib="lib" ; ld_linux="ld-linux" ; rpmarch="i386" ;; *) error "Unsupported architecture ($arch)" ;; esac relusrlib="usr/$rellib" chrome_name="Google Chrome" chrome_defaults="/etc/default/google-chrome" chrome_repo="/etc/yum.conf.d/google-chrome.repo" # Find the most stable installed Google Chrome and use that # as the default for the rest of the script (override with -b, -s or -U) old_rpm_type="" for each_old_rpm_type in stable beta unstable do if [ "$old_rpm_type" = "" ] then if [ "`is_installed google-chrome-$each_old_rpm_type`" != "" ] then old_rpm_type="$each_old_rpm_type" fi fi done # If nothing installed at all, default to stable if [ "$old_rpm_type" = "" ] then old_rpm_type="stable" fi set_rpm_type "$old_rpm_type" inst_tree="/opt/google/chrome" libdir="$inst_tree/lib" chrome_wrapper="$inst_tree/google-chrome" modify_wrapper="$inst_tree/modify_wrapper" deps_name="chrome-deps" deps_version="1.21" deps_latest="`is_installed $deps_name | grep $deps_version`" wrapper_mod_version="1.01" install_message="already installed" trap "interrupt" 1 2 3 fedver=15 # Fedora version with most of the needed libs (F16 doesn't work!) keyringver=17 # Fedora version needed for libgnome-keyring package suffix="$arch.rpm" # $fedver archived updated packages directory baseurl="http://archives.fedoraproject.org/pub/archive/fedora/linux/updates/$fedver/$rpmarch" # Fedora 17 archived libgnome-keyring package directory baseurlkeyring="http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/$keyringver/Fedora/$rpmarch/os/Packages/l/" wget="/usr/bin/wget" wget_options="--no-check-certificate" yum_options="-y" rpm_options="-U --force --nodeps" chcon_options="-u system_u" rpmbuild_options="-bb" new_ld_suff=."so.0" # Update checker URL checksite="http://chrome.richardlloyd.org.uk/" checkfile="version.dat" checkurl="$checksite$checkfile" scriptname="install_chrome.sh" upgradeurl="$checksite$scriptname" unsetlib="$libdir/unset_var.so" script="$1" case "$script" in ./*) script="`pwd`/`basename $script`" ;; /*) script="$script" ;; *) script="`pwd`/$script" ;; esac } download_file() # $1 = Full URL to download # $2 = Optional basename to save to (if omitted, then = basename $1) # Also allow download to fail without exit if $2 is set # $3 = Optional cksum value to compare download against { if [ "$2" = "" ] then dlbase="`basename "$1"`" else dlbase="$2" fi if [ $dry_run -eq 1 ] then echo "Would download this URL to $tmp_tree/$dlbase :" echo $1 ; echo return fi old_dlbase="$dlbase.old" if [ -f "$dlbase" ] then rm -f "$old_dlbase" mv -f "$dlbase" "$old_dlbase" fi message "Downloading $dlbase (please wait)" $wget $wget_options -O "$dlbase" "$1" if [ -s "$dlbase" -a "$3" != "" ] then if [ "`cksum $dlbase`" != "$3" ] then rm -f "$dlbase" warning "Deleted downloaded $dlbase - checksum or size incorrect" fi fi if [ ! -s "$dlbase" ] then if [ -f "$old_dlbase" ] then mv -f "$old_dlbase" "$dlbase" fi if [ "$2" = "" -o "$3" != "" ] then error "Failed to download $dlbase correctly" fi fi } change_se_context() # $1 = File or directory name # Change SELinux context type for $1 to lib_t (or other # types depending on its name) { if [ $selinux_enabled -eq 0 ] then # chcon commands fail if SELinux is disabled return fi if [ -s "$1" -o -d "$1" ] then case "$1" in *$ld_linux*) con_type="ld_so_t" ;; $chrome_wrapper) con_type="execmem_exec_t" ;; $unsetlib) con_type="textrel_shlib_t" ;; *) con_type="lib_t" ;; esac if [ $dry_run -eq 1 ] then echo "Would change SELinux context type of $1 to $con_type" echo else chcon $chcon_options -t $con_type "$1" fi else if [ $dry_run -eq 0 ] then error "Couldn't change SELinux context type of $1 - not found" fi fi } install_ld_preload_lib() # Compile and install LD_PRELOAD lib as $libdir/unset_var.so { if [ $dry_run -eq 1 ] then echo "Would compile/install $unsetlib and" echo "add LD_PRELOAD=$unsetlib to $chrome_wrapper" echo return fi cat <<@EOF >"$unsetsrc" /* unset_var.c 1.10 (C) Richard K. Lloyd 2014 <rklloyd@gmail.com> LD_PRELOAD code to save LD_LIBRARY_PATH, blank LD_LIBRARY_PATH if the file to be exec'd isn't a full path, unset LD_PRELOAD, run the original exec*() library routine and then restore LD_LIBRARY_PATH and LD_PRELOAD. This way, we can avoid Fedora 15/17 libraries being picked up by helper apps or plugins that are subsequently loaded by Google Chrome. strings -a /opt/google/chrome/chrome | grep ^exec reveals three exec* routines used by the binary: execvp(), execve() and execlp(). Compile with: gcc -O -fpic -shared -s -o unset_var.so unset_var.c -ldl Run with: export LD_PRELOAD=/path/to/unset_var.so /opt/google/chrome/google-chrome */ /* Have to build with this flag defined */ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif /* The environmental variables we're going to unsetenv() */ #define PATH_ENV_VAR "LD_LIBRARY_PATH" #define PRELOAD_ENV_VAR "LD_PRELOAD" /* Some system headers */ #include <stdio.h> #include <dlfcn.h> #include <stdlib.h> #include <sys/socket.h> #include <stdarg.h> #include <string.h> /* Each routine we intercept is likely to have different parameter types and return types too, so firstly, we create common code macros */ /* Define local variables for function, passing in the function return type */ #define INTERCEPT_LOCAL_VARS(return_type) char *pathenvptr=getenv(PATH_ENV_VAR), *preloadenvptr=getenv(PRELOAD_ENV_VAR); static char pathsavebuf[BUFSIZ],preloadsavebuf[BUFSIZ]; /* FILE *outhand=fopen("/tmp/exec.log","a"); */ return_type retval /* Save PATH_ENV_VAR and PRELOAD_ENV_VAR values in local buffers and then unset the former if it's not a full path or is a Google Talk plugin path and always unset the latter */ #define INTERCEPT_SAVE_VAR(fname) if (pathenvptr!=(char *)NULL && pathenvptr[0]!='