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.

How can I remove a package for a given user but leave it installed so that other users can still access it? I'm using Ubuntu 12.10.

share|improve this question
    
Packages are system wide. You can't remove it, for a single user. Setup the filesystem permissions on the application so that only the users you want can run it. –  Zoredache May 8 '13 at 6:35

1 Answer 1

up vote 3 down vote accepted

Most packages are installed in places and with permissions so they are accessible by multiple users. So unless the package has been prepared to take care of that by setting the permissions and ownership in a special way, it is not possible to achieve this by package removal.

What a package could do to restrict access is to set the group permissions for directories and executables to rwxr-x--- and for normal files to rw-r-- and setting group ownership to a specific group so non-members of that group don't have access any more.

You can do the above after the fact on most packages, as it does not change the structure of where things get installed. So the package will still find all of its components. Depending on what you exactly want to achieve it might suffice to just change the executables of the package.

Assuming a package abc is installed you could do something like the following (as root):

addgroup abcusers
adduser user abcusers
dpkg -L abc | xargs find -maxdepth 0 -type f | xargs chown o=
dpkg -L abc | xargs find -maxdepth 0 -type f | xargs chgrp abcusers

The first line creates a group, the second line needs to be repeated for all users that need access to the package. The third and fourth line change the permissions on all the files of a package (assuming there are no filenames with spaces). This may however still break the package so be careful with which you do this and/or roll back your changes with:

apt-get install --reinstall abc
share|improve this answer
    
Security-Enhanced Linux is probably the right tool for this job, but I'd probably kludge it as you suggest before trying to learn how to configure SEL. –  msw May 8 '13 at 14:11
    
@msw I agree that there are certainly better ways if you can start from scratch, but the way the question was worded, starting from scratch did not seem an option. –  Anthon May 8 '13 at 14:30
    
you need to use dpkg-statoverride to make these changes stick. Which you'll probably only have to do on the executable itself. –  derobert May 8 '13 at 22:33
    
also, your example code is broken, seems you want o= instead of g= and you need a package name after -L. –  derobert May 8 '13 at 22:35
    
@derobert thanks for spotting that, I did not cut and paste this (as you might have guessed). –  Anthon May 9 '13 at 5:12

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.