summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2004-01-15 01:28:50 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2004-01-15 01:28:50 (GMT)
commit5de12673ff24e0eb9bef48ef511b31e0065b9d67 (patch)
treeb74a1554977b627dbb777feae47d42f4f019140c
parentba547c0e908a601f30e863f011a9036736ef368b (diff)
downloadautofs3-5de12673ff24e0eb9bef48ef511b31e0065b9d67.zip
autofs3-5de12673ff24e0eb9bef48ef511b31e0065b9d67.tar.gz
autofs3-5de12673ff24e0eb9bef48ef511b31e0065b9d67.tar.bz2
autofs3-5de12673ff24e0eb9bef48ef511b31e0065b9d67.tar.xz
Fix bitrot; separate out default into a separate module
-rw-r--r--TODO5
-rw-r--r--daemon/automount.c6
-rw-r--r--daemon/mount.c3
-rw-r--r--modules/Makefile4
-rw-r--r--modules/lookup_file.c3
-rw-r--r--modules/lookup_program.c5
-rw-r--r--modules/lookup_userhome.c31
-rw-r--r--modules/mount_bind.c1
-rw-r--r--modules/mount_changer.c8
-rw-r--r--modules/mount_ext2.c1
-rw-r--r--modules/mount_generic.c1
-rw-r--r--modules/mount_nfs.c188
-rw-r--r--modules/parse_sun.c5
13 files changed, 85 insertions, 176 deletions
diff --git a/TODO b/TODO
index 652d2cb..898af50 100644
--- a/TODO
+++ b/TODO
@@ -14,7 +14,7 @@ autofs v4 TODO list
autofs v5 TODO list
-------------------
* Completely rewritten kernel protocol, using the new VFS features
- introduced by Alexander Viro for the 2.4 kernel series.
+ under development by Alexander Viro for the 2.6 kernel series.
* Use multithreading rather than processes in the daemon.
* Support multimount entries. (Quite messy: can't unmount the
tree as a unit, probably needs locking while constructing the tree,
@@ -23,5 +23,4 @@ autofs v5 TODO list
* /net support: need hostname resolver module (easy) as well as mountd
query (easy) plus all the multimount entry stuff...
* Direct mount support.
-* (Hopefully) some kind of inode spoofing to support browsable
- directories.
+* Ghosting to support browsable directories.
diff --git a/daemon/automount.c b/daemon/automount.c
index 5a2b97e..288b14b 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -790,6 +790,10 @@ int main(int argc, char *argv[])
our parent know that we have grown up and don't need supervision anymore. */
if ( submount )
kill(my_pid, SIGSTOP);
+
+ /* HACK HACK HACK HACK */
+ mkdir("/net/tazenda", 0755);
+ mkdir("/net/tazenda2", 0755);
while ( !shutdown ) {
if (handle_packet() && errno != EINTR)
@@ -811,4 +815,6 @@ int main(int argc, char *argv[])
umount_autofs(1);
cleanup_exit(0);
+
+ return 255; /* Not reached */
}
diff --git a/daemon/mount.c b/daemon/mount.c
index 11d5dbd..7aa618e 100644
--- a/daemon/mount.c
+++ b/daemon/mount.c
@@ -4,7 +4,7 @@
* mount.c - Abstract mount code used by modules for an unexpected
* filesystem type
*
- * Copyright 1997-2000 Transmeta Corporation - All Rights Reserved
+ * Copyright 1997-2004 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
@@ -21,6 +21,7 @@
#include <syslog.h>
#include <stdlib.h>
+#include <string.h>
#include "automount.h"
/* These filesystems are known not to work with the "generic" module */
diff --git a/modules/Makefile b/modules/Makefile
index b5a7f6b..abf948e 100644
--- a/modules/Makefile
+++ b/modules/Makefile
@@ -10,13 +10,13 @@ SRCS := lookup_yp.c lookup_file.c lookup_program.c lookup_userhome.c \
lookup_multi.c \
parse_sun.c \
mount_generic.c mount_nfs.c mount_afs.c mount_autofs.c \
- mount_changer.c mount_bind.c
+ mount_changer.c mount_bind.c mount_default.c
MODS := lookup_yp.so lookup_file.so lookup_program.so lookup_userhome.so \
lookup_multi.so \
parse_sun.so \
mount_generic.so mount_nfs.so mount_afs.so mount_autofs.so \
- mount_changer.so mount_bind.so
+ mount_changer.so mount_bind.so mount_default.so
ifeq ($(EXT2FS), 1)
SRCS += mount_ext2.c
diff --git a/modules/lookup_file.c b/modules/lookup_file.c
index d3b75e8..1e19dc7 100644
--- a/modules/lookup_file.c
+++ b/modules/lookup_file.c
@@ -197,7 +197,8 @@ int lookup_mount(const char *root, const char *name, int name_len,
}
break;
}
- next_char: /* End of loop, since we can't continue;
+
+ next_char: ; /* End of loop, since we can't continue;
inside a switch */
}
diff --git a/modules/lookup_program.c b/modules/lookup_program.c
index f330bba..9da57f5 100644
--- a/modules/lookup_program.c
+++ b/modules/lookup_program.c
@@ -85,7 +85,7 @@ int lookup_mount(const char *root, const char *name, int name_len,
char *p, ch;
int pipefd[2], epipefd[2];
pid_t f;
- int files_left;
+ int files_left, maxfd;
int status;
fd_set readfds, ourfds;
@@ -132,11 +132,12 @@ int lookup_mount(const char *root, const char *name, int name_len,
FD_SET(pipefd[0],&ourfds);
FD_SET(epipefd[0],&ourfds);
+ maxfd = pipefd[0] > epipefd[0] ? pipefd[0] : epipefd[0];
files_left = 2;
while (files_left) {
readfds = ourfds;
- if ( select(OPEN_MAX, &readfds, NULL, NULL, NULL) < 0 &&
+ if ( select(maxfd+1, &readfds, NULL, NULL, NULL) < 0 &&
errno != EINTR )
break;
diff --git a/modules/lookup_userhome.c b/modules/lookup_userhome.c
index 3953a02..5fa2579 100644
--- a/modules/lookup_userhome.c
+++ b/modules/lookup_userhome.c
@@ -1,10 +1,10 @@
#ident "$Id$"
/* ----------------------------------------------------------------------- *
*
- * lookup_userhome.c - module for Linux automount to generate symlinks
- * to user home directories
+ * lookup_userhome.c - module for Linux automount to generate
+ * bind mounts to user home directories
*
- * Copyright 1999 Transmeta Corporation - All Rights Reserved
+ * Copyright 1999-2004 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
@@ -31,10 +31,16 @@
int lookup_version = AUTOFS_LOOKUP_VERSION; /* Required by protocol */
+static struct mount_mod *mount_bind = NULL;
+
int lookup_init(const char *mapfmt, int argc, const char * const *argv,
void **context)
{
- return 0; /* Nothing to do */
+ /* Make sure we have the local mount method available */
+ if ( !mount_bind )
+ mount_bind = open_mount("bind", MODPREFIX);
+
+ return !mount_bind;
}
int lookup_mount(const char *root, const char *name,
@@ -51,21 +57,12 @@ int lookup_mount(const char *root, const char *name,
return 1; /* Unknown user or error */
}
- /* Create the appropriate symlink */
- if ( chdir(root) ) {
- syslog(LOG_ERR, MODPREFIX "chdir failed: %m");
- return 1;
- }
-
- if ( symlink(pw->pw_dir, name) && errno != EEXIST ) {
- syslog(LOG_DEBUG, MODPREFIX "symlink failed: %m");
- return 1;
- }
-
- return 0;
+ /* Create the appropriate bind mount */
+ return mount_bind->mount_mount(root, name, name_len, pw->pw_dir, "bind",
+ NULL, mount_bind->context);
}
int lookup_done(void *context)
{
- return 0;
+ return mount_bind->mount_done(mount_bind->context);
}
diff --git a/modules/mount_bind.c b/modules/mount_bind.c
index 5a4580e..25ed99f 100644
--- a/modules/mount_bind.c
+++ b/modules/mount_bind.c
@@ -14,6 +14,7 @@
*
* ----------------------------------------------------------------------- */
+#include <alloca.h>
#include <stdio.h>
#include <malloc.h>
#include <errno.h>
diff --git a/modules/mount_changer.c b/modules/mount_changer.c
index 275e3a6..2303ba0 100644
--- a/modules/mount_changer.c
+++ b/modules/mount_changer.c
@@ -117,7 +117,7 @@ slot = atoi (slotName) - 1;
fd = open(device, O_RDONLY | O_NONBLOCK);
if (fd < 0)
{
- syslog(LOG_NOTICE, MODPREFIX "Opening device %s failed : %s", device, strerror(errno));
+ syslog(LOG_NOTICE, MODPREFIX "Opening device %s failed : %m", device);
return 1;
}
@@ -125,7 +125,7 @@ if (fd < 0)
total_slots_available = ioctl (fd, CDROM_CHANGER_NSLOTS);
if (total_slots_available <= 1 )
{
- syslog(LOG_NOTICE, MODPREFIX, "Device %s is not an ATAPI compliant CD changer.\n", device);
+ syslog(LOG_NOTICE, MODPREFIX "Device %s is not an ATAPI compliant CD changer.\n", device);
return 1;
}
@@ -133,7 +133,7 @@ if (total_slots_available <= 1 )
slot=ioctl (fd, CDROM_SELECT_DISC, slot);
if (slot<0)
{
- syslog(LOG_NOTICE, MODPREFIX, "CDROM_SELECT_DISC failed");
+ syslog(LOG_NOTICE, MODPREFIX "CDROM_SELECT_DISC failed");
return 1;
}
@@ -141,7 +141,7 @@ if (slot<0)
status = close (fd);
if (status != 0)
{
- syslog(LOG_NOTICE, MODPREFIX, "close failed for `%s': %s\n", device, strerror(errno));
+ syslog(LOG_NOTICE, MODPREFIX "close failed for `%s': %m\n", device);
return 1;
}
return 0;
diff --git a/modules/mount_ext2.c b/modules/mount_ext2.c
index ec314d8..1c5c817 100644
--- a/modules/mount_ext2.c
+++ b/modules/mount_ext2.c
@@ -14,6 +14,7 @@
*
* ----------------------------------------------------------------------- */
+#include <alloca.h>
#include <stdio.h>
#include <malloc.h>
#include <errno.h>
diff --git a/modules/mount_generic.c b/modules/mount_generic.c
index 135a10b..30ad177 100644
--- a/modules/mount_generic.c
+++ b/modules/mount_generic.c
@@ -14,6 +14,7 @@
*
* ----------------------------------------------------------------------- */
+#include <alloca.h>
#include <stdio.h>
#include <malloc.h>
#include <errno.h>
diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
index e1d9e6b..6592dc1 100644
--- a/modules/mount_nfs.c
+++ b/modules/mount_nfs.c
@@ -1,10 +1,9 @@
#ident "$Id$"
/* ----------------------------------------------------------------------- *
*
- * mount_nfs.c - Module for Linux automountd to mount an NFS filesystem,
- * with fallback to symlinking if the path is local
+ * mount_nfs.c - Module for Linux automountd to mount an NFS filesystem
*
- * Copyright 1997-2000 Transmeta Corporation - All Rights Reserved
+ * Copyright 1997-2004 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
@@ -14,6 +13,7 @@
*
* ----------------------------------------------------------------------- */
+#include <alloca.h>
#include <stdio.h>
#include <malloc.h>
#include <errno.h>
@@ -34,121 +34,32 @@
#define MODPREFIX "mount(nfs): "
int mount_version = AUTOFS_MOUNT_VERSION; /* Required by protocol */
-static int udpproto;
-static short port_discard;
-
-static struct mount_mod *mount_bind = NULL;
-
int mount_init(void **context)
{
- struct protoent *udp;
- struct servent *port_dis;
-
- /* These are context independent */
- udp = getprotobyname("udp");
- udpproto = udp ? udp->p_proto : 0;
- port_dis = getservbyname("discard","udp");
- if ( port_dis )
- port_discard = port_dis->s_port;
- else
- port_discard = htons(9); /* 9 is the standard discard port */
-
- /* Make sure we have the local mount method available */
- if ( !mount_bind )
- mount_bind = open_mount("bind", MODPREFIX);
-
- return !mount_bind;
+ return 0;
}
int mount_mount(const char *root, const char *name, int name_len,
const char *what, const char *fstype,
const char *options, void *context)
{
- char *colon, *localname, **haddr, *fullpath;
- char *whatstr, *hostname, *comma, *paren;
- struct hostent *he;
- struct sockaddr_in saddr, laddr;
- int sock, local, err;
- size_t len;
-
- whatstr = alloca(strlen(what)+1);
- if ( !whatstr ) {
- syslog(LOG_NOTICE, MODPREFIX "alloca: %m");
- return 1;
- }
- strcpy(whatstr, what);
-
- colon = strchr(whatstr, ':');
- if ( !colon ) {
- /* No colon, take this as a bind (local) entry */
- local = 1;
- localname = whatstr;
+ const char *whatstr;
+ char *mntstr;
+ char *colon, *fullpath;
+ int err;
+
+ colon = strchr(what, ':');
+ if ( !colon || what[0] == ':' ) {
+ /* This is a localhost entry */
+ mntstr = alloca(strlen(what)+11);
+ if ( !mntstr ) {
+ syslog(LOG_ERR, MODPREFIX "alloca: %m");
+ return 1;
+ }
+ sprintf(mntstr, "localhost:%s", colon ? what+1 : what);
+ whatstr = mntstr;
} else {
- *colon = '\0';
-
- /* The host part may actually be a comma-separated list of hosts with
- parenthesized weights. We want to check each host, ignoring any
- weights, until we either find the localhost or reach the end of the
- list. */
- local = 0;
- localname = colon+1;
- hostname = whatstr;
- do {
- comma = strchr(hostname, ',');
- if ( comma )
- *comma = '\0';
-
- paren = strchr(hostname, '(');
- if ( paren )
- *paren = '\0';
-
- if ( !(he = gethostbyname(hostname)) ) {
- syslog(LOG_NOTICE, MODPREFIX "entry %s: host %s: lookup failure",
- name, hostname);
- return 1; /* No such host */
- }
-
- /* Probe to see if we are the local host. Open a UDP socket and see
- if the local address is the same as the remote one */
-
- for ( haddr = he->h_addr_list ; *haddr ; haddr++ ) {
- sock = socket(AF_INET, SOCK_DGRAM, udpproto);
- if ( sock < 0 ) {
- syslog(LOG_ERR, MODPREFIX "socket: %m");
- return 1;
- }
- saddr.sin_family = AF_INET;
- memcpy(&saddr.sin_addr, *haddr, he->h_length);
- saddr.sin_port = port_discard;
-
- len = sizeof(laddr);
-
- if ( connect(sock, (struct sockaddr *) &saddr, sizeof(saddr)) < 0 )
- continue; /* Assume it wasn't local */
-
- if ( getsockname(sock, (struct sockaddr *) &laddr, &len) < 0 ) {
- syslog(LOG_ERR, MODPREFIX "getsockname failed for %s: %m", name);
- close(sock);
- return 1;
- }
- close(sock);
-
- if ( !memcmp(&saddr.sin_addr,&laddr.sin_addr,he->h_length) ) {
- local = 1;
- break;
- }
- }
-
- if ( paren )
- *paren = '(';
-
- if ( comma ) {
- *comma = ',';
- hostname = comma + 1;
- } else {
- hostname += strlen(hostname);
- }
- } while (*hostname && !local);
+ whatstr = what;
}
fullpath = alloca(strlen(root)+name_len+2);
@@ -158,45 +69,34 @@ int mount_mount(const char *root, const char *name, int name_len,
}
sprintf(fullpath, "%s/%s", root, name);
- if ( local ) {
- /* Local host -- do a "bind" */
-
- syslog(LOG_DEBUG, MODPREFIX "%s is local, doing bind", name);
-
- return mount_bind->mount_mount(root,name,name_len,localname,"bind",NULL,mount_bind->context);
- } else {
- /* Not a local host - do an NFS mount */
-
- *colon = ':';
- syslog(LOG_DEBUG, MODPREFIX "calling mkdir %s", fullpath);
- if ( mkdir(fullpath, 0555) && errno != EEXIST ) {
- syslog(LOG_NOTICE, MODPREFIX "mkdir %s failed: %m", name);
- return 1;
- }
+ syslog(LOG_DEBUG, MODPREFIX "calling mkdir %s", fullpath);
+ if ( mkdir(fullpath, 0555) && errno != EEXIST ) {
+ syslog(LOG_NOTICE, MODPREFIX "mkdir %s failed: %m", name);
+ return 1;
+ }
- if ( options ) {
- syslog(LOG_DEBUG, MODPREFIX "calling mount -t nfs " SLOPPY "-o %s %s %s",
- options, whatstr, fullpath);
- err = spawnl(LOG_NOTICE, PATH_MOUNT, PATH_MOUNT, "-t", "nfs",
- SLOPPYOPT "-o", options, whatstr, fullpath, NULL);
- } else {
- syslog(LOG_DEBUG, MODPREFIX "calling mount -t nfs %s %s", whatstr, fullpath);
- err = spawnl(LOG_NOTICE, PATH_MOUNT, PATH_MOUNT, "-t", "nfs",
- whatstr, fullpath, NULL);
- }
- if ( err ) {
- rmdir(fullpath);
- syslog(LOG_NOTICE, MODPREFIX "nfs: mount failure %s on %s",
- whatstr, fullpath);
- return 1;
- } else {
- syslog(LOG_DEBUG, MODPREFIX "mounted %s on %s", whatstr, fullpath);
- return 0;
- }
+ if ( options ) {
+ syslog(LOG_DEBUG, MODPREFIX "calling mount -t nfs " SLOPPY "-o %s %s %s",
+ options, whatstr, fullpath);
+ err = spawnl(LOG_NOTICE, PATH_MOUNT, PATH_MOUNT, "-t", "nfs",
+ SLOPPYOPT "-o", options, whatstr, fullpath, NULL);
+ } else {
+ syslog(LOG_DEBUG, MODPREFIX "calling mount -t nfs %s %s", whatstr, fullpath);
+ err = spawnl(LOG_NOTICE, PATH_MOUNT, PATH_MOUNT, "-t", "nfs",
+ whatstr, fullpath, NULL);
+ }
+ if ( err ) {
+ rmdir(fullpath);
+ syslog(LOG_NOTICE, MODPREFIX "nfs: mount failure %s on %s",
+ whatstr, fullpath);
+ return 1;
+ } else {
+ syslog(LOG_DEBUG, MODPREFIX "mounted %s on %s", whatstr, fullpath);
+ return 0;
}
}
int mount_done(void *context)
{
- return mount_bind->mount_done(mount_bind->context);
+ return 0;
}
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
index 10851e4..6e7c0e9 100644
--- a/modules/parse_sun.c
+++ b/modules/parse_sun.c
@@ -4,7 +4,7 @@
* parse_sun.c - module for Linux automountd to parse a Sun-format
* automounter map
*
- * Copyright 1997 Transmeta Corporation - All Rights Reserved
+ * Copyright 1997-2004 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
@@ -14,6 +14,7 @@
*
* ----------------------------------------------------------------------- */
+#include <alloca.h>
#include <stdio.h>
#include <malloc.h>
#include <errno.h>
@@ -464,7 +465,7 @@ int parse_mount(const char *root, const char *name,
if ( !strncmp(q, "fstype=", 7) ) {
fstype = alloca(strlen(q+7)+1);
if ( !fstype ) {
- syslog(LOG_ERR, MODPREFIX "alloca: %s");
+ syslog(LOG_ERR, MODPREFIX "alloca: %m");
return 1;
}
strcpy(fstype, q+7);