LinuxQuestions.org
Review your favorite Linux distribution.
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 11-03-2019, 07:19 PM   #1
gabs247
Member
 
Registered: Jan 2018
Posts: 44

Rep: Reputation: Disabled
Symbolic Link with Reduced Access


Hi,

I've been trying to figure out if this is possible or not, and how to implement it?

I have a Source folder with files A, B and C.

I want to create a Limited Access Folder with only access to files A and B but not C. I don't want to duplicate the data.

I was thinking of a Symbolic link, and maybe adding permissions for a user to only see files A and B and not C?

The problem is, that I want to use a service account to access the two folders, Source and Limited and so then it'll have access to all the files anyway, so that wouldn't work?

Hope that makes sense, and someone may have a suggestion? Thanks
 
Old 11-03-2019, 07:38 PM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
A link’s permissions are not relevant. links “inherit” the permissions of the file being linked to.
Whatever you set the ownership of the original file(s) to will be reflected in the link(s)

If you don’t want the limited user to see file C, just don’t create a link to file C in the limited folder...
 
2 members found this post helpful.
Old 11-03-2019, 08:40 PM   #3
gabs247
Member
 
Registered: Jan 2018
Posts: 44

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
A link’s permissions are not relevant. links “inherit” the permissions of the file being linked to.
Whatever you set the ownership of the original file(s) to will be reflected in the link(s)

If you don’t want the limited user to see file C, just don’t create a link to file C in the limited folder...
Yep, that's what I thought. So I'm wondering if there's a way to implement this scenario?
 
Old 11-03-2019, 08:45 PM   #4
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by gabs247 View Post
So I'm wondering if there's a way to implement this scenario?
Um...
Quote:
Originally Posted by scasey View Post
If you don’t want the limited user to see file C, just don’t create a link to file C in the limited folder...

Last edited by scasey; 11-03-2019 at 09:11 PM.
 
1 members found this post helpful.
Old 11-04-2019, 01:52 AM   #5
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Just in case file C must exist in the second folder but not be accessible, explore bind mounts. You bind mount the source directory to the destination, and if I am not wrong, you can apply your own permissions on the destination.
 
Old 11-04-2019, 05:22 AM   #6
tshikose
Member
 
Registered: Apr 2010
Location: Kinshasa, Democratic Republic of Congo
Distribution: RHEL, Fedora, CentOS
Posts: 525

Rep: Reputation: 95
Hi,

If you can keep all the required folders in a same file system (any ext? or xfs will do), you can then create hard links to files (thus not duplicating them) and assign different ownerships and permissions.

Code:
mkdir -p /tmp/source /tmp/alice /tmp/bob
date > /tmp/source/file

ln /tmp/source/file /tmp/alice/file
chown alice /tmp/alice/file
chmod 700 /tmp/alice/file

ln /tmp/source/file /tmp/bob/file
chown bob /tmp/bob/file
chmod 400 /tmp/bob/file

ls -il /tmp/source/file /tmp/alice/file /tmp/bob/file
 
Old 11-04-2019, 11:19 AM   #7
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by tshikose View Post
If you can keep all the required folders in a same file system (any ext? or xfs will do), you can then create hard links to files (thus not duplicating them) and assign different ownerships and permissions.
As hardlinks link to the I-node itself and ownership and/or permissions are stored IN that I-node, when you change either of them they will be changed for BOTH of the links.
So in fact creating a hard link and then changing ownership or permissions works out as being the same as changing those for the original file.
There is only a single ownership/group and/or permissions field IN the I-node, the hard link is just "an extra filename" for that I-node/file.
 
Old 11-05-2019, 03:54 AM   #8
tshikose
Member
 
Registered: Apr 2010
Location: Kinshasa, Democratic Republic of Congo
Distribution: RHEL, Fedora, CentOS
Posts: 525

Rep: Reputation: 95
Hi,

Sorry my post #6 did not give the expected results.
I had not tested it before.
Please ignore it.

ehartman is right.
 
Old 11-06-2019, 06:55 AM   #9
LinuxGeek46
LQ Newbie
 
Registered: Oct 2019
Location: Raleigh, NC
Distribution: Fedora
Posts: 23

Rep: Reputation: Disabled
So this might seem counterintuitive but it will work regardless of where the file resides or links to it or the directory in which it resides.

First set the ownership of the file to that of the user you want to have no access to it and the group ownership to that of the group you do want to have access to it. Then set the permissions to 076 ---rwxrw- which says that the owner can not read, write or execute the file and that the group can do all three. Anyone else (Other) can read and write the file.

I hope this helps.
 
Old 11-06-2019, 02:13 PM   #10
Peverel
Member
 
Registered: May 2009
Location: Chelmsford, England
Distribution: OpenSuse 12.2 and 13.2, Leap 4.2
Posts: 128

Rep: Reputation: 24
Yes, LinuxGeek46, but an owner can change permissions herself, even then delete the file.
 
Old 11-06-2019, 03:37 PM   #11
gabs247
Member
 
Registered: Jan 2018
Posts: 44

Original Poster
Rep: Reputation: Disabled
Lightbulb

Quote:
Originally Posted by scasey View Post
Um...
Apologies, I either didn't read this properly or only saw the Frist part in the email and replied quickly without reading the rest...but that seems so obvious now! Thanks for showing me what was in front of my eyes all along!

Basically, I need to come up with a script that only creates links to file that I want in the other location 👌
 
Old 11-06-2019, 03:38 PM   #12
gabs247
Member
 
Registered: Jan 2018
Posts: 44

Original Poster
Rep: Reputation: Disabled
Thanks everyone for trying to come up with alternatives, but it seems the simplest solution is often the best (of only I'd realised it myself) ��
 
Old 11-06-2019, 03:43 PM   #13
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by gabs247 View Post
Apologies, I either didn't read this properly or only saw the Frist part in the email and replied quickly without reading the rest...but that seems so obvious now! Thanks for showing me what was in front of my eyes all along!

Basically, I need to come up with a script that only creates links to file that I want in the other location 👌
No worries. "Forest for the trees," as they say.

If you want, you can mark the thread SOLVED using the thread tools at the top of the page.
 
Old 11-06-2019, 03:49 PM   #14
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Keep in mind that anyone who sees the links in that "Limited Access" folder can simply go to the target directory and see all the files. There is no way to make a file or directory accessible only via a symlink. If the link resolver can follow the path, so can the user. You can make that directory "sort of" private by not giving the user "read" permission on the directory. That will prevent listing the contents of the directory, but any known (or guessed) file name can still be accessed.
 
1 members found this post helpful.
Old 11-06-2019, 03:54 PM   #15
gabs247
Member
 
Registered: Jan 2018
Posts: 44

Original Poster
Rep: Reputation: Disabled
The other users are my kids, I think I have a few more years before they figure out how to access a computer...and they don't have access to the server anyway, only via Plex (which is the other account I'm talking about, using Docker).
 
  


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
Physical link vs Relative link vs Symbolic link hack3rcon Linux - Newbie 13 01-13-2018 10:48 AM
[SOLVED] Can I make a symbolic link that is dynamic link->$HOME/file? croog Linux - General 4 10-14-2012 07:55 PM
Symbolic link not allowed or link target not accessible rheluser Linux - Server 3 09-04-2012 10:22 AM
symbolic link not allowed or link target not accessible paullaubscher Linux - Newbie 4 03-10-2010 06:47 AM
How to create symbolic link to html file and avoid page link problem? haxpor Linux - General 2 01-29-2008 07:40 AM

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

All times are GMT -5. The time now is 04:01 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