summaryrefslogtreecommitdiff
path: root/source3/client
diff options
context:
space:
mode:
Diffstat (limited to 'source3/client')
-rwxr-xr-xsource3/client/mount.cifs.c106
1 files changed, 61 insertions, 45 deletions
diff --git a/source3/client/mount.cifs.c b/source3/client/mount.cifs.c
index 55934e04b3..6a7d1e65a1 100755
--- a/source3/client/mount.cifs.c
+++ b/source3/client/mount.cifs.c
@@ -38,7 +38,7 @@
#include <fcntl.h>
#define MOUNT_CIFS_VERSION_MAJOR "1"
-#define MOUNT_CIFS_VERSION_MINOR "4"
+#define MOUNT_CIFS_VERSION_MINOR "5"
#ifndef MOUNT_CIFS_VENDOR_SUFFIX
#define MOUNT_CIFS_VENDOR_SUFFIX ""
@@ -77,7 +77,13 @@ static void mount_cifs_usage(void)
printf("\nMount the remote target, specified as a UNC name,");
printf(" to a local directory.\n\nOptions:\n");
printf("\tuser=<arg>\n\tpass=<arg>\n\tdom=<arg>\n");
- printf("\nOther less commonly used options are described in the manual page");
+ printf("\nLess commonly used options:");
+ printf("\n\tcredentials=<filename>,guest,perm,noperm,setuids,nosetuids,\n\trw,ro,sep=<char>,iocharset=<codepage>,suid,nosuid,exec,noexec");
+ printf("\n\nOptions not needed for servers supporting CIFS Unix extensions (e.g. most Samba versions):");
+ printf("\n\tuid=<uid>,gid=<gid>,dir_mode=<mode>,file_mode=<mode>");
+ printf("\n\nRarely used options:");
+ printf("\n\tport=<tcpport>,rsize=<size>,wsize=<size>,unc=<unc_name>,ip=<ip_address>,dev,nodev");
+ printf("\n\nOptions are described in more detail in the manual page");
printf("\n\tman 8 mount.cifs\n");
printf("\nTo display the version number of the mount helper:");
printf("\n\t%s -V\n",thisprogram);
@@ -246,9 +252,9 @@ static int get_password_from_file(int file_descript, char * filename)
static int parse_options(char * options, int * filesys_flags)
{
char * data;
- char * percent_char = 0;
- char * value = 0;
- char * next_keyword = 0;
+ char * percent_char = NULL;
+ char * value = NULL;
+ char * next_keyword = NULL;
int rc = 0;
if (!options)
@@ -344,6 +350,8 @@ static int parse_options(char * options, int * filesys_flags)
if (!value || !*value) {
printf("target ip address argument missing");
} else if (strnlen(value, 35) < 35) {
+ if(verboseflag)
+ printf("ip address %s override specified\n",value);
got_ip = 1;
} else {
printf("ip address too long\n");
@@ -497,7 +505,7 @@ static int parse_options(char * options, int * filesys_flags)
if(next_keyword)
*next_keyword = ',';
else
- data = 0;
+ data = NULL;
}
return 0;
}
@@ -515,7 +523,7 @@ char * parse_server(char ** punc_name)
if(length > 1023) {
printf("mount error: UNC name too long");
- return 0;
+ return NULL;
}
if (strncasecmp("cifs://",unc_name,7) == 0)
return parse_cifs_url(unc_name+7);
@@ -526,7 +534,7 @@ char * parse_server(char ** punc_name)
if(length < 3) {
/* BB add code to find DFS root here */
printf("\nMounting the DFS root for domain not implemented yet");
- return 0;
+ return NULL;
} else {
if(strncmp(unc_name,"//",2) && strncmp(unc_name,"\\\\",2)) {
/* check for nfs syntax ie server:share */
@@ -542,7 +550,7 @@ char * parse_server(char ** punc_name)
} else {
printf("mount error: improperly formatted UNC name.");
printf(" %s does not begin with \\\\ or //\n",unc_name);
- return 0;
+ return NULL;
}
} else {
continue_unc_parsing:
@@ -553,15 +561,20 @@ continue_unc_parsing:
(share = strchr(unc_name,'\\'))) {
*share = 0; /* temporarily terminate the string */
share += 1;
- host_entry = gethostbyname(unc_name);
+ if(got_ip == 0) {
+ host_entry = gethostbyname(unc_name);
+ }
*(share - 1) = '/'; /* put the slash back */
-/* rc = getipnodebyname(unc_name, AF_INET, AT_ADDRCONFIG ,&rc);*/
+ if(got_ip) {
+ if(verboseflag)
+ printf("ip address specified explicitly\n");
+ return NULL;
+ }
if(host_entry == NULL) {
printf("mount error: could not find target server. TCP name %s not found ", unc_name);
printf(" rc = %d\n",rc);
- return 0;
- }
- else {
+ return NULL;
+ } else {
/* BB should we pass an alternate version of the share name as Unicode */
/* BB what about ipv6? BB */
/* BB add retries with alternate servers in list */
@@ -571,46 +584,46 @@ continue_unc_parsing:
ipaddress_string = inet_ntoa(server_ipaddr);
if(ipaddress_string == NULL) {
printf("mount error: could not get valid ip address for target server\n");
- return 0;
+ return NULL;
}
return ipaddress_string;
}
} else {
/* BB add code to find DFS root (send null path on get DFS Referral to specified server here */
printf("Mounting the DFS root for a particular server not implemented yet\n");
- return 0;
+ return NULL;
}
}
}
}
static struct option longopts[] = {
- { "all", 0, 0, 'a' },
- { "help",0, 0, 'h' },
- { "move",0, 0, 'm' },
- { "bind",0, 0, 'b' },
- { "read-only", 0, 0, 'r' },
- { "ro", 0, 0, 'r' },
- { "verbose", 0, 0, 'v' },
- { "version", 0, 0, 'V' },
- { "read-write", 0, 0, 'w' },
- { "rw", 0, 0, 'w' },
- { "options", 1, 0, 'o' },
- { "type", 1, 0, 't' },
- { "rsize",1, 0, 'R' },
- { "wsize",1, 0, 'W' },
- { "uid", 1, 0, '1'},
- { "gid", 1, 0, '2'},
- { "user",1,0,'u'},
- { "username",1,0,'u'},
- { "dom",1,0,'d'},
- { "domain",1,0,'d'},
- { "password",1,0,'p'},
- { "pass",1,0,'p'},
- { "credentials",1,0,'c'},
- { "port",1,0,'P'},
- /* { "uuid",1,0,'U'}, */ /* BB unimplemented */
- { NULL, 0, 0, 0 }
+ { "all", 0, NULL, 'a' },
+ { "help",0, NULL, 'h' },
+ { "move",0, NULL, 'm' },
+ { "bind",0, NULL, 'b' },
+ { "read-only", 0, NULL, 'r' },
+ { "ro", 0, NULL, 'r' },
+ { "verbose", 0, NULL, 'v' },
+ { "version", 0, NULL, 'V' },
+ { "read-write", 0, NULL, 'w' },
+ { "rw", 0, NULL, 'w' },
+ { "options", 1, NULL, 'o' },
+ { "type", 1, NULL, 't' },
+ { "rsize",1, NULL, 'R' },
+ { "wsize",1, NULL, 'W' },
+ { "uid", 1, NULL, '1'},
+ { "gid", 1, NULL, '2'},
+ { "user",1,NULL,'u'},
+ { "username",1,NULL,'u'},
+ { "dom",1,NULL,'d'},
+ { "domain",1,NULL,'d'},
+ { "password",1,NULL,'p'},
+ { "pass",1,NULL,'p'},
+ { "credentials",1,NULL,'c'},
+ { "port",1,NULL,'P'},
+ /* { "uuid",1,NULL,'U'}, */ /* BB unimplemented */
+ { NULL, 0, NULL, 0 }
};
int main(int argc, char ** argv)
@@ -767,12 +780,15 @@ int main(int argc, char ** argv)
get_password_from_file(0, getenv("PASSWD_FILE"));
}
+ if (orgoptions && parse_options(orgoptions, &flags))
+ return -1;
+
ipaddr = parse_server(&share_name);
- if(ipaddr == NULL)
+ if((ipaddr == NULL) && (got_ip == 0)) {
+ printf("No ip address specified and hostname not found\n");
return -1;
+ }
- if (orgoptions && parse_options(orgoptions, &flags))
- return -1;
/* BB save off path and pop after mount returns? */
resolved_path = malloc(PATH_MAX+1);