Removable storage tests fail write without sudo access.

Bug #1014813 reported by Jeff Marcom
24
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Checkbox
Fix Released
High
Jeff Lane 

Bug Description

This issue was found while looking at possible resolutions for bug: https://bugs.launchpad.net/checkbox/+bug/1004131.

I've found instances where running the following: removable_storage_test usb causes mount and write errors if the usb key previously had an install.

Example:
jeff:~/checkbox_repo/dev_checkbox/checkbox/scripts$ python3 removable_storage_test usb
mount: only root can do that
Error: can't mount /dev/sdc5
mount: only root can do that
Error: can't mount /dev/sdc2
There're total 2 device(s) failed at mounting.
Found the following mounted ['usb'] partitions:
/dev/sdc1 : /media/44545355-28f2-4d0f-b4ef-b6cefb4d26d6
--------------------
Running ['usb'] file transfer test for 1 iterations
Creating Temp Data file
File name is :/tmp/tmpmcwhn4
File size is 1052041 bytes
Parent hash is: c0151b27b0b27b2385c6e5c9ebabbb3c
Copying /tmp/tmpmcwhn4 to /media/44545355-28f2-4d0f-b4ef-b6cefb4d26d6
ERROR: Unable to copy the file to /media/44545355-28f2-4d0f-b4ef-b6cefb4d26d6
Completed 1 test iterations, but there were errors

Suppling sudo before hand will allow the script to write to disk:

Output from: sudo python3 removable_storage_test usb

Running ['usb'] file transfer test for 1 iterations
Creating Temp Data file
File name is :/tmp/tmph1ah08
File size is 1052081 bytes
Parent hash is: a2f74ae2293a1e43eafbb555b04efcf9
Copying /tmp/tmph1ah08 to /media/44545355-28f2-4d0f-b4ef-b6cefb4d26d6
Hashing copy on /media/44545355-28f2-4d0f-b4ef-b6cefb4d26d6
Hash of /media/44545355-28f2-4d0f-b4ef-b6cefb4d26d6/tmph1ah08 on /media/44545355-28f2-4d0f-b4ef-b6cefb4d26d6 is a2f74ae2293a1e43eafbb555b04efcf9
Completed 1 test iterations, but there were errors

Workaround: Provide root permissions.

Results

Related branches

Jeff Marcom (jeffmarcom)
summary: - Removable storage tests fail stating: only root can do that
+ Removable storage tests fail write without sudo access.
Revision history for this message
Daniel Manrique (roadmr) wrote :

The USB key has a weird partitioning scheme. Just for the sake of completeness, could you post the output of sudo fdisk -l /dev/sdc so we can see what the USB key's partition table contains?

Also, output of ls -la /media/ would be useful to see the actual permissions for the directories where the USB key's partitions are mounted.

Finally, the following bugs are related to this problem (multiple partitions and writableness on USB sticks), although they are not duplicates:

https://bugs.launchpad.net/checkbox/+bug/887049
https://bugs.launchpad.net/ubuntu/+source/checkbox/+bug/912522

The second one in particular has a lengthy discussion about the exact problem (some partitions on USB stick unwritable). I guess this bug is about the "NO partitions writable" corner case :)

Changed in checkbox:
status: New → Incomplete
Revision history for this message
Jeff Marcom (jeffmarcom) wrote :

Partitions:
   Device Boot Start End Blocks Id System
/dev/sdc1 * 2048 3610623 1804288 83 Linux
/dev/sdc2 3612670 3909631 148481 5 Extended
/dev/sdc5 3612672 3909631 148480 82 Linux swap / Solaris

drwxr-xr-x 4 root root 4096 Jun 18 15:44 44545355-28f2-4d0f-b4ef-b6cefb4d26d6

Files:
total 16
drwxr-xr-x 4 root root 4096 Jun 18 15:44 ./
drwxr-xr-x 3 root root 4096 Jun 18 16:33 ../
drwxr-xr-x 2 root root 4096 May 16 08:25 .disk/
drwxr-xr-x 2 root root 4096 May 16 08:25 .oem/

Changed in checkbox:
status: Incomplete → New
Revision history for this message
Daniel Manrique (roadmr) wrote :

OK, your average USB stick has a FAT partition:

$ sudo fdisk -l /dev/sdc

Disk /dev/sdc: 2002 MB, 2002780160 bytes
16 heads, 32 sectors/track, 7640 cylinders, total 3911680 sectors
Disk identifier: 0xc3072e18

   Device Boot Start End Blocks Id System
/dev/sdc1 8064 3911679 1951808 6 FAT16

and it gets mounted as the user:

$ ls -la /media/
total 44
drwxr-xr-x 4 root root 4096 Jun 18 16:57 .
drwxr-xr-x 25 root root 4096 Jun 14 16:37 ..
drwx------ 2 roadmr roadmr 16384 Dec 31 1969 MUSHKIN

So it looks like yours has a weird partitioning scheme. Just for completeness, here's the line from "mount" that describes the USB stick:

/dev/sdc1 on /media/MUSHKIN type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks)

I'll set importance: Low as it would affect only weird partitioning schemes, but it's still worthwhile to fix it.

Changed in checkbox:
importance: Undecided → Low
Daniel Manrique (roadmr)
Changed in checkbox:
status: New → Triaged
Jeff Lane  (bladernr)
Changed in checkbox:
importance: Low → High
status: Triaged → In Progress
assignee: nobody → Jeff Lane (bladernr)
Revision history for this message
Jeff Lane  (bladernr) wrote :

After discussion, similar things have happened elsewhere and since we think root permissions will fix the problem, I've added "user: root" to every job that runs removable_storage_test.

Some of them already did this, so I just made root permissions uniform across the test cases.

Changed in checkbox:
status: In Progress → Fix Committed
Changed in checkbox:
status: Fix Committed → Fix Released
Zygmunt Krynicki (zyga)
Changed in checkbox:
status: Fix Released → Fix Committed
Changed in checkbox:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.