summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>1999-12-17 19:03:17 (GMT)
committerH. Peter Anvin <hpa@zytor.com>1999-12-17 19:03:17 (GMT)
commit57bd98fd004382c43467ff4491a1253b5d90fcfe (patch)
tree43eb3d144f623f67dbd06806e63af7cab15ce90c
parent98b09747969444f2dff268ad1d59c7280b1bcacb (diff)
downloadautofs3-57bd98fd004382c43467ff4491a1253b5d90fcfe.zip
autofs3-57bd98fd004382c43467ff4491a1253b5d90fcfe.tar.gz
autofs3-57bd98fd004382c43467ff4491a1253b5d90fcfe.tar.bz2
autofs3-57bd98fd004382c43467ff4491a1253b5d90fcfe.tar.xz
Add files missing from previous commit
-rw-r--r--README.smbfs11
-rw-r--r--modules/lookup_multi.c138
2 files changed, 149 insertions, 0 deletions
diff --git a/README.smbfs b/README.smbfs
new file mode 100644
index 0000000..9405fc5
--- /dev/null
+++ b/README.smbfs
@@ -0,0 +1,11 @@
+The functionality of converting map options to smbmnt arguments is now
+handled by /bin/mount.smbfs, which is shipped with Sakba 2.0.6 or
+later. You therefore needs to make sure yopu hae /bin/mount.smbfs
+installed on your system if you plan on using smbfs with autofs.
+
+WARNING: Some versions of Samba incorrectly installs this as
+/bin/mount.smb rather than /bin/mount.smbfs. If that is the case on
+your system, please link or move /bin/mount.smb to /bin/mount.smbfs.
+This is a Samba bug/misfeature and has been reported to the Samba
+maintainers.
+
diff --git a/modules/lookup_multi.c b/modules/lookup_multi.c
new file mode 100644
index 0000000..1d17408
--- /dev/null
+++ b/modules/lookup_multi.c
@@ -0,0 +1,138 @@
+#ident "$Id$"
+/* ----------------------------------------------------------------------- *
+ *
+ * lookup_multi.c - module for Linux automount to seek multiple lookup
+ * methods in succession
+ *
+ * Copyright 1999 Transmeta Corporation - All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
+ * USA; either version 2 of the License, or (at your option) any later
+ * version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <malloc.h>
+#include <stdio.h>
+#include <string.h>
+#include <syslog.h>
+#include <unistd.h>
+
+#define MODULE_LOOKUP
+#include "automount.h"
+
+#define MODPREFIX "lookup(multi): "
+
+#define MAPENT_MAX_LEN 4095
+
+struct module_info {
+ int argc;
+ const char * const *argv;
+ struct lookup_mod *mod;
+};
+
+struct lookup_context {
+ int n;
+ const char **argl;
+ struct module_info *m;
+};
+
+int lookup_version = AUTOFS_LOOKUP_VERSION; /* Required by protocol */
+
+int lookup_init(const char *my_mapfmt, int argc, const char * const *argv,
+ void **context)
+{
+ struct lookup_context *ctxt;
+ char *map, *mapfmt;
+ int i, j, an;
+
+ if ( !(*context = ctxt = malloc(sizeof(struct lookup_context))) )
+ goto nomem;
+
+ if ( argc < 1 ) {
+ syslog(LOG_CRIT, MODPREFIX "No map list");
+ return 1;
+ }
+ ctxt->n = 1; /* Always at least one map */
+ for ( i = 0 ; i < argc ; i++ ) {
+ if ( !strcmp(argv[i], "--") ) /* -- separates maps */
+ ctxt->n++;
+ }
+
+ if ( !(ctxt->m = malloc(ctxt->n*sizeof(struct module_info))) ||
+ !(ctxt->argl = malloc((argc+1)*sizeof(const char **))) )
+ goto nomem;
+
+ memcpy(ctxt->argl, argv, (argc+1)*sizeof(const char **));
+
+ for ( i = j = an = 0 ; argv[an] ; an++ ) {
+ if ( j == 0 )
+ ctxt->m[i].argv = &ctxt->argl[an];
+ if ( !strcmp(ctxt->argl[an], "--") ) {
+ ctxt->argl[an] = NULL;
+ i++; j = 0;
+ } else {
+ ctxt->m[i].argc++;
+ }
+ }
+
+ for ( i = 0 ; i < ctxt->n ; i++ ) {
+ if ( !ctxt->m[i].argv[0] ) {
+ syslog(LOG_CRIT, MODPREFIX "missing module name");
+ return 1;
+ }
+ map = strdup(ctxt->m[i].argv[0]);
+ if ( !map )
+ goto nomem;
+
+ if ( (mapfmt = strchr(map, ',')) )
+ *(mapfmt++) = '\0';
+
+ if ( !(ctxt->m[i].mod = open_lookup(map, MODPREFIX,
+ mapfmt ? mapfmt : my_mapfmt,
+ ctxt->m[i].argc, ctxt->m[i].argv)) )
+ return 1;
+ }
+
+ *context = ctxt;
+ return 0;
+
+ nomem:
+ syslog(LOG_CRIT, MODPREFIX "malloc: %m");
+ return 1;
+}
+
+int lookup_mount(const char *root, const char *name, int name_len,
+ void *context)
+{
+ struct lookup_context *ctxt = (struct lookup_context *) context;
+ int i;
+
+ for ( i = 0 ; i < ctxt->n ; i++ ) {
+ if ( ctxt->m[i].mod->lookup_mount(root,name,name_len,
+ ctxt->m[i].mod->context) == 0 )
+ return 0;
+ }
+ return 1; /* No module succeeded */
+}
+
+int lookup_done(void *context)
+{
+ struct lookup_context *ctxt = (struct lookup_context *) context;
+ int i, rv = 0;
+
+ for ( i = 0 ; i < ctxt->n ; i++ ) {
+ rv = rv || close_lookup(ctxt->m[i].mod);
+ }
+
+ free(ctxt->argl);
+ free(ctxt->m);
+ free(ctxt);
+
+ return rv;
+}