LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Restrict File Access (http://www.linuxquestions.org/questions/linux-newbie-8/restrict-file-access-771466/)

dysons 11-25-2009 08:44 AM

Restrict File Access
 
I need to create e different folders Chunk1, Chunk2 and Chunk3. I then want to have 3 different scripts (or even better one script with 3 different options), the options being...

1) Allow RW access to Chunk1, RO access to Chunk2
2) Allow RW access to Chunk2, RO access to Chunk1
3) Allow RW access to Chunk3, RO access to Chunk2

This is because I will be developing software with one of 3 hats on and I don't want to inadvertently access/edit the wrong file!

Is this easy to do?

Thanks,
Steve.

lazlow 11-25-2009 08:54 AM

Probably much easier to just make three users (one for each hat) and assign each user to a group with the appropriate permissions.

pcunix 11-25-2009 10:01 AM

So the script would be run as you start work on each project?

Yeah, as lazlow suggested, you could do this with three different users and "su" between them.

Or, you could just "chmod -w", "chmod +w" as desired in your script. It could take the argument of the RW set and act appropriately.

Something like

Code:

if [ $1 = "Chunk1" ]
then
  chmod -R +w Chunk1/*
  chmod R -w Chunk2/*

and so on.

chrism01 11-25-2009 05:37 PM

Yeah, 3 groups/dirs, then use 'newgrp' http://linux.die.net/man/1/newgrp to change your current primary group on demand.

dysons 11-26-2009 01:24 PM

Done!
 
Thanks for the advice.

Ended up reading through bash script manual and writing a little addition to an existing logon script that calls chmod for aech combination. Seems to work fairly effectively.

I now need to set up 3 eclipse c++ projects (one for each chunk) so that I can edit the source code appropriate to the current 'hat' I am wearing! Not sure how eclipse is going to like to being able to access one of its project areas.

Thanks again.
Steve.


All times are GMT -5. The time now is 01:23 AM.