bunzip2 refuses to extract a file if it can't set the mode

Bug #146225 reported by Nicolò Chieffo
16
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bzip2 (Ubuntu)
Triaged
Low
Unassigned

Bug Description

If bunzip2 fails to chmod the extracted file, it bails out and deletes it. It should not do this.

To reproduce, mount an ntfs filesystem with the uid=0 option so files are owned by root, then try to bunzip2 a file as non root. Since the file is owned by root, the chmod fails. This should not be a fatal error.

Original Description:

If I try to decompress any bz2 files I get this error
bunzip2: I/O or other error, bailing out. Possible reason follows.
bunzip2: Operation not permitted
        Input file = odf-converter_1.0.0-1~getdeb1_i386.deb.bz2, output file = odf-converter_1.0.0-1~getdeb1_i386.deb
bunzip2: Deleting output file odf-converter_1.0.0-1~getdeb1_i386.deb, if it exists.

with gunzip I get 2 these errors
gzip: odf-converter_1.0.0-1~getdeb1_i386.deb: Operation not permitted
gzip: odf-converter_1.0.0-1~getdeb1_i386.deb: Operation not permitted

but at least the file is created

Revision history for this message
Szabolcs Szakacsits (szaka) wrote :

bunzip2 is definitely able to unpack files, people do it all the time.
Your problem is unique and it's quite probably a configuration or
usage one.

Do you have the same problem as root too?

If not then the message is correct, you don't have the permission
to do what you want in that directory.

If yes then please send the output of

grep -i ntfs /var/log/daemon.log

and make sure you use the latest stable ntfs-3g 1.913.
Thank you,

Szaka

--
NTFS-3G Lead Developer: http://ntfs-3g.org

Revision history for this message
Nicolò Chieffo (yelo3) wrote : Re: [Bug 146225] Re: bunzip2 cannot extract files

I tried as root and I don't have this problem.

I have my partition configured in this way (fstab line):
/dev/sda5 /media/Dati ntfs-3g
rw,users,exec,noatime,silent,uid=0,gid=1001,umask=007,locale=it_IT.UTF-8
0 0

gid 1001 is a special group added to limit the write of the ntfs
partition, to some users only.
of course my user belongs to this group, and normally I can create,
move and delete files without any problem

Revision history for this message
Szabolcs Szakacsits (szaka) wrote : Re: bunzip2 cannot extract files

Using strace bunzip2 ... you can see why the kernel doesn't allow you to do what you want. Bunzip2 wants to set the owner or a permission it's not authorized to do according to your mount parameters. Set the uid= to the user you're bunzip2'ing and it will work.

Revision history for this message
Nicolò Chieffo (yelo3) wrote : Re: [Bug 146225] Re: bunzip2 cannot extract files

Sorry but I can't do this, since I must share the partition between
multiple users, and I cannot mount and remount it every time a user
needs to extract a file...

Revision history for this message
Szabolcs Szakacsits (szaka) wrote : Re: bunzip2 cannot extract files

Then you need to fix bunzip2 to work the way as gzip, or turn off NTFS-3G permission handling completely (no umask=, fmask=, dmask=, uid=, gid= mount options).

Revision history for this message
Nicolò Chieffo (yelo3) wrote : Re: [Bug 146225] Re: bunzip2 cannot extract files

Since I cannot let everyone write on the partition I will file a bug
to bunzip2, thanks.
By the way, I have to say that it would be great that ntfs-3g could
handle these problems automatically, so that we do not have to fix
every software like bunzip2. Would it be possible or not?
Thanks

Revision history for this message
Szabolcs Szakacsits (szaka) wrote : Re: bunzip2 cannot extract files

Sure, it's possible. DARPA paid $US 600,000 for reiser4 ACL/permission handling. Our job is a bit more difficult because we have to deal with Windows/Unix user and ACL mappings, and smooth Windows interoperability too. But yes, with the right development team, it could be done in a year with a budget less than $US 1,000,000. We could discuss in private the details and in which form you would prefer to sponsor the development of this feature. Thank you a lot in advance for supporting Open Source! :-)))

Btw, experimental, non-production ready permission handling is already available for NTFS-3G, thanks to Jean-Pierre André: http://perso.orange.fr/b.andre/security.html

Revision history for this message
Nicolò Chieffo (yelo3) wrote : Re: [Bug 146225] Re: bunzip2 cannot extract files

