*** empty log message ***
authorVolker Lendecke <vlendec@samba.org>
Thu, 22 Jan 1998 03:47:48 +0000 (03:47 +0000)
committerVolker Lendecke <vlendec@samba.org>
Thu, 22 Jan 1998 03:47:48 +0000 (03:47 +0000)
(This used to be commit 1e1b0c80f84657f89ffcd4132887cd9f8a26885a)

docs/textdocs/BROWSING.txt
source3/client/smbmnt.c
source3/client/smbmount.c

index f81ff06b689b120e650952fd0d223932436dbd9d..83f43bc5fa0f099e6df13c33f761957407f67475 100644 (file)
@@ -74,7 +74,7 @@ parameters on the command line of nmbd in inetd.conf.  This trick is to
 not use spaces between the option and the parameter (eg: -d2 instead
 of -d 2), and to not use the -B and -N options.  New versions of nmbd
 are now far more likely to correctly find your broadcast and network
 not use spaces between the option and the parameter (eg: -d2 instead
 of -d 2), and to not use the -B and -N options.  New versions of nmbd
 are now far more likely to correctly find your broadcast and network
-addess, so in most cases these aren't needed.
+address, so in most cases these aren't needed.
 
 The other big problem people have is that their broadcast address,
 netmask or IP address is wrong (specified with the "interfaces" option
 
 The other big problem people have is that their broadcast address,
 netmask or IP address is wrong (specified with the "interfaces" option
index 9bb7f5667217102a5962edad426d4f528c290e0f..2891ea709cdb6a1d504b393e1df3cf809a42f544 100644 (file)
@@ -53,18 +53,18 @@ help(void)
                "-f mode        permission the files get (octal notation)\n"
                "-d mode        permission the dirs get (octal notation)\n"
               "-P pid         connection handler's pid\n\n"
                "-f mode        permission the files get (octal notation)\n"
                "-d mode        permission the dirs get (octal notation)\n"
               "-P pid         connection handler's pid\n\n"
+              "-s share       share name on server\n\n"
                "-h             print this help text\n");
 }
 
 static int
                "-h             print this help text\n");
 }
 
 static int
-parse_args(int argc, char *argv[], struct smb_mount_data *data)
+parse_args(int argc, char *argv[], struct smb_mount_data *data, char **share)
 {
         int opt;
         struct passwd *pwd;
         struct group  *grp;
 
 {
         int opt;
         struct passwd *pwd;
         struct group  *grp;
 
-        while ((opt = getopt (argc, argv, "u:g:f:d:"))
-              != EOF)
+        while ((opt = getopt (argc, argv, "u:g:f:d:s:")) != EOF)
        {
                 switch (opt)
                {
        {
                 switch (opt)
                {
@@ -108,6 +108,9 @@ parse_args(int argc, char *argv[], struct smb_mount_data *data)
                 case 'd':
                         data->dir_mode = strtol(optarg, NULL, 8);
                         break;
                 case 'd':
                         data->dir_mode = strtol(optarg, NULL, 8);
                         break;
+                case 's':
+                        *share = optarg;
+                        break;
                 default:
                         return -1;
                 }
                 default:
                         return -1;
                 }
@@ -157,17 +160,13 @@ mount_ok(struct stat *st)
 int 
 main(int argc, char *argv[])
 {
 int 
 main(int argc, char *argv[])
 {
-        struct smb_mount_data data;
-        struct stat st;
-
-        int fd;
-        int um;
+       char *mount_point, *share_name = NULL;
+       FILE *mtab;
+       int fd, um;
        unsigned int flags;
        unsigned int flags;
-
-        char *mount_point;
-
-        struct mntent ment;
-        FILE *mtab;
+       struct smb_mount_data data;
+       struct stat st;
+       struct mntent ment;
 
         progname = argv[0];
 
 
         progname = argv[0];
 
@@ -222,7 +221,7 @@ main(int argc, char *argv[])
         data.file_mode = (S_IRWXU|S_IRWXG|S_IRWXO) & ~um;
         data.dir_mode  = 0;
 
         data.file_mode = (S_IRWXU|S_IRWXG|S_IRWXO) & ~um;
         data.dir_mode  = 0;
 
-        if (parse_args(argc, argv, &data) != 0) {
+        if (parse_args(argc, argv, &data, &share_name) != 0) {
                 usage();
                 return -1;
         }
                 usage();
                 return -1;
         }
@@ -239,15 +238,14 @@ main(int argc, char *argv[])
 
        flags = MS_MGC_VAL;
 
 
        flags = MS_MGC_VAL;
 
-       if (mount(NULL, mount_point, "smbfs",
-                  flags, (char *)&data) < 0) {
+       if (mount(share_name, mount_point, "smbfs", flags, (char *)&data) < 0)
+       {
                perror("mount error");
                perror("mount error");
-               printf("Please look at smbmount's manual page for "
-                      "possible reasons\n");
+               printf("Please refer to the smbmnt(8) manual page\n");
                return -1;
        }
 
                return -1;
        }
 
-        ment.mnt_fsname = "none";
+        ment.mnt_fsname = share_name ? share_name : "none";
         ment.mnt_dir = fullpath(mount_point);
         ment.mnt_type = "smbfs";
         ment.mnt_opts = "";
         ment.mnt_dir = fullpath(mount_point);
         ment.mnt_type = "smbfs";
         ment.mnt_opts = "";
index 645523db0f2253f9ef8446618692df702aac4bd9..abf00e2b785a79afcbfa98f43e22a6bb578c3227 100644 (file)
 #undef SYSLOG
 #endif
 
 #undef SYSLOG
 #endif
 
+#include <linux/version.h>
+#define LVERSION(major,minor,patch) (((((major)<<8)+(minor))<<8)+(patch))
+#if LINUX_VERSION_CODE < LVERSION(2,1,70)
+#error this code will only compile on versions of linux after 2.1.70
+#endif
+
 #include "includes.h"
 #include <linux/smb_fs.h>
 static struct smb_conn_opt conn_options;
 #include "includes.h"
 #include <linux/smb_fs.h>
 static struct smb_conn_opt conn_options;
@@ -31,6 +37,9 @@ static struct smb_conn_opt conn_options;
 #define REGISTER 0
 #endif
 
 #define REGISTER 0
 #endif
 
+/* Uncomment this to allow debug the smbmount daemon */
+#define SMBFS_DEBUG 1
+
 pstring cur_dir = "\\";
 pstring cd_path = "";
 extern pstring service;
 pstring cur_dir = "\\";
 pstring cd_path = "";
 extern pstring service;
@@ -60,6 +69,7 @@ extern pstring user_socket_options;
 extern int name_type;
 
 extern int max_protocol;
 extern int name_type;
 
 extern int max_protocol;
+int port = SMB_PORT;
 
 
 time_t newer_than = 0;
 
 
 time_t newer_than = 0;
@@ -178,9 +188,6 @@ static BOOL chkpath(char *path,BOOL report)
   return(CVAL(inbuf,smb_rcls) == 0);
 }
 
   return(CVAL(inbuf,smb_rcls) == 0);
 }
 
-
-/* #define SMBFS_DEBUG 1 */
-
 static void
 daemonize(void)
 {
 static void
 daemonize(void)
 {
@@ -260,9 +267,7 @@ send_fs_socket(char *mount_point, char *inbuf, char *outbuf)
        {
                if ((fd = open(mount_point, O_RDONLY)) < 0)
                {
        {
                if ((fd = open(mount_point, O_RDONLY)) < 0)
                {
-#ifdef SMBFS_DEBUG
-                       printf("smbclient: can't open %s\n", mount_point);
-#endif
+                       DEBUG(0, ("smbmount: can't open %s\n", mount_point));
                        break;
                }               
 
                        break;
                }               
 
@@ -276,9 +281,7 @@ send_fs_socket(char *mount_point, char *inbuf, char *outbuf)
                res = ioctl(fd, SMB_IOC_NEWCONN, &conn_options);
                if (res != 0)
                {
                res = ioctl(fd, SMB_IOC_NEWCONN, &conn_options);
                if (res != 0)
                {
-#ifdef SMBFS_DEBUG
-                       printf("smbclient: ioctl failed, res=%d\n",res);
-#endif
+                       DEBUG(0, ("smbmount: ioctl failed, res=%d\n", res));
                }
 
                close_sockets();
                }
 
                close_sockets();
@@ -299,21 +302,22 @@ send_fs_socket(char *mount_point, char *inbuf, char *outbuf)
                 */
                signal(SIGUSR1, &usr1_handler);
                pause();
                 */
                signal(SIGUSR1, &usr1_handler);
                pause();
-#ifdef SMBFS_DEBUG
-               printf("smbclient: got signal, getting new socket\n");
-#endif
+               DEBUG(0, ("smbmount: got signal, getting new socket\n"));
 
 
-               res = mount_send_login(inbuf,outbuf);
+               res = cli_open_sockets(port);
                if (!res)
                {
                if (!res)
                {
-#ifdef SMBFS_DEBUG
-                       printf("smbclient: login failed\n");
-#endif
+                       DEBUG(0, ("smbmount: can't open sockets\n"));
+                       continue;
+               }
+
+               res = mount_send_login(inbuf, outbuf);
+               if (!res)
+               {
+                       DEBUG(0, ("smbmount: login failed\n"));
                }
        }
                }
        }
-#ifdef SMBFS_DEBUG
-       printf("smbclient: exit\n");
-#endif
+       DEBUG(0, ("smbmount: exit\n"));
        exit(1);
 }
 
        exit(1);
 }
 
@@ -323,10 +327,11 @@ mount smbfs
 static void cmd_mount(char *inbuf,char *outbuf)
 {
        pstring mpoint;
 static void cmd_mount(char *inbuf,char *outbuf)
 {
        pstring mpoint;
-       char mount_point[MAXPATHLEN+1];
+       pstring share_name;
        pstring mount_command;
        fstring buf;
        int retval;
        pstring mount_command;
        fstring buf;
        int retval;
+       char mount_point[MAXPATHLEN+1];
 
        if (!next_token(NULL, mpoint, NULL))
        {
 
        if (!next_token(NULL, mpoint, NULL))
        {
@@ -342,7 +347,15 @@ static void cmd_mount(char *inbuf,char *outbuf)
                return;
        }
 
                return;
        }
 
-       sprintf(mount_command, "smbmnt %s", mount_point);
+       /*
+        * Build the service name to report on the Unix side,
+        * converting '\' to '/' and ' ' to '_'.
+        */
+       strcpy(share_name, service);  
+       string_replace(share_name, '\\', '/');
+       string_replace(share_name, ' ', '_');
+
+       sprintf(mount_command, "smbmnt %s -s %s", mount_point, share_name);
 
        while(next_token(NULL, buf, NULL))
        {
 
        while(next_token(NULL, buf, NULL))
        {
@@ -350,7 +363,7 @@ static void cmd_mount(char *inbuf,char *outbuf)
                strcat(mount_command, buf);
        }
 
                strcat(mount_command, buf);
        }
 
-       DEBUG(3,("mount command: %s\n", mount_command));
+       DEBUG(3, ("mount command: %s\n", mount_command));
 
        /*
         * Create the background process before trying the mount.
 
        /*
         * Create the background process before trying the mount.
@@ -368,9 +381,6 @@ static void cmd_mount(char *inbuf,char *outbuf)
 }      
 
 
 }      
 
 
-
-
-
 /* This defines the commands supported by this client */
 struct
 {
 /* This defines the commands supported by this client */
 struct
 {
@@ -667,7 +677,6 @@ static void usage(char *pname)
 {
   fstring base_directory;
   char *pname = argv[0];
 {
   fstring base_directory;
   char *pname = argv[0];
-  int port = SMB_PORT;
   int opt;
   extern FILE *dbf;
   extern char *optarg;
   int opt;
   extern FILE *dbf;
   extern char *optarg;
@@ -739,7 +748,7 @@ static void usage(char *pname)
   if (*argv[1] != '-')
     {
 
   if (*argv[1] != '-')
     {
 
-      strcpy(service,argv[1]);  
+      strcpy(service, argv[1]);  
       /* Convert any '/' characters in the service name to '\' characters */
       string_replace( service, '/','\\');
       argc--;
       /* Convert any '/' characters in the service name to '\' characters */
       string_replace( service, '/','\\');
       argc--;
@@ -752,15 +761,6 @@ static void usage(char *pname)
          exit(1);
        }
 
          exit(1);
        }
 
-/*
-      if (count_chars(service,'\\') > 3)
-       {
-         usage(pname);
-         printf("\n%s: Too many '\\' characters in service\n",service);
-         exit(1);
-       }
-       */
-
       if (argc > 1 && (*argv[1] != '-'))
        {
          got_pass = True;
       if (argc > 1 && (*argv[1] != '-'))
        {
          got_pass = True;