LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-08-2009, 06:20 PM   #1
icmp_request
Member
 
Registered: Jun 2007
Location: 127.0.0.1
Distribution: Changing a lot over time
Posts: 46

Rep: Reputation: 15
Mounting cifs with read/write permissions for a non-root user


Hello guys!

I want to mount a cifs folder and I wish to give the user id 1701 read AND write permission. I've already tried adding "user" on fstab but when I try to mount the mount command cannot be run by a user. I tried as root anyway and gave the following command:

mount -t cifs //192.168.0.2/Share /mnt/share/ -o iocharset=utf8,uid=1701,gid=1701,rw

The problem is, it only mounts the folder with r-x permissions so I don't have +w on any of its files. I've already tried chmod the folder to 1777 but no success... any ideas? :/

Edit: See below:

root@voyager:/mnt# ls -n
total 8
drwxr-xr-x 2 0 0 4096 2009-07-08 19:14 cifs-1
drwxr-xr-x 2 0 0 4096 2009-07-08 19:14 cifs-2
dr-xr-xr-x 1 1701 1701 0 2009-07-08 18:52 share

Last edited by icmp_request; 07-08-2009 at 06:23 PM.
 
Old 07-08-2009, 09:13 PM   #2
shane25119
Member
 
Registered: Aug 2003
Location: Illinois
Distribution: Linux Mint XFCE
Posts: 647

Rep: Reputation: 52
This isn't completely the same issue, but you may find this helpful- I wrote a howto article on mounting a Iomega Network Drive (which uses cifs back in the day- your answer may be included therein:

http://www.linuxquestions.org/linux/...issues_with_cp

Specifically, the command I used to mount:

Code:
sudo mount -t cifs //192.168.0.11/backup /media/network_drive -o username=$USER,password=$PASSWORD,uid=$USER
password=$ROOT_PASSWORD
Let me know if this is what you were looking for.
 
Old 07-09-2009, 09:08 AM   #3
icmp_request
Member
 
Registered: Jun 2007
Location: 127.0.0.1
Distribution: Changing a lot over time
Posts: 46

Original Poster
Rep: Reputation: 15
Thanks for the reply, shane25119.

But when I visit the page, I receive the message:

You are not authorized to access this page.

Also, isn't a security issue giving a command or assigning a variable the root password?
 
Old 07-09-2009, 01:31 PM   #4
shane25119
Member
 
Registered: Aug 2003
Location: Illinois
Distribution: Linux Mint XFCE
Posts: 647

Rep: Reputation: 52
You are right it is a security issue- I'm hoping however that my script might contain the proper permissions to at least get it mounted. Please remember- this script doesn't work via fstab- it mounts when the script is executed. No different than a USB stick really.
Let me know if you glean anything from here... else I'll start doing some research to help ya out.

Here it is pasted:::::

Data is valuable and making backups is a great idea. Unfortunately, backing up is time consuming, so it makes great sense to have a script do it for you. Rsync is the undisputed favorite script for this task.

However, there is a bug in rsync that causes it to completely mangle timestamps on some systems, everything I have read suggest it is a Nautilus problem. This is a work around to allow you to automatically backup to a network harddrive if you run into rsync's timestamp problems.

This guide is written for Ubuntu, but can easily be adapted to any distribution.

First off, hook up your network hard drive and configure it (i.e. set passwords, name it, etc).

Next, create a mount point for our network drive- from the command prompt:

Code:

sudo mkdir /media/network_drive

Of course, you can call it anything you want, network_drive, backup, lollipops etc.

