How do linux Permissions Work?

For discussions about security.
Post Reply
Message
Author
s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

How do linux Permissions Work?

#1 Post by s243a »

So, I'm looking at the permissions of a directory:
I see:
Owner
Group
World

I have two users, spot and root. Root can run anything right? What if root runs something that is owned by spot? In this case will the application run with the permissions of root or spot?

How is it implemented? I recall reading some configuration files that gives user root, root like permissions. I can't recall where they are located though.

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#2 Post by Semme »

Pass..
Last edited by Semme on Sat 18 Apr 2015, 20:17, edited 3 times in total.
>>> Living with the immediacy of death helps you sort out your priorities. It helps you live a life less trivial <<<

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#3 Post by Semme »

Wow! ₩hat came over me?
Last edited by Semme on Sun 19 Apr 2015, 01:36, edited 2 times in total.
>>> Living with the immediacy of death helps you sort out your priorities. It helps you live a life less trivial <<<

Scooby
Posts: 599
Joined: Sat 03 Mar 2012, 09:04

Re: How do linux Permissions Work?

#4 Post by Scooby »

s243a wrote: What if root runs something that is owned by spot? In this case will the application run with the permissions of root or spot?
It will run with root's permissions

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

Re: How do linux Permissions Work?

#5 Post by rufwoof »

s243a wrote:How is it implemented? I recall reading some configuration files that gives user root, root like permissions. I can't recall where they are located though.
inodes store file, directories etc permission data http://en.wikipedia.org/wiki/Inode

I suspect the file you're referring to for permissions is /etc/passwd

Ibidem
Posts: 549
Joined: Wed 26 May 2010, 03:31
Location: State of Jefferson

#6 Post by Ibidem »

Standard permissions refer to one's ability to access the file.
So, if you have execute permissions for a file, you can run it.
The *process* will belong to you, if it is a regular file.
However, read-write-execute permissions for "user", "group", and "other" only occupies 9 bits of the 32 bits available for storing the file mode.
The other bits include:
-setuid: if you run a setuid file, the process will belong to the owner of the file
-setgid: if you run a setgid file, the user owning the process is unchanged but the group owning the process is the group owning the file
-sticky: when set on a directory, only owners of files in the directory can delete them (by default, anyone with write access to the directory can delete any of its contents)
These are bits 04000, 02000, and 01000 respecttively.

Besides those, there are a lot of bits to do with "special files", describing whether the file is a block device, char device, socket, symbolic link, named pipe (FIFO), or directory.

Code: Select all

man 2 stat
has more of the technical details, if you're interested.


From the kernel's perspective, a "user" is identified by a number, their "user id" (uid).
On most unix-like systems, these are mapped to user names via entries in /etc/passwd; generally, "root" is uid 0.
A similar situation applies to groups, though the file mapping group ids to group names is /etc/group.
root is able to do what it can do because it's uid 0, rather than because of user name; the behavior is mostly set in the kernel.
Other users are generally able to do a subset of what root can do under certain conditions:
-via sudo (configured via /etc/sudoers) or setuid binaries
-for devices, if the device has permissions giving them access
-if files have filesystem capabilities enabled (a topic I'm barely aware of)

Post Reply