LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 01-12-2013, 08:33 AM   #1
morganfreeman
LQ Newbie
 
Registered: Jan 2013
Posts: 4

Rep: Reputation: Disabled
Question how to make a link (user)folder that links to a root folder


i have a situation where i need someone to upload files to a root folder without having root permissions.

in other words, i want to link "/home/username/fakeuploadfolder" user folder to the "/opt/application/mainuploadfolder" root folder.

now when the user uploads a file (with his ftp) to his "fakeuploadfolder" then the root should see it from his "mainuploadfolder" as well and the aplication should be able to use this file too. now everytime the user changes the file he can uplad and update the application.

i have tried using a soft link with "ln -s /opt/application/mainuploadfolder /home/username/fakeuploadfolder". it worked but when the user uploads a file, the root cant see it neither the application can see it.

i dont know how i could do this whitout taking security risks.
 
Old 01-12-2013, 11:19 AM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,592
Blog Entries: 2

Rep: Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046
Hello and welcome to LQ.

The approach with the link will not work, due to problems with file-permissions. The correct approach would be to create a user-group for users that are allowed to upload/change files, setting the group ownership of the directory in question to that group, give the group write permissions and then add the user to that group.
 
1 members found this post helpful.
Old 01-12-2013, 11:26 AM   #3
morganfreeman
LQ Newbie
 
Registered: Jan 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
heyy danke dir tobias (hoffe das ist dein name ) ja ich glaube du hast recht. aber ich weis nicht wie ich das machen soll. heattest du zeit und lust mir das einbishen zu zeigen. ich weis das es nur wenige zeilen dauert aber ich binn halt kein profie. und wenn nicht danke ich dir trotzdem. nun habe einen weg den ich verfolgen kann. danke

heyy thank you tobias(hope thats your name) yess i think you are right. but i dont know how i should do that. could you please show me. i know that i takes just some lines but i am not a pro. if not thank you anyway. at least i know yhat way i have to follow. thank you.

Last edited by morganfreeman; 01-12-2013 at 12:52 PM.
 
Old 01-12-2013, 12:06 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,592
Blog Entries: 2

Rep: Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046
Please keep your posts in English (and add a translation to English to your previous post) so that everyone can follow the discussion, other languages are not appreciated here.

Ok, how to do that step-by-step:

First step: Create a new user-group, I will name this group uploaders, but of course you can choose any name you want:
Code:
groupadd uploaders
Second step: Change the group ownership of the folder in question (here /opt/application/mainuploadfolder) to the new group, but keep root as user that owns the directory:
Code:
chown root:uploaders /opt/application/mainuploadfolder
You can check that this has worked using the command
Code:
ls -ld /opt/application/mainuploadfolder
The output should look like this:
Code:
drwxr-xr-x 2 root uploaders 4096 Jan 12 18:51 /opt/application/mainuploadfolder
Of course the creation date and time be different on your machine.

Third step: The output of the ls command has shown that the group already has the right to read and descend into the directory (drwxr-xr-x), but we also need to add the write permission:
Code:
chmod g+w /opt/application/mainuploadfolder
The ls command from above should now show the changed permissions drwxrwxr-x if everything worked.

The last step: Add your user to the new group, so that he can access the directory:
Code:
usermod -G uploaders -a USERNAME
You have to replace USERNAME with the actual username.

Now the user should have access to the directory, you can test that with logging in as the user and launching the command
Code:
touch /opt/application/mainuploadfolder/test
That should create a new file named test in that directory. Alternatively you can simply try to upload a file.

For more information n the used commands have a look at
Code:
man groupadd
man chown
man chmod
man usermod

Last edited by TobiSGD; 01-12-2013 at 12:40 PM. Reason: fixed typo
 
1 members found this post helpful.
Old 01-12-2013, 02:08 PM   #5
morganfreeman
LQ Newbie
 
Registered: Jan 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
wow that is great. exactly what i needed. i am sure this this will do the trick. i will apply this as soon a possible. i am really grateful for your help. thank you for spending time and attention to answer.
 
Old 01-12-2013, 03:00 PM   #6
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,592
Blog Entries: 2

Rep: Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046
Always happy to help. If that has solved your problems please mark this thread as solved using the thread tools at the top of the thread.

Last edited by TobiSGD; 01-14-2013 at 06:08 AM. Reason: fixed typos
 
Old 01-14-2013, 05:56 AM   #7
morganfreeman
LQ Newbie
 
Registered: Jan 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
please correct me if there is something wrong here. i have added a user via Cpanel. then i added him to the "uploaders" (as in tobi's example) group. and the last step was making a soft link so that the user could see the folder over his ftp account. everything works now big big thanks TobiSGD.

HERE WE GO
  1. STEP create a user with Cpanel or with useradd command, i decided to add user over cpanel so i had not to make other congurations like ftp, cpanel ect. for the new user.
  2. STEP add the user "mynewusersname" to the "uploaders" group
    Code:
    # usermod -a -G uploaders mynewusersname
  3. STEP check the users group if the command was successful
    Code:
    # id mynewusersname
    output ("groups=506(mynewusersname),32012(uploaders)" will show us that the user is added to the "uploaders" group)
    Code:
    uid=509(mynewusersname) gid=506(mynewusersname) groups=506(mynewusersname),32012(uploaders)
  4. STEP do a softlink for the user to the desired (it was not possible to see the content of the roots /opt... folder before TobiSGD instructions)
    Code:
    ln -s /opt/application/mainuploadfolder /home/mynewusersname/mainuploadfolderlink
Now the user is able to r/w inside the roots folder (but not somewhere else) over his ftp account or cpanel. he will be able to see the folder on his root as "mainuploadfolderlink". this is great. Thank you again for your help TobiSGD
 
  


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
[SOLVED] Seperating Home folder from Root Folder to a new partition. baxzius Linux - Newbie 5 08-01-2011 03:26 PM
How to make a public folder within a private folder? Virchanza Linux - General 3 09-22-2010 08:13 AM
I can not open the user folder in home and write in a shared folder jorge_ivan Linux - General 8 08-02-2006 11:28 AM
Im the only user on SUSE 10.0 and it will not allow me in the root folder BFGeier Linux - Newbie 4 01-02-2006 07:09 AM
permissions difference between /home/..../folder and /root/folder darkleaf Linux - General 3 07-21-2005 05:23 PM


All times are GMT -5. The time now is 09:54 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration