LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 03-19-2005, 03:48 PM   #1
cdavidson
Member
 
Registered: Jan 2004
Location: Mississippi
Distribution: Gentoo 2006.1, openSuSe 10.2
Posts: 43

Rep: Reputation: 15
how to make cifs run as root


I've been Googling for a while now and I haven't found the answer to this yet, so I was hoping the good folks at LQ could lend a hand. I'm working on mounting shares from a W2K3 server on my FC3 workstation. I can mount the shares with no problem by executing:

mount -t cifs //servername/sharename /mnt/windows -o user=username,password=pwd

from a terminal as root. I put the same line in my /etc/fstab file to execute at bootup, but I get a message saying "line number x is bad in /etc/fstab". I'm assuming that this is because the command must be run as root, which it is not doing at boot up. My questions are these:

1. How can I make the above command run as root at bootup in my /etc/fstab?
2. I want to take my UN and PWD out of the command and use a credentials file. I created a file, /etc/credentials, with the syntax of:

username=un
password=pwd

I tried executing:

mount -t cifs //servername/sharename /mnt/windows -o credentials=/etc/credentials

from a terminal as root, but my syntax is off somewhere, and the man pages weren't much help to me. Once I can get the command to run as root at bootup, what should the proper syntax be to use the command with a credentials file? Thanks in advance.
 
Old 03-19-2005, 04:21 PM   #2
cylix
Member
 
Registered: Dec 2004
Location: Ohio
Distribution: Fedora Core 3
Posts: 125

Rep: Reputation: 15
mount -t smbfs -ousername=blah,password=blah //machinename/share /mnt/location
 
Old 03-19-2005, 04:59 PM   #3
cdavidson
Member
 
Registered: Jan 2004
Location: Mississippi
Distribution: Gentoo 2006.1, openSuSe 10.2
Posts: 43

Original Poster
Rep: Reputation: 15
Thanks for the reply cylix. I started out trying to use SMBFS, but there is apparently a problem between it and W2K3 shares. Whenever I try to mount the shares using SMBFS, I get the following:

cli_negprot: SMB signing is mandatory and we have disabled it.
17906: protocol negotiation failed
SMB connection failed

I have added "client signing=yes" to my globals in my smb.conf file, but that doesn't fix the problem. After a long conversation with Google, it told me to use cifs. This would be perfect if I could just figure out how to make it run as root at bootup in my /etc/fstab. Anyone got any ideas?

CD
 
Old 03-19-2005, 07:16 PM   #4
cylix
Member
 
Registered: Dec 2004
Location: Ohio
Distribution: Fedora Core 3
Posts: 125

Rep: Reputation: 15
Gotcha,

Must have misread that... don't worry... I'm going to correct my mistake or at least try..

If you are getting an error message in your logs about needing root access to mount.

chmod +s /path/to/mount.cifs

If you had to put in your own mount.cifs utility you probably want to make sure it's in the executable path or just along side the mount utility. Mount will call the mount.whatever and it doesn't need compiled against it. (checked just to be sure)

So your fstab line should look like this... I use vi so no newline spill over occurs. *fstab varies a bit from the mount stuff... so you need to make sure you make it all happy.

//share/name /mount cifs defaults,credentials=/path/to/credentials/file 0 0

note, you will absolutely need to make sure it runs as root before hand.

mount -t cifs -ocredentials=/path/to/file //share/name /mnt

At least, in my case I had to use smbfs because I have no 2003 box lying around. *I know, I need to sit down with it*
 
Old 03-19-2005, 09:27 PM   #5
cdavidson
Member
 
Registered: Jan 2004
Location: Mississippi
Distribution: Gentoo 2006.1, openSuSe 10.2
Posts: 43

Original Poster
Rep: Reputation: 15
thanks again cylix...

I ran "chmod +s /sbin/mount.cifs" on my system. I got the following syntax to work from a terminal as root:

