commit b7c546a23531f99ea15a9e10636dc1dae5351833
parent 2b068d2bda66aacf152140376ce49626a5516c8e
Author: geoff <devnull@localhost>
Date: Fri, 29 Jun 2007 17:49:22 +0000
utime() allows the struct utimbuf * to be NULL.
Added contact email address in the version information.
Diffstat:
5 files changed, 141 insertions(+), 17 deletions(-)
diff --git a/README b/README
@@ -1 +1,104 @@
-See doc/README.
+usmb - Unprivileged mounting of SMB/CIFS shares via FUSE
+========================================================
+
+Acknowledgement
+---------------
+
+Jonathan Schultz (Email firstname at imatix.com) provided a patch
+to fix the display of file modification times.
+
+
+Introduction
+------------
+
+usmb lets you mount SMB/CIFS shares via FUSE, in the vein of the Map Network
+Drive functionality in Windows.
+
+The two existing FUSE filesystems that I know of (SMB for FUSE and fusesmb)
+mimic Windows' Network Neighbourhood by letting you browse hosts and shares.
+This means that you must run a NetBIOS name server and can't see hosts that
+aren't advertised via NetBIOS.
+
+You can build [u]mount.cifs in the Samba distribution and install them
+setuid root, but that has its own set of security implications. In any
+case there's no need for network filesystem code to be in the kernel:
+bugs could lead to remotely exploitable kernel vulnerabilities. Running
+the SMB client code in user space as an unprivileged user limits the
+potential damage due to bugs.
+
+A user space implementation will be slower than a kernel filesystem since
+the data must be copied in and out of the fuse process' context as well as
+in/out of the user process' context. Mitigating factors are:
+
+1. Increased security.
+2. Containment of bugs.
+3. Throughput is more likely to be limited by network bandwidth rather than
+ local memory copying.
+4. The client filesystem code can be upgraded/fixed without kernel changes.
+
+
+Pre-Requisites
+--------------
+
+glib 2.6 or later - www.gtk.org.
+libxml2 - ftp.gnome.org.
+FUSE 2.5 or later - fuse.sourgeforge.net.
+libsmbclient 3.0 (part of Samba) - www.samba.org.
+
+
+Installation
+------------
+
+Sorry, no autoconf yet.
+You need GNU sed.
+Edit the Makefile with brain engaged.
+Run make.
+Run make install (maybe as root).
+
+
+Configuration
+-------------
+
+You need an XML configuration file - ${HOME}/.usmb.conf by default. There's an
+example in doc/usmb.conf.
+
+There are two main elements: credentials and mounts.
+
+Credentials:
+
+ <credentials id="some_id">
+ <domain>mydomain</domain>
+ <username>username</username>
+ <password>password</password>
+ </credentials>
+
+Each credentials element gives authentication details. You can have multiple
+credentials elements; each must have a distinct id attribute.
+
+A mount element describes an SMB share:
+
+ <mount id="mount_id" credentials="some_id">
+ <server>1.2.3.4</server>
+ <share>sharename</share>
+ <mountpoint>/tmp/share</mountpoint>
+ </mount>
+
+The credentials attribute identifies the id of the credentials element that
+provides authentication details for the share. The server, share and
+mountpoint should be self-explanatory. The id is given on the usmb command
+line to identify the SMB share to mount.
+
+You can specify multiple mount elements; each must have a distinct id
+(though credentials and mount IDs can be the same).
+
+The whole file is wrapped in a <usmbconfig> element.
+
+
+Usage
+-----
+
+$ usmb [options] mount_ID
+
+Use usmb --help for a list of options.
+Mount IDs are defined in the configuration file.
+
diff --git a/conffile.c b/conffile.c
@@ -93,12 +93,12 @@ bool conffile_get_mount (const char *filename, const char *key,
if (!do_xpath_text (ctx, "mount", key, "server", server)) break;
if (!do_xpath_text (ctx, "mount", key, "share", share)) break;
if (!do_xpath_text (ctx, "mount", key, "mountpoint", mountpoint)) break;
- do_xpath_text (ctx, "mount", key, "options", options);
+ (void)do_xpath_text (ctx, "mount", key, "options", options);
snprintf (xp, sizeof (xp), "/usmbconfig/mount[@id='%s']", key);
if (!xml_xpath_attr_value (ctx, xp, "credentials", &creds)) break;
- do_xpath_text (ctx, "credentials", creds, "domain", domain);
+ (void)do_xpath_text (ctx, "credentials", creds, "domain", domain);
if (!do_xpath_text (ctx, "credentials", creds, "username", username)) break;
if (!do_xpath_text (ctx, "credentials", creds, "password", password)) break;
diff --git a/doc/README b/doc/README
@@ -4,9 +4,8 @@ usmb - Unprivileged mounting of SMB/CIFS shares via FUSE
Acknowledgement
---------------
-Jonathan Schultz provided a patch against a previous version, included in
-this version, for incorrect timestamps in the usmb_file.c:
-http://legacy.imatix.com/patches/usmb/.
+Jonathan Schultz (Email firstname at imatix.com) provided a patch
+to fix the display of file modification times.
Introduction
diff --git a/usmb_file.c b/usmb_file.c
@@ -197,15 +197,33 @@ int usmb_rename (const char *from, const char *to)
int usmb_utime (const char *filename, struct utimbuf *utb)
{
+ struct utimbuf tmp_utb;
+
+ if (NULL == utb)
+ {
+ for (;;)
+ {
+ time_t now = time (NULL);
+ if ((time_t)-1 != now)
+ {
+ tmp_utb.actime = tmp_utb.modtime = now;
+ break;
+ }
+
+ if (EINTR != errno)
+ return -errno;
+ }
+
+ utb = &tmp_utb;
+ }
+
char *url = make_url (filename);
if (NULL == url)
return -ENOMEM;
struct timeval tv[2] = {
- { .tv_sec = utb->actime,
- .tv_usec = 0 },
- { .tv_sec = utb->modtime,
- .tv_usec = 0 }
+ { .tv_sec = utb->actime, .tv_usec = 0 },
+ { .tv_sec = utb->modtime, .tv_usec = 0 },
};
DEBUG (fprintf (stderr, "utime (%s)\n", url));
@@ -216,7 +234,7 @@ int usmb_utime (const char *filename, struct utimbuf *utb)
#if 0
-Samab 3.0.24 defines utimes as taking struct timevals rather than timespecs.
+Samba defines utimes as taking struct timevals rather than timespecs.
int usmb_utimes (const char *filename, const struct timespec ts[2])
{
char *url = make_url (filename);
diff --git a/version.c b/version.c
@@ -33,12 +33,16 @@
void show_about (FILE *fp)
{
- fputs ("usmb - mount SMB shares via FUSE and Samba\n"
- "\n"
- "Copyright (C) 2006-2007 Geoff Johnstone.\n"
- "Licensed under the GNU General Public License.\n"
- "usmb comes with ABSOLUTELY NO WARRANTY; for details please see\n"
- "http://www.gnu.org/licenses/gpl.txt\n", fp);
+ fprintf (fp, "usmb - mount SMB shares via FUSE and Samba\n"
+ "\n"
+ "Copyright (C) 2006-2007 Geoff Johnstone.\n"
+ "Licensed under the GNU General Public License.\n"
+ "usmb comes with ABSOLUTELY NO WARRANTY; "
+ "for details please see\n"
+ "http://www.gnu.org/licenses/gpl.txt\n"
+ "\n"
+ "Please send bugs, patches etc. to %s@%s.org\n",
+ "geoffjohnstone", "acm"); // anti-spam.
}