ad-schema/license.txt: Fix typo.
[samba.git] / packaging / Debian / debian-sarge / patches / smbmount-nomtab.patch
1 diff -uNr samba-3.0alpha22.orig/source/client/smbmnt.c samba-3.0alpha22/source/client/smbmnt.c
2 --- samba-3.0alpha22.orig/source/client/smbmnt.c        2003-03-15 12:11:39.000000000 -0600
3 +++ samba-3.0alpha22/source/client/smbmnt.c     2003-03-15 12:11:49.000000000 -0600
4 @@ -28,6 +28,7 @@
5  static uid_t mount_uid;
6  static gid_t mount_gid;
7  static int mount_ro;
8 +static int no_mtab;
9  static unsigned mount_fmask;
10  static unsigned mount_dmask;
11  static int user_mount;
12 @@ -40,6 +41,7 @@
13          printf("Usage: smbmnt mount-point [options]\n");
14         printf("Version %s\n\n",VERSION);
15          printf("-s share       share name on server\n"
16 +               "-n             don't update /etc/mtab\n"
17                 "-r             mount read-only\n"
18                 "-u uid         mount as uid\n"
19                 "-g gid         mount as gid\n"
20 @@ -54,7 +56,7 @@
21  {
22          int opt;
23  
24 -        while ((opt = getopt (argc, argv, "s:u:g:rf:d:o:")) != EOF)
25 +        while ((opt = getopt (argc, argv, "s:u:g:nrf:d:o:")) != EOF)
26         {
27                  switch (opt)
28                 {
29 @@ -71,6 +73,9 @@
30                                 mount_gid = strtol(optarg, NULL, 0);
31                         }
32                          break;
33 +               case 'n':
34 +                       no_mtab = 1;
35 +                       break;
36                  case 'r':
37                          mount_ro = 1;
38                          break;
39 @@ -274,36 +279,38 @@
40                 return -1;
41         }
42         
43 -        if ((fd = open(MOUNTED"~", O_RDWR|O_CREAT|O_EXCL, 0600)) == -1)
44 -        {
45 -                fprintf(stderr, "Can't get "MOUNTED"~ lock file");
46 -                return 1;
47 -        }
48 -        close(fd);
49 +       if (!no_mtab) {
50 +               if ((fd = open(MOUNTED"~", O_RDWR|O_CREAT|O_EXCL, 0600)) == -1)
51 +               {
52 +                       fprintf(stderr, "Can't get "MOUNTED"~ lock file");
53 +                       return 1;
54 +               }
55 +               close(fd);
56         
57 -        if ((mtab = setmntent(MOUNTED, "a+")) == NULL)
58 -        {
59 -                fprintf(stderr, "Can't open " MOUNTED);
60 -                return 1;
61 -        }
62 +               if ((mtab = setmntent(MOUNTED, "a+")) == NULL)
63 +               {
64 +                       fprintf(stderr, "Can't open " MOUNTED);
65 +                       return 1;
66 +               }
67  
68 -        if (addmntent(mtab, &ment) == 1)
69 -        {
70 -                fprintf(stderr, "Can't write mount entry");
71 -                return 1;
72 -        }
73 -        if (fchmod(fileno(mtab), 0644) == -1)
74 -        {
75 -                fprintf(stderr, "Can't set perms on "MOUNTED);
76 -                return 1;
77 -        }
78 -        endmntent(mtab);
79 +               if (addmntent(mtab, &ment) == 1)
80 +               {
81 +                       fprintf(stderr, "Can't write mount entry");
82 +                       return 1;
83 +               }
84 +               if (fchmod(fileno(mtab), 0644) == -1)
85 +               {
86 +                       fprintf(stderr, "Can't set perms on "MOUNTED);
87 +                       return 1;
88 +               }
89 +               endmntent(mtab);
90  
91 -        if (unlink(MOUNTED"~") == -1)
92 -        {
93 -                fprintf(stderr, "Can't remove "MOUNTED"~");
94 -                return 1;
95 -        }
96 +               if (unlink(MOUNTED"~") == -1)
97 +               {
98 +                       fprintf(stderr, "Can't remove "MOUNTED"~");
99 +                       return 1;
100 +               }
101 +       }
102  
103         return 0;
104  }      
105 diff -uNr samba-3.0alpha22.orig/source/client/smbmount.c samba-3.0alpha22/source/client/smbmount.c
106 --- samba-3.0alpha22.orig/source/client/smbmount.c      2003-03-15 12:04:29.000000000 -0600
107 +++ samba-3.0alpha22/source/client/smbmount.c   2003-03-15 12:15:10.000000000 -0600
108 @@ -48,6 +48,7 @@
109  static int mount_ro;
110  static unsigned mount_fmask;
111  static unsigned mount_dmask;
112 +static BOOL no_mtab = False;
113  static BOOL use_kerberos;
114  /* TODO: Add code to detect smbfs version in kernel */
115  static BOOL status32_smbfs = False;
116 @@ -273,6 +274,9 @@
117                  return;
118          }
119  
120 +       if (no_mtab)
121 +               return;
122 +
123          if ((fd = open(MOUNTED"~", O_RDWR|O_CREAT|O_EXCL, 0600)) == -1) {
124                  DEBUG(0,("%d: Can't get "MOUNTED"~ lock file", sys_getpid()));
125                  return;
126 @@ -467,6 +471,9 @@
127         args[i++] = "-s";
128         args[i++] = svc2;
129  
130 +       if (no_mtab) {
131 +               args[i++] = "-n";
132 +       }
133         if (mount_ro) {
134                 args[i++] = "-r";
135         }
136 @@ -662,7 +669,7 @@
137  ****************************************************************************/
138  static void usage(void)
139  {
140 -       printf("Usage: mount.smbfs service mountpoint [-o options,...]\n");
141 +       printf("Usage: mount.smbfs service mountpoint [-n] [-o options,...]\n");
142  
143         printf("Version %s\n\n",VERSION);
144  
145 @@ -740,8 +747,13 @@
146         argc -= 2;
147         argv += 2;
148  
149 -       opt = getopt(argc, argv, "o:");
150 -       if(opt != 'o') {
151 +       opt = getopt(argc, argv, "no:");
152 +       if (opt == 'n') {
153 +               DEBUG(3,("No mtab!\n"));
154 +               no_mtab = True;
155 +               opt = getopt(argc, argv, "o:");
156 +       }
157 +       if (opt != 'o') {
158                 return;
159         }
160