Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My intention is to generate distributable binaries - I am doing a ./configure - make - make install in my build machine, and I archived the content of the install directory (the one I gave a prefix to while doing ./configure and make install) and moved it to another machine under another user for testing. Upon testing, I see that the copied files still tries to access some files at a path which was at my build machine - and hence I get permissions denied error. Previously I was thinking that it might be a tar issue while extracting, but thanks to Daniel Beck who helped me realize that it has nothing to do with the archiving process.

I do not have root/sudo privileges. The crux is - how do I build in one machine and use the install-files in many others without running into permissions related problems? What are the rules to create universally distributable tarballs?


share|improve this question
Sghosh is a user name. Is it user_01 or user_02? – Daniel Beck Nov 12 '11 at 11:20
Sorry my mistake, yes you're right, what I wanted to say is I am moving files from my userspace to another..edited – Sayan Nov 12 '11 at 17:53
OK -- and what's the ls -l and ls -ln output after extracting on the destination host? – Daniel Beck Nov 12 '11 at 17:58
So this is the ls -ln output - drwxr-xr-x 2 10036 501 4096 Nov 11 04:52 bin and ls -l gives drwxr-xr-x 2 user_02 staff 4096 Nov 11 04:52 bin – Sayan Nov 12 '11 at 18:09
Is this the output for a file (or folder) user_02 is denied access to? – Daniel Beck Nov 12 '11 at 18:11
up vote 1 down vote accepted

The problem is that many Unix programs are not relocatable. They will always search for files in the path you give to configure (not relative to it's own location). If you want it to be relocatable, so it can be installed in any user directory (or anywhere else) and still find it's files, where is no other way than to modify the program to behave that way.

There are no generic rules for creating generally distributable tarballs, especially for programs made to be installed from source. Most Unix distributions have some kind of special package system for distributing binaries. The best thing is to use that/those. Most comercial applications that ship as binaries in tarballs use an environment variable to locate it's files and use a wrapper shell script that sets this variable (by searching for the files relative it's own path for example). Then again you probably have to modify the program to behave in this way.

share|improve this answer

Use tar --no-same-owner (for the GNU version) when unpacking the tarball. --no-same-permissions could also be useful.

share|improve this answer
I am still getting the same errors. – Sayan Nov 12 '11 at 8:17
@Sayan who owns these files? They should be owned by the extracting user if given this option. Do you use gnu tar which has this option, or something else? – Daniel Beck Nov 12 '11 at 8:52
Umm, please help me understand - I tar a bunch of files giving +x options...and then I upload it to a website where any user could download and use it; so how do I set the ownership/permission for any user who downloads the tarball? Yes I am using gnu tar. – Sayan Nov 12 '11 at 9:54
@Sayan You don't. While you can set chmod like permissions for the included files using the --mode argument to GNU tar, it's the responsibility of the extracting user to discard the original ownership of the files in the tar ball. For example, I downloaded OpenSSH source code today. tar tzvf filename.tar.gz lists the files as owned by the "snap" user, tar tzvf --numeric-owner filename.tar.gz shows it's numeric user ID 1018. On my system, there is no such user. I, as the user extracting the archive, need to take care of specifying --no-same-owner or --owner MyUserName. – Daniel Beck Nov 12 '11 at 10:30
@Sayan This only happens when you extract as root though, since other users aren't able to create files belonging to a different user. It would help if you explained in detail how you create and extract the tar archive, and included a (partial) tar tv listing, showing permissions and users/groups within the tar ball. – Daniel Beck Nov 12 '11 at 10:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .