Print this page
OS-3489 lxbrand 64bit LTP recvmsg01 hangs - cmsghdr size mismatch
OS-3491 lx_boot should bypass distro detection when 'docker' flag set
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
OS-3023 lx brand installer cleanup

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/brand/shared/zone/common.ksh
          +++ new/usr/src/lib/brand/shared/zone/common.ksh
↓ open down ↓ 11 lines elided ↑ open up ↑
  12   12  #
  13   13  # When distributing Covered Code, include this CDDL HEADER in each
  14   14  # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15  # If applicable, add the following below this CDDL HEADER, with the
  16   16  # fields enclosed by brackets "[]" replaced with your own identifying
  17   17  # information: Portions Copyright [yyyy] [name of copyright owner]
  18   18  #
  19   19  # CDDL HEADER END
  20   20  #
  21   21  # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
       22 +# Copyright 2014, Joyent, Inc. All rights reserved.
  22   23  #
  23   24  
  24   25  #
  25   26  # Send the error message to the screen and to the logfile.
  26   27  #
  27   28  error()
  28   29  {
  29   30          typeset fmt="$1"
  30   31          shift
  31   32  
↓ open down ↓ 57 lines elided ↑ open up ↑
  89   90  # If, for example, you need to ensure that every component of the path
  90   91  # '/foo/bar/baz' is a directory and not a symlink, then do the following:
  91   92  #
  92   93  #       safe_dir /foo
  93   94  #       safe_dir /foo/bar
  94   95  #       safe_dir /foo/bar/baz
  95   96  #
  96   97  safe_dir()
  97   98  {
  98   99          typeset dir="$1"
      100 +        typeset pwd_dir=""
  99  101  
 100      -        if [[ -h $ZONEROOT/$dir || ! -d $ZONEROOT/$dir ]]; then
 101      -                fatal "$e_baddir" "$dir"
      102 +        if [[ -d $ZONEROOT/$dir ]]; then
      103 +                if [[ -h $ZONEROOT/$dir ]]; then
      104 +                        #
      105 +                        # When dir is a symlink to a directory, we 'cd' to that
      106 +                        # directory to ensure that's under $ZONEROOT. We use pwd
      107 +                        # from /usr/bin instead of built-in because they give
      108 +                        # different results.
      109 +                        #
      110 +                        pwd_dir=$(cd $ZONEROOT/$dir && /usr/bin/pwd)
      111 +                        if [[ $pwd_dir =~ "^$ZONEROOT" ]]; then
      112 +                                return;
      113 +                        else
      114 +                                fatal \
      115 +                                    "$e_baddir: symlink out of zoneroot" "$dir"
      116 +                        fi
      117 +                else
      118 +                        # it's a dir and not a symlink, so that's ok.
      119 +                        return
      120 +                fi
 102  121          fi
 103  122  }
 104  123  
 105  124  # Like safe_dir except the dir doesn't have to exist.
 106  125  safe_opt_dir()
 107  126  {
 108  127          typeset dir="$1"
 109  128  
 110  129          [[ ! -e $ZONEROOT/$dir ]] && return
 111  130  
 112      -        if [[ -h $ZONEROOT/$dir || ! -d $ZONEROOT/$dir ]]; then
 113      -                fatal "$e_baddir" "$dir"
 114      -        fi
      131 +        safe_dir $dir
 115  132  }
 116  133  
 117  134  # Only make a copy if we haven't already done so.
 118  135  safe_backup()
 119  136  {
 120  137          typeset src="$1"
 121  138          typeset dst="$2"
 122  139  
 123  140          if [[ ! -h $src && ! -h $dst && ! -d $dst && ! -f $dst ]]; then
 124  141                  /usr/bin/cp -p $src $dst || fatal "$e_badfile" "$src"
↓ open down ↓ 55 lines elided ↑ open up ↑
 180  197          if [ $? -eq 0 ]; then
 181  198                  return
 182  199          fi
 183  200  
 184  201          safe_backup $filename $filename.pre_p2v
 185  202          if [ $rem = "remove" ]; then
 186  203                  rm -f $filename
 187  204          fi
 188  205  
 189  206          cat <<-END >$filename || exit 1
 190      -        #!/bin/sh -p
      207 +        #!/bin/sh
 191  208          #
 192  209          # Solaris Brand Replacement
 193  210          #
 194  211          # Attention.  This file has been replaced with a new version for
 195  212          # use in a virtualized environment.  Modification of this script is not
 196  213          # supported and all changes will be lost upon reboot.  The
 197  214          # {name}.pre_p2v version of this file is a backup copy of the
 198  215          # original and should not be deleted.
 199  216          #
 200  217          END
↓ open down ↓ 867 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX