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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
03-19-2005, 02:48 PM
|
#1
|
|
Member
Registered: Jan 2004
Location: Mississippi
Distribution: Gentoo 2006.1, openSuSe 10.2
Posts: 43
Rep:
|
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.
|
|
|
|
03-19-2005, 03:21 PM
|
#2
|
|
Member
Registered: Dec 2004
Location: Ohio
Distribution: Fedora Core 3
Posts: 125
Rep:
|
mount -t smbfs -ousername=blah,password=blah //machinename/share /mnt/location
|
|
|
|
03-19-2005, 03:59 PM
|
#3
|
|
Member
Registered: Jan 2004
Location: Mississippi
Distribution: Gentoo 2006.1, openSuSe 10.2
Posts: 43
Original Poster
Rep:
|
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
|
|
|
|
03-19-2005, 06:16 PM
|
#4
|
|
Member
Registered: Dec 2004
Location: Ohio
Distribution: Fedora Core 3
Posts: 125
Rep:
|
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*
|
|
|
|
03-19-2005, 08:27 PM
|
#5
|
|
Member
Registered: Jan 2004
Location: Mississippi
Distribution: Gentoo 2006.1, openSuSe 10.2
Posts: 43
Original Poster
Rep:
|
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.
|
|
|
|
03-19-2005, 08:44 PM
|
#6
|
|
Member
Registered: Dec 2004
Location: Ohio
Distribution: Fedora Core 3
Posts: 125
Rep:
|
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.
|
|
|
|
03-19-2005, 10:03 PM
|
#7
|
|
Member
Registered: Jan 2004
Location: Mississippi
Distribution: Gentoo 2006.1, openSuSe 10.2
Posts: 43
Original Poster
Rep:
|
 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...
|
|
|
|
03-19-2005, 10:32 PM
|
#8
|
|
Member
Registered: Dec 2004
Location: Ohio
Distribution: Fedora Core 3
Posts: 125
Rep:
|
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.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:32 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|