heheheh :)
Well fortunately "supporting" open source is not only give some money
to developers :) :)
Unfortunately I cannot help you if you need more than testing/finding bugs :(

Anyway you know what to do if you want your project to be the project
of the millennium ;) and maybe who knows... if you slowly start to
project this feature, sooner or later it could happen that is ready
without you even don't notice it :D

Anyway I will have a look at Jean-Pierre André's work, thanks!

Revision history for this message
Szabolcs Szakacsits (szaka) wrote : Re: bunzip2 cannot extract files

Well, then I'd like to welcome You in the Virtual Million Budget NTFS-3G Permission Handling Project! Unfortunately we can pay only virtually for the testing but we do can offer the **REAL** Lead Quality Assurance Engineer role ;-)

Please note that this is very new and __really__ experimental code. Don't use it on real data or surely have good backup. You can freely send the feedback, bug reports to <email address hidden>. No need to be subscribed to that mailing list. Thanks! :-)

Revision history for this message
Nicolò Chieffo (yelo3) wrote : Re: [Bug 146225] Re: bunzip2 cannot extract files

Ok, let's switch off ironic mode for now :)
I just want to know if there is an intention to implement it or if you
really want to wait for some big company that can give you some money
to support the project.

I've had a look at it, but I think it is too experimental, as you told me.

Revision history for this message
Szabolcs Szakacsits (szaka) wrote : Re: bunzip2 cannot extract files

The intention is here: http://perso.orange.fr/b.andre/security.html
I'm very disappointed you don't want to help us anymore.

Revision history for this message
Nicolò Chieffo (yelo3) wrote : Re: [Bug 146225] Re: bunzip2 cannot extract files

As I've already told you, I cannot do so much, sorry.

Revision history for this message
Daniel T Chen (crimsun) wrote : Re: bunzip2 cannot extract files

Is this symptom still reproducible in 8.10 RC or later?

Changed in ntfs-3g:
status: New → Incomplete
Revision history for this message
Nicolò Chieffo (yelo3) wrote : Re: [Bug 146225] Re: bunzip2 cannot extract files

Yes, aslo for bzip2, not only bunzip2

Revision history for this message
Nicolò Chieffo (yelo3) wrote : Re: bunzip2 cannot extract files

Also here in Jaunty

Changed in ntfs-3g:
status: Incomplete → Confirmed
Revision history for this message
Phillip Susi (psusi) wrote :

I am unable to reproduce this. Are you still able to reproduce it on a supported release?

Changed in ntfs-3g (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Jean-Pierre (jean-pierre-andre) wrote :

This issue is still present, as it should :

[root@dimension ntfslowprof]# ntfs-3g -o uid=0,gid=500 ../images/cf32M-9.clone disk
[root@dimension ntfslowprof]# exit
exit
[linux@dimension ntfslowprof]$ cd disk/linux
[linux@dimension linux]$ bunzip2 linemode.try.bz2

bunzip2: I/O or other error, bailing out. Possible reason follows.
bunzip2: Operation not permitted
 Input file = linemode.try.bz2, output file = linemode.try
bunzip2: Deleting output file linemode.try, if it exists.
[...]
[linux@dimension linux]$ strace bunzip2 linemode.try.bz2
[...]
fchmod(4, 0100777) = -1 EPERM (Operation not permitted)
write(2, "\nbunzip2: I/O or other error, ba"..., 69
bunzip2: I/O or other error, bailing out. Possible reason follows.
) = 69

Explanation : when mounting with uid=0,gid=500 the files are created as owner root, and a user process cannot do a chmod on a file it does not own. With these mount parameters the check is done by the kernel and the chmod does not even reach ntfs-3g (so a "silent" optionhas no effect).

When mounting this way, you should get "Warning : using problematic uid==0 and gid!=0" in your syslog file. You also can only set the mtime to the current time, and copying a file does not preserve the mtime.

In real life, I do not have this issue, because I mount with option "permissions".

Revision history for this message
Phillip Susi (psusi) wrote :

What release is this on? I have not been able to reproduce this on quantal or raring. An strace shows it is calling fchmod and chown but they claim to succeed even though they don't actually do anything.

Revision history for this message
Phillip Susi (psusi) wrote :

Wait, I got it.. I see now, you have to mount the fs with the files owned by root, then try to unzip it NOT as root.

summary: - bunzip2 cannot extract files
+ bunzip2 refuses to extract a file if it can't set the mode
affects: ntfs-3g (Ubuntu) → bzip2 (Ubuntu)
Changed in bzip2 (Ubuntu):
importance: Undecided → Low
status: Incomplete → Triaged
description: updated
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.