summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2015-04-21 20:48:47 +0200
committerGuillem Jover <guillem@debian.org>2015-05-09 05:02:07 +0200
commit2a76ceda76f462cea6f50ac740ed95c343ec409e (patch)
tree635aef38f8337b553cd4dfbe29014f0d7be63700
parentaea291e3db1ac0414dcf005a0a607e78bdd77a5e (diff)
downloaddpkg-2a76ceda76f462cea6f50ac740ed95c343ec409e.tar.gz
Dpkg::Source::Patch: Pass PATCH_GET envvar instead of -g0 to patch
For GNU patch the default value for -g is already 0, but that option is not available in other systems, such as FreeBSD. Let's switch to use the environment variable PATCH_GET, so that we make sure it gets set to a known value, and so that we can stop using the unportable option.
-rw-r--r--debian/changelog3
-rw-r--r--scripts/Dpkg/Source/Patch.pm8
-rw-r--r--scripts/Dpkg/Source/Quilt.pm4
3 files changed, 9 insertions, 6 deletions
diff --git a/debian/changelog b/debian/changelog
index f0cdb2b66..17ad820e4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -82,6 +82,9 @@ dpkg (1.18.0) UNRELEASED; urgency=low
clarify what whitespace really maps to, we should really match the GnuPG
implementation anyway, as that's what we use to verify the signatures.
Reported by Jann Horn <jann@thejh.net>. Fixes CVE-2015-0840.
+ - Pass PATCH_GET environment varialbe instead of -g0 to the patch command
+ in Dpkg::Source::Patch. This allows using non-GNU patch programs, like
+ FreeBSD's patch.
* Test suite:
- Check perl code compilation, warnings and strictness.
- Fix dpkg-divert unit test to work on BSD «rm -rf» that cannot traverse
diff --git a/scripts/Dpkg/Source/Patch.pm b/scripts/Dpkg/Source/Patch.pm
index 2cc0c97c9..dbc0fa7b7 100644
--- a/scripts/Dpkg/Source/Patch.pm
+++ b/scripts/Dpkg/Source/Patch.pm
@@ -565,7 +565,7 @@ sub apply {
$opts{remove_backup} //= 1;
$opts{create_dirs} //= 1;
$opts{options} ||= [ '-t', '-F', '0', '-N', '-p1', '-u',
- '-V', 'never', '-g0', '-b', '-z', '.dpkg-orig'];
+ '-V', 'never', '-b', '-z', '.dpkg-orig'];
$opts{add_options} //= [];
push @{$opts{options}}, @{$opts{add_options}};
# Check the diff and create missing directories
@@ -577,7 +577,7 @@ sub apply {
spawn(
exec => [ 'patch', @{$opts{options}} ],
chdir => $destdir,
- env => { LC_ALL => 'C', LANG => 'C' },
+ env => { LC_ALL => 'C', LANG => 'C', PATCH_GET => '0' },
delete_env => [ 'POSIXLY_CORRECT' ], # ensure expected patch behaviour
wait_child => 1,
nocheck => 1,
@@ -616,7 +616,7 @@ sub check_apply {
# Set default values to options
$opts{create_dirs} //= 1;
$opts{options} ||= [ '--dry-run', '-s', '-t', '-F', '0', '-N', '-p1', '-u',
- '-V', 'never', '-g0', '-b', '-z', '.dpkg-orig'];
+ '-V', 'never', '-b', '-z', '.dpkg-orig'];
$opts{add_options} //= [];
push @{$opts{options}}, @{$opts{add_options}};
# Check the diff and create missing directories
@@ -627,7 +627,7 @@ sub check_apply {
my $patch_pid = spawn(
exec => [ 'patch', @{$opts{options}} ],
chdir => $destdir,
- env => { LC_ALL => 'C', LANG => 'C' },
+ env => { LC_ALL => 'C', LANG => 'C', PATCH_GET => '0' },
delete_env => [ 'POSIXLY_CORRECT' ], # ensure expected patch behaviour
from_handle => $self->get_filehandle(),
to_file => '/dev/null',
diff --git a/scripts/Dpkg/Source/Quilt.pm b/scripts/Dpkg/Source/Quilt.pm
index 208b59795..a07abb20b 100644
--- a/scripts/Dpkg/Source/Quilt.pm
+++ b/scripts/Dpkg/Source/Quilt.pm
@@ -179,7 +179,7 @@ sub push {
verbose => $opts{verbose},
force_timestamp => 1, create_dirs => 1, remove_backup => 0,
options => [ '-t', '-F', '0', '-N', '-p1', '-u',
- '-V', 'never', '-g0', '-E', '-b',
+ '-V', 'never', '-E', '-b',
'-B', ".pc/$patch/", '--reject-file=-' ]);
};
if ($@) {
@@ -216,7 +216,7 @@ sub pop {
$obj->apply($self->{dir}, timestamp => $opts{timestamp},
verbose => 0, force_timestamp => 1, remove_backup => 0,
options => [ '-R', '-t', '-N', '-p1',
- '-u', '-V', 'never', '-g0', '-E',
+ '-u', '-V', 'never', '-E',
'--no-backup-if-mismatch' ]);
}