r6514: Allow domain= to be specified in credentials file. Fix umount.cifs help, allow...
authorSteve French <sfrench@samba.org>
Thu, 28 Apr 2005 22:28:11 +0000 (22:28 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:56:44 +0000 (10:56 -0500)
else's mount
(This used to be commit ed27740397817c1f1b14ba187139c877dbf22168)

source3/client/mount.cifs.c
source3/client/umount.cifs.c

index 7ac4291f17de6157666f307c944fb6a5465968bc..9c0f582d85fd2e0617d3f49bfd1b0d8cac505062 100755 (executable)
@@ -39,7 +39,7 @@
 #include <fcntl.h>
 
 #define MOUNT_CIFS_VERSION_MAJOR "1"
-#define MOUNT_CIFS_VERSION_MINOR "7"
+#define MOUNT_CIFS_VERSION_MINOR "8"
 
 #ifndef MOUNT_CIFS_VENDOR_SUFFIX
 #define MOUNT_CIFS_VENDOR_SUFFIX ""
@@ -185,13 +185,41 @@ static int open_cred_file(char * file_name)
                                        } else
                                                memset(mountpassword,0,64);
                                        if(mountpassword) {
-                                               /* BB add handling for commas in password here */
                                                strncpy(mountpassword,temp_val,length);
                                                got_password = 1;
                                        }
                                }
                        }
-               }
+                } else if (strncasecmp("domain",line_buf+i,6) == 0) {
+                        temp_val = strchr(line_buf+i,'=');
+                        if(temp_val) {
+                                /* go past equals sign */
+                                temp_val++;
+                               if(verboseflag)
+                                       printf("\nDomain %s\n",temp_val);
+                                for(length = 0;length<65;length++) {
+                                        if(temp_val[length] == '\n')
+                                                break;
+                                }
+                                if(length > 64) {
+                                        printf("mount.cifs failed: domain in credentials file too long\n");
+                                        if(mountpassword) {
+                                                memset(mountpassword,0,64);
+                                        }
+                                        exit(1);
+                                } else {
+                                        if(domain_name == NULL) {
+                                                domain_name = calloc(65,1);
+                                        } else
+                                                memset(domain_name,0,64);
+                                        if(domain_name) {
+                                                strncpy(domain_name,temp_val,length);
+                                                got_domain = 1;
+                                        }
+                                }
+                        }
+                }
+
        }
        fclose(fs);
        if(line_buf) {
@@ -888,6 +916,7 @@ int main(int argc, char ** argv)
                        break;
                case 'd':
                        domain_name = optarg; /* BB fix this - currently ignored */
+                       got_domain = 1;
                        break;
                case 'p':
                        if(mountpassword == NULL)
@@ -1017,7 +1046,8 @@ mount_retry:
 
        if(user_name) {
                /* check for syntax like user=domain\user */
-               domain_name = check_for_domain(&user_name);
+               if(got_domain == 0)
+                       domain_name = check_for_domain(&user_name);
                strncat(options,",user=",6);
                strcat(options,user_name);
        }
index 02ed2caba4011a55557a61649079b8aeee8c5b25..88a9776b04822423fbdad8ead44e34dea14ffa6f 100644 (file)
@@ -37,7 +37,7 @@
 #include <fstab.h>
 
 #define UNMOUNT_CIFS_VERSION_MAJOR "0"
-#define UNMOUNT_CIFS_VERSION_MINOR "3"
+#define UNMOUNT_CIFS_VERSION_MINOR "4"
 
 #ifndef UNMOUNT_CIFS_VENDOR_SUFFIX
 #define UNMOUNT_CIFS_VENDOR_SUFFIX ""
@@ -93,6 +93,7 @@ static void umount_cifs_usage(void)
        printf("\n\tman 8 umount.cifs\n");
        printf("\nTo display the version number of the cifs umount utility:");
        printf("\n\t%s -V\n",thisprogram);
+       printf("\nNote that invoking the umount utility on cifs mounts, can execute /sbin/umount.cifs (if it is present and -i is not specified to umount).\n");
 }
 
 static int umount_check_perm(char * dir)
@@ -100,8 +101,11 @@ static int umount_check_perm(char * dir)
        int fileid;
        int rc;
 
-       /* presumably can not chdir into the target as we do on mount */
+       /* allow root to unmount, no matter what */
+       if(getuid() == 0)
+               return 0;
 
+       /* presumably can not chdir into the target as we do on mount */
        fileid = open(dir, O_RDONLY | O_DIRECTORY | O_NOFOLLOW, 0);
        if(fileid == -1) {
                if(verboseflg)