LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 04-23-2024, 07:30 AM   #1
Jason.nix
Member
 
Registered: Feb 2023
Posts: 562

Rep: Reputation: 10
Post Multiple user permissions on a directory


Hello,
I changed the docker storage to another location:
Code:
{
"data-root": "/mnt/newlocation/"
}
The root user has access to this directory:
Code:
# ls -l /mnt/newlocation/
total 20
drwxr-xr-x 5 root root  4096 Apr 22 09:22 containers
drwx------ 2 root root 16384 Apr  9 16:50 lost+found
I have installed GitLab Runner and want it to have full access to this directory. I did the following command:
Code:
# chown -R gitlab-runner /mnt/newlocation/
The permissions were changed as follows:
Code:
# ls -l /mnt/newlocation/
total 20
drwxr-xr-x 5 gitlab-runner root  4096 Apr 22 09:22 containers
drwx------ 2 gitlab-runner root 16384 Apr  9 16:50 lost+found
The GitLab Runner problem is fixed, but what problems might this cause for Docker and others? Can I make both the root user and the gitlab-runner user have full access to this directory?

I found solutions on the internet that were about creating a group, then adding users to that group, and finally giving that group full permission for that directory. Is this OK?

Thank you.
 
Old 04-23-2024, 07:33 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,665
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Yes, this would be the correct solution, versus changing the "owner." I recommend that you [immediately ...] change the owner back, define a group, add "gitlab-runner" to that group, and change the group of that directory and its contents appropriately. Assign the desired permissions to the group.

FYI: There is also an entirely-parallel permissions system known as ACLs = Access Control Lists. Which are much more flexible, and which can coexist. I encourage you to research this option also.
 
1 members found this post helpful.
Old 04-25-2024, 06:29 AM   #3
Jason.nix
Member
 
Registered: Feb 2023
Posts: 562

Original Poster
Rep: Reputation: 10
Quote:
Originally Posted by sundialsvcs View Post
Yes, this would be the correct solution, versus changing the "owner." I recommend that you [immediately ...] change the owner back, define a group, add "gitlab-runner" to that group, and change the group of that directory and its contents appropriately. Assign the desired permissions to the group.

FYI: There is also an entirely-parallel permissions system known as ACLs = Access Control Lists. Which are much more flexible, and which can coexist. I encourage you to research this option also.
Hello,
Thank you so much for your reply.
So I create a group and add the root and gitlab-runner users to it and then give permission to this group for that directory. I did:
Code:
# chown -R root data/
# groupadd runner
# /sbin/usermod -a -G runner gitlab-runner
# /sbin/usermod -a -G runner root
# chgrp -R runner data/
# chmod -R g+rwx data/
And result is:
Code:
# ls -l
total 20
drwxrwxr-x 5 root runner  4096 Apr 22 09:22 containers
drwxrwx--- 2 root runner 16384 Apr  9 16:50 lost+found
Now, root and gitlab-runner users have full access to the directories. Right?

Last edited by Jason.nix; 04-25-2024 at 06:53 AM.
 
Old 04-26-2024, 08:24 AM   #4
Jason.nix
Member
 
Registered: Feb 2023
Posts: 562

Original Poster
Rep: Reputation: 10
Hello,
I have a problem. When I ran the runner, I got the following error message:
Code:
$ rm -rf /mnt/data/containers/
rm: cannot remove '/mnt/data/containers/.gitlab-ci.yml': Permission denied
rm: cannot remove '/mnt/data/containers/CHANGELOG.md': Permission denied
rm: cannot remove '/mnt/data/containers/README.md': Permission denied
 
Old 04-26-2024, 09:58 AM   #5
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,804

Rep: Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203
/mnt and /mnt/data/ must have an x bit (access) set, otherwise all access is denied.
/mnt/data/containers/ looks ok, gives write access for the group members. (Note that a modified group is recognized at the next login.)

A remaining problem is that a directory created by one user is not writable by the other, unless the one user does a chgrp and chmod. The traditional fix is
  1. a g+s bit on all the directories that make new items inherit the group from its directory
  2. the users use a umask 002 that sets the g+w bit on new items.

Regarding the ACL alternative, I posted a solution that worked in Linux and Solaris
https://community.unix.com/t/tip-gro...rectory/383754

Last edited by MadeInGermany; 04-26-2024 at 09:59 AM.
 
  


Reply



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
[SOLVED] Permissions Permissions Permissions! makem Linux - Newbie 13 07-30-2015 11:54 AM
File permissions v. directory permissions Completely Clueless Linux - Newbie 7 07-09-2009 08:33 AM
User shown as "already exist" when there is no user directory shown on home directory Sharpeye Linux - Newbie 3 03-18-2009 01:17 AM
Su permissions (User A can su to User B, but not User C) Whir47 Linux - Security 1 01-21-2009 03:56 AM
getting a directory's permissions and creating a new one with the same permissions newbie1000101 Programming 1 04-10-2004 12:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:57 PM.

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
Open Source Consulting | Domain Registration