This file is indexed.

/usr/share/pyshared/rdiff_backup/increment.py is in rdiff-backup 1.2.8-7.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Copyright 2002 Ben Escoto
#
# This file is part of rdiff-backup.
#
# rdiff-backup is free software; you can redistribute it and/or modify
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# rdiff-backup is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with rdiff-backup; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA

"""Provides functions and *ITR classes, for writing increment files"""

import Globals, Time, rpath, Rdiff, log, statistics, robust


def Increment(new, mirror, incpref):
	"""Main file incrementing function, returns inc file created

	new is the file on the active partition,
	mirror is the mirrored file from the last backup,
	incpref is the prefix of the increment file.

	This function basically moves the information about the mirror
	file to incpref.

	"""
	log.Log("Incrementing mirror file " + mirror.path, 5)
	if ((new and new.isdir()) or mirror.isdir()) and not incpref.lstat():
		incpref.mkdir()

	if not mirror.lstat(): incrp = makemissing(incpref)
	elif mirror.isdir(): incrp = makedir(mirror, incpref)
	elif new.isreg() and mirror.isreg():
		incrp = makediff(new, mirror, incpref)
	else: incrp = makesnapshot(mirror, incpref)
	statistics.process_increment(incrp)
	return incrp

def makemissing(incpref):
	"""Signify that mirror file was missing"""
	incrp = get_inc(incpref, "missing")
	incrp.touch()
	return incrp

def iscompressed(mirror):
	"""Return true if mirror's increments should be compressed"""
	return (Globals.compression and
			not Globals.no_compression_regexp.match(mirror.path))

def makesnapshot(mirror, incpref):
	"""Copy mirror to incfile, since new is quite different"""
	compress = iscompressed(mirror)
	if compress and mirror.isreg():
		snapshotrp = get_inc(incpref, "snapshot.gz")
	else: snapshotrp = get_inc(incpref, "snapshot")

	if mirror.isspecial(): # check for errors when creating special increments
		eh = robust.get_error_handler("SpecialFileError")
		if robust.check_common_error(eh, rpath.copy_with_attribs,
									 (mirror, snapshotrp, compress)) == 0:
			snapshotrp.setdata()
			if snapshotrp.lstat(): snapshotrp.delete()
			snapshotrp.touch()
	else: rpath.copy_with_attribs(mirror, snapshotrp, compress)
	return snapshotrp

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

def makedir(mirrordir, incpref):
	"""Make file indicating directory mirrordir has changed"""
	dirsign = get_inc(incpref, "dir")
	dirsign.touch()
	rpath.copy_attribs_inc(mirrordir, dirsign)
	return dirsign

def get_inc(rp, typestr, time = None):
	"""Return increment like rp but with time and typestr suffixes

	To avoid any quoting, the returned rpath has empty index, and the
	whole filename is in the base (which is not quoted).

	"""
	if time is None: time = Time.prevtime
	addtostr = lambda s: "%s.%s.%s" % (s, Time.timetostring(time), typestr)
	if rp.index:
		incrp = rp.__class__(rp.conn, rp.base, rp.index[:-1] +
							 (addtostr(rp.index[-1]),))
	else:
		dirname, basename = rp.dirsplit()
		incrp = rp.__class__(rp.conn, dirname, (addtostr(basename),))
	assert not incrp.lstat(), incrp
	return incrp