Commit f4c657b5 authored by ben's avatar ben

Fixed bad high bit permissions mode in cmodule.c, and assorted changes

to make --windows-mode work.


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@180 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent d47848c5
...@@ -19,9 +19,9 @@ them over the usual 255 character limit. ...@@ -19,9 +19,9 @@ them over the usual 255 character limit.
import re import re
from log import * from log import *
from robust import *
import Globals import Globals
max_filename_length = 255 max_filename_length = 255
# If true, enable character quoting, and set characters making # If true, enable character quoting, and set characters making
...@@ -43,7 +43,7 @@ def set_init_quote_vals(): ...@@ -43,7 +43,7 @@ def set_init_quote_vals():
def set_init_quote_vals_local(): def set_init_quote_vals_local():
"""Set value on local connection, initialize regexps""" """Set value on local connection, initialize regexps"""
global chars_to_quote global chars_to_quote, quoting_char
chars_to_quote = Globals.chars_to_quote chars_to_quote = Globals.chars_to_quote
if len(Globals.quoting_char) != 1: if len(Globals.quoting_char) != 1:
Log.FatalError("Expected single character for quoting char," Log.FatalError("Expected single character for quoting char,"
......
...@@ -163,6 +163,7 @@ def init_connection_settings(conn): ...@@ -163,6 +163,7 @@ def init_connection_settings(conn):
conn.Log.setterm_verbosity(Log.term_verbosity) conn.Log.setterm_verbosity(Log.term_verbosity)
for setting_name in Globals.changed_settings: for setting_name in Globals.changed_settings:
conn.Globals.set(setting_name, Globals.get(setting_name)) conn.Globals.set(setting_name, Globals.get(setting_name))
FilenameMapping.set_init_quote_vals()
def init_connection_remote(conn_number): def init_connection_remote(conn_number):
"""Run on server side to tell self that have given conn_number""" """Run on server side to tell self that have given conn_number"""
...@@ -187,6 +188,11 @@ def BackupInitConnections(reading_conn, writing_conn): ...@@ -187,6 +188,11 @@ def BackupInitConnections(reading_conn, writing_conn):
writing_conn.Globals.set("isbackup_writer", 1) writing_conn.Globals.set("isbackup_writer", 1)
UpdateGlobal("backup_reader", reading_conn) UpdateGlobal("backup_reader", reading_conn)
UpdateGlobal("backup_writer", writing_conn) UpdateGlobal("backup_writer", writing_conn)
if (Globals.change_source_perms and
reading_conn.Globals.get("process_uid") == 0):
Log("Warning: --change_source_perms should usually not be used when\n"
"the reading connection is running as root, because root can\n"
"read all files regardless of their permissions.", 2)
def CloseConnections(): def CloseConnections():
"""Close all connections. Run by client""" """Close all connections. Run by client"""
...@@ -224,4 +230,5 @@ Remote version: %s""" % (Globals.version, version) ...@@ -224,4 +230,5 @@ Remote version: %s""" % (Globals.version, version)
from log import * from log import *
from rpath import * from rpath import *
from connection import * from connection import *
import Globals import Globals, FilenameMapping
...@@ -53,7 +53,7 @@ static PyObject *c_make_file_dict(self, args) ...@@ -53,7 +53,7 @@ static PyObject *c_make_file_dict(self, args)
inode = PyInt_FromLong((long)sbuf.st_ino); inode = PyInt_FromLong((long)sbuf.st_ino);
#endif #endif
mode = (long)sbuf.st_mode; mode = (long)sbuf.st_mode;
perms = mode & (S_IRWXU | S_IRWXG | S_IRWXO); perms = mode & 07777;
#if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS) #if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS)
devloc = PyLong_FromLongLong((LONG_LONG)sbuf.st_dev); devloc = PyLong_FromLongLong((LONG_LONG)sbuf.st_dev);
#else #else
......
...@@ -110,7 +110,6 @@ class SigFile(LikeFile): ...@@ -110,7 +110,6 @@ class SigFile(LikeFile):
try: self.maker = _librsync.new_sigmaker() try: self.maker = _librsync.new_sigmaker()
except _librsync.librsyncError, e: raise librsyncError(str(e)) except _librsync.librsyncError, e: raise librsyncError(str(e))
class DeltaFile(LikeFile): class DeltaFile(LikeFile):
"""File-like object which incrementally generates a librsync delta""" """File-like object which incrementally generates a librsync delta"""
def __init__(self, signature, new_file): def __init__(self, signature, new_file):
...@@ -147,3 +146,41 @@ class PatchedFile(LikeFile): ...@@ -147,3 +146,41 @@ class PatchedFile(LikeFile):
try: self.maker = _librsync.new_patchmaker(basis_file) try: self.maker = _librsync.new_patchmaker(basis_file)
except _librsync.librsyncError, e: raise librsyncError(str(e)) except _librsync.librsyncError, e: raise librsyncError(str(e))
class SigGenerator:
"""Calculate signature.
Input and output is same as SigFile, but the interface is like md5
module, not filelike object
"""
def __init__(self):
"""Return new signature instance"""
try: self.sig_maker = _librsync.new_sigmaker()
except _librsync.librsyncError, e: raise librsyncError(str(e))
self.gotsig = None
self.buffer = ""
self.sig_string = ""
def update(self, buf):
"""Add buf to data that signature will be calculated over"""
if self.gotsig:
raise librsyncError("SigGenerator already provided signature")
self.buffer += buf
while len(self.buffer) >= blocksize:
if self.process_buffer():
raise librsyncError("Premature EOF received from sig_maker")
def process_buffer(self):
"""Run self.buffer through sig_maker, add to self.sig_string"""
try: eof, len_buf_read, cycle_out = self.sig_maker.cycle(self.buffer)
except _librsync.librsyncError, e: raise librsyncError(str(e))
self.buffer = self.buffer[len_buf_read:]
self.sig_string += cycle_out
return eof
def getsig(self):
"""Return signature over given data"""
while not self.process_buffer(): pass # keep running until eof
return self.sig_string
...@@ -803,12 +803,13 @@ class RPathFileHook: ...@@ -803,12 +803,13 @@ class RPathFileHook:
self.closing_thunk() self.closing_thunk()
return result return result
# Import these late to avoid circular dependencies # Import these late to avoid circular dependencies
import FilenameMapping
from lazy import * from lazy import *
from selection import * from selection import *
from destructive_stepping import * from destructive_stepping import *
class RpathDeleter(ITRBranch): class RpathDeleter(ITRBranch):
"""Delete a directory. Called by RPath.delete()""" """Delete a directory. Called by RPath.delete()"""
def start_process(self, index, dsrp): def start_process(self, index, dsrp):
......
...@@ -20,6 +20,7 @@ import re ...@@ -20,6 +20,7 @@ import re
from log import * from log import *
from robust import * from robust import *
from destructive_stepping import * from destructive_stepping import *
import FilenameMapping
class SelectError(Exception): class SelectError(Exception):
......
...@@ -19,9 +19,9 @@ them over the usual 255 character limit. ...@@ -19,9 +19,9 @@ them over the usual 255 character limit.
import re import re
from log import * from log import *
from robust import *
import Globals import Globals
max_filename_length = 255 max_filename_length = 255
# If true, enable character quoting, and set characters making # If true, enable character quoting, and set characters making
...@@ -43,7 +43,7 @@ def set_init_quote_vals(): ...@@ -43,7 +43,7 @@ def set_init_quote_vals():
def set_init_quote_vals_local(): def set_init_quote_vals_local():
"""Set value on local connection, initialize regexps""" """Set value on local connection, initialize regexps"""
global chars_to_quote global chars_to_quote, quoting_char
chars_to_quote = Globals.chars_to_quote chars_to_quote = Globals.chars_to_quote
if len(Globals.quoting_char) != 1: if len(Globals.quoting_char) != 1:
Log.FatalError("Expected single character for quoting char," Log.FatalError("Expected single character for quoting char,"
......
...@@ -163,6 +163,7 @@ def init_connection_settings(conn): ...@@ -163,6 +163,7 @@ def init_connection_settings(conn):
conn.Log.setterm_verbosity(Log.term_verbosity) conn.Log.setterm_verbosity(Log.term_verbosity)
for setting_name in Globals.changed_settings: for setting_name in Globals.changed_settings:
conn.Globals.set(setting_name, Globals.get(setting_name)) conn.Globals.set(setting_name, Globals.get(setting_name))
FilenameMapping.set_init_quote_vals()
def init_connection_remote(conn_number): def init_connection_remote(conn_number):
"""Run on server side to tell self that have given conn_number""" """Run on server side to tell self that have given conn_number"""
...@@ -187,6 +188,11 @@ def BackupInitConnections(reading_conn, writing_conn): ...@@ -187,6 +188,11 @@ def BackupInitConnections(reading_conn, writing_conn):
writing_conn.Globals.set("isbackup_writer", 1) writing_conn.Globals.set("isbackup_writer", 1)
UpdateGlobal("backup_reader", reading_conn) UpdateGlobal("backup_reader", reading_conn)
UpdateGlobal("backup_writer", writing_conn) UpdateGlobal("backup_writer", writing_conn)
if (Globals.change_source_perms and
reading_conn.Globals.get("process_uid") == 0):
Log("Warning: --change_source_perms should usually not be used when\n"
"the reading connection is running as root, because root can\n"
"read all files regardless of their permissions.", 2)
def CloseConnections(): def CloseConnections():
"""Close all connections. Run by client""" """Close all connections. Run by client"""
...@@ -224,4 +230,5 @@ Remote version: %s""" % (Globals.version, version) ...@@ -224,4 +230,5 @@ Remote version: %s""" % (Globals.version, version)
from log import * from log import *
from rpath import * from rpath import *
from connection import * from connection import *
import Globals import Globals, FilenameMapping
...@@ -53,7 +53,7 @@ static PyObject *c_make_file_dict(self, args) ...@@ -53,7 +53,7 @@ static PyObject *c_make_file_dict(self, args)
inode = PyInt_FromLong((long)sbuf.st_ino); inode = PyInt_FromLong((long)sbuf.st_ino);
#endif #endif
mode = (long)sbuf.st_mode; mode = (long)sbuf.st_mode;
perms = mode & (S_IRWXU | S_IRWXG | S_IRWXO); perms = mode & 07777;
#if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS) #if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS)
devloc = PyLong_FromLongLong((LONG_LONG)sbuf.st_dev); devloc = PyLong_FromLongLong((LONG_LONG)sbuf.st_dev);
#else #else
......
...@@ -110,7 +110,6 @@ class SigFile(LikeFile): ...@@ -110,7 +110,6 @@ class SigFile(LikeFile):
try: self.maker = _librsync.new_sigmaker() try: self.maker = _librsync.new_sigmaker()
except _librsync.librsyncError, e: raise librsyncError(str(e)) except _librsync.librsyncError, e: raise librsyncError(str(e))
class DeltaFile(LikeFile): class DeltaFile(LikeFile):
"""File-like object which incrementally generates a librsync delta""" """File-like object which incrementally generates a librsync delta"""
def __init__(self, signature, new_file): def __init__(self, signature, new_file):
...@@ -147,3 +146,41 @@ class PatchedFile(LikeFile): ...@@ -147,3 +146,41 @@ class PatchedFile(LikeFile):
try: self.maker = _librsync.new_patchmaker(basis_file) try: self.maker = _librsync.new_patchmaker(basis_file)
except _librsync.librsyncError, e: raise librsyncError(str(e)) except _librsync.librsyncError, e: raise librsyncError(str(e))
class SigGenerator:
"""Calculate signature.
Input and output is same as SigFile, but the interface is like md5
module, not filelike object
"""
def __init__(self):
"""Return new signature instance"""
try: self.sig_maker = _librsync.new_sigmaker()
except _librsync.librsyncError, e: raise librsyncError(str(e))
self.gotsig = None
self.buffer = ""
self.sig_string = ""
def update(self, buf):
"""Add buf to data that signature will be calculated over"""
if self.gotsig:
raise librsyncError("SigGenerator already provided signature")
self.buffer += buf
while len(self.buffer) >= blocksize:
if self.process_buffer():
raise librsyncError("Premature EOF received from sig_maker")
def process_buffer(self):
"""Run self.buffer through sig_maker, add to self.sig_string"""
try: eof, len_buf_read, cycle_out = self.sig_maker.cycle(self.buffer)
except _librsync.librsyncError, e: raise librsyncError(str(e))
self.buffer = self.buffer[len_buf_read:]
self.sig_string += cycle_out
return eof
def getsig(self):
"""Return signature over given data"""
while not self.process_buffer(): pass # keep running until eof
return self.sig_string
...@@ -803,12 +803,13 @@ class RPathFileHook: ...@@ -803,12 +803,13 @@ class RPathFileHook:
self.closing_thunk() self.closing_thunk()
return result return result
# Import these late to avoid circular dependencies # Import these late to avoid circular dependencies
import FilenameMapping
from lazy import * from lazy import *
from selection import * from selection import *
from destructive_stepping import * from destructive_stepping import *
class RpathDeleter(ITRBranch): class RpathDeleter(ITRBranch):
"""Delete a directory. Called by RPath.delete()""" """Delete a directory. Called by RPath.delete()"""
def start_process(self, index, dsrp): def start_process(self, index, dsrp):
......
...@@ -20,6 +20,7 @@ import re ...@@ -20,6 +20,7 @@ import re
from log import * from log import *
from robust import * from robust import *
from destructive_stepping import * from destructive_stepping import *
import FilenameMapping
class SelectError(Exception): class SelectError(Exception):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment