Beispiel #1
	def get_one_sig_fp(cls, dest_rp):
		"""Return a signature fp of given index, corresponding to reg file"""
		if not dest_rp.isreg():
			log.ErrorLog.write_if_open("UpdateError", dest_rp,
				"File changed from regular file before signature")
			return None
		if (Globals.process_uid != 0 and not dest_rp.readable() and
			# This branch can happen with root source and non-root
			# destination.  Permissions are changed permanently, which
			# should propogate to the diffs
			dest_rp.chmod(0400 | dest_rp.getperms())
			return Rdiff.get_signature(dest_rp)
		except IOError, e:
			if (e.errno == errno.EPERM or e.errno == errno.EACCES):
					# Try chmod'ing anyway -- This can work on NFS and AFS
					# depending on the setup. We keep the if() statement
					# above for performance reasons.
					dest_rp.chmod(0400 | dest_rp.getperms())
					return Rdiff.get_signature(dest_rp)
				except (IOError, OSError):
					log.Log.FatalError("Could not open %s for reading. Check "
						"permissions on file." % (dest_rp.path,))
Beispiel #2
def makediff(new, mirror, incpref):
	"""Make incfile which is a diff new -> mirror"""
	compress = iscompressed(mirror)
	if compress: diff = get_inc(incpref, "diff.gz")
	else:  diff = get_inc(incpref, "diff")

	old_new_perms, old_mirror_perms = (None, None)

	if Globals.process_uid != 0:
		# Check for unreadable files
		if not new.readable():
			old_new_perms = new.getperms()
			new.chmod(0400 | old_new_perms)
		if not mirror.readable():
			old_mirror_perms = mirror.getperms()
			mirror.chmod(0400 | old_mirror_perms)
	Rdiff.write_delta(new, mirror, diff, compress)

	if old_new_perms: new.chmod(old_new_perms)
	if old_mirror_perms: mirror.chmod(old_mirror_perms)

	rpath.copy_attribs_inc(mirror, diff)
	return diff