Bug#649174: update-inetd: make robust against being run when perl-base and perl-modules are out of sync

November 18th, 2011 - 09:20 am ET by Colin Watson | Report spam
Package: update-inetd
Version: 4.40
Severity: normal
Tags: patch
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch precise

There are a few situations where it's possible for update-inetd to be
called in the middle of an upgrade from one Perl major version to the
next: for example, https://bugs.launchpad.net/bugs/862129 turned out to
be a case where the samba postrm was called in such a situation. If
that happens, then any modules provided by the perl-modules package will
be unavailable. This includes File::Temp and File::Copy, both of which
are used by update-inetd.

It would be very helpful for update-inetd to work even when only
perl-base is available. I appreciate that this requires slightly more
complex code, but it would make the whole system more robust during
upgrades.

Here's a suggested patch to implement this. It implements fallback
versions of the 'tempfile' and 'move' functions if the module versions
are unavailable. These will be a bit slower since they involve calling
external programs, but at least the complexity is all kept up in the
part of the code that imports modules rather than polluting the main
body of DebianNet.pm.

I've tested this by performing an upgrade from Ubuntu oneiric to precise
(which involves an upgrade from perl 5.12 to 5.14), pausing it
immediately after perl-base is configured, and then running update-inetd
File/Temp.pm in @INC"; with this patch, it behaves as expected (and
strace output looks sensible as well).

Making this truly robust will probably also involve having perl-base
declare Breaks on versions of update-inetd prior to this patch being
applied. I've CCed perl@packages.debian.org in case they'd like to
comment on this.

* Fall back to external 'tempfile' and 'mv' commands in case perl-base and
perl-modules are out of sync during an upgrade (LP: #862129).

modified file 'DebianNet.pm'
DebianNet.pm 2011-09-11 19:03:14 +0000
+++ DebianNet.pm 2011-11-18 14:06:39 +0000
@@ -15,8 +15,44 @@ package DebianNet;
require 5.6.1;

use Debconf::Client::ConfModule ':all';
-use File::Temp qw/ tempfile /;
-use File::Copy qw/ move /;
+
+BEGIN {
+ eval 'use File::Temp qw/ tempfile /';
+ if ($@) {
+ # If perl-base and perl-modules are out of sync, fall back to the
+ # external 'tempfile' command. In this case we don't bother trying
+ # to mangle the template we're given into something that tempfile
+ # can understand.
+ sub tempfile {
+ open my $tempfile_fh, '-|', 'tempfile'
+ or die "Error running tempfile: $!";
+ chomp (my $tempfile_name = <$tempfile_fh>);
+ unless (length $tempfile_name) {
+ die "tempfile did not return a temporary file name";
+ }
+ unless (close $tempfile_fh) {
+ if ($!) {
+ die "Error closing tempfile pipe: $!";
+ } else {
+ die "tempfile returned exit status $?";
+ }
+ }
+ open my $fh, '+<', $tempfile_name
+ or die "Error opening temporary file $tempfile_name: $!";
+ return ($fh, $tempfile_name);
+ }
+ }
+
+ eval 'use File::Copy qw/ move /';
+ if ($@) {
+ # If perl-base and perl-modules are out of sync, fall back to the
+ # external 'mv' command.
+ sub move {
+ my ($from, $to) = @_;
+ return system('mv', $from, $to) == 0;
+ }
+ }
+}

$inetdcf="/etc/inetd.conf";
$sep = "#<off># ";

Thanks,

Colin Watson [cjwatson@ubuntu.com]



To UNSUBSCRIBE, email to debian-bugs-dist-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
email Follow the discussionReplies 6 repliesReplies Make a reply

Similar topics

Replies

#1 Dominic Hargreaves
November 18th, 2011 - 09:40 am ET | Report spam
Package: perl-base
Version: 5.14.2-5
Severity: serious
Justification: maintainer

On Fri, Nov 18, 2011 at 02:14:05PM +0000, Colin Watson wrote:
There are a few situations where it's possible for update-inetd to be
called in the middle of an upgrade from one Perl major version to the
next: for example, https://bugs.launchpad.net/bugs/862129 turned out to
be a case where the samba postrm was called in such a situation. If
that happens, then any modules provided by the perl-modules package will
be unavailable. This includes File::Temp and File::Copy, both of which
are used by update-inetd.

It would be very helpful for update-inetd to work even when only
perl-base is available. I appreciate that this requires slightly more
complex code, but it would make the whole system more robust during
upgrades.

Here's a suggested patch to implement this. It implements fallback
versions of the 'tempfile' and 'move' functions if the module versions
are unavailable. These will be a bit slower since they involve calling
external programs, but at least the complexity is all kept up in the
part of the code that imports modules rather than polluting the main
body of DebianNet.pm.

I've tested this by performing an upgrade from Ubuntu oneiric to precise
(which involves an upgrade from perl 5.12 to 5.14), pausing it
immediately after perl-base is configured, and then running update-inetd
File/Temp.pm in @INC"; with this patch, it behaves as expected (and
strace output looks sensible as well).

