Package: interimap
Version: 0.5.7-2
Severity: normal
Tags: patch
X-Debbugs-Cc: scho...@ubuntu.com
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu noble ubuntu-patch

Hi,

interimap is packing structs that are sensible to the time_t transition.
Please see the attached debdiff as a *very* crude attempt to fix it in
Ubuntu. I'm hoping it'll be possible to come up with a neater way to
solve this?
diff -Nru 
interimap-0.5.7/debian/patches/lp2059120/0001-Fix-flock-packing-on-armhf-for-64-bit-off_t.patch
 
interimap-0.5.7/debian/patches/lp2059120/0001-Fix-flock-packing-on-armhf-for-64-bit-off_t.patch
--- 
interimap-0.5.7/debian/patches/lp2059120/0001-Fix-flock-packing-on-armhf-for-64-bit-off_t.patch
     1970-01-01 01:00:00.000000000 +0100
+++ 
interimap-0.5.7/debian/patches/lp2059120/0001-Fix-flock-packing-on-armhf-for-64-bit-off_t.patch
     2024-03-26 13:20:24.000000000 +0100
@@ -0,0 +1,37 @@
+From 55fa5aec2d1eaddb31465b61645951c954673397 Mon Sep 17 00:00:00 2001
+From: Simon Chopin <simon.cho...@canonical.com>
+Date: Tue, 26 Mar 2024 13:19:53 +0100
+Subject: [PATCH 1/2] Fix flock packing on armhf for 64-bit off_t
+
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/interimap/+bug/2059120
+---
+ pullimap | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/pullimap b/pullimap
+index 8be78da..4a8cd41 100755
+--- a/pullimap
++++ b/pullimap
+@@ -31,6 +31,8 @@ use Getopt::Long qw/:config posix_default no_ignore_case 
gnu_getopt auto_version
+ use List::Util 'first';
+ use Socket qw/PF_INET PF_INET6 SOCK_STREAM IPPROTO_TCP/;
+ 
++use Config;
++
+ use lib "./lib";
+ use Net::IMAP::InterIMAP 0.5.7 qw/xdg_basedir read_config compact_set/;
+ 
+@@ -88,7 +90,9 @@ do {
+ 
+     sysopen($STATE, $statefile, $mode, 0600) or die "Can't open $statefile: 
$!";
+     # XXX we need to pack the struct flock manually: not portable!
+-    my $struct_flock = pack('s!s!l!l!i!', F_WRLCK, SEEK_SET, 0, 0, 0);
++    my $is_arm = $Config{archname} =~ /^arm-/;
++    my $tpl = $is_arm ? 's!s!q!q!i!' : 's!s!l!l!i!';
++    my $struct_flock = pack($tpl, F_WRLCK, SEEK_SET, 0, 0, 0);
+     fcntl($STATE, F_SETLK, $struct_flock) or die "Can't lock $statefile: $!";
+     my $flags = fcntl($STATE, F_GETFD, 0)       or die "fcntl F_GETFD: $!";
+     fcntl($STATE, F_SETFD, $flags | FD_CLOEXEC) or die "fcntl F_SETFD: $!";
+-- 
+2.43.0
+
diff -Nru 
interimap-0.5.7/debian/patches/lp2059120/0002-Fix-the-timeval-template-on-t64-enabled-armhf.patch
 
interimap-0.5.7/debian/patches/lp2059120/0002-Fix-the-timeval-template-on-t64-enabled-armhf.patch
--- 
interimap-0.5.7/debian/patches/lp2059120/0002-Fix-the-timeval-template-on-t64-enabled-armhf.patch
   1970-01-01 01:00:00.000000000 +0100
+++ 
interimap-0.5.7/debian/patches/lp2059120/0002-Fix-the-timeval-template-on-t64-enabled-armhf.patch
   2024-03-26 13:20:24.000000000 +0100
@@ -0,0 +1,37 @@
+From 83282d24a033eb38f36fa64139e15df0bf8a0cb2 Mon Sep 17 00:00:00 2001
+From: Simon Chopin <simon.cho...@canonical.com>
+Date: Tue, 26 Mar 2024 13:16:24 +0100
+Subject: [PATCH 2/2] Fix the timeval template on t64-enabled armhf
+
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/interimap/+bug/2059120
+---
+ lib/Net/IMAP/InterIMAP.pm | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/lib/Net/IMAP/InterIMAP.pm b/lib/Net/IMAP/InterIMAP.pm
+index 55a18a0..ec72e6a 100644
+--- a/lib/Net/IMAP/InterIMAP.pm
++++ b/lib/Net/IMAP/InterIMAP.pm
+@@ -23,6 +23,7 @@ use strict;
+ 
+ use Compress::Raw::Zlib qw/Z_OK Z_STREAM_END Z_FULL_FLUSH Z_SYNC_FLUSH 
MAX_WBITS/;
+ use Config::Tiny ();
++use Config;
+ use Errno qw/EEXIST EINTR/;
+ use Net::SSLeay 1.86_06 ();
+ use List::Util qw/all first/;
+@@ -1492,7 +1493,10 @@ sub _tcp_connect($$$) {
+         # timeout connect/read/write/... after 30s
+         # XXX we need to pack the struct timeval manually: not portable!
+         # 
https://stackoverflow.com/questions/8284243/how-do-i-set-so-rcvtimeo-on-a-socket-in-perl
+-        my $timeout = pack('l!l!', 30, 0);
++        # On Ubuntu, armhf is the only arch where time_t != long
++        my $is_arm = $Config{archname} =~ /^arm-/;
++        my $tpl = $is_arm ? 'q!q!' : 'l!l!';
++        my $timeout = pack($tpl, 30, 0);
+         setsockopt($s, Socket::SOL_SOCKET, Socket::SO_RCVTIMEO, $timeout)
+                 or $self->fail("setsockopt SO_RCVTIMEO: $!");
+         setsockopt($s, Socket::SOL_SOCKET, Socket::SO_SNDTIMEO, $timeout)
+-- 
+2.43.0
+
diff -Nru interimap-0.5.7/debian/patches/series 
interimap-0.5.7/debian/patches/series
--- interimap-0.5.7/debian/patches/series       2023-01-25 02:35:21.000000000 
+0100
+++ interimap-0.5.7/debian/patches/series       2024-03-26 13:20:24.000000000 
+0100
@@ -1,2 +1,4 @@
 Mention-the-Debian-BTS-in-the-manpages.patch
 Skip-randomized-tests.patch
+lp2059120/0001-Fix-flock-packing-on-armhf-for-64-bit-off_t.patch
+lp2059120/0002-Fix-the-timeval-template-on-t64-enabled-armhf.patch

Reply via email to