Initial import
[samba] / debian / patches / smbmount-nomtab.patch
diff --git a/debian/patches/smbmount-nomtab.patch b/debian/patches/smbmount-nomtab.patch
new file mode 100644 (file)
index 0000000..4763e5b
--- /dev/null
@@ -0,0 +1,162 @@
+Index: samba-3.0.21c/source/client/smbmnt.c
+===================================================================
+--- samba-3.0.21c.orig/source/client/smbmnt.c  2006-02-25 11:58:25.369473493 +0100
++++ samba-3.0.21c/source/client/smbmnt.c       2006-02-25 11:58:26.169312103 +0100
+@@ -44,6 +44,7 @@
+ static uid_t mount_uid;
+ static gid_t mount_gid;
+ static int mount_ro;
++static int no_mtab;
+ static unsigned mount_fmask;
+ static unsigned mount_dmask;
+ static int user_mount;
+@@ -56,6 +57,7 @@
+         printf("Usage: smbmnt mount-point [options]\n");
+       printf("Version %s\n\n",SAMBA_VERSION_STRING);
+         printf("-s share       share name on server\n"
++               "-n             don't update /etc/mtab\n"
+                "-r             mount read-only\n"
+                "-u uid         mount as uid\n"
+                "-g gid         mount as gid\n"
+@@ -70,7 +72,7 @@
+ {
+         int opt;
+-        while ((opt = getopt (argc, argv, "s:u:g:rf:d:o:")) != EOF)
++        while ((opt = getopt (argc, argv, "s:u:g:nrf:d:o:")) != EOF)
+       {
+                 switch (opt)
+               {
+@@ -87,6 +89,9 @@
+                               mount_gid = strtol(optarg, NULL, 0);
+                       }
+                         break;
++              case 'n':
++                      no_mtab = 1;
++                      break;
+                 case 'r':
+                         mount_ro = 1;
+                         break;
+@@ -291,36 +296,38 @@
+               return -1;
+       }
+       
+-        if ((fd = open(MOUNTED"~", O_RDWR|O_CREAT|O_EXCL, 0600)) == -1)
+-        {
+-                fprintf(stderr, "Can't get "MOUNTED"~ lock file");
+-                return 1;
+-        }
+-        close(fd);
++      if (!no_mtab) {
++              if ((fd = open(MOUNTED"~", O_RDWR|O_CREAT|O_EXCL, 0600)) == -1)
++              {
++                      fprintf(stderr, "Can't get "MOUNTED"~ lock file");
++                      return 1;
++              }
++              close(fd);
+       
+-        if ((mtab = setmntent(MOUNTED, "a+")) == NULL)
+-        {
+-                fprintf(stderr, "Can't open " MOUNTED);
+-                return 1;
+-        }
++              if ((mtab = setmntent(MOUNTED, "a+")) == NULL)
++              {
++                      fprintf(stderr, "Can't open " MOUNTED);
++                      return 1;
++              }
+-        if (addmntent(mtab, &ment) == 1)
+-        {
+-                fprintf(stderr, "Can't write mount entry");
+-                return 1;
+-        }
+-        if (fchmod(fileno(mtab), 0644) == -1)
+-        {
+-                fprintf(stderr, "Can't set perms on "MOUNTED);
+-                return 1;
+-        }
+-        endmntent(mtab);
++              if (addmntent(mtab, &ment) == 1)
++              {
++                      fprintf(stderr, "Can't write mount entry");
++                      return 1;
++              }
++              if (fchmod(fileno(mtab), 0644) == -1)
++              {
++                      fprintf(stderr, "Can't set perms on "MOUNTED);
++                      return 1;
++              }
++              endmntent(mtab);
+-        if (unlink(MOUNTED"~") == -1)
+-        {
+-                fprintf(stderr, "Can't remove "MOUNTED"~");
+-                return 1;
+-        }
++              if (unlink(MOUNTED"~") == -1)
++              {
++                      fprintf(stderr, "Can't remove "MOUNTED"~");
++                      return 1;
++              }
++      }
+       return 0;
+ }     
+Index: samba-3.0.21c/source/client/smbmount.c
+===================================================================
+--- samba-3.0.21c.orig/source/client/smbmount.c        2006-02-25 11:58:23.681814024 +0100
++++ samba-3.0.21c/source/client/smbmount.c     2006-02-25 11:58:26.184309077 +0100
+@@ -46,6 +46,7 @@
+ static int mount_ro;
+ static unsigned mount_fmask;
+ static unsigned mount_dmask;
++static BOOL no_mtab = False;
+ static BOOL use_kerberos;
+ /* TODO: Add code to detect smbfs version in kernel */
+ static BOOL status32_smbfs = False;
+@@ -271,6 +272,9 @@
+                 return;
+         }
++      if (no_mtab)
++              return;
++
+         if ((fd = open(MOUNTED"~", O_RDWR|O_CREAT|O_EXCL, 0600)) == -1) {
+                 DEBUG(0,("%d: Can't get "MOUNTED"~ lock file", sys_getpid()));
+                 return;
+@@ -468,6 +472,9 @@
+       args[i++] = "-s";
+       args[i++] = svc2;
++      if (no_mtab) {
++              args[i++] = "-n";
++      }
+       if (mount_ro) {
+               args[i++] = "-r";
+       }
+@@ -663,7 +670,7 @@
+ ****************************************************************************/
+ static void usage(void)
+ {
+-      printf("Usage: mount.smbfs service mountpoint [-o options,...]\n");
++      printf("Usage: mount.smbfs service mountpoint [-n] [-o options,...]\n");
+       printf("Version %s\n\n",SAMBA_VERSION_STRING);
+@@ -741,8 +748,13 @@
+       argc -= 2;
+       argv += 2;
+-      opt = getopt(argc, argv, "o:");
+-      if(opt != 'o') {
++      opt = getopt(argc, argv, "no:");
++      if (opt == 'n') {
++              DEBUG(3,("No mtab!\n"));
++              no_mtab = True;
++              opt = getopt(argc, argv, "o:");
++      }
++      if (opt != 'o') {
+               return;
+       }