Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am experiencing a behavior in the installation of a .deb package that I don't really understand.

I have a set of "things" in my computer that I deploy to remote computers using a .deb package. I work in my local machine logged as the user "borrajax". There's also a "borrajax" user in the remote machine where I install my .deb. When I need to deploy my "things", I create a .deb package in my machine (with sudo dpkg --build), copy it to the remote machine and install it with sudo dpkg -i myPackage.deb . When I do that, the "expanded" (or installed) files become owned by the local user borrajax, which is good.

Now, I have a coworker that also tries to do the same thing but he is logged in as a different local username (he doesn't have a borrajax user in his machine, but... foobar - I guess his parents didn't like him much-). He follows exactly the same process I do with my local user borrajax but with his local foobar user: Create the .deb in his machine, copy it to the remote machine and install it with dpkg -i. Well... In that case, the installed files become owned by root, which prevents the installation to continue (which is not a bug, but a feature).

All these machines are Ubuntu (11.10 mine, 12.04 the remote one and my coworker's one) so what I would like is the package become installed with whatever user has the uuid 1000. I would expect the name not to be so relevant (It may be just a coincidence there's a borrajax user in my machine and in the remote one).

So in this case, the username seems very relevant. Why is that? As I mentioned earlier, my local user borrajax, my coworker's foobar and the borrajax in the remote machine are all the uid=1000. Why does the user's name (seem to be) so important? My local borrajax user may not have anything to see at all with the borrajax in the remote machine. If the package was created by the user with uid 1000, why "sometimes" (if I've created it) it is installed with whatever user has the uid 1000 in the remote machine and "sometimes" it's installed with root (if my coworker has created it)?

I can always change the owner of the installed files using chown 1000 in the postint script, or use some other kind of workaround but I would like to understand first why is this happening, and how is it that the username in two different machines seems so important?

Thank you in advance

share|improve this question
1  
Show us the output of ls -l path/to/file in the package build tree, where path/to/file is one of the files that has the wrong ownership. Also show us the output of dpkg-deb --fsys-tarfile foo.deb | tar tvf - on each machine. –  Gilles Aug 16 '12 at 17:54
    
Your question seems to be based on a flawed assumption and / or a local override for an important system default. sudo dpkg -i should always run as root and the installed files should be owned by root (except for suid scripts perhaps, and files belonging to a dedicated system account such as www-data). –  tripleee Jan 31 '13 at 10:08

1 Answer 1

In /etc/sudoers you can give users permission to run special commands. My mohsen user is:

mohsen ALL =(ALL) ALL

In your case you should have this in your /etc/sudoers file:

borrajax ALL =(ALL) ALL

You can become root using sudo su. When you install Ubuntu, Ubuntu asks you to define a normal user, and then Ubuntu adds it to the sudoers file, so the original user you set up should be in there.

share|improve this answer
    
I am not the downvoter, but the "proper" way to get a root shell via sudo is with sudo -i. –  jordanm Aug 16 '12 at 16:42
    
yes, sudo su is same that.sudi su just a trick. –  Mohsen Pahlevanzadeh Aug 16 '12 at 17:55
1  
sudo -i does not run sudo su, it requires sudo bash permissions and the way the environment is or isn't preserved differs. –  jordanm Aug 16 '12 at 21:45
    
sudo -i same as sudo - but a bit difference. –  Mohsen Pahlevanzadeh Aug 18 '12 at 18:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.