Problems using a USB flash drive as an apt source

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems using a USB flash drive as an apt source

Steve McIntyre
Hey folks,

I'm trying to support some users, using Debian (CD/DVD) media written
to USB flash. Lots of people are using things this way rather than
optical media these days, of course.

I spoke to Julian a while back about this, and he suggested something
along the lines of "oh, just use apt-cdrom as normal, but configure
apt to look at all removable media, not just cdrom drives". That seems
sensible enough, so I'm trying that now, using apt on my buster
system.

I might just be doing something stupid (very possible, tired after an
over-running point release weekend!). After looking in the apt-cdrom
code, I've added the following config item:

APT::cdrom::CdromOnly "false";

in /etc/apt/apt.conf.d/00trustcdrom, and I've added in /etc/fstab, to
mount my USB stick at /media/cdrom as expected:

/dev/sdc1          /media/cdrom      auto    noauto             0 0

Now using "apt-cdrom add" crashes:

tack:/home/steve# apt-cdrom add
Segmentation fault (core dumped)

GNU gdb (Debian 8.2.1-2+b1) 8.2.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/apt-cdrom...Reading symbols from /usr/lib/debug/.build-id/a1/8e9304d77d24ef5f6a2c88966d92e1a3e5a4b8.debug...done.
done.
[New LWP 17871]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `apt-cdrom add'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  __strcmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:102
102     ../sysdeps/x86_64/multiarch/strcmp-avx2.S: No such file or directory.
(gdb) bt
#0  __strcmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:102
#1  0x00007f642c0dd9a9 in FindMountPointForDevice[abi:cxx11](char const*) (devnode=devnode@entry=0x0)
    at ../apt-pkg/contrib/cdromutl.cc:279
#2  0x00007f642c0d4380 in pkgUdevCdromDevices::ScanForRemovable (this=<optimized out>,
    CdromOnly=<optimized out>) at ../apt-pkg/cdrom.cc:972
#3  0x00007f642c0d461a in pkgUdevCdromDevices::Scan (this=this@entry=0x7ffd36bedd50)
    at ../apt-pkg/cdrom.cc:936
#4  0x000055b44a6d81ba in AddOrIdent (Add=true) at ../cmdline/apt-cdrom.cc:118
#5  0x00007f642c0def46 in CommandLine::DispatchArg (this=this@entry=0x7ffd36bee010, Map=<optimized out>,
    NoMatch=NoMatch@entry=true) at ../apt-pkg/contrib/cmndline.cc:368
#6  0x00007f642c209630 in DispatchCommandLine (CmdL=..., Cmds=std::vector of length 4, capacity 4 = {...})
    at /usr/include/c++/8/bits/stl_iterator.h:783
#7  0x000055b44a6d7667 in main (argc=<optimized out>, argv=0x7ffd36bee158) at ../cmdline/apt-cdrom.cc:233
(gdb) up
#1  0x00007f642c0dd9a9 in FindMountPointForDevice[abi:cxx11](char const*) (devnode=devnode@entry=0x0)
    at ../apt-pkg/contrib/cdromutl.cc:279
279                 if (strcmp(out[0], devnode) != 0)
(gdb) p devnode
$1 = 0x0

devnode is NULL, which the code is clearly not expecting. Am I doing
something wrong here? What am I missing, please?

Cheers,

Steve

--
Steve McIntyre, Cambridge, UK.                                [hidden email]
  Getting a SCSI chain working is perfectly simple if you remember that there
  must be exactly three terminations: one on one end of the cable, one on the
  far end, and the goat, terminated over the SCSI chain with a silver-handled
  knife whilst burning *black* candles. --- Anthony DeBoer

Reply | Threaded
Open this post in threaded view
|

Re: Problems using a USB flash drive as an apt source

David Kalnischkies-4
On Mon, Sep 09, 2019 at 07:20:17PM +0100, Steve McIntyre wrote:
> I spoke to Julian a while back about this, and he suggested something
> along the lines of "oh, just use apt-cdrom as normal, but configure
> apt to look at all removable media, not just cdrom drives". That seems
> sensible enough, so I'm trying that now, using apt on my buster
> system.

[To be honest, I am a tiny bit surprised that this isn't the default…
I thought it is, but a quick check says it isn't… mhhhh. Wasn't that
like the point of using udev all these years ago I wonder…]


> I might just be doing something stupid (very possible, tired after an
> over-running point release weekend!). After looking in the apt-cdrom
> code, I've added the following config item:

No worries… you tried and even looked at the code! That means you are
more experienced with that program than [at least] I am and potentially
everyone else in the team!

On the upside, if that turns out to be a bug we can backport that even
into the dark ages with ease! ;)  [only partly joking…].


> #1  0x00007f642c0dd9a9 in FindMountPointForDevice[abi:cxx11](char const*) (devnode=devnode@entry=0x0)
>     at ../apt-pkg/contrib/cdromutl.cc:279
> 279                 if (strcmp(out[0], devnode) != 0)
> (gdb) p devnode
> $1 = 0x0
>
> devnode is NULL, which the code is clearly not expecting. Am I doing
> something wrong here? What am I missing, please?

That is an input parameter which comes from udev_device_get_devnode(3).
Call is in apt-pkg/cdrom.cc and I don't see much error checking there,
but then the manpage doesn't say what those errors could be – nor do
I have a sensible idea why/how that call could fail.


We have no test covering this udev stuff, so I wouldn't really be
surprised if that is "just" completely broken. I guess from your CD team
PoV you might have some experience with writing automatic tests
in that area so if you have some valuable pointers…

That said, shouldn't that work even without touching fstab (even if the
apt-cdrom manpage says the opposite)?


On the other hand, it might be good to skip udev-based auto-everything
to check if at least the rest works [we have a basic test for that, but
who knows…]. apt-cdrom --no-mount --cdrom /path/to/mounted/usbstick …



Sorry for not having a more useful reply for now. I guess Julian or
I have to bite the bullet and actually have a closer look at apt-cdrom.


Best regards

David Kalnischkies

P.S.: "Shotgun, not me!" ;)

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problems using a USB flash drive as an apt source

Steve McIntyre
Hi David!

On Mon, Sep 09, 2019 at 09:36:14PM +0200, David Kalnischkies wrote:

>On Mon, Sep 09, 2019 at 07:20:17PM +0100, Steve McIntyre wrote:
>> I spoke to Julian a while back about this, and he suggested something
>> along the lines of "oh, just use apt-cdrom as normal, but configure
>> apt to look at all removable media, not just cdrom drives". That seems
>> sensible enough, so I'm trying that now, using apt on my buster
>> system.
>
>[To be honest, I am a tiny bit surprised that this isn't the default…
>I thought it is, but a quick check says it isn't… mhhhh. Wasn't that
>like the point of using udev all these years ago I wonder…]

ACK!

>> I might just be doing something stupid (very possible, tired after an
>> over-running point release weekend!). After looking in the apt-cdrom
>> code, I've added the following config item:
>
>No worries… you tried and even looked at the code! That means you are
>more experienced with that program than [at least] I am and potentially
>everyone else in the team!

Oh, bugger - I was *hoping* I was doing something obviously wrong and
you'd be able to point out my mistake. :-)

>On the upside, if that turns out to be a bug we can backport that even
>into the dark ages with ease! ;)  [only partly joking…].
>
>> #1  0x00007f642c0dd9a9 in FindMountPointForDevice[abi:cxx11](char const*) (devnode=devnode@entry=0x0)
>>     at ../apt-pkg/contrib/cdromutl.cc:279
>> 279                 if (strcmp(out[0], devnode) != 0)
>> (gdb) p devnode
>> $1 = 0x0
>>
>> devnode is NULL, which the code is clearly not expecting. Am I doing
>> something wrong here? What am I missing, please?
>
>That is an input parameter which comes from udev_device_get_devnode(3).
>Call is in apt-pkg/cdrom.cc and I don't see much error checking there,
>but then the manpage doesn't say what those errors could be – nor do
>I have a sensible idea why/how that call could fail.

ACK. I don't know how to drive udev *either* here -it's not something
I've ever had to do...

>We have no test covering this udev stuff, so I wouldn't really be
>surprised if that is "just" completely broken. I guess from your CD team
>PoV you might have some experience with writing automatic tests
>in that area so if you have some valuable pointers…

Ummm, maybe... :-)

>That said, shouldn't that work even without touching fstab (even if the
>apt-cdrom manpage says the opposite)?

I was wondering, but not sure.

>On the other hand, it might be good to skip udev-based auto-everything
>to check if at least the rest works [we have a basic test for that, but
>who knows…]. apt-cdrom --no-mount --cdrom /path/to/mounted/usbstick …

Not good:

tack:/home/steve# mount /dev/sdc1 /mnt
mount: /mnt: WARNING: device write-protected, mounted read-only.
tack:/home/steve# ulimit -c unlimited
tack:/home/steve# apt-cdrom add --no-mount --cdrom /mnt
Segmentation fault (core dumped)

The stack trace points to the same problem I reported.

>Sorry for not having a more useful reply for now. I guess Julian or
>I have to bite the bullet and actually have a closer look at apt-cdrom.

ACK!

--
Steve McIntyre, Cambridge, UK.                                [hidden email]
Dance like no one's watching. Encrypt like everyone is.
 - @torproject