I prefer to only mount my network drive while in use; so, I begin my script by mounting the drive: (Please note, the echos are not strictly speaking needed, I just like to know what's going on).

Code:

#!/bin/bash
echo "Remote Backup Script- Docs"

echo "Mounting Remote Drive"

sudo mount -t cifs //192.168.0.11/backup /media/network_drive -o username=$USER,password=$PASSWORD,uid=$USER
password=$ROOT_PASSWORD

In the above code, //192.168.0.11/backup represents first the IP address of the network hard drive on the network, and then the topmost directory there in.

$USER represents the username you have set for your network drive
$PASSWORD is, you guessed it, the password for your network drive

$ROOT_PASSWORD is the system's root password, you don't have to enter this, but if you don't you will have to enter the root password everytime the script runs before it can go onward.

Next up, we'll start backing things up.

Now, normally, we'd launch straight into rsync and just be done with it. But since goofed up time stamps can totally mess up any backup scheme we're going to use a hybrid of rsync and cp.

Since we want a copy of what's on our computer we should make sure the network drive and the local drive are the same. So, we're going to have rsync compare the local drive to the network drive and delete the files on the network drive that are not on the local drive. For this example, we're going to use my documents folder:

Code:

rsync -r --delete /home/shane/docs/ /media/network_drive/docs/

/home/shane/docs is my documents folder, the source.
/media/network_drive/docs/ is my backup, the destination.

-r stands for recursive, this tells rsync to go down into folders to look.
--delete tells it to delete excess files on the destination.

After that's done, we're going to go ahead and backup:

Code:

cp -aupr /home/shane/docs /media/network_drive/

-a stands for archieve, to create a backup.
-u stands for update, this way we'll only be copying files which are newer on the source (our local drive and leave the other files alone).
-r stands for recursive, this tells cp to go down into the folders.
-p is preserve, this makes sure the timestamps stay the same across both the local drive and the network drive.

You can repeat this as many times as you need to with as many different directories as you
like.


Once you're all done you need to take the network drive down:

Code:

echo "Unmounting Network Drive..."
sudo umount /media/network_drive

Of course, make sure to change 'network_drive' to whatever you called your network drive.


Go ahead and save the file, now it is time to set it's permissions so it can be executed by a regular user:::

From the command line

Code:

chown root yourscript
chmod 4755 yourscript

yourscript- is whatever you named the script, make sure you change the command prompt's directory to whereever the script is at.

Next up, we'll set how often you want it to run. This we can do from a graphical interface in GNOME.

That tutorial has been written already, and it is here: https://help.ubuntu.com/community/CronHowto

For some reason, gnome-schedule was not on my start-menu, so I just used the run command to start 'scheduled-tasks'.
 
Old 07-09-2009, 03:08 PM   #5
icmp_request
Member
 
Registered: Jun 2007
Location: 127.0.0.1
Distribution: Changing a lot over time
Posts: 46

Original Poster
Rep: Reputation: 15
Hello shane25119! I thank you for the script but it still mounts my 'mnt' folder as read-only. So the rest of the script I didn't even try. The point is to be able to mount to read and write for a non-root user.

I've decided to continue this discussion in a Forum that I believe that's better for this kind of question:

http://www.linuxquestions.org/questi...8/#post3602555

Admins please feel free to lock this thread.
 
Old 07-09-2009, 08:16 PM   #6
shane25119
Member
 
Registered: Aug 2003
Location: Illinois
Distribution: Linux Mint XFCE
Posts: 647

Rep: Reputation: 52
No worries, I don't really have much idea at this point... but I will be following the new thread.
 
  


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
Mounting CIFS with write permissions alkos333 Slackware 5 03-02-2012 12:16 PM
Granting full read/write permissions to all files for a specific user laserjim Linux - Security 10 01-31-2009 11:17 AM
How can I have: Root has Read-Write, user has read only for the boot filesystem? xmrkite Linux - Software 6 10-16-2008 04:31 AM
Giving user/group permissions to read&write Windows partitions? zaqwe Slackware 3 08-26-2007 11:07 AM
NFS share not mounting with read/write permissions syphoncode.32 Linux - Software 1 06-15-2007 02:46 AM


All times are GMT -5. The time now is 08:56 AM.

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