Print this page
5166 sendmail package should be replaceable

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/scripts/validate_pkg.py
          +++ new/usr/src/tools/scripts/validate_pkg.py
↓ open down ↓ 52 lines elided ↑ open up ↑
  53   53          ("path", "path=")
  54   54      ],
  55   55      "file": [
  56   56          ("hash", ""),
  57   57          ("group", "group="),
  58   58          ("mode", "mode="),
  59   59          ("owner", "owner="),
  60   60          ("path", "path=")
  61   61      ],
  62   62      "link": [
       63 +        ("mediator", "mediator="),
  63   64          ("path", "path="),
  64   65          ("target", "target=")
  65   66      ],
  66   67      "hardlink": [
  67   68          ("path", "path="),
  68   69          ("hardkey", "target=")
  69   70      ],
  70   71  }
  71   72  
  72   73  # Mode checks used to validate safe file and directory permissions
↓ open down ↓ 116 lines elided ↑ open up ↑
 189  190          # must be the same.  For file and hardlink, see below.
 190  191          #
 191  192          typelhs = lhs.name()
 192  193          typerhs = rhs.name()
 193  194          if typelhs in ("link", "dir"):
 194  195              if typelhs != typerhs:
 195  196                  return True
 196  197  
 197  198          #
 198  199          # For symlinks, all that's left is the link target.
      200 +        # For mediated symlinks targets can differ.
 199  201          #
 200  202          if typelhs == "link":
 201      -            return lhs.target != rhs.target
      203 +            return (lhs.mediator is None) and (lhs.target != rhs.target)
 202  204  
 203  205          #
 204  206          # For a directory, it's important that both be directories,
 205  207          # the modes be identical, and the paths are identical.  We already
 206  208          # checked all but the modes above.
 207  209          #
 208  210          # If both objects are files, then we're in the same boat.
 209  211          #
 210  212          if typelhs == "dir" or (typelhs == "file" and typerhs == "file"):
 211  213              return lhs.mode != rhs.mode
↓ open down ↓ 87 lines elided ↑ open up ↑
 299  301          if action.name == "file":
 300  302              self.owner = action.attrs["owner"]
 301  303              self.group = action.attrs["group"]
 302  304              self.mode = action.attrs["mode"]
 303  305              self.hash = action.hash
 304  306              if "preserve" in action.attrs:
 305  307                  self.editable = True
 306  308          elif action.name == "link":
 307  309              target = action.attrs["target"]
 308  310              self.target = os.path.normpath(target)
      311 +            if "mediator" in action.attrs:
      312 +                self.mediator = action.attrs["mediator"]
      313 +            else:
      314 +                self.mediator = None
 309  315          elif action.name == "dir":
 310  316              self.owner = action.attrs["owner"]
 311  317              self.group = action.attrs["group"]
 312  318              self.mode = action.attrs["mode"]
 313  319              self.isdir = True
 314  320          elif action.name == "hardlink":
 315  321              target = os.path.normpath(action.get_target_path())
 316  322              self.hardkey = target
 317  323              self.hardpaths.add(target)
 318  324  
↓ open down ↓ 40 lines elided ↑ open up ↑
 359  365  
 360  366          #
 361  367          # Per stat.py, these cases are mutually exclusive.
 362  368          #
 363  369          if stat.S_ISREG(mode):
 364  370              self.hash = self.path
 365  371          elif stat.S_ISDIR(mode):
 366  372              self.isdir = True
 367  373          elif stat.S_ISLNK(mode):
 368  374              self.target = os.path.normpath(os.readlink(path))
      375 +            self.mediator = None
 369  376          else:
 370  377              raise UnsupportedFileFormatError(path, mode)
 371  378  
 372  379          if not stat.S_ISLNK(mode):
 373  380              self.mode = "%04o" % stat.S_IMODE(mode)
 374  381              #
 375  382              # Instead of reading the group and owner from the proto area after
 376  383              # a non-root build, just drop in dummy values.  Since we don't
 377  384              # compare them anywhere, this should allow at least marginally
 378  385              # useful comparisons of protolist-style output.
↓ open down ↓ 513 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX