From 31e5116a88b57d20ba8017e779345f8e2108c8d7 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 14 Feb 2008 12:03:32 -0500 Subject: Revert "Merge in J.Layton patch and resolve conflict." This reverts commit 6b1a118eaaab405eeef0cf3c0488a2747af562ba. We found that this patch does not play well with currently released cifs.ko code, so after discussions with Jeff Layton and Steve french we decided it is best to back it off and re-think a better approach. Jeff will send new patches later, but for now it is better to just revert to the previous code (This used to be commit c5b7d538ecfa93377ff20704633ac57dbf8dd530) --- source3/client/mount.cifs.c | 90 +++++++++++++-------------------------------- 1 file changed, 26 insertions(+), 64 deletions(-) (limited to 'source3/client/mount.cifs.c') diff --git a/source3/client/mount.cifs.c b/source3/client/mount.cifs.c index 79f402a7d4..3acf2154b6 100644 --- a/source3/client/mount.cifs.c +++ b/source3/client/mount.cifs.c @@ -62,8 +62,6 @@ #define MS_BIND 4096 #endif -#define MAX_UNC_LEN 1024 - #define CONST_DISCARD(type, ptr) ((type) ((void *) (ptr))) const char *thisprogram; @@ -75,6 +73,7 @@ static int got_ip = 0; static int got_unc = 0; static int got_uid = 0; static int got_gid = 0; +static int free_share_name = 0; static char * user_name = NULL; static char * mountpassword = NULL; char * domain_name = NULL; @@ -831,27 +830,17 @@ static char * check_for_domain(char **ppuser) return domainnm; } -/* replace all occurances of "from" in a string with "to" */ -static void replace_char(char *string, char from, char to) -{ - while (string) { - string = strchr(string, from); - if (string) - *string = to; - } -} - /* Note that caller frees the returned buffer if necessary */ static char * parse_server(char ** punc_name) { char * unc_name = *punc_name; - int length = strnlen(unc_name, MAX_UNC_LEN); + int length = strnlen(unc_name,1024); char * share; char * ipaddress_string = NULL; struct hostent * host_entry = NULL; struct in_addr server_ipaddr; - if(length > (MAX_UNC_LEN - 1)) { + if(length > 1023) { printf("mount error: UNC name too long"); return NULL; } @@ -870,6 +859,7 @@ static char * parse_server(char ** punc_name) /* check for nfs syntax ie server:share */ share = strchr(unc_name,':'); if(share) { + free_share_name = 1; *punc_name = (char *)malloc(length+3); if(*punc_name == NULL) { /* put the original string back if @@ -877,9 +867,9 @@ static char * parse_server(char ** punc_name) *punc_name = unc_name; return NULL; } + *share = '/'; strncpy((*punc_name)+2,unc_name,length); - free(unc_name); unc_name = *punc_name; unc_name[length+2] = 0; goto continue_unc_parsing; @@ -890,21 +880,18 @@ static char * parse_server(char ** punc_name) } } else { continue_unc_parsing: - unc_name[0] = '\\'; - unc_name[1] = '\\'; + unc_name[0] = '/'; + unc_name[1] = '/'; unc_name += 2; - - /* convert any '/' in unc to '\\' */ - replace_char(unc_name, '/', '\\'); - - if ((share = strchr(unc_name,'\\'))) { + if ((share = strchr(unc_name, '/')) || + (share = strchr(unc_name,'\\'))) { *share = 0; /* temporarily terminate the string */ share += 1; if(got_ip == 0) { host_entry = gethostbyname(unc_name); } - *(share - 1) = '\\'; /* put delimiter back */ - if ((prefixpath = strchr(share, '\\'))) { + *(share - 1) = '/'; /* put the slash back */ + if ((prefixpath = strchr(share, '/'))) { *prefixpath = 0; /* permanently terminate the string */ if (!strlen(++prefixpath)) prefixpath = NULL; /* this needs to be done explicitly */ @@ -969,25 +956,6 @@ static struct option longopts[] = { { NULL, 0, NULL, 0 } }; -/* convert a string to uppercase. return false if the string - * wasn't ASCII or was a NULL ptr */ -static int -uppercase_string(char *string) -{ - if (!string) - return 0; - - while (*string) { - /* check for unicode */ - if ((unsigned char) string[0] & 0x80) - return 0; - *string = toupper((unsigned char) *string); - string++; - } - - return 1; -} - int main(int argc, char ** argv) { int c; @@ -1000,7 +968,6 @@ int main(int argc, char ** argv) char * options = NULL; char * resolved_path = NULL; char * temp; - char * dev_name; int rc; int rsize = 0; int wsize = 0; @@ -1037,16 +1004,8 @@ int main(int argc, char ** argv) printf(" node: %s machine: %s sysname %s domain %s\n", sysinfo.nodename,sysinfo.machine,sysinfo.sysname,sysinfo.domainname); #endif */ if(argc > 2) { - dev_name = argv[1]; - share_name = strndup(argv[1], MAX_UNC_LEN); - if (share_name == NULL) { - fprintf(stderr, "%s: %s", argv[0], strerror(ENOMEM)); - exit(1); - } + share_name = argv[1]; mountpoint = argv[2]; - } else { - mount_cifs_usage(); - exit(1); } /* add sharename in opts string as unc= parm */ @@ -1186,7 +1145,7 @@ int main(int argc, char ** argv) } } - if((argc < 3) || (dev_name == NULL) || (mountpoint == NULL)) { + if((argc < 3) || (share_name == NULL) || (mountpoint == NULL)) { mount_cifs_usage(); exit(1); } @@ -1344,12 +1303,10 @@ mount_retry: } if(verboseflag) printf("\nmount.cifs kernel mount options %s \n",options); - - /* convert all '\\' to '/' so that /proc/mounts looks pretty */ - replace_char(dev_name, '\\', '/'); - - if(mount(dev_name, mountpoint, "cifs", flags, options)) { + if(mount(share_name, mountpoint, "cifs", flags, options)) { /* remember to kill daemon on error */ + char * tmp; + switch (errno) { case 0: printf("mount failed but no error number set\n"); @@ -1360,9 +1317,12 @@ mount_retry: case ENXIO: if(retry == 0) { retry = 1; - if (uppercase_string(dev_name) && - uppercase_string(share_name) && - uppercase_string(prefixpath)) { + tmp = share_name; + while (*tmp && !(((unsigned char)tmp[0]) & 0x80)) { + *tmp = toupper((unsigned char)*tmp); + tmp++; + } + if(!*tmp) { printf("retrying with upper case share name\n"); goto mount_retry; } @@ -1376,7 +1336,7 @@ mount_retry: } else { pmntfile = setmntent(MOUNTED, "a+"); if(pmntfile) { - mountent.mnt_fsname = dev_name; + mountent.mnt_fsname = share_name; mountent.mnt_dir = mountpoint; mountent.mnt_type = CONST_DISCARD(char *,"cifs"); mountent.mnt_opts = (char *)malloc(220); @@ -1436,6 +1396,8 @@ mount_exit: free(resolved_path); } - free(share_name); + if(free_share_name) { + free(share_name); + } return rc; } -- cgit From d88e40106f2864e0e105b5d4fe7c25c577df8643 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 22 Feb 2008 14:10:28 -0500 Subject: Make sure mount.cifs.c compiles on Fedora 9 with gcc 4.3 (This used to be commit ce57d388251063c22f89680e9d1c2129d9879975) --- source3/client/mount.cifs.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/client/mount.cifs.c') diff --git a/source3/client/mount.cifs.c b/source3/client/mount.cifs.c index 3acf2154b6..44614f6e8a 100644 --- a/source3/client/mount.cifs.c +++ b/source3/client/mount.cifs.c @@ -37,6 +37,7 @@ #include #include #include +#include #define MOUNT_CIFS_VERSION_MAJOR "1" #define MOUNT_CIFS_VERSION_MINOR "11" -- cgit From 90ad42fad3b59384953faff30925affb32677e03 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 25 Feb 2008 09:51:33 +0100 Subject: Fix confusing error message -- bug 5252 Thanks to Walter Franzini (This used to be commit 19de47fef1b35c47885acc40760a232e4643079c) --- source3/client/mount.cifs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source3/client/mount.cifs.c') diff --git a/source3/client/mount.cifs.c b/source3/client/mount.cifs.c index 44614f6e8a..c68c9ee7f7 100644 --- a/source3/client/mount.cifs.c +++ b/source3/client/mount.cifs.c @@ -205,8 +205,10 @@ static int open_cred_file(char * file_name) /* go past equals sign */ temp_val++; for(length = 0;length<4087;length++) { - if(temp_val[length] == '\n') + if ((temp_val[length] == '\n') + || (temp_val[length] == '\0')) { break; + } } if(length > 4086) { printf("mount.cifs failed due to malformed username in credentials file"); @@ -229,7 +231,7 @@ static int open_cred_file(char * file_name) /* go past equals sign */ temp_val++; for(length = 0;length<65;length++) { - if(temp_val[length] == '\n') + if(temp_val[length] == '\n' || temp_val[length] == '\0') break; } if(length > 64) { @@ -258,7 +260,7 @@ static int open_cred_file(char * file_name) if(verboseflag) printf("\nDomain %s\n",temp_val); for(length = 0;length<65;length++) { - if(temp_val[length] == '\n') + if(temp_val[length] == '\n' || temp_val[length] == '\0') break; } if(length > 64) { -- cgit From c7522804a57e839334e8165c8a2f14d1948ff450 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 25 Feb 2008 09:55:53 +0100 Subject: Do the formatting change in all 3 places :-) (This used to be commit d32066eaef1d09ec41fd5365e18eacd93e485d53) --- source3/client/mount.cifs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3/client/mount.cifs.c') diff --git a/source3/client/mount.cifs.c b/source3/client/mount.cifs.c index c68c9ee7f7..e73d90859c 100644 --- a/source3/client/mount.cifs.c +++ b/source3/client/mount.cifs.c @@ -231,8 +231,10 @@ static int open_cred_file(char * file_name) /* go past equals sign */ temp_val++; for(length = 0;length<65;length++) { - if(temp_val[length] == '\n' || temp_val[length] == '\0') + if ((temp_val[length] == '\n') + || (temp_val[length] == '\0')) { break; + } } if(length > 64) { printf("mount.cifs failed: password in credentials file too long\n"); @@ -260,8 +262,10 @@ static int open_cred_file(char * file_name) if(verboseflag) printf("\nDomain %s\n",temp_val); for(length = 0;length<65;length++) { - if(temp_val[length] == '\n' || temp_val[length] == '\0') - break; + if ((temp_val[length] == '\n') + || (temp_val[length] == '\0')) { + break; + } } if(length > 64) { printf("mount.cifs failed: domain in credentials file too long\n"); -- cgit