RPM Community Forums

Mailing List Message of <rpm-users>

Re: Unpacking RPM, root:root files inside, fails to create all files

From: Jeffrey Johnson <n3npq@me.com>
Date: Mon 26 Dec 2011 - 17:10:51 CET
Message-id: <ACD45081-B6C9-456A-B39F-B7CE75D10EB5@me.com>

On Dec 26, 2011, at 5:35 AM, David Abdurachmanov wrote:

> Hi All,
> 
> I am trying to unpack RPM, which has all files with root:root permissions. Unpacking is done in the environment, where user does not have root permissions. I am using something like this:
> 
> rpm2cpio /Users/david/tmp/RPMS/gcc+4.6.1.rpm | cpio -idmvu --insecure -R david:staff
> 

That's the basic pipe (though  -v is optional, and -u and --insecure and -R user:group
are a matter of taste and style).

There are no ".." in any *.rpm payload, and all paths are absolute (*.src.rpm's
are just base names, not paths); if unpacking into an empty directory, you are
unlikely (as non-root) to overwrite any file with any file in a *.rpm payload.
So --insecure (and -u if empty directory) is likely unneeded.

> Important flags:
> --insecure # Install into location, which is pointed by symlink
> -u # Overwrite destination files is such already exists
> -R david:staff # Change file permissions to david:staff as there is no access to root:root
> 
> If I run this under "david" user it will fail at the end [1]. If I run it as root user, everything is okay. While on the Linux machines I do not have any problems unpacking such RPMS (holds root:root files) and making cpio to set my permissions on the files, I can't do that on Mac OS X. Some of the executables are zero-size files [2].
> 
> Any suggestions how to unpack RPM, which holds root:root permission files, using non-root user would be very welcomed. 
> 

Your question is ultimately about cpio behavior (apparently on Mac OS X) rather
than RPM itself.

Apple may have a modified cpio (iirc) to handle resource forks etc. E.g. ditto
is basically a cpio with some additional options and _file "magic names".

But the core issue appears to be that -R is root-only (from "man cpio" on Lion):

     -R [user][:][group]
             Set the owner and/or group on files in the output.  If group is
             specified with no user (for example, -R :wheel) then the group
             will be set but not the user.  If the user is specified with a
             trailing colon and no group (for example, -R root:) then the
             group will be set to the user's default group.  If the user is
             specified with no trailing colon, then the user will be set but
             not the group.  In -i and -p modes, this option can only be used
             by the super-user.  (For compatibility, a period can be used in
             place of the colon.)

> Thanks in advance and Merry Christmas!

And to you as well!

73 de Jeff


> David
> 
> [1]
> ./opt/gcc/4.6.1/bin/gfortran
> ./opt/gcc/4.6.1/bin/x86_64-apple-darwin10.8.0-gfortran
> ./opt/gcc/4.6.1/bin/x86_64-apple-darwin10.8.0-gfortran: Can't create 'opt/gcc/4.6.1/bin/x86_64-apple-darwin10.8.0-gfortran'
> ./opt/gcc/4.6.1/bin/gcc
> ./opt/gcc/4.6.1/bin/x86_64-apple-darwin10.8.0-gcc
> ./opt/gcc/4.6.1/bin/x86_64-apple-darwin10.8.0-gcc-4.6.1
> ./opt/gcc/4.6.1/bin/x86_64-apple-darwin10.8.0-gcc-4.6.1: Can't create 'opt/gcc/4.6.1/bin/x86_64-apple-darwin10.8.0-gcc-4.6.1'
> ./opt/gcc/4.6.1/bin/c++
> ./opt/gcc/4.6.1/bin/g++
> ./opt/gcc/4.6.1/bin/x86_64-apple-darwin10.8.0-c++
> ./opt/gcc/4.6.1/bin/x86_64-apple-darwin10.8.0-g++
> ./opt/gcc/4.6.1/bin/x86_64-apple-darwin10.8.0-g++: Can't create 'opt/gcc/4.6.1/bin/x86_64-apple-darwin10.8.0-g++'
> 
> [2]
> drwxr-xr-x  18 david  staff     612 Grd 25 00:36 .
> drwxr-xr-x   8 david  staff     272 Grd 25 00:36 ..
> -r-xr-xr-x   4 david  staff       0 Grd 25 00:36 c++
> lrwxr-xr-x   1 david  staff       3 Grd 25 00:36 cc -> gcc
> -r-xr-xr-x   1 david  staff    9504 Grd 25 00:36 cloog
> -r-xr-xr-x   1 david  staff  431392 Grd 25 00:36 cpp
> -r-xr-xr-x   4 david  staff       0 Grd 25 00:36 g++
> -r-xr-xr-x   3 david  staff       0 Grd 25 00:36 gcc
> -r-xr-xr-x   1 david  staff   51680 Grd 25 00:36 gcov
> -r-xr-xr-x   2 david  staff       0 Grd 25 00:36 gfortran
> -r-xr-xr-x   1 david  staff  119464 Grd 25 00:36 ppl-config
> -r-xr-xr-x   1 david  staff   91472 Grd 25 00:36 ppl_lcdd
> -r-xr-xr-x   1 david  staff   73448 Grd 25 00:36 ppl_pips
> -r-xr-xr-x   4 david  staff       0 Grd 25 00:36 x86_64-apple-darwin10.8.0-c++
> -r-xr-xr-x   4 david  staff       0 Grd 25 00:36 x86_64-apple-darwin10.8.0-g++
> -r-xr-xr-x   3 david  staff       0 Grd 25 00:36 x86_64-apple-darwin10.8.0-gcc
> -r-xr-xr-x   3 david  staff       0 Grd 25 00:36 x86_64-apple-darwin10.8.0-gcc-4.6.1
> -r-xr-xr-x   2 david  staff       0 Grd 25 00:36 x86_64-apple-darwin10.8.0-gfortran______________________________________________________________________
> RPM Package Manager                                    http://rpm5.org
> User Communication List                             rpm-users@rpm5.org
Received on Mon Dec 26 17:11:09 2011
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.