summaryrefslogtreecommitdiff
path: root/mount.cifs.c
AgeCommit message (Collapse)AuthorFilesLines
2011-02-08mount.cifs: reacquire CAP_DAC_READ_SEARCH before calling mount(2)Jeff Layton1-2/+8
It's possible that the user is trying to mount onto a directory to which he doesn't have execute perms. If that's the case then the mount will currently fail. Fix this by reenabling CAP_DAC_READ_SEARCH before calling mount(2). That will ensure that the kernel's permissions check for this is bypassed. Reported-by: Erik Logtenberg <erik@logtenberg.eu> Signed-off-by: Jeff Layton <jlayton@samba.org> Reviewed-by: Steve French <sfrench@us.ibm.com>
2011-02-01mount.cifs: fix possible use of uninitialized variableJeff Layton1-1/+1
It's possible to "goto return_i" in this function at several points before line_buf is set. At that point, the NULL pointer check won't work correctly and we can end up with a SIGSEGV. Signed-off-by: Jeff Layton <jlayton@samba.org>
2011-01-31mount.cifs: don't try to alter mtab if it's a symlinkJeff Layton1-1/+1
Some distros replace /etc/mtab with a symlink to /proc/mounts. In that situation, mount.cifs will hang for a while trying to lock the mtab. /bin/mount checks to see if the mtab is a symlink. If it is or if a stat() call on it fails, it doesn't try to to update the mtab. Have mount.cifs do the same. Signed-off-by: Jeff Layton <jlayton@samba.org>
2011-01-14mount.cifs: add cruid= mount optionJeff Layton1-2/+38
Allow admins to pass in a username for the cruid= mount option. Signed-off-by: Jeff Layton <jlayton@samba.org> Reviewed-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com>
2011-01-14mount.cifs: clean up handling of uid= and gid=Jeff Layton1-46/+52
The handling of these options is quite convoluted. Change it so that these options are stored as numbers and then appended to the option strings. Signed-off-by: Jeff Layton <jlayton@samba.org> Reviewed-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com>
2010-10-08mount.cifs: reinstate ip= as an override for address resolutionJeff Layton1-1/+5
The manpage says: ip=arg sets the destination IP address. This option is set automatically if the server name portion of the requested UNC name can be resolved so rarely needs to be specified by the user. ...but recent changes have made it not work anymore as an override if someone specifies an ip= option as part of the mount options. Reinstate that behavior by copying the ip= option verbatim into the addrlist of the parsed options struct and then skipping the name resolution. That should allow the ip= option to pass unadulterated to the kernel. Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-08-20cifs-utils: moving resolve_host into separate fileIgor Druzhinin1-92/+13
The resolve_host routine from mount.cifs is carried out in separate file and appropriate corrections are made. Signed-off-by: Igor Druzhinin <jaxbrigs@gmail.com>
2010-08-04mount.cifs: remove redundant error assignmentSuresh Jayaraman1-4/+4
Avoid setting error code twice by moving error handling out of add_mtab_exit block. We already set error code and report error in other places. Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
2010-07-27mount.cifs: add 'fsc' mount option to the usage help textSuresh Jayaraman1-1/+1
Add 'fsc' mount option to the 'Less commonly used options' section of mount.cifs usage help text. As with the previous patch, this one too could be queued and considered once the local caching patches gets merged upstream. Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
2010-07-27mount.cifs: handle the "mand" and "nomand" mount options (try #2)Jeff Layton1-2/+12
These are filesystem-independent mount options that get passed to mount.cifs too. Handle them appropriately by enabling and disabling MS_MANDLOCK and not handing them off to the kernel. Also, don't set MS_MANDLOCK by default. There's no reason to ask the kernel to enforce mandatory locking by default. This also matches up better with the way that "mand" is set in the mtab. Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-07-27mount.cifs: ignore the "_netdev" mount optionJeff Layton1-0/+5
This mount options is used to clue in init scripts that the filesystem shouldn't be mounted until networking is available. /bin/mount also passes that option to the filesystem however, and cifs currently chokes on it. mount.nfs ignores this option -- have mount.cifs do the same. Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-07-07mount.cifs: switch to using _PATH_MNTTAB and paths.hJeff Layton1-4/+4
The code currently uses fstab.h and _PATH_FSTAB, but uClibc apparently doesn't have that header. It does have paths.h and _PATH_MNTTAB however and so does glibc, so use that instead. Fixes samba bug #7539. Reported-and-Tested-by: Armin Kuster <linux@kama-aina.net> Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-06-16mount.cifs: use original device name as-is for mtabJeff Layton1-1/+1
We don't want to alter the device name in any way for the mtab as /bin/umount depends on the string being identical for user mounts. Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-06-06mount.cifs: accept all supported values for dir_modeScott Lovenberg1-1/+1
The option parsing function now accepts all values for 'dir_mode' that are supported by the kernel side code. Signed-off-by: Scott Lovenberg <scott.lovenberg@gmail.com>
2010-05-30mount.cifs: fix parsing of "cred=" optionJeff Layton1-0/+2
When the mount option parsing was cleaned up recently, the detection of the "cred=" option was dropped. Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-05-14mount.cifs: cosmetic alignment patchScott Lovenberg1-3/+3
Align CRED_ macro values to keep style consistent with last patch. Signed-off-by: Scott Lovenberg <scott.lovenberg@gmail.com>
2010-05-14mount.cifs: clean up option parsingScott Lovenberg1-74/+189
Moved option string parsing to function parse_opt_token(char*). Main loop in parse_options(const char*, struct parsed_mount_info*) transplanted to a switch block. The parsing function folds common options to a single macro: 1.) 'unc','target', and 'path' -> 'OPT_UNC' 2.) 'dom*' and 'workg*' -> 'OPT_DOM' 3.) 'nobrl' and 'nolock' -> 'OPT_NO_LOCK' Kept 'fmask' and 'dmask' (OPT_FMASK, OPT_DMASK), which fall through to 'file_mode' and 'dir_mode' in the main loop. Signed-off-by: Scott Lovenberg <scott.lovenberg@gmail.com>
2010-05-14mount.cifs: unitialized variable in cred parsing error pathSteve French1-4/+4
Signed-off-by: Steve French <smfrench@gmail.com> Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-05-11mount.cifs: turn into a multicall binary for smb2Steve French1-15/+68
mount.smb2 has different help (many fewer mount options) and different fsname, but otherwise can reuse all of the good work Jeff did on mount.cifs. This patch allow mount.cifs to detect if run as mount.smb2 (to display different help and fsname). Signed-off-by: Steve French <smfrench@gmail.com>
2010-05-11mount.cifs: removed magic number for max username in parse_optionsScott Lovenberg1-1/+5
Replaced max username in parse_options with the sum of its potential parts for "domain/user%password" formatted values. Note that forward slashes still expand to a double back slash in the parse_username function, though. Signed-off-by: Scott Lovenberg <scott.lovenberg@gmail.com>
2010-05-02mount.cifs: strip leading delimiter off of prefixpath optionJeff Layton1-0/+5
...the kernel doesn't expect to see it and it causes a regression when mounting some UNCs. Reported-by: Ales Zelinka <azelinka@redhat.com> Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-04-28mount.cifs: fix parsing of password in parse_usernamecifs-utils-4.4Jeff Layton1-1/+2
Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-04-25mount.cifs: continued cleanup of open_cred_file and zero out bufferScott Lovenberg1-52/+78
The parsing for values has been moved to its own function and is a bit cleaner. Temporary buffers are zeroed out before being freed to ensure passwords/credentials aren't left in released memory. Signed-off-by: Scott Lovenberg <scott.lovenberg@gmail.com> Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-04-23mount.cifs: clean up credential file parsingScott Lovenberg1-46/+32
Remove magic numbers, redundant code and extra variables from open_cred_file(). Remove check for domain length since strlcpy is safe from buffer overflows. Signed-off-by: Scott Lovenberg <scott.lovenberg@gmail.com>
2010-04-17mount.cifs: remove unneeded newline in verbose outputJeff Layton1-1/+1
Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-04-14mount.cifs: check for NULL pointer before calling strchr()Jeff Layton1-3/+5
mount.cifs calls strchr on currentaddress, which may be a NULL pointer. Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-04-12cifs: enable CAP_DAC_READ_SEARCH before chdir() and realpath() callsJeff Layton1-0/+6
It's possible that root won't have privileges to chdir or evaluate the paths without that capability. Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-04-06mount.cifs: fix capability issues when libcap isn't presentJeff Layton1-14/+17
...some #defines are missing in that case. This fixes the build for all possible libcap/libcap-ng availability scenarios. Signed-off-by: Jeff Layton <jlayton@redhat.com>
2010-04-06mount.cifs: make credentials file parameters consistent with mount optionsScott Lovenberg1-3/+3
This patch makes the mount.cifs credentials file parameters consistent with the command line parameters to remove ambiguity between the command line parameter format and the credentials file format. That is, it parses for both short and long form of the 'username', 'password', and 'domain' parameters. This patch is against the current cifs-utils-4.2. I'm also thinking of adding a second patch that allows for parsing a "domain/user", "domain%user" and "domain/user%password" formats as allowed from the command line. Signed-off-by: Scott Lovenberg <scott.lovenberg@gmail.com>
2010-04-05mount.cifs: restrict capabilities furtherJeff Layton1-26/+29
Only the parent process will ever need CAP_DAC_OVERRIDE. The child can get by with CAP_DAC_READ_SEARCH. Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-04-05mount.cifs: properly prune the capabilities bounding setJeff Layton1-1/+36
...libcap-ng does this in a much easier fashion. If that's not available, then we have to do it manually. Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-04-04mount.cifs: use libcap-ng to manage capabilitiesJeff Layton1-0/+43
...in preference to libcap if it's available. Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-04-03mount.cifs: fix toggle_cap_dac_overrideJeff Layton1-7/+6
...it clears the capability set completely, which it shouldn't do. It also doesn't call cap_set_proc to make the new capability set active. Signed-off-by: Jeff Layton <jlayton@redhat.com>
2010-04-03mount.cifs: only enable CAP_DAC_OVERRIDE when neededJeff Layton1-66/+144
When dropping capabilities, drop CAP_DAC_OVERRIDE from the effective set but not the permitted. When we need to open credential or password files, make it effective again and drop it after the open completes. This reduces CAP_DAC_OVERRIDE exposure. Signed-off-by: Jeff Layton <jlayton@redhat.com>
2010-04-02mount.cifs: if real uid is 0, child must keep CAP_DAC_OVERRIDEJeff Layton1-7/+10
...otherwise, root may not be able to read credential files. The ideal thing would be to remove it from the effective set, and only turn it on when needed, but for now this should fix the immediate problem. Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-04-02cifs-utils: bump version to 4.2cifs-utils-4.2Jeff Layton1-0/+1
- fix URL's and email addresses - update copyright notices Signed-off-by: Jeff Layton <jlayton@samba.org>
2010-04-01mount.cifs: re-enable setuid usageJeff Layton1-27/+18
Now that mount.cifs is safe(r) we don't need to disable setuid capability by default. Signed-off-by: Jeff Layton <jlayton@redhat.com>
2010-04-01mount.cifs: drop capabilities if libcap is availableJeff Layton1-0/+68
Might as well be as safe as possible. Have child drop all capabilities, and have the parent drop all but CAP_SYS_ADMIN (needed for mounting) and CAP_DAC_OVERRIDE (needed in case mtab isn't writable by root). We might even eventually consider being clever and dropping CAP_DAC_OVERRIDE when root has access to the mtab. Signed-off-by: Jeff Layton <jlayton@redhat.com>
2010-04-01mount.cifs: guard against signals by unprivileged usersJeff Layton1-9/+38
If mount.cifs is setuid root, then the unprivileged user who runs the program can send the mount.cifs process a signal and kill it. This is not a huge problem unless we happen to be updating the mtab at the time, in which case the mtab lockfiles might not get cleaned up. To remedy this, have the privileged mount.cifs process set its real uid to the effective uid (usually, root). This prevents unprivileged users from being able to signal the process. While we're at it, also mask off signals while we're updating the mtab. This leaves a SIGKILL by root as the only way to interrupt the mtab update, but there's really nothing we can do about that. Signed-off-by: Jeff Layton <jlayton@redhat.com>
2010-04-01mount.cifs: introduce privilege separationJeff Layton1-16/+80
Much of the mount option parsing and other activities can be done by an unprivileged process. Allocate the parsed_mount_info struct as an anonymous mmap() segment and then fork to do the actual mount option parsing. The child can then drop root privileges before populating the parsed_mount_info struct. The parent waits for the child to exit and then continues the mount process based on the child's exit status. Signed-off-by: Jeff Layton <jlayton@redhat.com>
2010-04-01mount.cifs: move nomtab, fakemnt, and verboseflag flags to parsed_mount_infoJeff Layton1-13/+13
Signed-off-by: Jeff Layton <jlayton@redhat.com>
2010-04-01mount.cifs: move assembly of parsed_mount_info to separate functionJeff Layton1-94/+110
...later, we'll want to introduce privilege separation so make this a separate function to facilitate that. Signed-off-by: Jeff Layton <jlayton@redhat.com>
2010-04-01mount.cifs: run mount.cifs through LindentJeff Layton1-282/+336
...code cleanup Signed-off-by: Jeff Layton <jlayton@redhat.com>
2010-04-01mount.cifs: move mtab adding code to separate functionJeff Layton1-57/+71
Signed-off-by: Jeff Layton <jlayton@redhat.com>
2010-04-01mount.cifs: clean up command-line optionsJeff Layton1-96/+3
The mount.cifs command apparently tries to take a ton of command-line options. Many of these will never be passed to mount.cifs by /bin/mount. Others are more appropriately specified as mount options. In both cases, there are a lot of options in the switch statement that are not listed in the optstring, and there are characters in the optstring that are not dealt with by the switch statement. Other options are poorly wired to the rest of the code and don't actually do anything. Clean it up by removing all but the ones that are likely to ever be used. Signed-off-by: Jeff Layton <jlayton@redhat.com>
2010-04-01mount.cifs: reassemble device name from piecesJeff Layton1-8/+30
Signed-off-by: Jeff Layton <jlayton@redhat.com>
2010-04-01mount.cifs: clean up setting of password fieldJeff Layton1-109/+84
Add a function to set and escape the password properly. Signed-off-by: Jeff Layton <jlayton@redhat.com>
2010-04-01mount.cifs: eliminate "legacy" setuid behaviorJeff Layton1-81/+9
This behavior is demonstrably unsafe and not something we want to support going forward. Signed-off-by: Jeff Layton <jlayton@redhat.com>
2010-04-01mount.cifs: eliminate some unneeded flags in parsed_mount_infoJeff Layton1-6/+1
Signed-off-by: Jeff Layton <jlayton@redhat.com>
2010-04-01mount.cifs: parse unc into separate fieldsJeff Layton1-196/+179
The UNC is currently handled as a single string and mount.cifs will just munge it whenever it needs to change the delimiter type or uppercase it, etc. This is tricky to handle correctly and means that we often need to keep track of what's already been changed. Instead of doing this, just track the pieces of the UNC in separate fields in the parsed_mount_info, and then use those pieces to build strings as needed. Signed-off-by: Jeff Layton <jlayton@redhat.com>