Tags: patch Hello,
Patch included as this bug is quite annoying to me because: 1. the remote server only allow scp 2. inoticoming is way too fast The "scp" one is tested, not the "rsync". Regards. From 827c2760fb104251120eb736682573e338d4298b Mon Sep 17 00:00:00 2001 From: Daniel Dehennin <daniel.dehen...@baby-gnu.org> Date: Thu, 7 Jun 2012 19:16:56 +0200 Subject: [PATCH] Fix permissions on files before uploading. As noted in #389908[1], the chmod can not always be done after uploading by ssh or rsync. It happens too when remote server is using rssh and allow only scp. * scp.py (upload): Fix mode locally before the upload. * rsync.py (upload): Ditoo. Footnotes: [1] http://bugs.debian.org/389908 --- rsync.py | 15 ++++++++------- scp.py | 26 +++++++++----------------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/rsync.py b/rsync.py index 8f0adb4..f439a0c 100644 --- a/rsync.py +++ b/rsync.py @@ -6,10 +6,18 @@ def upload(fqdn,login,incoming,files_to_upload,debug, dummy,progress=0): files_to_fix = [] + fix_command = ['chmod', '0644'] for file in files_to_upload: to_fix = os.path.basename(file) file_to_fix = os.path.join(incoming, to_fix) files_to_fix.append(file_to_fix) + if not stat.S_IMODE(os.lstat(file)[stat.ST_MODE])==0644: + if debug: + print "D: Fixing some permissions" + print "D: %s" % (fix_command + [file]) + if dputhelper.spawnv(os.P_WAIT, "/bin/chmod", fix_command + [file]): + print "Error while fixing permissions." + sys.exit(1) if login and login != '*': login_spec = '%s@'%login @@ -17,8 +25,6 @@ def upload(fqdn,login,incoming,files_to_upload,debug, dummy,progress=0): login_spec = '' upload_command = ['rsync', '', '--copy-links', '--progress', '--partial', '-zave', 'ssh -x', '%s%s:%s' % (login_spec, fqdn, incoming)] - fix_command = ['ssh', '%s%s' % (login_spec, fqdn), 'chmod', '0644'] \ - + files_to_fix upload_command[1:2] = files_to_upload if debug: @@ -28,8 +34,3 @@ def upload(fqdn,login,incoming,files_to_upload,debug, dummy,progress=0): print print "Error while uploading." sys.exit(1) - if debug: - print "D: Fixing file permissions with %s%s" % (login_spec, fqdn) - if dputhelper.spawnv(os.P_WAIT, '/usr/bin/ssh', fix_command): - print "Error while fixing permission." - sys.exit(1) diff --git a/scp.py b/scp.py index ec80cd8..5ed43b6 100644 --- a/scp.py +++ b/scp.py @@ -7,11 +7,19 @@ def upload(fqdn,login,incoming,files_to_upload,debug,compress, files_to_fix = [] + fix_command = ['/bin/chmod', '0644'] for file in files_to_upload: to_fix = os.path.basename(file) file_to_fix = os.path.join(incoming, to_fix) files_to_fix.append(file_to_fix) - + if not stat.S_IMODE(os.lstat(file)[stat.ST_MODE])==0644: + if debug: + print "D: Fixing some permissions" + print "D: %s" % (fix_command + [file]) + if dputhelper.spawnv(os.P_WAIT, "/bin/chmod", fix_command + [file]): + print "Error while fixing permissions." + sys.exit(1) + command = ['scp', '-p'] if compress: command.append('-C') @@ -24,10 +32,6 @@ def upload(fqdn,login,incoming,files_to_upload,debug,compress, else: login_spec = '' command.append('%s%s:%s' % (login_spec, fqdn, incoming)) - change_mode = 0 - for file in files_to_upload: - if not stat.S_IMODE(os.lstat(file)[stat.ST_MODE])==0644: - change_mode = 1 if debug: print "D: Uploading with scp to %s%s:%s" % \ (login_spec, fqdn, incoming) @@ -35,15 +39,3 @@ def upload(fqdn,login,incoming,files_to_upload,debug,compress, if dputhelper.spawnv(os.P_WAIT, '/usr/bin/scp', command): print "Error while uploading." sys.exit(1) - if change_mode: - fix_command = ['ssh'] - for anopt in ssh_config_options: - fix_command += ['-o', anopt] - fix_command += ['%s%s' % (login_spec, fqdn), 'chmod', '0644'] \ - + files_to_fix - if debug: - print "D: Fixing some permissions" - print "D: %s" % fix_command - if dputhelper.spawnv(os.P_WAIT, '/usr/bin/ssh', fix_command): - print "Error while fixing permissions." - sys.exit(1) -- 1.7.10 -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF
pgp0D6xjsbTsn.pgp
Description: PGP signature