LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-28-2004, 03:49 PM   #1
floydian219
LQ Newbie
 
Registered: Jul 2004
Location: Western Indiana, USA
Distribution: Red Hat 9 & SuSE 8.2
Posts: 7

Rep: Reputation: 0
Understanding permissions - from a Windows user's perspective


I've been using and administering programs running on Linux systems for probably two years or longer, but luckily, I've never had to worry about permissions and users. Now I'm in a situation where I'll be administering a BIND server, and the user permissions issue has raised its head. I guess my question relates in some degree to a lack of understanding of chmod , but principally, it relates to a failure on my part to understand the conceptual framework of Linux permissions, which I hope someone can give me some pointers on.


From the perspective of administering a Win2k server, permissions seem fairly straightforward. You have users, and groups. Every user is a member of one or more groups. Virtually every system resource has an ACL, to which any given user or group can be added or removed. Any individual user, or group of users, can be assigned any level of permissions on any resources anywhere in the file system

My understanding of groups and permissions in Linux is that the landscape is very different. You still have users and groups, and every user is still a member of one or more groups. However, system resources have permissions only for the owner (in almost every case i.e., but sometimes e.g., the resource's creator), the owner's group, and everyone who isn't the owner or i the owner's group.

This seems to me to make a laberynthine nightmare a permissions request that is simple under the Win2k model. As noted before, I'm administering a BIND server on RH9; virtualy all of the important files relating to Bind are owned by root. If I want to create one or more administrative accounts that have RWX access to /etc/named.conf, /etc/rc.d/init.d/named, and all files in the directory /var/named/master, my understanding coming from a Win2k perspective would be to create a user (or group of users), and set the ACL on each of the above-named files and directories to allow those users to have RWX permissions for that resource. In Linux, this doesn't seem possible.

In this case, I suppose it is arguable that I could change the owner of each of these files to a user named-supremo, a member of the group named-admins, create other accounts in that group, and run chmod 775, but a) I don't necessarily want to do that, b) one can foresee numerous situations beyond this one example where one wants to assign permissions to users on certain files without wanting to add the user to a given group or change the owner of a resource.


Another example would be that I have three files: paper, scissors and stone. I have three users, mickey, goofey and donald. mickey owns paper and scissors, root owns stone. I want to give goofey rwx permissions on paper, scissors and stone, and donald wrx permissions on paper and stone, but only rx permissions on scissors. Any other user should only have rx permissions on paper and stone, but only r permissions on scissors.

In Windows, I'd just assign goofey rwx permissions on paper, scissors and stone, and assign donald rwx permissions on paper and stone, rx permissions on scissors.

In Linux, as it seems to me, goofey has easy requirements. Make him a member of mickey's group. However, to give donald wrx permissions on paper, I either have to make him a member of the same group as mickey, or change the any user permissions for paper, which I don't want to do! But I can't make donald a member of mickey's group, because then either donald gets wrx permissions for scissors (remembering that goofey has and should have access to scissors, as a member of mickey's group) or I have to deny rwx permissions for group permissions on scissors.


I guess what I'm saying is that if I'm understanding Linux right, directory security is necessarily about groups and owners, and there is no detailed control over individual nightmares. I have to maintain an elaborate scheme of which users are in which groups and which groups have permissions on what objects; any unforeseen security requirements may mean adding a dozen users to a completely new group, whose permissions may conflict with existing requirements. This makes no sense to me.

Am I missing some really huge chunk of understanding, because this to my mind is perfectly potty. To my understanding - to me, as someone who uses Linux, likes Linux, and would move a lot more of the services we run over to Linux if that was my choice, so in every way someone pro-Linux - my understanding of Linux permissions vs. Windows permissions is that Linux permissions are no-where near as flexible as Windows permissions. This doesn't seem to square against everything else I know about Linux vs. Windows, in which Linux is vastly more flexible than Windows, hence the question: quite aside from the command syntax, which is well-documented, am I missing something, conceptually, here?


My standard references are Using Linux System Administration (Danesh & Das, Que 2000) and Linux Complete (Aulds, Danesh, Hontanon, Hunt, Minasi, Pfaffenberger, Smith, Stanfield & Wells, Sybex 2002). Neither of these include a particularly good discussion of this subject material, and the same is true of most of the web resources. All of these sources provide discussion of the technical minutiae - chmod , chgrp and so on - but lack a strong conceptual framework to explain directory security and permissions in a Linux paradigm to those used to the same subject but from a Windows paradigm.

I'm not here having a dig at Linux permissions; I freely confess that this problem is born of my own lack of understanding of the mindset I need to view Linux permissions from. If anyone could offer guidelines or reccomend links / books that they found helpful, I'd appreciate it.



Regards,
Simon

chmod

Last edited by floydian219; 07-28-2004 at 03:57 PM.
 
Old 07-28-2004, 04:04 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Hi, and welcome to LQ!

I won't take quite as much time and many words as you to
give you a working scenario for the bind problem... :) I will
ignore the two blokes with the three names for my sanity's
sake, too ;)