mount -t cifs //server/share /mnt/windows -o credentials=/etc/credentials

I also made /etc/credentials readable only by root, chmod 700 /etc/credentials, as root. During bootup, i'm still getting the error message "line 9 in /etc/fstab is bad", ditto for the other 3 mount commands in my fstab file. Is there not a way to make fstab execute as root at startup, or is that not even my problem? Is there another startup file, .bashrc maybe???, that i can add the commands to that will execute properly?

I know...I know I'm a , I'm working on it though.
 
Old 03-19-2005, 09:44 PM   #6
cylix
Member
 
Registered: Dec 2004
Location: Ohio
Distribution: Fedora Core 3
Posts: 125

Rep: Reputation: 15
Someone didn't look at my fstab line closely.

It's not a root related issue (I don't know why mount wouldn't be running as root, but I thought to use that just in case)

If you fire up vi /etc/fstab it should highlight elements not syntactly correct. (at least if you have ansi color on and it's really vim and not that aged vi)

It should be something precisely like this....

"//servername/share /mnt/point cifs defaults,credentials=/etc/credentials 0 0"

The only difference between here and my fstab, all spaces are tabs except when I get to 0 0, but any whitespace should be fine. Also, make sure the target directory exists.

+S is the setuid bit, so when the binary is executed it is ran as the owner of the file. (in this case we did setuid on both owner and group, which was a little overboard) Just make sure mount.cifs is owned by root and if that is still a worry, you could always do the same for mount (just for testing now)

But the error you are describing I reproduced quite well on my first stab entries. It's a syntax error purely.

Additionally, you don't have to reboot.

Just issue a mount -a

This will mount all things listed in the fstab file.
 
Old 03-19-2005, 11:03 PM   #7
cdavidson
Member
 
Registered: Jan 2004
Location: Mississippi
Distribution: Gentoo 2006.1, openSuSe 10.2
Posts: 43

Original Poster
Rep: Reputation: 15
Many thanks cylix, that did the trick . One question though ...I was always able to succesfully execute:

mount -t cifs //server/share /mnt/windows -o credentials=/etc/credentials

from the terminal. Is there a specific reason that the same syntax wouldn't work from fstab, possibly that fstab just has to have that certain syntax? Either way, thanks again...
 
Old 03-19-2005, 11:32 PM   #8
cylix
Member
 
Registered: Dec 2004
Location: Ohio
Distribution: Fedora Core 3
Posts: 125

Rep: Reputation: 15
The short answer is yes....

when called by sysinit, mount -a and a few other options are all that are called.

Simply, when mount was written, the code that parses the /etc/fstab file is different. Certain things are implicit *like not needing to mention mount* and all the options are parsed by column. (or really white space)

So there are literally two different sections of code for applying options. One section deals with information coming in as arguements on the command line and another section is called when the -a option is provided.

so when parsing options by file, you can save a great deal of time to simply knowing knowing where your data is going to be. Additionally, mount isn't the only tool which uses the fstab file. Utilities to dump the file system to archive also reference the fstab file. ala 0 0 (which are actually directives for the dump utility and any one else who cares to use them).

This is advantageous because you can now store meta parameters for other applications in a bit of a central location.

There are other applications for this as well, but I think this covers the basics.

I had to write a utility that accepted input from standard in, arguements and a configuration file. Trust me, I saved time wherever I could.
 
  


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
How do I make a command run as root at boot up under Fedora 3? versaulis Linux - Software 5 02-10-2005 07:22 PM
I have to ssh -l root to run root processes!? paul.nel Red Hat 3 11-15-2004 12:55 PM
how do I make sure that the user that is going to run the script is a root user??? nikold01 Linux - General 3 09-10-2004 08:54 AM
using CIFS witukind Linux - Networking 0 12-18-2003 06:31 PM
LimeWire installed as root, can't run if not root sulzla Linux - Newbie 1 07-01-2003 08:48 PM


All times are GMT -5. The time now is 06:45 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration