summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>1998-01-22 03:33:42 +0000
committerVolker Lendecke <vlendec@samba.org>1998-01-22 03:33:42 +0000
commit4d109593ce7ac22a9452e6a8c7adb9027cfe787a (patch)
treea23962d710be8671ba686a6635384e6c80269ba6 /source
parent529929e98ad5889be3b930b17550e540f2e4bec5 (diff)
downloadsamba-4d109593ce7ac22a9452e6a8c7adb9027cfe787a.tar.gz
samba-4d109593ce7ac22a9452e6a8c7adb9027cfe787a.tar.xz
samba-4d109593ce7ac22a9452e6a8c7adb9027cfe787a.zip
*** empty log message ***
Diffstat (limited to 'source')
-rw-r--r--source/client/smbmnt.c36
-rw-r--r--source/client/smbmount.c72
2 files changed, 53 insertions, 55 deletions
diff --git a/source/client/smbmnt.c b/source/client/smbmnt.c
index 9bb7f566721..2891ea709cd 100644
--- a/source/client/smbmnt.c
+++ b/source/client/smbmnt.c
@@ -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"
+ "-s share share name on server\n\n"
"-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;
- while ((opt = getopt (argc, argv, "u:g:f:d:"))
- != EOF)
+ while ((opt = getopt (argc, argv, "u:g:f:d:s:")) != EOF)
{
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 's':
+ *share = optarg;
+ break;
default:
return -1;
}
@@ -157,17 +160,13 @@ mount_ok(struct stat *st)
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;
-
- char *mount_point;
-
- struct mntent ment;
- FILE *mtab;
+ struct smb_mount_data data;
+ struct stat st;
+ struct mntent ment;
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;
- if (parse_args(argc, argv, &data) != 0) {
+ if (parse_args(argc, argv, &data, &share_name) != 0) {
usage();
return -1;
}
@@ -239,15 +238,14 @@ main(int argc, char *argv[])
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");
- printf("Please look at smbmount's manual page for "
- "possible reasons\n");
+ printf("Please refer to the smbmnt(8) manual page\n");
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 = "";
diff --git a/source/client/smbmount.c b/source/client/smbmount.c
index 645523db0f2..abf00e2b785 100644
--- a/source/client/smbmount.c
+++ b/source/client/smbmount.c
@@ -23,6 +23,12 @@
#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;
@@ -31,6 +37,9 @@ static struct smb_conn_opt conn_options;
#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;
@@ -60,6 +69,7 @@ extern pstring user_socket_options;
extern int name_type;
extern int max_protocol;
+int port = SMB_PORT;
time_t newer_than = 0;
@@ -178,9 +188,6 @@ static BOOL chkpath(char *path,BOOL report)
return(CVAL(inbuf,smb_rcls) == 0);
}
-
-/* #define SMBFS_DEBUG 1 */
-
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)
{
-#ifdef SMBFS_DEBUG
- printf("smbclient: can't open %s\n", mount_point);
-#endif
+ DEBUG(0, ("smbmount: can't open %s\n", mount_point));
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)
{
-#ifdef SMBFS_DEBUG
- printf("smbclient: ioctl failed, res=%d\n",res);
-#endif
+ DEBUG(0, ("smbmount: ioctl failed, res=%d\n", res));
}
close_sockets();
@@ -299,21 +302,22 @@ send_fs_socket(char *mount_point, char *inbuf, char *outbuf)
*/
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)
{
-#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);
}
@@ -323,10 +327,11 @@ mount smbfs
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;
+ char mount_point[MAXPATHLEN+1];
if (!next_token(NULL, mpoint, NULL))
{
@@ -342,7 +347,15 @@ static void cmd_mount(char *inbuf,char *outbuf)
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))
{
@@ -350,7 +363,7 @@ static void cmd_mount(char *inbuf,char *outbuf)
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.
@@ -368,9 +381,6 @@ static void cmd_mount(char *inbuf,char *outbuf)
}
-
-
-
/* 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];
- int port = SMB_PORT;
int opt;
extern FILE *dbf;
extern char *optarg;
@@ -739,7 +748,7 @@ static void usage(char *pname)
if (*argv[1] != '-')
{
- strcpy(service,argv[1]);
+ strcpy(service, argv[1]);
/* Convert any '/' characters in the service name to '\' characters */
string_replace( service, '/','\\');
argc--;
@@ -752,15 +761,6 @@ static void usage(char *pname)
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;