diff options
author | H. Peter Anvin <hpa@zytor.com> | 1999-03-07 22:34:52 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 1999-03-07 22:34:52 +0000 |
commit | 5f1a8c61b586d953629132f5b152188ef2ccc7f1 (patch) | |
tree | 7439c9db127a4dab72135ae38937e947a2d9f0a8 /modules | |
parent | 1560e5fe1628486d8f60d45a7cdd2d6e3995498b (diff) | |
download | autofs3-5f1a8c61b586d953629132f5b152188ef2ccc7f1.tar.gz autofs3-5f1a8c61b586d953629132f5b152188ef2ccc7f1.tar.xz autofs3-5f1a8c61b586d953629132f5b152188ef2ccc7f1.zip |
Added lookup_userhome.
Fixed options bug in mount_autofs.
Removed dummy comment in lookup_yp.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/Makefile | 4 | ||||
-rw-r--r-- | modules/lookup_userhome.c | 71 | ||||
-rw-r--r-- | modules/lookup_yp.c | 3 | ||||
-rw-r--r-- | modules/mount_autofs.c | 14 |
4 files changed, 84 insertions, 8 deletions
diff --git a/modules/Makefile b/modules/Makefile index c49ff27..8871934 100644 --- a/modules/Makefile +++ b/modules/Makefile @@ -6,11 +6,11 @@ -include ../Makefile.conf include ../Makefile.rules -SRCS := lookup_yp.c lookup_file.c lookup_program.c \ +SRCS := lookup_yp.c lookup_file.c lookup_program.c lookup_userhome.c \ parse_sun.c \ mount_generic.c mount_nfs.c mount_afs.c mount_autofs.c -MODS := lookup_yp.so lookup_file.so lookup_program.so \ +MODS := lookup_yp.so lookup_file.so lookup_program.so lookup_userhome.so \ parse_sun.so \ mount_generic.so mount_nfs.so mount_afs.so mount_autofs.so diff --git a/modules/lookup_userhome.c b/modules/lookup_userhome.c new file mode 100644 index 0000000..3953a02 --- /dev/null +++ b/modules/lookup_userhome.c @@ -0,0 +1,71 @@ +#ident "$Id$" +/* ----------------------------------------------------------------------- * + * + * lookup_userhome.c - module for Linux automount to generate symlinks + * to user home directories + * + * 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 <stdio.h> +#include <malloc.h> +#include <errno.h> +#include <pwd.h> +#include <unistd.h> +#include <syslog.h> +#include <sys/param.h> +#include <sys/types.h> +#include <sys/stat.h> + +#define MODULE_LOOKUP +#include "automount.h" + +#define MODPREFIX "lookup(userhome): " + +int lookup_version = AUTOFS_LOOKUP_VERSION; /* Required by protocol */ + +int lookup_init(const char *mapfmt, int argc, const char * const *argv, + void **context) +{ + return 0; /* Nothing to do */ +} + +int lookup_mount(const char *root, const char *name, + int name_len, void *context) +{ + struct passwd *pw; + + syslog(LOG_DEBUG, MODPREFIX "looking up %s", name); + + /* Get the equivalent username */ + pw = getpwnam(name); + if ( !pw ) { + syslog(LOG_DEBUG, MODPREFIX "not found: %s", 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; +} + +int lookup_done(void *context) +{ + return 0; +} diff --git a/modules/lookup_yp.c b/modules/lookup_yp.c index 953c4bb..fe2699c 100644 --- a/modules/lookup_yp.c +++ b/modules/lookup_yp.c @@ -14,9 +14,6 @@ * * ----------------------------------------------------------------------- */ -/* - */ - #include <stdio.h> #include <malloc.h> #include <errno.h> diff --git a/modules/mount_autofs.c b/modules/mount_autofs.c index 967d747..3a5e84d 100644 --- a/modules/mount_autofs.c +++ b/modules/mount_autofs.c @@ -75,6 +75,7 @@ int mount_mount(const char *root, const char *name, int name_len, char *p = options; do { argc++; + if ( *p == ',' ) p++; } while ((p = strchr(p,',')) != NULL); } argv = (char **) alloca((argc+1) * sizeof(char *)); @@ -94,9 +95,16 @@ int mount_mount(const char *root, const char *name, int name_len, argv[argc++] = p; if ( options ) { - argv[argc++] = strtok(options, ","); - while ((argv[argc++] = strtok(NULL, ",")) != NULL) - continue; + /* Rainer Clasen reported funniness using strtok() here. */ + + p = options; + do { + if ( *p == ',' ) { + *p = '\0'; + p++; + } + argv[argc++] = p; + } while ( (p = strchr(p,',')) != NULL ); } argv[argc] = NULL; |