Making this truly robust will probably also involve having perl-base
declare Breaks on versions of update-inetd prior to this patch being
applied. I've CCed in case they'd like to
comment on this.



Only that I think that I ought to hold off on adding more Breaks
for a little while longer, otherwise I risk an explosion in the number
of small updates to perl. I was in two minds about whether to upload
5.14.2-5 straight away or whether to wait..

Cheers,
Dominic.

Dominic Hargreaves | http://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)



To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Replies Reply to this message
#2 Colin Watson
November 18th, 2011 - 09:50 am ET | Report spam
On Fri, Nov 18, 2011 at 02:32:52PM +0000, Dominic Hargreaves wrote:
Package: perl-base
Version: 5.14.2-5
Severity: serious
Justification: maintainer



Thanks.

On Fri, Nov 18, 2011 at 02:14:05PM +0000, Colin Watson wrote:
> Making this truly robust will probably also involve having perl-base
> declare Breaks on versions of update-inetd prior to this patch being
> applied. I've CCed in case they'd like to
> comment on this.

Only that I think that I ought to hold off on adding more Breaks
for a little while longer, otherwise I risk an explosion in the number
of small updates to perl. I was in two minds about whether to upload
5.14.2-5 straight away or whether to wait..



Yep. I suspect the impact of this is a bit less widespread than the
doc-base one anyway.

Colin Watson []



To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Replies Reply to this message
#3 Serafeim Zanikolas
November 21st, 2011 - 08:20 am ET | Report spam
Thanks for the patch Colin. I'll make sure to upload a new update-inetd
release within a few days.

cheers,
sez



To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Replies Reply to this message
#4 Dominic Hargreaves
November 21st, 2011 - 12:40 pm ET | Report spam
severity 649177 important
severity 649174 important
unblock 637809 by 649177
thanks

On Fri, Nov 18, 2011 at 02:47:17PM +0000, Colin Watson wrote:
On Fri, Nov 18, 2011 at 02:32:52PM +0000, Dominic Hargreaves wrote:
> Package: perl-base
> Version: 5.14.2-5
> Severity: serious
> Justification: maintainer

Thanks.

> On Fri, Nov 18, 2011 at 02:14:05PM +0000, Colin Watson wrote:
> > Making this truly robust will probably also involve having perl-base
> > declare Breaks on versions of update-inetd prior to this patch being
> > applied. I've CCed in case they'd like to
> > comment on this.
>
> Only that I think that I ought to hold off on adding more Breaks
> for a little while longer, otherwise I risk an explosion in the number
> of small updates to perl. I was in two minds about whether to upload
> 5.14.2-5 straight away or whether to wait..

Yep. I suspect the impact of this is a bit less widespread than the
doc-base one anyway.



Okay. I've tweaked the severities of both bugs related to this
issue, and unblocked the perl transition, to reflect the
not-quite-blocking-perl-transition status.

Serafeim: thanks for your response on this. Depending on how things
progress this week, we might be able to include a Breaks: before
perl transitions to testing.

Cheers,
Dominic.

Dominic Hargreaves | http://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)



To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Replies Reply to this message
#5 Dominic Hargreaves
November 21st, 2011 - 06:20 pm ET | Report spam
On Mon, Nov 21, 2011 at 05:34:23PM +0000, Dominic Hargreaves wrote:
severity 649177 important
severity 649174 important
unblock 637809 by 649177
thanks

On Fri, Nov 18, 2011 at 02:47:17PM +0000, Colin Watson wrote:
> On Fri, Nov 18, 2011 at 02:32:52PM +0000, Dominic Hargreaves wrote:
> > Package: perl-base
> > Version: 5.14.2-5
> > Severity: serious
> > Justification: maintainer
>
> Thanks.
>
> > On Fri, Nov 18, 2011 at 02:14:05PM +0000, Colin Watson wrote:
> > > Making this truly robust will probably also involve having perl-base
> > > declare Breaks on versions of update-inetd prior to this patch being
> > > applied. I've CCed in case they'd like to
> > > comment on this.
> >
> > Only that I think that I ought to hold off on adding more Breaks
> > for a little while longer, otherwise I risk an explosion in the number
> > of small updates to perl. I was in two minds about whether to upload
> > 5.14.2-5 straight away or whether to wait..
>
> Yep. I suspect the impact of this is a bit less widespread than the
> doc-base one anyway.

Okay. I've tweaked the severities of both bugs related to this
issue, and unblocked the perl transition, to reflect the
not-quite-blocking-perl-transition status.

Serafeim: thanks for your response on this. Depending on how things
progress this week, we might be able to include a Breaks: before
perl transitions to testing.



Transition has now completed; let me know when this does get fixed,
though.

Cheers,
Dominic.

Dominic Hargreaves | http://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)



To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Replies Reply to this message
Help Create a new topicNext page Replies Make a reply
Search Make your own search