What you want to do is create a group dnsadmin (or the
like), and just
chgrp -r dnsadmin /etc/named.conf /etc/rc.d/init.d/named /var/named/master
chmod g+rw /etc/named.conf
chmod -R g+rwx /etc/rc.d/init.d/named /var/named/master
and make the fellas member of that group. There's no need
to take roots ownership away.

With that scenario both root and the jokers in dnsadmin
can edit configuration files, and all of them can start/stop/restart
the service for the change to take effect.

As for the potty-ness of Linux' permissions: experience
and performance to me justify the approach, my Linux
boxes without complex ACL's outperform any other server
system I ever dealt with.



Cheers,
Tink

Last edited by Tinkster; 07-28-2004 at 04:06 PM.
 
Old 07-28-2004, 05:10 PM   #3
floydian219
LQ Newbie
 
Registered: Jul 2004
Location: Western Indiana, USA
Distribution: Red Hat 9 & SuSE 8.2
Posts: 7

Original Poster
Rep: Reputation: 0
Tinkster,
Thanks for the reply, I appreciate the help. I think I see what you're saying, but only within the scope of this example.

Trying your suggestion on a test file, I do this:

Create a group called bind-admins and assign an admin user to it:

[root@linux1 master]# /usr/sbin/groupadd -g 501 bind-admins
[root@linux1 master]# /usr/sbin/usermod -Gbind-admins shawn



The unmodified file:

[root@linux1 named]# ls -l named.conf.test
-rw-r--r-- 1 root root 14647 Jul 28 15:34 named.conf.test



Then I change the group ownership of the file:

[root@linux1 named]# chgrp -v bind-admins named.conf.test
changed group of `named.conf.test' to bind-admins
[root@linux1 named]# ls -l named.conf.test
-rw-r--r-- 1 root bind-admins 14647 Jul 28 15:34 named.conf.test



And lastly change the group permissions:

[root@linux1 named]# chmod g+rw named.conf.test
[root@linux1 named]# ls -l named.conf.test
-rw-rw-r-- 1 root bind-admins 14647 Jul 28 15:34 named.conf.test


This is good, insofar as now, both root and any users in the bind-admins group can read and write to named.conf.test, while any other users can simply view it. So this does solve the immediate quandry, and I guess the missing bit of information on my part was that you can change the group ownership without changing the owner. However, it still seems to me that this approach, when looked at in a wider field, has problems.

For example:

If I want to make one of my staff a junior bind admin, with permission to stop, start and reload the name server, then that junior admin needs rwx access to two files: /usr/sbin/rndc and /etc/rc.d/init.d.named. Because I've changed the group ownership of those files to the group bind-admins, making that user a member of bind-admins will give them permission to do what we want them to do. However, it will also give that user rw access to /var/named.conf and the zone files in /var/named/master, because bind-admins have rw permissions on those folders. How can I grant both junior admins and senior admins alike access to /usr/sbin/rndc and /etc/rc.d/init.d.named, while allowing only senior admins access to /var/named?


I agree with you that the rock-paper-scissors scenario in my previous post was somewhat mind-bending, and I apologize for that - although it does illustrate nicely how mixed up these permissions issues seem to me! It baffles me that I seem to have used Linux systems at work - and at home! - for quite a while, and never had to have run-ins with this area before. I'm also sure that you're right, and that the seeming pottyness of Linux permissions relates to gaps in my knowledge, rather than inherent problems with the OS. I remain a Linux fan, I'm just confused about this aspect of its operation.
 
Old 07-28-2004, 05:25 PM   #4
shilo
Senior Member
 
Registered: Nov 2002
Location: Stockton, CA
Distribution: Slackware 11 - kernel 2.6.19.1 - Dropline Gnome 2.16.2
Posts: 1,132

Rep: Reputation: 50
Quote:
However, system resources have permissions only for the owner (in almost every case i.e., but sometimes e.g., the resource's creator), the owner's group, and everyone who isn't the owner or i the owner's group.
I don't know if this will help you at all, but your description of permissions is a little bit off. You are correct that each file (or system resource, if you want to call it that) has owner, group, and other permissions. The group, though is not the "owner's" group. The owner can be a member of many groups. This wouldn't make sense having the file belong to the "owner's group". It may be confusing that groups and owners/users can share the same name. For instance, you have a user named "root" and a group named "root". You'll see a lot of files belong to both the owner "root" and the group "root". THey could just as easily be owned by the user "root" and the group "users".

Hope that makes sense.

Good luck,

Shilo
 
Old 07-28-2004, 05:43 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally posted by floydian219
If I want to make one of my staff a junior bind admin, with permission to stop, start and reload the name server, then that junior admin needs rwx access to two files: /usr/sbin/rndc and /etc/rc.d/init.d.named. Because I've changed the group ownership of those files to the group bind-admins, making that user a member of bind-admins will give them permission to do what we want them to do. However, it will also give that user rw access to /var/named.conf and the zone files in /var/named/master, because bind-admins have rw permissions on those folders. How can I grant both junior admins and senior admins alike access to /usr/sbin/rndc and /etc/rc.d/init.d.named, while allowing only senior admins access to /var/named?
make a group bind-minors, add the one fellow and the bind-admins
to it, and chgrp the files the minor needs to the minor group ;)




Cheers,
Tink
 
Old 07-29-2004, 10:13 AM   #6
floydian219
LQ Newbie
 
Registered: Jul 2004
Location: Western Indiana, USA
Distribution: Red Hat 9 & SuSE 8.2
Posts: 7

Original Poster
Rep: Reputation: 0
Hmm. This is helping a bit, but I'm still struggling to grasp the mindset. Okay...Can I add the bind-admins group to the proposed bind-minors group as a whole, or only one by one?

And if I want to give bind-admins rw- permissions on named.conf, bind-minors r-- permission only, and any other user on the system no permissions even to read named.conf - is this possible? This seems a fairly reasonable security requirement; the admins need to be able to make changes, the minors should be able to read the file to check to ensure there isn't a syntax gaffe or the like, but because the file contains the secure RNDC key, any other users on the system should not have access.
 
Old 07-29-2004, 02:14 PM   #7
floydian219
LQ Newbie
 
Registered: Jul 2004
Location: Western Indiana, USA
Distribution: Red Hat 9 & SuSE 8.2
Posts: 7

Original Poster
Rep: Reputation: 0
Another issue -
I changed the group ownership of the /var/named/master directory, recursively, then assigned group permissions to rw-:

[root@dauth1 master]# chgrp -vR bind-admins /var/named/master
[root@dauth1 master]# chmod -vR 660 master >output
[root@dauth1 master]# cd ..
[root@dauth1 named]# ls -l |grep master
drw-rw---- 7 root bind-admins 12288 Jul 28 16:35 master


Logged in as root, I can, obviously, view anything I want. Logged in as a regular user, if I try to cd to /var/named/master, I get this:

[simon@dauth1 named]$ groups
simon
[simon@dauth1 named]$ cd /var/named/master
bash: cd: /var/named/master: Permission denied


All well and good.

However, I have three users in the group bind-admins, but none of them can view or list, let alone write to, files in and under the /var/named/master directory:

[hostmaster@dauth1 named]$ groups
bind-admins
[hostmaster@dauth1 named]$ cd /var/named/master
bash: cd: /var/named/master: Permission denied


Any ideas? I've checked the contents of the directories; the group ownership change has propagated down into the files and directories, and the directory itself has the right permissions, as you can see. Logged in to any user in the bind-admins group, however, I can't do what the permissions explicitly tell me I should be able to do:

[root@dauth1 named]# ls -l |grep master
drw-rw---- 7 root bind-admins 12288 Jul 28 16:35 master
[root@dauth1 named]# su hostmaster
[hostmaster@dauth1 named]$ groups
bind-admins

[hostmaster@dauth1 named]$ cd /var/named/master
bash: cd: /var/named/master: Permission denied
 
Old 07-29-2004, 02:23 PM   #8
floydian219
LQ Newbie
 
Registered: Jul 2004
Location: Western Indiana, USA
Distribution: Red Hat 9 & SuSE 8.2
Posts: 7

Original Poster
Rep: Reputation: 0
On suggestion of a colleague, I've tried opening the directory up entirely, then locking it down:

[root@dauth1 named]# chmod -R 777 /var/named/master
[root@dauth1 named]# ls -l |grep master
drwxrwxrwx 7 root bind-admins 12288 Jul 28 16:35 master
[root@dauth1 named]# su shawn
[shawn@dauth1 named]$ cd /var/named/master
[shawn@dauth1 master]$ exit
exit
[root@dauth1 named]# chmod -R 660 /var/named/master
[root@dauth1 named]# ls -l |grep master
drw-rw---- 7 root bind-admins 12288 Jul 28 16:35 master
[root@dauth1 named]# su shawn
[shawn@dauth1 named]$ groups
named bind-admins
[shawn@dauth1 named]$ cd /var/named/master
bash: cd: /var/named/master: Permission denied
[shawn@dauth1 named]$


Doesn't work either.
 
Old 07-29-2004, 03:31 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
That's because to be able to cd into a directory
you need to have execute permissions on it...
so your recursive chmod caused some havoc in
this case ...

What you want is to use
find /var/named -type d -exec chmod g+x {} \;


Cheers,
Tink
 
Old 07-29-2004, 04:11 PM   #10
floydian219
LQ Newbie
 
Registered: Jul 2004
Location: Western Indiana, USA
Distribution: Red Hat 9 & SuSE 8.2
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by Tinkster
That's because to be able to cd into a directory, you need to have execute permissions on it...
so your recursive chmod caused some havoc in this case ...
Aha - you're absolutely right, that fixed it. I didn't realize that you needed to be have x permissions to even cd into a directory, although that is a potentially usefull weapon for future note.

You can sense the inevitable question here, then.

Suppose I want to give bind-minors permission to read and write to the zone files in /var/named/master, but I don't want them to be able to execute files in that directory - how can this be achieved? In order for them to be able to read files from the directory, they have to be able to cd to the directory, and to cd to the directory, as I now understand, the users require execute permissions for that directory. If the directory was static, I could probably run chmod on all the files within the directory, but what happens as files are added? Surely, they'll inherit the directory permissions and have x permissions?

Also, any thoughts on my previous question about giving bind-admins rw- permissions on named.conf, bind-minors r-- permission only, and any other user on the system no permissions even to read named.conf - is this possible?

I continue to appreciate the sage guidance.
 
Old 07-29-2004, 04:54 PM   #11
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally posted by floydian219
You can sense the inevitable question here, then. ;)

Suppose I want to give bind-minors permission to read and write to the zone files in /var/named/master, but I don't want them to be able to execute files in that directory - how can this be achieved? In order for them to be able to read files from the directory, they have to be able to cd to the directory, and to cd to the directory, as I now understand, the users require execute permissions for that directory.
Almost, but not quite :)
If the person who wants to change the file knows the
fully qualified name of the file he can read/write it without
having the permission to "execute" the directory. This
has the positive side-effect that you can e.g. make
backup-copies of the files that he won't see ... furthermore
you can even take the write permissions on the directory
away which e.g. will then allow that user to MODIFY a
file he has write-permissions to, but not delete it :)



Quote:
If the directory was static, I could probably run chmod on all the files within the directory, but what happens as files are added? Surely, they'll inherit the directory permissions and have x permissions?
Nope, they don't. Files basically get their permissions a)
via the umask during creation or b) manually via chmod


Quote:
Also, any thoughts on my previous question about giving bind-admins rw- permissions on named.conf, bind-minors r-- permission only, and any other user on the system no permissions even to read named.conf - is this possible?
To achieve that you'll have to make use of
/etc/sudoers, I'm afraid ... have a read in
man sudo and man sudoers for that ...


Cheers,
Tink
 
Old 08-03-2004, 09:46 AM   #12
floydian219
LQ Newbie
 
Registered: Jul 2004
Location: Western Indiana, USA
Distribution: Red Hat 9 & SuSE 8.2
Posts: 7

Original Poster
Rep: Reputation: 0
Okay, thanks for the guidance - I'll look into SUDO as well.
 
Old 09-07-2004, 09:10 AM   #13
1n33d2kn0w
LQ Newbie
 
Registered: Oct 2003
Location: Johannesburg
Distribution: Red Hat, Fedora Core2
Posts: 4

Rep: Reputation: 0
Try using getfacl and setfacl. You use these to set permissions specific to a user or group for a file or directory. Get more info via man getfacl and man setfacl

Hope this helps
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for a Windows Manager easy to learn and install from a technical perspective TGWDNGHN Linux - Software 1 10-07-2005 04:15 PM
Trouble understanding chmod & group permissions gen-ik Linux - Newbie 3 07-19-2004 02:51 PM
Linux from a desktop user's perspective locke86 General 9 05-26-2004 03:21 PM
Fedora Core Linux from a Windows user's perspective Travis S General 9 02-13-2004 06:31 PM
Increasing normal user's permissions gboutwel Linux - Security 3 11-10-2002 04:21 AM


All times are GMT -5. The time now is 05:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration