From 71cd403331aa14c5f8c30440e60cf6d8d83ada06 Mon Sep 17 00:00:00 2001 From: Packit Service Date: Nov 06 2020 06:10:23 +0000 Subject: Prepare for a new update Reverting patches so we can apply the latest update and changes can be seen in the spec file and sources. --- diff --git a/CHANGELOG b/CHANGELOG index 4557bcd..246279a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,87 +1,3 @@ -xx/xx/2018 autofs-5.1.5 -- fix flag file permission. -- fix directory create permission. -- fix use after free in do_master_list_reset(). -- fix deadlock in dumpmaps. -- dont use array for path when not necessary. -- fix prefix option handling in expand_entry(). -- fix sublink option not set from defaults. -- fix error return in do_nfs_mount(). -- add error handling for ext_mount_add(). -- account for recent libnsl changes. -- use_hostname_for_mounts shouldn't prevent selection among replicas. -- fix monotonic_elapsed. -- Makefiles.rules: remove 'samples' from SUBDIRS. -- dont allow trailing slash in master map mount points. -- fix libresolv configure check. -- add fedfs-getsrvinfo.c. -- add mount.fedfs.c. -- add fedfs-map-nfs4.c. -- add conditional inclusion of fedfs binaries. -- add an example fedfs master map entry to the installed master map. -- improve hostname lookup error logging. -- tiny patch for autofs typo and possible bug. -- add units After line to include statd service. -- use systemd sd_notify() at startup. -- fix NFS version mask usage. -- fix fd leak in rpc_do_create_client(). -- add-man page note about extra slashes in paths. -- covarity fixes. -- fix program usage message. -- fix update_negative_cache() map source usage. -- mark removed cache entry negative. -- set bind mount as propagation slave. -- add master map pseudo options for mount propagation. -- fix age setting at startup. -- fix use after free in parse_ldap_config(). -- fix incorrect locking in sss lookup. -- fix amd parser opts option handling. -- better handle hesiod support not built in. -- fix hesiod string check in master_parse(). -- remove autofs4 module load code. -- add NULL check in prepare_attempt_prefix(). -- update build info with systemd. -- use flags for startup boolean options. -- move close stdio descriptors to become_daemon(). -- add systemd service command line option. -- support strictexpire mount option. -- add NULL check for get_addr_string() return. -- use malloc(3) in spawn.c. -- add mount_verbose configuration option. -- optionally log mount requestor process info. -- log mount call arguments if mount_verbose is set. -- make expire remaining log level debug. -- allow period following macro in selector value. -- fix macro expansion in selector values. -- also use strictexpire for offsets. -- change expire type naming to better reflect usage. -- remove unused function has_fstab_option(). -- remove unused function reverse_mnt_list(). -- remove a couple of old debug messages. -- fix amd entry memory leak. -- fix unlink_mount_tree() not umounting mounts. -- add ignore mount option. -- use ignore option for offset mounts as well. -- add config option for "ignore" mount option -- use bit flags for autofs mount types in mnt_list. -- use mp instead of path in mnt_list entries. -- always use PROC_MOUNTS to make mount lists. -- add glibc getmntent_r(). -- use local getmntent_r in table_is_mounted(). -- refactor unlink_active_mounts() in direct.c. -- don't use tree_is_mounted() for mounted checks. -- use single unlink_umount_tree() for both direct and indirect mounts. -- move unlink_mount_tree() to lib/mounts.c. -- use local_getmntent_r() for unlink_mount_tree(). -- use local getmntent_r() in get_mnt_list(). -- use local getmntent_r() in tree_make_mnt_list(). -- fix missing initialization of autofs_point flags. -- fix a regression with map instance lookup. -- fix trailing dollar sun entry expansion. -- initialize struct addrinfo for getaddrinfo() calls. -- fix quoted string length calc in expandsunent(). -- fix autofs mount options construction. - 19/12/2017 autofs-5.1.4 - fix spec file url. - fix unset tsd group name handling. diff --git a/Makefile b/Makefile index 99db2c7..e560a7c 100644 --- a/Makefile +++ b/Makefile @@ -19,9 +19,6 @@ kernel: samples: set -e; if [ -d samples ]; then $(MAKE) -C samples all; fi -fedfs: - set -e; if [ -d fedfs ]; then $(MAKE) -C fedfs all; fi - clean: for i in $(SUBDIRS) samples; do \ if [ -d $$i ]; then $(MAKE) -C $$i clean; fi; done diff --git a/Makefile.conf.in b/Makefile.conf.in index ff9b18a..f879e26 100644 --- a/Makefile.conf.in +++ b/Makefile.conf.in @@ -14,13 +14,10 @@ DAEMON_LDFLAGS = @DAEMON_LDFLAGS@ # Glibc < 2.17 requires librt for clock_gettime() LIBCLOCK_GETTIME = @LIBCLOCK_GETTIME@ -NSLLIB = @NSL_LIBS@ -NSLCFLAGS = @NSL_CFLAGS@ +# Special parameters for glibc (libc 6) +LIBNSL = @LIBNSL@ LIBRESOLV = @LIBRESOLV@ -SYSTEMD = @WITH_SYSTEMD@ -LIBSYSTEMD = @systemd_LIBS@ - # Hesiod support: yes (1) no (0) HESIOD = @HAVE_HESIOD@ LIBHESIOD = @LIBHESIOD@ @@ -61,8 +58,6 @@ EXT3FS = @HAVE_E3FSCK@ # Support for calling e4fsck when mounting ext4 filesystems EXT4FS = @HAVE_E4FSCK@ -FEDFS = @ENABLE_FEDFS@ - LEX = @PATH_LEX@ YACC = @PATH_YACC@ RPCGEN = @PATH_RPCGEN@ diff --git a/Makefile.rules b/Makefile.rules index 2ccb1f6..0edf9bf 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -3,16 +3,12 @@ # # Root directory contents -SUBDIRS = lib daemon modules man +SUBDIRS = lib daemon modules man samples INCDIRS = include INCFILES = COPYING COPYRIGHT NEWS README* TODO Makefile Makefile.rules \ Makefile.conf.in .version .autofs-* configure.in aclocal.m4 \ configure *.patch autofs.spec -ifeq ($(FEDFS), 1) - SUBDIRS += fedfs -endif - # Attempt to be friends with autotools INSTALLROOT = $(DESTDIR) @@ -58,6 +54,8 @@ ifdef DMALLOCLIB LIBS += $(DMALLOCLIB) endif +LIBS += $(LIBNSL) + LIBS += $(LIBCLOCK_GETTIME) # Standard rules diff --git a/README.autofs-schema b/README.autofs-schema index b8c6d6a..c121e1c 100644 --- a/README.autofs-schema +++ b/README.autofs-schema @@ -9,10 +9,10 @@ not clear what schema to use for Linux autofs information. The schema was corrected somewhere along the line but the autofs distribution copy was never updated. The schema has now been -updated but may not be accurate and may conflict with other LDAP -schemas so it is not recommended for use for autofs map information. +updated but it is not recommended for use as the schema for autofs +map information. -The rfc2307 or the rfc2307bis schema is the recommened schema to -use, based on requirements. +The rfc2307 or, preferably the, rfc2307bis schema is the recommened +schema to use. Ian diff --git a/README.ldap-schema b/README.ldap-schema deleted file mode 100644 index 6cb0ba1..0000000 --- a/README.ldap-schema +++ /dev/null @@ -1,14 +0,0 @@ -LDAP Schema -=========== - -LDAP Schema definitions may be found in the samples sub-directory. - -The ldap schema rfc2307.schema and rfc2307bis.schema may be used by -autofs for Sun format automount maps, the choice of which is used is -dependent on user needs. They are included for reference only as at -least one of these should be included in LDAP server distributions. - -The ldap schema am-utils-ldap.schema and am-utils-ldap-id.txt describe -the schema used by autofs for amd format maps. - -Ian diff --git a/aclocal.m4 b/aclocal.m4 index ec362bb..5177204 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -257,17 +257,14 @@ AC_DEFUN([AF_WITH_SYSTEMD], fi done fi - WITH_SYSTEMD=0 if test -n "$systemddir"; then AC_MSG_RESULT($systemddir) - WITH_SYSTEMD=1 else AC_MSG_RESULT(not found) fi else if test "$withval" != no; then systemddir=$withval - WITH_SYSTEMD=1 fi fi]) ]) @@ -420,48 +417,3 @@ fi LIBS="$af_check_ldap_parse_page_control_save_libs" ]) -dnl -------------------------------------------------------------------------- -dnl AF_CHECK_YPCLNT_HEADER -dnl -dnl Check for include file rpcsvc/ypclnt.h for YellowPages support. -dnl -------------------------------------------------------------------------- -AC_DEFUN([AF_CHECK_YPCLNT_HEADER], -[ -# save current CFLAGS -af_check_ypclnt_header_save_cflags="$CFLAGS" -CFLAGS="$CFLAGS $NSL_CFLAGS $TIRPC_CFLAGS" - -HAVE_YPCLNT=0 -AC_CHECK_HEADER([rpcsvc/ypclnt.h], HAVE_YPCLNT=1) -AC_SUBST(HAVE_YPCLNT) -if test "$HAVE_YPCLNT" = "1"; then - AC_DEFINE(HAVE_YPCLNT, 1, - [Define if using YellowPages]) -fi - -# restore libs -CFLAGS="$af_check_ypclnt_header_save_cflags" -]) - -dnl -------------------------------------------------------------------------- -dnl AF_CHECK_NIS_HEADER -dnl -dnl Check for include file rpcsvc/nis.h for NIS+ support. -dnl -------------------------------------------------------------------------- -AC_DEFUN([AF_CHECK_NIS_HEADER], -[ -# save current CFLAGS -af_check_nis_header_save_cflags="$CFLAGS" -CFLAGS="$CFLAGS $NSL_CFLAGS $TIRPC_CFLAGS" - -HAVE_NISPLUS=0 -AC_CHECK_HEADER([rpcsvc/nis.h], HAVE_NISPLUS=1) -AC_SUBST(HAVE_NISPLUS) -if test "$HAVE_NISPLUS" = "1"; then - AC_DEFINE(HAVE_NISPLUS, 1, - [Define if using NIS+]) -fi - -# restore libs -CFLAGS="$af_check_nis_header_save_cflags" -]) diff --git a/autofs.spec b/autofs.spec index a4d6dc8..6da0655 100644 --- a/autofs.spec +++ b/autofs.spec @@ -16,10 +16,6 @@ # disable them. %define with_libtirpc %{?_without_libtirpc: 0} %{?!_without_libtirpc: 1} -# Use --without fedfs in your rpmbuild command or force values to 0 to -# disable them. -%define with_fedfs %{?_without_fedfs: 0} %{?!_without_fedfs: 1} - Summary: A tool from automatically mounting and umounting filesystems. Name: autofs %define version 5.1.4 @@ -32,7 +28,6 @@ Source: https://www.kernel.org/pub/linux/daemons/autofs/v5/autofs-%{version}.tar Buildroot: %{_tmppath}/%{name}-tmp %if %{with_systemd} BuildRequires: systemd-units -BuildRequires: systemd-devel %endif %if %{with_libtirpc} BuildRequires: libtirpc-devel @@ -87,9 +82,6 @@ echo %{version}-%{release} > .version %if %{with_libtirpc} %define libtirpc_configure_arg --with-libtirpc %endif -%if %{with_fedfs} - %define fedfs_configure_arg --enable-fedfs -%endif %build CFLAGS="$RPM_OPT_FLAGS -Wall" \ @@ -98,8 +90,7 @@ LDFLAGS="-Wl,-z,now" \ --disable-mount-locking \ --enable-ignore-busy \ %{?systemd_configure_arg:} \ - %{?libtirpc_configure_arg:} \ - %{?fedfs_configure_arg:} + %{?libtirpc_configure_arg:} CFLAGS="$RPM_OPT_FLAGS -Wall" LDFLAGS="-Wl,-z,now" make initdir=/etc/rc.d/init.d DONTSTRIP=1 %install @@ -130,12 +121,6 @@ install -m 755 redhat/autofs.init $RPM_BUILD_ROOT/etc/rc.d/init.d/autofs install -m 644 redhat/autofs.conf $RPM_BUILD_ROOT/etc/autofs.conf install -m 644 redhat/autofs.sysconfig $RPM_BUILD_ROOT/etc/sysconfig/autofs -install -m 644 samples/auto.master $RPM_BUILD_ROOT/etc/auto.master -install -m 644 samples/auto.misc $RPM_BUILD_ROOT/etc/auto.misc -install -m 644 samples/auto.net $RPM_BUILD_ROOT/etc/auto.net -install -m 644 samples/auto.smb $RPM_BUILD_ROOT/etc/auto.smb -install -m 600 samples/autofs_ldap_auth.conf $RPM_BUILD_ROOT/etc/autofs_ldap_auth.conf - %clean [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT @@ -200,10 +185,6 @@ fi %config(noreplace) /etc/sysconfig/autofs %config(noreplace) /etc/autofs_ldap_auth.conf %{_sbindir}/automount -%if %{with_fedfs} -%{_sbindir}/mount.fedfs -%{_sbindir}/fedfs-map-nfs4 -%endif %dir %{_libdir}/autofs %{_libdir}/autofs/* %{_mandir}/*/* diff --git a/configure b/configure index 2116668..476cea4 100755 --- a/configure +++ b/configure @@ -634,8 +634,8 @@ XML_FLAGS LIBLDAP HAVE_LDAP LDAP_FLAGS -HAVE_NISPLUS HAVE_YPCLNT +HAVE_NISPLUS EGREP GREP CPP @@ -643,12 +643,10 @@ HESIOD_FLAGS LIBHESIOD HAVE_HESIOD LIBRESOLV -NSL_LIBS -NSL_CFLAGS +LIBNSL LIBCLOCK_GETTIME KRB5_CONFIG XML_CONFIG -ENABLE_FEDFS sssldir HAVE_SSS_AUTOFS PATH_RPCGEN @@ -659,6 +657,8 @@ PATH_YACC YACC PATH_LEX LEX +HAVE_MODPROBE +MODPROBE HAVE_E4FSCK E4FSCK HAVE_E3FSCK @@ -672,12 +672,6 @@ MOUNT_NFS HAVE_MOUNT MOUNT DMALLOCLIB -TIRPC_LIBS -TIRPC_CFLAGS -flagdir -fifodir -mapdir -confdir OBJEXT EXEEXT ac_ct_CC @@ -685,13 +679,16 @@ CPPFLAGS LDFLAGS CFLAGS CC -systemd_LIBS -systemd_CFLAGS -WITH_SYSTEMD -systemddir +TIRPC_LIBS +TIRPC_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG +flagdir +fifodir +mapdir +confdir +systemddir piddir initdir target_alias @@ -745,7 +742,6 @@ with_libtirpc with_dmalloc enable_sloppy_mount enable_no_canon_umount -enable_fedfs with_hesiod with_openldap with_sasl @@ -761,17 +757,13 @@ target_alias PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR -systemd_CFLAGS -systemd_LIBS +TIRPC_CFLAGS +TIRPC_LIBS CC CFLAGS LDFLAGS LIBS CPPFLAGS -TIRPC_CFLAGS -TIRPC_LIBS -NSL_CFLAGS -NSL_LIBS CPP' @@ -1382,7 +1374,6 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-sloppy-mount enable the use of the -s option to mount --enable-no-canon-umount enable the use of the -c option to umount - --enable-fedfs enable inclusion of fedfs binaries mount.fedfs and fedfs-map-nfs4 --disable-ext-env disable search in environment for substitution variable --disable-mount-locking disable use of locking when spawning mount command --enable-force-shutdown enable USR1 signal to force unlink umount of any @@ -1416,10 +1407,9 @@ Some influential environment variables: directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path - systemd_CFLAGS - C compiler flags for systemd, overriding pkg-config - systemd_LIBS - linker flags for systemd, overriding pkg-config + TIRPC_CFLAGS + C compiler flags for TIRPC, overriding pkg-config + TIRPC_LIBS linker flags for TIRPC, overriding pkg-config CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a @@ -1427,11 +1417,6 @@ Some influential environment variables: LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory - TIRPC_CFLAGS - C compiler flags for TIRPC, overriding pkg-config - TIRPC_LIBS linker flags for TIRPC, overriding pkg-config - NSL_CFLAGS C compiler flags for NSL, overriding pkg-config - NSL_LIBS linker flags for NSL, overriding pkg-config CPP C preprocessor Use these variables to override the choices made by `configure' or to help @@ -2298,6 +2283,166 @@ if test -z "$piddir"; then fi +# +# Check for systemd unit files direectory exists if unit file installation +# is requested +# + +# Check whether --with-systemd was given. +if test "${with_systemd+set}" = set; then : + withval=$with_systemd; if test "$withval" = yes; then + if test -z "$systemddir"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking location of the systemd unit files directory" >&5 +$as_echo_n "checking location of the systemd unit files directory... " >&6; } + for systemd_d in /usr/lib/systemd/system /usr/lib64/systemd/system /lib/systemd/system /lib64/systemd/system; do + if test -z "$systemddir"; then + if test -d "$systemd_d"; then + systemddir="$systemd_d" + fi + fi + done + fi + if test -n "$systemddir"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $systemddir" >&5 +$as_echo "$systemddir" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + fi +else + if test "$withval" != no; then + systemddir=$withval + fi +fi +fi + + + + +# +# Location of system config script directory? +# +if test -z "$confdir"; then + for conf_d in /etc/sysconfig /etc/defaults /etc/conf.d /etc/default; do + if test -z "$confdir"; then + if test -d "$conf_d"; then + confdir="$conf_d" + fi + fi + done +fi + +# Check whether --with-confdir was given. +if test "${with_confdir+set}" = set; then : + withval=$with_confdir; if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no" + then + : + else + confdir="${withval}" + fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for autofs configuration file directory" >&5 +$as_echo_n "checking for autofs configuration file directory... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $confdir" >&5 +$as_echo "$confdir" >&6; } + + +# +# The user can specify --with-mapsdir=PATH to specify autofs maps go +# +if test -z "$mapdir"; then + for map_d in /etc/autofs /etc; do + if test -z "$mapdir"; then + if test -d "$map_d"; then + mapdir="$map_d" + fi + fi + done +fi + +# Check whether --with-mapdir was given. +if test "${with_mapdir+set}" = set; then : + withval=$with_mapdir; if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no" + then + : + else + mapdir="${withval}" + fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for autofs maps directory" >&5 +$as_echo_n "checking for autofs maps directory... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $mapdir" >&5 +$as_echo "$mapdir" >&6; } + + +# +# The user can specify --with-fifodir=PATH to specify where autofs fifos go +# +if test -z "$fifodir"; then + for fifo_d in /run /var/run /tmp; do + if test -z "$fifodir"; then + if test -d "$fifo_d"; then + fifodir="$fifo_d" + fi + fi + done +fi + +# Check whether --with-fifodir was given. +if test "${with_fifodir+set}" = set; then : + withval=$with_fifodir; if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no" + then + : + else + fifodir="${withval}" + fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for autofs fifos directory" >&5 +$as_echo_n "checking for autofs fifos directory... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $fifodir" >&5 +$as_echo "$fifodir" >&6; } + + +# +# The user can specify --with-flagdir=PATH to specify where autofs flag file goes +# +if test -z "$flagdir"; then + for flag_d in /run /var/run /tmp; do + if test -z "$flagdir"; then + if test -d "$flag_d"; then + flagdir="$flag_d" + fi + fi + done +fi + +# Check whether --with-flagdir was given. +if test "${with_flagdir+set}" = set; then : + withval=$with_flagdir; if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no" + then + : + else + flagdir="${withval}" + fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for autofs flag file directory" >&5 +$as_echo_n "checking for autofs flag file directory... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $flagdir" >&5 +$as_echo "$flagdir" >&6; } + + +# +# Use libtirpc +# + @@ -2418,46 +2563,111 @@ $as_echo "no" >&6; } fi fi -# -# Check for systemd unit files direectory exists if unit file installation -# is requested -# +# Check whether --with-libtirpc was given. +if test "${with_libtirpc+set}" = set; then : + withval=$with_libtirpc; +fi -# Check whether --with-systemd was given. -if test "${with_systemd+set}" = set; then : - withval=$with_systemd; if test "$withval" = yes; then - if test -z "$systemddir"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking location of the systemd unit files directory" >&5 -$as_echo_n "checking location of the systemd unit files directory... " >&6; } - for systemd_d in /usr/lib/systemd/system /usr/lib64/systemd/system /lib/systemd/system /lib64/systemd/system; do - if test -z "$systemddir"; then - if test -d "$systemd_d"; then - systemddir="$systemd_d" - fi - fi - done - fi - WITH_SYSTEMD=0 - if test -n "$systemddir"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $systemddir" >&5 -$as_echo "$systemddir" >&6; } - WITH_SYSTEMD=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - fi +if test "x$with_libtirpc" = "xyes"; then + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for TIRPC" >&5 +$as_echo_n "checking for TIRPC... " >&6; } + +if test -n "$TIRPC_CFLAGS"; then + pkg_cv_TIRPC_CFLAGS="$TIRPC_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtirpc\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libtirpc") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_TIRPC_CFLAGS=`$PKG_CONFIG --cflags "libtirpc" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else - if test "$withval" != no; then - systemddir=$withval - WITH_SYSTEMD=1 - fi + pkg_failed=yes fi + else + pkg_failed=untried +fi +if test -n "$TIRPC_LIBS"; then + pkg_cv_TIRPC_LIBS="$TIRPC_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtirpc\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libtirpc") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_TIRPC_LIBS=`$PKG_CONFIG --libs "libtirpc" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried fi - -ac_ext=c +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + TIRPC_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libtirpc" 2>&1` + else + TIRPC_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libtirpc" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$TIRPC_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (libtirpc) were not met: + +$TIRPC_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables TIRPC_CFLAGS +and TIRPC_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables TIRPC_CFLAGS +and TIRPC_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + TIRPC_CFLAGS=$pkg_cv_TIRPC_CFLAGS + TIRPC_LIBS=$pkg_cv_TIRPC_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + + +$as_echo "#define WITH_LIBTIRPC 1" >>confdefs.h + + +$as_echo "#define TIRPC_WORKAROUND 1" >>confdefs.h + + +fi + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' @@ -3193,565 +3403,61 @@ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for systemd" >&5 -$as_echo_n "checking for systemd... " >&6; } - -if test -n "$systemd_CFLAGS"; then - pkg_cv_systemd_CFLAGS="$systemd_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libsystemd\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libsystemd") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_systemd_CFLAGS=`$PKG_CONFIG --cflags "libsystemd" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$systemd_LIBS"; then - pkg_cv_systemd_LIBS="$systemd_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libsystemd\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libsystemd") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_systemd_LIBS=`$PKG_CONFIG --libs "libsystemd" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - systemd_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libsystemd" 2>&1` - else - systemd_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libsystemd" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$systemd_PKG_ERRORS" >&5 - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sm_notify in -lsystemd" >&5 -$as_echo_n "checking for sm_notify in -lsystemd... " >&6; } -if ${ac_cv_lib_systemd_sm_notify+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lsystemd $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char sm_notify (); -int -main () -{ -return sm_notify (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_systemd_sm_notify=yes -else - ac_cv_lib_systemd_sm_notify=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_systemd_sm_notify" >&5 -$as_echo "$ac_cv_lib_systemd_sm_notify" >&6; } -if test "x$ac_cv_lib_systemd_sm_notify" = xyes; then : - systemd_LIBS="-lsystemd" -fi - - - -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sm_notify in -lsystemd" >&5 -$as_echo_n "checking for sm_notify in -lsystemd... " >&6; } -if ${ac_cv_lib_systemd_sm_notify+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lsystemd $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char sm_notify (); -int -main () -{ -return sm_notify (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_systemd_sm_notify=yes -else - ac_cv_lib_systemd_sm_notify=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_systemd_sm_notify" >&5 -$as_echo "$ac_cv_lib_systemd_sm_notify" >&6; } -if test "x$ac_cv_lib_systemd_sm_notify" = xyes; then : - systemd_LIBS="-lsystemd" -fi - - - -else - systemd_CFLAGS=$pkg_cv_systemd_CFLAGS - systemd_LIBS=$pkg_cv_systemd_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -fi - -# -# Location of system config script directory? -# -if test -z "$confdir"; then - for conf_d in /etc/sysconfig /etc/defaults /etc/conf.d /etc/default; do - if test -z "$confdir"; then - if test -d "$conf_d"; then - confdir="$conf_d" - fi - fi - done -fi - -# Check whether --with-confdir was given. -if test "${with_confdir+set}" = set; then : - withval=$with_confdir; if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no" - then - : - else - confdir="${withval}" - fi - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for autofs configuration file directory" >&5 -$as_echo_n "checking for autofs configuration file directory... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $confdir" >&5 -$as_echo "$confdir" >&6; } - - -# -# The user can specify --with-mapsdir=PATH to specify autofs maps go -# -if test -z "$mapdir"; then - for map_d in /etc/autofs /etc; do - if test -z "$mapdir"; then - if test -d "$map_d"; then - mapdir="$map_d" - fi - fi - done -fi - -# Check whether --with-mapdir was given. -if test "${with_mapdir+set}" = set; then : - withval=$with_mapdir; if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no" - then - : - else - mapdir="${withval}" - fi - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for autofs maps directory" >&5 -$as_echo_n "checking for autofs maps directory... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $mapdir" >&5 -$as_echo "$mapdir" >&6; } - - -# -# The user can specify --with-fifodir=PATH to specify where autofs fifos go -# -if test -z "$fifodir"; then - for fifo_d in /run /var/run /tmp; do - if test -z "$fifodir"; then - if test -d "$fifo_d"; then - fifodir="$fifo_d" - fi - fi - done -fi - -# Check whether --with-fifodir was given. -if test "${with_fifodir+set}" = set; then : - withval=$with_fifodir; if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no" - then - : - else - fifodir="${withval}" - fi - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for autofs fifos directory" >&5 -$as_echo_n "checking for autofs fifos directory... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $fifodir" >&5 -$as_echo "$fifodir" >&6; } - - -# -# The user can specify --with-flagdir=PATH to specify where autofs flag file goes -# -if test -z "$flagdir"; then - for flag_d in /run /var/run /tmp; do - if test -z "$flagdir"; then - if test -d "$flag_d"; then - flagdir="$flag_d" - fi - fi - done -fi - -# Check whether --with-flagdir was given. -if test "${with_flagdir+set}" = set; then : - withval=$with_flagdir; if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no" - then - : - else - flagdir="${withval}" - fi - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for autofs flag file directory" >&5 -$as_echo_n "checking for autofs flag file directory... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $flagdir" >&5 -$as_echo "$flagdir" >&6; } - - -# -# Use libtirpc -# - - - - - - - -if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. -set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PKG_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -PKG_CONFIG=$ac_cv_path_PKG_CONFIG -if test -n "$PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 -$as_echo "$PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_path_PKG_CONFIG"; then - ac_pt_PKG_CONFIG=$PKG_CONFIG - # Extract the first word of "pkg-config", so it can be a program name with args. -set dummy pkg-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $ac_pt_PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG -if test -n "$ac_pt_PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 -$as_echo "$ac_pt_PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_pt_PKG_CONFIG" = x; then - PKG_CONFIG="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - PKG_CONFIG=$ac_pt_PKG_CONFIG - fi -else - PKG_CONFIG="$ac_cv_path_PKG_CONFIG" -fi - -fi -if test -n "$PKG_CONFIG"; then - _pkg_min_version=0.9.0 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 -$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } - if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - PKG_CONFIG="" - fi -fi - -# Check whether --with-libtirpc was given. -if test "${with_libtirpc+set}" = set; then : - withval=$with_libtirpc; -fi - -if test "x$with_libtirpc" = "xyes"; then - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for TIRPC" >&5 -$as_echo_n "checking for TIRPC... " >&6; } - -if test -n "$TIRPC_CFLAGS"; then - pkg_cv_TIRPC_CFLAGS="$TIRPC_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtirpc\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libtirpc") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_TIRPC_CFLAGS=`$PKG_CONFIG --cflags "libtirpc" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$TIRPC_LIBS"; then - pkg_cv_TIRPC_LIBS="$TIRPC_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtirpc\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libtirpc") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_TIRPC_LIBS=`$PKG_CONFIG --libs "libtirpc" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - TIRPC_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libtirpc" 2>&1` - else - TIRPC_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libtirpc" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$TIRPC_PKG_ERRORS" >&5 - - as_fn_error $? "Package requirements (libtirpc) were not met: - -$TIRPC_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -Alternatively, you may set the environment variables TIRPC_CFLAGS -and TIRPC_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details." "$LINENO" 5 -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -Alternatively, you may set the environment variables TIRPC_CFLAGS -and TIRPC_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. - -To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5; } -else - TIRPC_CFLAGS=$pkg_cv_TIRPC_CFLAGS - TIRPC_LIBS=$pkg_cv_TIRPC_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC -$as_echo "#define WITH_LIBTIRPC 1" >>confdefs.h +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : +fi -$as_echo "#define TIRPC_WORKAROUND 1" >>confdefs.h +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu -fi - for ac_func in getrpcbyname getservbyname +for ac_func in getrpcbyname getservbyname do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -4153,6 +3859,65 @@ else HAVE_E4FSCK=0 fi +for ac_prog in modprobe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_MODPROBE+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $MODPROBE in + [\\/]* | ?:[\\/]*) + ac_cv_path_MODPROBE="$MODPROBE" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $searchpath +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_MODPROBE="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +MODPROBE=$ac_cv_path_MODPROBE +if test -n "$MODPROBE"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MODPROBE" >&5 +$as_echo "$MODPROBE" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$MODPROBE" && break +done + +if test -n "$MODPROBE"; then + +$as_echo "#define HAVE_MODPROBE 1" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define PATH_MODPROBE "$MODPROBE" +_ACEOF + + HAVE_MODPROBE=1 +else + HAVE_MODPROBE=0 +fi + for ac_prog in flex lex do @@ -4476,19 +4241,6 @@ $as_echo "#define HAVE_NO_CANON_UMOUNT 1" >>confdefs.h fi -ENABLE_FEDFS="" -# Check whether --enable-fedfs was given. -if test "${enable_fedfs+set}" = set; then : - enableval=$enable_fedfs; -else - enable_fedfs=no -fi - -if test x$enable_fedfs = xyes; then - ENABLE_FEDFS="1" -fi - - # LDAP SASL auth needs libxml and Kerberos for ac_prog in xml2-config do @@ -4748,113 +4500,9 @@ fi - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for NSL" >&5 -$as_echo_n "checking for NSL... " >&6; } - -if test -n "$NSL_CFLAGS"; then - pkg_cv_NSL_CFLAGS="$NSL_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnsl\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libnsl") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_NSL_CFLAGS=`$PKG_CONFIG --cflags "libnsl" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$NSL_LIBS"; then - pkg_cv_NSL_LIBS="$NSL_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnsl\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libnsl") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_NSL_LIBS=`$PKG_CONFIG --libs "libnsl" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - NSL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libnsl" 2>&1` - else - NSL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libnsl" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$NSL_PKG_ERRORS" >&5 - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for yp_match in -lnsl" >&5 -$as_echo_n "checking for yp_match in -lnsl... " >&6; } -if ${ac_cv_lib_nsl_yp_match+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lnsl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char yp_match (); -int -main () -{ -return yp_match (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_nsl_yp_match=yes -else - ac_cv_lib_nsl_yp_match=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_yp_match" >&5 -$as_echo "$ac_cv_lib_nsl_yp_match" >&6; } -if test "x$ac_cv_lib_nsl_yp_match" = xyes; then : - NSL_LIBS="-lnsl" -fi - - -NSL_CFLAGS="" - -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - +# +# glibc/libc 6 new libraries +# { $as_echo "$as_me:${as_lineno-$LINENO}: checking for yp_match in -lnsl" >&5 $as_echo_n "checking for yp_match in -lnsl... " >&6; } if ${ac_cv_lib_nsl_yp_match+:} false; then : @@ -4892,19 +4540,10 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_yp_match" >&5 $as_echo "$ac_cv_lib_nsl_yp_match" >&6; } if test "x$ac_cv_lib_nsl_yp_match" = xyes; then : - NSL_LIBS="-lnsl" + LIBNSL="-lnsl" fi -NSL_CFLAGS="" - -else - NSL_CFLAGS=$pkg_cv_NSL_CFLAGS - NSL_LIBS=$pkg_cv_NSL_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for res_query in -lresolv" >&5 $as_echo_n "checking for res_query in -lresolv... " >&6; } @@ -4944,47 +4583,6 @@ fi $as_echo "$ac_cv_lib_resolv_res_query" >&6; } if test "x$ac_cv_lib_resolv_res_query" = xyes; then : LIBRESOLV="-lresolv" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __res_query in -lresolv" >&5 -$as_echo_n "checking for __res_query in -lresolv... " >&6; } -if ${ac_cv_lib_resolv___res_query+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lresolv $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char __res_query (); -int -main () -{ -return __res_query (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_resolv___res_query=yes -else - ac_cv_lib_resolv___res_query=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolv___res_query" >&5 -$as_echo "$ac_cv_lib_resolv___res_query" >&6; } -if test "x$ac_cv_lib_resolv___res_query" = xyes; then : - LIBRESOLV="-lresolv" -fi - fi @@ -5061,6 +4659,8 @@ fi LDFLAGS="${AF_tmp_ldflags}" +# NIS+ support? +HAVE_NISPLUS=0 ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -5458,11 +5058,15 @@ fi done +ac_fn_c_check_header_mongrel "$LINENO" "rpcsvc/nis.h" "ac_cv_header_rpcsvc_nis_h" "$ac_includes_default" +if test "x$ac_cv_header_rpcsvc_nis_h" = xyes; then : + HAVE_NISPLUS=1 +fi + -# save current CFLAGS -af_check_ypclnt_header_save_cflags="$CFLAGS" -CFLAGS="$CFLAGS $NSL_CFLAGS $TIRPC_CFLAGS" + +# YellowPages support? HAVE_YPCLNT=0 ac_fn_c_check_header_mongrel "$LINENO" "rpcsvc/ypclnt.h" "ac_cv_header_rpcsvc_ypclnt_h" "$ac_includes_default" if test "x$ac_cv_header_rpcsvc_ypclnt_h" = xyes; then : @@ -5477,32 +5081,6 @@ $as_echo "#define HAVE_YPCLNT 1" >>confdefs.h fi -# restore libs -CFLAGS="$af_check_ypclnt_header_save_cflags" - - -# save current CFLAGS -af_check_nis_header_save_cflags="$CFLAGS" -CFLAGS="$CFLAGS $NSL_CFLAGS $TIRPC_CFLAGS" - -HAVE_NISPLUS=0 -ac_fn_c_check_header_mongrel "$LINENO" "rpcsvc/nis.h" "ac_cv_header_rpcsvc_nis_h" "$ac_includes_default" -if test "x$ac_cv_header_rpcsvc_nis_h" = xyes; then : - HAVE_NISPLUS=1 -fi - - - -if test "$HAVE_NISPLUS" = "1"; then - -$as_echo "#define HAVE_NISPLUS 1" >>confdefs.h - -fi - -# restore libs -CFLAGS="$af_check_nis_header_save_cflags" - - # # OpenLDAP support? Expect that this may have a special directory... # diff --git a/configure.in b/configure.in index dbee99f..d366092 100644 --- a/configure.in +++ b/configure.in @@ -48,7 +48,6 @@ AF_INIT_D() AC_SUBST(initdir) AF_PID_D() AC_SUBST(piddir) -PKG_PROG_PKG_CONFIG() # # Check for systemd unit files direectory exists if unit file installation @@ -56,12 +55,6 @@ PKG_PROG_PKG_CONFIG() # AF_WITH_SYSTEMD() AC_SUBST(systemddir) -AC_SUBST(WITH_SYSTEMD) -PKG_CHECK_MODULES([systemd],[libsystemd],, -[ - AC_CHECK_LIB(systemd, sm_notify, systemd_LIBS="-lsystemd") - AC_SUBST(systemd_LIBS) -]) # # Location of system config script directory? @@ -161,6 +154,7 @@ AF_PATH_INCLUDE(UMOUNT, umount, /bin/umount, $searchpath) AF_PATH_INCLUDE(E2FSCK, fsck.ext2 e2fsck, , $searchpath) AF_PATH_INCLUDE(E3FSCK, fsck.ext3 e3fsck, , $searchpath) AF_PATH_INCLUDE(E4FSCK, fsck.ext4 e4fsck, , $searchpath) +AF_PATH_INCLUDE(MODPROBE, modprobe, , $searchpath) AF_CHECK_PROG(LEX, flex lex, , $searchpath) AF_CHECK_PROG(YACC, bison, , $searchpath) @@ -201,15 +195,6 @@ if test x$enable_no_canon_umount = xyes; then AC_DEFINE(HAVE_NO_CANON_UMOUNT, 1, [define if the umount command supports the -c option]) fi -ENABLE_FEDFS="" -AC_ARG_ENABLE(fedfs, -[ --enable-fedfs enable inclusion of fedfs binaries mount.fedfs and fedfs-map-nfs4],, - enable_fedfs=no) -if test x$enable_fedfs = xyes; then - ENABLE_FEDFS="1" -fi -AC_SUBST(ENABLE_FEDFS) - # LDAP SASL auth needs libxml and Kerberos AF_CHECK_LIBXML() AF_CHECK_KRB5() @@ -224,14 +209,13 @@ fi AC_CHECK_LIB(rt, clock_gettime, LIBCLOCK_GETTIME="-lrt") AC_SUBST(LIBCLOCK_GETTIME) -PKG_CHECK_MODULES([NSL],[libnsl],, -[ -AC_CHECK_LIB(nsl, yp_match, NSL_LIBS="-lnsl") -AC_SUBST(NSL_LIBS) -NSL_CFLAGS="" -]) +# +# glibc/libc 6 new libraries +# +AC_CHECK_LIB(nsl, yp_match, LIBNSL="-lnsl") +AC_SUBST(LIBNSL) -AC_CHECK_LIB(resolv, res_query, LIBRESOLV="-lresolv", AC_CHECK_LIB(resolv, __res_query, LIBRESOLV="-lresolv")) +AC_CHECK_LIB(resolv, res_query, LIBRESOLV="-lresolv") AC_SUBST(LIBRESOLV) # @@ -270,8 +254,19 @@ AC_SUBST(LIBHESIOD) AC_SUBST(HESIOD_FLAGS) LDFLAGS="${AF_tmp_ldflags}" -AF_CHECK_YPCLNT_HEADER() -AF_CHECK_NIS_HEADER() +# NIS+ support? +HAVE_NISPLUS=0 +AC_CHECK_HEADER(rpcsvc/nis.h, HAVE_NISPLUS=1) +AC_SUBST(HAVE_NISPLUS) + +# YellowPages support? +HAVE_YPCLNT=0 +AC_CHECK_HEADER([rpcsvc/ypclnt.h], HAVE_YPCLNT=1) +AC_SUBST(HAVE_YPCLNT) +if test "$HAVE_YPCLNT" = "1"; then + AC_DEFINE(HAVE_YPCLNT, 1, + [Define if using YellowPages]) +fi # # OpenLDAP support? Expect that this may have a special directory... diff --git a/daemon/Makefile b/daemon/Makefile index a7ce430..a455c68 100644 --- a/daemon/Makefile +++ b/daemon/Makefile @@ -22,11 +22,6 @@ CFLAGS += -DVERSION_STRING=\"$(version)\" LDFLAGS += -rdynamic LIBS += -ldl -lpthread -ifeq ($(SYSTEMD), 1) - CFLAGS += -DWITH_SYSTEMD - LIBS += $(LIBSYSTEMD) -endif - ifeq ($(LDAP), 1) CFLAGS += $(XML_FLAGS) LIBS += $(XML_LIBS) diff --git a/daemon/automount.c b/daemon/automount.c index 8ec4ac5..5c73961 100644 --- a/daemon/automount.c +++ b/daemon/automount.c @@ -36,9 +36,6 @@ #include #include #include -#ifdef WITH_SYSTEMD -#include -#endif #include "automount.h" #if defined(LIBXML2_WORKAROUND) || defined(TIRPC_WORKAROUND) @@ -54,8 +51,6 @@ const char *libdir = AUTOFS_LIB_DIR; /* Location of library modules */ const char *mapdir = AUTOFS_MAP_DIR; /* Location of mount maps */ const char *confdir = AUTOFS_CONF_DIR; /* Location of autofs config file */ -unsigned int mp_mode = 0755; - unsigned int nfs_mount_uses_string_options = 0; static struct nfs_mount_vers vers, check = {1, 1, 1}; @@ -70,7 +65,7 @@ unsigned int global_selection_options; long global_negative_timeout = -1; int do_force_unlink = 0; /* Forceably unlink mount tree at startup */ -static int start_pipefd[2] = {-1, -1}; +static int start_pipefd[2]; static int st_stat = 1; static int *pst_stat = &st_stat; static pthread_t state_mach_thid; @@ -333,7 +328,7 @@ static int walk_tree(const char *base, int (*fn) (struct autofs_point *ap, struct stat st, *pst = &st; int ret; - if (!is_mounted(base, MNTS_REAL)) + if (!is_mounted(_PATH_MOUNTED, base, MNTS_REAL)) ret = lstat(base, pst); else { pst = NULL; @@ -593,11 +588,11 @@ static int umount_subtree_mounts(struct autofs_point *ap, const char *path, unsi * If this is the root of a multi-mount we've had to umount * it already to ensure it's ok to remove any offset triggers. */ - if (!is_mm_root && is_mounted(path, MNTS_REAL)) { + if (!is_mm_root && is_mounted(_PATH_MOUNTED, path, MNTS_REAL)) { struct amd_entry *entry; debug(ap->logopt, "unmounting dir = %s", path); if (umount_ent(ap, path) && - is_mounted(path, MNTS_REAL)) { + is_mounted(_PATH_MOUNTED, path, MNTS_REAL)) { warn(ap->logopt, "could not umount dir %s", path); left++; goto done; @@ -1195,7 +1190,7 @@ static int handle_packet(struct autofs_point *ap) return -1; } -static void become_daemon(unsigned int flags) +static void become_daemon(unsigned foreground, unsigned daemon_check) { FILE *pidfp; char buf[MAX_ERR_BUF]; @@ -1209,31 +1204,21 @@ static void become_daemon(unsigned int flags) exit(0); } + if (open_pipe(start_pipefd) < 0) { + fprintf(stderr, "%s: failed to create start_pipefd.\n", + program); + exit(0); + } + /* Detach from foreground process */ - if (flags & DAEMON_FLAGS_FOREGROUND && - !(flags & DAEMON_FLAGS_SYSTEMD_SERVICE)) { - if ((flags & DAEMON_FLAGS_CHECK_DAEMON) && !aquire_flag_file()) { + if (foreground) { + if (daemon_check && !aquire_flag_file()) { fprintf(stderr, "%s: program is already running.\n", program); exit(1); } log_to_stderr(); - } else if (flags & DAEMON_FLAGS_SYSTEMD_SERVICE) { - if ((flags & DAEMON_FLAGS_CHECK_DAEMON) && !aquire_flag_file()) { - fprintf(stderr, "%s: program is already running.\n", - program); - exit(1); - } - open_log(); } else { - int nullfd; - - if (open_pipe(start_pipefd) < 0) { - fprintf(stderr, "%s: failed to create start_pipefd.\n", - program); - exit(0); - } - pid = fork(); if (pid > 0) { close(start_pipefd[1]); @@ -1248,7 +1233,7 @@ static void become_daemon(unsigned int flags) } close(start_pipefd[0]); - if ((flags & DAEMON_FLAGS_CHECK_DAEMON) && !aquire_flag_file()) { + if (daemon_check && !aquire_flag_file()) { fprintf(stderr, "%s: program is already running.\n", program); /* Return success if already running */ @@ -1271,30 +1256,7 @@ static void become_daemon(unsigned int flags) close(start_pipefd[1]); exit(*pst_stat); } - - /* Redirect all our file descriptors to /dev/null */ - nullfd = open("/dev/null", O_RDWR); - if (nullfd < 0) { - char *estr = strerror_r(errno, buf, MAX_ERR_BUF); - fprintf(stderr, "cannot open /dev/null: %s", estr); - res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); - close(start_pipefd[1]); - exit(*pst_stat); - } - - if (dup2(nullfd, STDIN_FILENO) < 0 || - dup2(nullfd, STDOUT_FILENO) < 0 || - dup2(nullfd, STDERR_FILENO) < 0) { - char *estr = strerror_r(errno, buf, MAX_ERR_BUF); - fprintf(stderr, - "redirecting file descriptors failed: %s", estr); - res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); - close(start_pipefd[1]); - exit(*pst_stat); - } - - open_log(); - close(nullfd); + log_to_syslog(); } /* Write pid file if requested */ @@ -1926,15 +1888,9 @@ static void usage(void) " -h --help this text\n" " -p --pid-file f write process id to file f\n" " -t --timeout n auto-unmount in n seconds (0-disable)\n" - " -M --master-wait n\n" - " maximum wait time (seconds) for master\n" - " map to become available\n" " -v --verbose be verbose\n" " -d --debug log debuging info\n" - " -Dvariable=value, --define variable=value\n" - " define global macro variable\n" - " -S --systemd-service\n" - " run automounter as a systemd service\n" + " -D --define define global macro variable\n" " -f --foreground do not fork into background\n" " -r --random-multimount-selection\n" " use ramdom replicated server selection\n" @@ -1986,15 +1942,6 @@ static void show_build_info(void) } #endif -#ifdef WITH_SYSTEMD - printf("WITH_SYSTEMD "); - count = count + 13; - - if (count > 60) { - printf("\n "); - count = 0; - } -#endif #ifdef WITH_HESIOD printf("WITH_HESIOD "); @@ -2121,18 +2068,14 @@ static void remove_empty_args(char **argv, int *argc) static void do_master_list_reset(struct master *master) { - struct list_head *head, *p, *n; + struct list_head *head, *p; master_mutex_lock(); head = &master->mounts; - n = head->next; - while (n != head) { + list_for_each(p, head) { struct master_mapent *entry; - p = n; - n = p->next; - entry = list_entry(p, struct master_mapent, list); if (!list_empty(&entry->list)) @@ -2193,14 +2136,14 @@ int main(int argc, char *argv[]) { int res, opt, status; int logpri = -1; - unsigned int flags; - unsigned int logging; + unsigned ghost, logging, daemon_check; + unsigned dumpmaps, foreground, have_global_options; unsigned master_read; int master_wait; time_t timeout; time_t age = monotonic_time(NULL); struct rlimit rlim; - const char *options = "+hp:t:vmdD:SfVrO:l:n:CFM"; + const char *options = "+hp:t:vmdD:fVrO:l:n:CFM"; static const struct option long_options[] = { {"help", 0, 0, 'h'}, {"pid-file", 1, 0, 'p'}, @@ -2208,7 +2151,6 @@ int main(int argc, char *argv[]) {"verbose", 0, 0, 'v'}, {"debug", 0, 0, 'd'}, {"define", 1, 0, 'D'}, - {"systemd-service", 0, 0, 'S'}, {"foreground", 0, 0, 'f'}, {"random-multimount-selection", 0, 0, 'r'}, {"negative-timeout", 1, 0, 'n'}, @@ -2238,15 +2180,17 @@ int main(int argc, char *argv[]) nfs_mount_uses_string_options = check_nfs_mount_version(&vers, &check); - flags = defaults_get_browse_mode() ? DAEMON_FLAGS_GHOST : 0; - flags |= DAEMON_FLAGS_CHECK_DAEMON; - kpkt_len = get_kpkt_len(); master_wait = defaults_get_master_wait(); timeout = defaults_get_timeout(); + ghost = defaults_get_browse_mode(); logging = defaults_get_logging(); global_selection_options = 0; global_options = NULL; + have_global_options = 0; + foreground = 0; + dumpmaps = 0; + daemon_check = 1; remove_empty_args(argv, &argc); @@ -2277,12 +2221,8 @@ int main(int argc, char *argv[]) macro_parse_globalvar(optarg); break; - case 'S': - flags |= DAEMON_FLAGS_SYSTEMD_SERVICE; - break; - case 'f': - flags |= DAEMON_FLAGS_FOREGROUND; + foreground = 1; break; case 'V': @@ -2298,7 +2238,7 @@ int main(int argc, char *argv[]) break; case 'm': - flags |= DAEMON_FLAGS_DUMP_MAPS; + dumpmaps = 1; break; case 'M': @@ -2306,9 +2246,9 @@ int main(int argc, char *argv[]) break; case 'O': - if (!(flags & DAEMON_FLAGS_HAVE_GLOBAL_OPTIONS)) { + if (!have_global_options) { global_options = strdup(optarg); - flags |= DAEMON_FLAGS_HAVE_GLOBAL_OPTIONS; + have_global_options = 1; break; } printf("%s: global options already specified.\n", @@ -2333,7 +2273,7 @@ int main(int argc, char *argv[]) break; case 'C': - flags &= ~DAEMON_FLAGS_CHECK_DAEMON; + daemon_check = 0; break; case 'F': @@ -2383,9 +2323,16 @@ int main(int argc, char *argv[]) exit(exit_code); } +#if 0 + if (!load_autofs4_module()) { + fprintf(stderr, "%s: can't load %s filesystem module.\n", + program, FS_MODULE_NAME); + exit(1); + } +#endif + /* Don't need the kernel module just to look at the configured maps */ - if (!(flags & DAEMON_FLAGS_DUMP_MAPS) && - (!query_kproto_ver() || get_kver_major() < 5)) { + if (!dumpmaps && (!query_kproto_ver() || get_kver_major() < 5)) { fprintf(stderr, "%s: test mount forbidden or " "incorrect kernel protocol version, " @@ -2416,7 +2363,7 @@ int main(int argc, char *argv[]) /* Get processor information for predefined escapes */ macro_init(); - if (flags & DAEMON_FLAGS_DUMP_MAPS) { + if (dumpmaps) { struct master_mapent *entry; struct list_head *head, *p; struct mapent_cache *nc; @@ -2434,9 +2381,9 @@ int main(int argc, char *argv[]) } if (master) - master_list = master_new(NULL, timeout, flags); + master_list = master_new(NULL, timeout, ghost); else - master_list = master_new(master, timeout, flags); + master_list = master_new(master, timeout, ghost); if (!master_list) { printf("%s: can't create master map", program); macro_free_global_table(); @@ -2482,9 +2429,9 @@ int main(int argc, char *argv[]) } if (argc == 0) - master_list = master_new(NULL, timeout, flags); + master_list = master_new(NULL, timeout, ghost); else - master_list = master_new(argv[0], timeout, flags); + master_list = master_new(argv[0], timeout, ghost); if (!master_list) { printf("%s: can't create master map %s", program, argv[0]); @@ -2492,15 +2439,13 @@ int main(int argc, char *argv[]) exit(1); } - become_daemon(flags); + become_daemon(foreground, daemon_check); if (pthread_attr_init(&th_attr)) { logerr("%s: failed to init thread attribute struct!", program); - if (start_pipefd[1] != -1) { - res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); - close(start_pipefd[1]); - } + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); + close(start_pipefd[1]); release_flag_file(); macro_free_global_table(); exit(1); @@ -2509,10 +2454,8 @@ int main(int argc, char *argv[]) if (pthread_attr_init(&th_attr_detached)) { logerr("%s: failed to init thread attribute struct!", program); - if (start_pipefd[1] != -1) { - res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); - close(start_pipefd[1]); - } + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); + close(start_pipefd[1]); release_flag_file(); macro_free_global_table(); exit(1); @@ -2522,10 +2465,8 @@ int main(int argc, char *argv[]) &th_attr_detached, PTHREAD_CREATE_DETACHED)) { logerr("%s: failed to set detached thread attribute!", program); - if (start_pipefd[1] != -1) { - res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); - close(start_pipefd[1]); - } + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); + close(start_pipefd[1]); release_flag_file(); macro_free_global_table(); exit(1); @@ -2536,10 +2477,8 @@ int main(int argc, char *argv[]) &th_attr_detached, detached_thread_stack_size)) { logerr("%s: failed to set stack size thread attribute!", program); - if (start_pipefd[1] != -1) { - res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); - close(start_pipefd[1]); - } + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); + close(start_pipefd[1]); release_flag_file(); macro_free_global_table(); exit(1); @@ -2550,10 +2489,8 @@ int main(int argc, char *argv[]) &th_attr_detached, &detached_thread_stack_size)) { logerr("%s: failed to get detached thread stack size!", program); - if (start_pipefd[1] != -1) { - res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); - close(start_pipefd[1]); - } + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); + close(start_pipefd[1]); release_flag_file(); macro_free_global_table(); exit(1); @@ -2570,10 +2507,8 @@ int main(int argc, char *argv[]) logerr("%s: failed to create thread data key for std env vars!", program); master_kill(master_list); - if (start_pipefd[1] != -1) { - res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); - close(start_pipefd[1]); - } + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); + close(start_pipefd[1]); release_flag_file(); macro_free_global_table(); exit(1); @@ -2584,10 +2519,8 @@ int main(int argc, char *argv[]) logerr("%s: failed to create thread data key for attempt ID!", program); master_kill(master_list); - if (start_pipefd[1] != -1) { - res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); - close(start_pipefd[1]); - } + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); + close(start_pipefd[1]); release_flag_file(); macro_free_global_table(); exit(1); @@ -2598,10 +2531,8 @@ int main(int argc, char *argv[]) if (!alarm_start_handler()) { logerr("%s: failed to create alarm handler thread!", program); master_kill(master_list); - if (start_pipefd[1] != -1) { - res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); - close(start_pipefd[1]); - } + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); + close(start_pipefd[1]); release_flag_file(); macro_free_global_table(); exit(1); @@ -2610,10 +2541,8 @@ int main(int argc, char *argv[]) if (!st_start_handler()) { logerr("%s: failed to create FSM handler thread!", program); master_kill(master_list); - if (start_pipefd[1] != -1) { - res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); - close(start_pipefd[1]); - } + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); + close(start_pipefd[1]); release_flag_file(); macro_free_global_table(); exit(1); @@ -2650,7 +2579,7 @@ int main(int argc, char *argv[]) * we have anyway. */ do_master_list_reset(master_list); - age = monotonic_time(NULL); + age = time(NULL); master_read_master(master_list, age, 1); } } @@ -2661,16 +2590,9 @@ int main(int argc, char *argv[]) */ do_force_unlink = 0; - if (start_pipefd[1] != -1) { - st_stat = 0; - res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); - close(start_pipefd[1]); - } - -#ifdef WITH_SYSTEMD - if (flags & DAEMON_FLAGS_SYSTEMD_SERVICE) - sd_notify(1, "READY=1"); -#endif + st_stat = 0; + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); + close(start_pipefd[1]); state_mach_thid = pthread_self(); statemachine(NULL); diff --git a/daemon/direct.c b/daemon/direct.c index c494872..9a13435 100644 --- a/daemon/direct.c +++ b/daemon/direct.c @@ -82,7 +82,7 @@ static void mnts_cleanup(void *arg) return; } -int do_umount_autofs_direct(struct autofs_point *ap, struct mapent *me) +int do_umount_autofs_direct(struct autofs_point *ap, struct mnt_list *mnts, struct mapent *me) { struct ioctl_ops *ops = get_ioctl_ops(); char buf[MAX_ERR_BUF]; @@ -98,7 +98,7 @@ int do_umount_autofs_direct(struct autofs_point *ap, struct mapent *me) if (me->ioctlfd != -1) { if (ap->state == ST_READMAP && - is_mounted(me->key, MNTS_REAL)) { + tree_is_mounted(mnts, me->key, MNTS_REAL)) { error(ap->logopt, "attempt to umount busy direct mount %s", me->key); @@ -204,8 +204,11 @@ int umount_autofs_direct(struct autofs_point *ap) { struct map_source *map; struct mapent_cache *nc, *mc; + struct mnt_list *mnts; struct mapent *me, *ne; + mnts = tree_make_mnt_tree(_PROC_MOUNTS, "/"); + pthread_cleanup_push(mnts_cleanup, mnts); nc = ap->entry->master->nc; cache_readlock(nc); pthread_cleanup_push(cache_lock_cleanup, nc); @@ -230,7 +233,7 @@ int umount_autofs_direct(struct autofs_point *ap) * catatonic regardless of the reason for the * failed umount. */ - error = do_umount_autofs_direct(ap, me); + error = do_umount_autofs_direct(ap, mnts, me); if (!error) goto done; @@ -243,6 +246,7 @@ done: map = map->next; } pthread_cleanup_pop(1); + pthread_cleanup_pop(1); close(ap->state_pipe[0]); close(ap->state_pipe[1]); @@ -256,37 +260,58 @@ done: return 0; } -int do_mount_autofs_direct(struct autofs_point *ap, - struct mapent *me, time_t timeout) +static int unlink_mount_tree(struct autofs_point *ap, struct list_head *list) { - const char *str_direct = mount_type_str(t_direct); - struct ioctl_ops *ops = get_ioctl_ops(); - struct mnt_params *mp; - struct stat st; - int status, ret, ioctlfd; - const char *map_name; - time_t runfreq; - int err; + struct list_head *p; + int rv, ret; + pid_t pgrp = getpgrp(); + char spgrp[20]; - if (timeout) { - /* Calculate the expire run frequency */ - runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO; - if (ap->exp_runfreq) - ap->exp_runfreq = min(ap->exp_runfreq, runfreq); + sprintf(spgrp, "pgrp=%d", pgrp); + + ret = 1; + list_for_each(p, list) { + struct mnt_list *mnt; + + mnt = list_entry(p, struct mnt_list, list); + + if (strstr(mnt->opts, spgrp)) + continue; + + if (strcmp(mnt->fs_type, "autofs")) + rv = spawn_umount(ap->logopt, "-l", mnt->path, NULL); else - ap->exp_runfreq = runfreq; + rv = umount2(mnt->path, MNT_DETACH); + if (rv == -1) { + debug(ap->logopt, + "can't unlink %s from mount tree", mnt->path); + + switch (errno) { + case EINVAL: + warn(ap->logopt, + "bad superblock or not mounted"); + break; + + case ENOENT: + case EFAULT: + ret = 0; + warn(ap->logopt, "bad path for mount"); + break; + } + } } + return ret; +} - if (ops->version && !do_force_unlink) { - ap->flags |= MOUNT_FLAG_REMOUNT; - ret = try_remount(ap, me, t_direct); - ap->flags &= ~MOUNT_FLAG_REMOUNT; - if (ret == 1) - return 0; - if (ret == 0) - return -1; - } else { - if (ap->state == ST_READMAP && is_mounted(me->key, MNTS_ALL)) { +static int unlink_active_mounts(struct autofs_point *ap, struct mnt_list *mnts, struct mapent *me) +{ + struct ioctl_ops *ops = get_ioctl_ops(); + struct list_head list; + + INIT_LIST_HEAD(&list); + + if (tree_get_mnt_list(mnts, &list, me->key, 1)) { + if (ap->state == ST_READMAP) { time_t tout = get_exp_timeout(ap, me->source); int save_ioctlfd, ioctlfd; @@ -310,14 +335,59 @@ int do_mount_autofs_direct(struct autofs_point *ap, return 0; } + } - ret = unlink_mount_tree(ap, ap->path); - if (!ret) { - error(ap->logopt, - "already mounted as other than autofs " - "or failed to unlink entry in tree"); - goto out_err; - } + if (!unlink_mount_tree(ap, &list)) { + debug(ap->logopt, + "already mounted as other than autofs " + "or failed to unlink entry in tree"); + return 0; + } + + return 1; +} + +int do_mount_autofs_direct(struct autofs_point *ap, + struct mnt_list *mnts, struct mapent *me, + time_t timeout) +{ + const char *str_direct = mount_type_str(t_direct); + struct ioctl_ops *ops = get_ioctl_ops(); + struct mnt_params *mp; + struct stat st; + int status, ret, ioctlfd; + const char *map_name; + time_t runfreq; + int err; + + if (timeout) { + /* Calculate the expire run frequency */ + runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO; + if (ap->exp_runfreq) + ap->exp_runfreq = min(ap->exp_runfreq, runfreq); + else + ap->exp_runfreq = runfreq; + } + + if (ops->version && !do_force_unlink) { + ap->flags |= MOUNT_FLAG_REMOUNT; + ret = try_remount(ap, me, t_direct); + ap->flags &= ~MOUNT_FLAG_REMOUNT; + if (ret == 1) + return 0; + if (ret == 0) + return -1; + } else { + /* + * A return of 0 indicates we're re-reading the map. + * A return of 1 indicates we successfully unlinked + * the mount tree if there was one. A return of -1 + * inducates we failed to unlink the mount tree so + * we have to return a failure. + */ + ret = unlink_active_mounts(ap, mnts, me); + if (ret == -1 || ret == 0) + return ret; if (me->ioctlfd != -1) { error(ap->logopt, "active direct mount %s", me->key); @@ -348,14 +418,13 @@ int do_mount_autofs_direct(struct autofs_point *ap, } if (!mp->options) { - mp->options = make_options_string(ap->path, - ap->kpipefd, str_direct, ap->flags); + mp->options = make_options_string(ap->path, ap->kpipefd, str_direct); if (!mp->options) return 0; } /* In case the directory doesn't exist, try to mkdir it */ - if (mkdir_path(me->key, mp_mode) < 0) { + if (mkdir_path(me->key, 0555) < 0) { if (errno != EEXIST && errno != EROFS) { crit(ap->logopt, "failed to create mount directory %s", me->key); @@ -417,6 +486,7 @@ int mount_autofs_direct(struct autofs_point *ap) struct map_source *map; struct mapent_cache *nc, *mc; struct mapent *me, *ne, *nested; + struct mnt_list *mnts; time_t now = monotonic_time(NULL); if (strcmp(ap->path, "/-")) { @@ -432,6 +502,8 @@ int mount_autofs_direct(struct autofs_point *ap) return -1; } + mnts = tree_make_mnt_tree(_PROC_MOUNTS, "/"); + pthread_cleanup_push(mnts_cleanup, mnts); pthread_cleanup_push(master_source_lock_cleanup, ap->entry); master_source_readlock(ap->entry); nc = ap->entry->master->nc; @@ -459,7 +531,7 @@ int mount_autofs_direct(struct autofs_point *ap) if (ne) { if (map->master_line < ne->age) { /* TODO: check return, locking me */ - do_mount_autofs_direct(ap, me, timeout); + do_mount_autofs_direct(ap, mnts, me, timeout); } me = cache_enumerate(mc, me); continue; @@ -476,7 +548,7 @@ int mount_autofs_direct(struct autofs_point *ap) } /* TODO: check return, locking me */ - do_mount_autofs_direct(ap, me, timeout); + do_mount_autofs_direct(ap, mnts, me, timeout); me = cache_enumerate(mc, me); } @@ -485,6 +557,7 @@ int mount_autofs_direct(struct autofs_point *ap) } pthread_cleanup_pop(1); pthread_cleanup_pop(1); + pthread_cleanup_pop(1); return 0; } @@ -497,7 +570,7 @@ int umount_autofs_offset(struct autofs_point *ap, struct mapent *me) int opened = 0; if (me->ioctlfd != -1) { - if (is_mounted(me->key, MNTS_REAL)) { + if (is_mounted(_PATH_MOUNTED, me->key, MNTS_REAL)) { error(ap->logopt, "attempt to umount busy offset %s", me->key); return 1; @@ -505,7 +578,7 @@ int umount_autofs_offset(struct autofs_point *ap, struct mapent *me) ioctlfd = me->ioctlfd; } else { /* offset isn't mounted, return success and try to recover */ - if (!is_mounted(me->key, MNTS_AUTOFS)) { + if (!is_mounted(_PROC_MOUNTS, me->key, MNTS_AUTOFS)) { debug(ap->logopt, "offset %s not mounted", me->key); @@ -621,7 +694,7 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, const char * if (!(ret == -1 && errno == ENOENT)) return MOUNT_OFFSET_FAIL; } else { - if (is_mounted(me->key, MNTS_AUTOFS)) { + if (is_mounted(_PROC_MOUNTS, me->key, MNTS_AUTOFS)) { if (ap->state != ST_READMAP) warn(ap->logopt, "trigger %s already mounted", me->key); @@ -657,8 +730,7 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, const char * } if (!mp->options) { - mp->options = make_options_string(ap->path, - ap->kpipefd, str_offset, ap->flags); + mp->options = make_options_string(ap->path, ap->kpipefd, str_offset); if (!mp->options) return MOUNT_OFFSET_OK; } @@ -667,7 +739,7 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, const char * strcat(mountpoint, offset); /* In case the directory doesn't exist, try to mkdir it */ - if (mkdir_path(mountpoint, mp_mode) < 0) { + if (mkdir_path(mountpoint, 0555) < 0) { if (errno == EEXIST) { /* * If the mount point directory is a real mount @@ -676,7 +748,7 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, const char * * the kernel NFS client. */ if (me->multi != me && - is_mounted(mountpoint, MNTS_REAL)) + is_mounted(_PROC_MOUNTS, mountpoint, MNTS_REAL)) return MOUNT_OFFSET_IGNORE; /* @@ -769,7 +841,7 @@ void *expire_proc_direct(void *arg) struct expire_args ec; struct autofs_point *ap; struct mapent *me = NULL; - unsigned int how; + unsigned int now; int ioctlfd, cur_state; int status, ret, left; @@ -780,7 +852,7 @@ void *expire_proc_direct(void *arg) fatal(status); ap = ec.ap = ea->ap; - how = ea->how; + now = ea->when; ec.status = -1; ea->signaled = 1; @@ -796,7 +868,7 @@ void *expire_proc_direct(void *arg) left = 0; - mnts = tree_make_mnt_tree("/"); + mnts = tree_make_mnt_tree(_PROC_MOUNTS, "/"); pthread_cleanup_push(mnts_cleanup, mnts); /* Get a list of mounts select real ones and expire them if possible */ @@ -815,12 +887,12 @@ void *expire_proc_direct(void *arg) */ pthread_cleanup_push(master_source_lock_cleanup, ap->entry); master_source_readlock(ap->entry); - me = lookup_source_mapent(ap, next->mp, LKP_DISTINCT); + me = lookup_source_mapent(ap, next->path, LKP_DISTINCT); pthread_cleanup_pop(1); if (!me) continue; - if (next->flags & MNTS_AUTOFS) { + if (!strcmp(next->fs_type, "autofs")) { struct stat st; int ioctlfd; @@ -831,8 +903,8 @@ void *expire_proc_direct(void *arg) * one of them and pass on state change. */ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state); - if (next->flags & MNTS_INDIRECT) { - master_notify_submount(ap, next->mp, ap->state); + if (strstr(next->opts, "indirect")) { + master_notify_submount(ap, next->path, ap->state); pthread_setcancelstate(cur_state, NULL); continue; } @@ -843,7 +915,7 @@ void *expire_proc_direct(void *arg) } /* It's got a mount, deal with in the outer loop */ - if (is_mounted(me->key, MNTS_REAL)) { + if (tree_is_mounted(mnts, me->key, MNTS_REAL)) { pthread_setcancelstate(cur_state, NULL); continue; } @@ -863,7 +935,7 @@ void *expire_proc_direct(void *arg) cache_writelock(me->mc); if (me->ioctlfd != -1 && fstat(me->ioctlfd, &st) != -1 && - !count_mounts(ap, next->mp, st.st_dev)) { + !count_mounts(ap, next->path, st.st_dev)) { ops->close(ap->logopt, me->ioctlfd); me->ioctlfd = -1; cache_unlock(me->mc); @@ -874,7 +946,7 @@ void *expire_proc_direct(void *arg) ioctlfd = me->ioctlfd; - ret = ops->expire(ap->logopt, ioctlfd, next->mp, how); + ret = ops->expire(ap->logopt, ioctlfd, next->path, now); if (ret) { left++; pthread_setcancelstate(cur_state, NULL); @@ -897,10 +969,10 @@ void *expire_proc_direct(void *arg) if (ap->state == ST_EXPIRE || ap->state == ST_PRUNE) pthread_testcancel(); - debug(ap->logopt, "send expire to trigger %s", next->mp); + debug(ap->logopt, "send expire to trigger %s", next->path); pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state); - ret = ops->expire(ap->logopt, ioctlfd, next->mp, how); + ret = ops->expire(ap->logopt, ioctlfd, next->path, now); if (ret) left++; pthread_setcancelstate(cur_state, NULL); @@ -908,7 +980,7 @@ void *expire_proc_direct(void *arg) pthread_cleanup_pop(1); if (left) - debug(ap->logopt, "%d remaining in %s", left, ap->path); + info(ap->logopt, "%d remaining in %s", left, ap->path); ec.status = left; @@ -1160,12 +1232,6 @@ static void *do_mount_direct(void *arg) pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state); - if (defaults_get_mount_verbose()) { - pid_t ppid = log_pidinfo(ap, mt.pid, "requestor"); - if (ppid > 0) - log_pidinfo(ap, ppid, "parent"); - } - status = fstat(mt.ioctlfd, &st); if (status == -1) { error(ap->logopt, diff --git a/daemon/flag.c b/daemon/flag.c index ff9858c..99f2684 100644 --- a/daemon/flag.c +++ b/daemon/flag.c @@ -164,7 +164,7 @@ int aquire_flag_file(void) while (!we_created_flagfile) { int errsv, i, j; - i = open_fd_mode(linkf, O_WRONLY|O_CREAT, 0644); + i = open_fd_mode(linkf, O_WRONLY|O_CREAT, 0); if (i < 0) { release_flag_file(); return 0; diff --git a/daemon/indirect.c b/daemon/indirect.c index 43bcb34..ffb11b8 100644 --- a/daemon/indirect.c +++ b/daemon/indirect.c @@ -40,6 +40,49 @@ /* Attribute to create detached thread */ extern pthread_attr_t th_attr_detached; +static int unlink_mount_tree(struct autofs_point *ap, struct mnt_list *mnts) +{ + struct mnt_list *this; + int rv, ret; + pid_t pgrp = getpgrp(); + char spgrp[20]; + + sprintf(spgrp, "pgrp=%d", pgrp); + + ret = 1; + this = mnts; + while (this) { + if (strstr(this->opts, spgrp)) { + this = this->next; + continue; + } + + if (strcmp(this->fs_type, "autofs")) + rv = spawn_umount(ap->logopt, "-l", this->path, NULL); + else + rv = umount2(this->path, MNT_DETACH); + if (rv == -1) { + debug(ap->logopt, + "can't unlink %s from mount tree", this->path); + + switch (errno) { + case EINVAL: + warn(ap->logopt, + "bad superblock or not mounted"); + break; + + case ENOENT: + case EFAULT: + ret = 0; + warn(ap->logopt, "bad path for mount"); + break; + } + } + this = this->next; + } + return ret; +} + static int do_mount_autofs_indirect(struct autofs_point *ap, const char *root) { const char *str_indirect = mount_type_str(t_indirect); @@ -50,6 +93,7 @@ static int do_mount_autofs_indirect(struct autofs_point *ap, const char *root) const char *map_name = hosts_map_name; const char *type; struct stat st; + struct mnt_list *mnts; int ret; int err; @@ -69,24 +113,27 @@ static int do_mount_autofs_indirect(struct autofs_point *ap, const char *root) if (ret == 0) return -1; } else { - ret = unlink_mount_tree(ap, ap->path); - if (!ret) { - error(ap->logopt, - "already mounted as other than autofs " - "or failed to unlink entry in tree"); - goto out_err; + mnts = get_mnt_list(_PROC_MOUNTS, ap->path, 1); + if (mnts) { + ret = unlink_mount_tree(ap, mnts); + free_mnt_list(mnts); + if (!ret) { + error(ap->logopt, + "already mounted as other than autofs " + "or failed to unlink entry in tree"); + goto out_err; + } } } - options = make_options_string(ap->path, - ap->kpipefd, str_indirect, ap->flags); + options = make_options_string(ap->path, ap->kpipefd, str_indirect); if (!options) { error(ap->logopt, "options string error"); goto out_err; } /* In case the directory doesn't exist, try to mkdir it */ - if (mkdir_path(root, mp_mode) < 0) { + if (mkdir_path(root, 0555) < 0) { if (errno != EEXIST && errno != EROFS) { crit(ap->logopt, "failed to create autofs directory %s", @@ -345,7 +392,7 @@ void *expire_proc_indirect(void *arg) struct mnt_list *mnts = NULL, *next; struct expire_args *ea; struct expire_args ec; - unsigned int how; + unsigned int now; int offsets, submnts, count; int retries; int ioctlfd, cur_state; @@ -358,7 +405,7 @@ void *expire_proc_indirect(void *arg) fatal(status); ap = ec.ap = ea->ap; - how = ea->how; + now = ea->when; ec.status = -1; ea->signaled = 1; @@ -375,34 +422,34 @@ void *expire_proc_indirect(void *arg) left = 0; /* Get a list of real mounts and expire them if possible */ - mnts = get_mnt_list(ap->path, 0); + mnts = get_mnt_list(_PROC_MOUNTS, ap->path, 0); pthread_cleanup_push(mnts_cleanup, mnts); for (next = mnts; next; next = next->next) { char *ind_key; int ret; - if (next->flags & MNTS_AUTOFS) { + if (!strcmp(next->fs_type, "autofs")) { /* * If we have submounts check if this path lives below * one of them and pass on the state change. */ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state); - if (next->flags & MNTS_INDIRECT) - master_notify_submount(ap, next->mp, ap->state); - else if (next->flags & MNTS_OFFSET) { + if (strstr(next->opts, "indirect")) + master_notify_submount(ap, next->path, ap->state); + else if (strstr(next->opts, "offset")) { struct map_source *map; struct mapent_cache *mc = NULL; struct mapent *me = NULL; struct stat st; /* It's got a mount, deal with in the outer loop */ - if (is_mounted(next->mp, MNTS_REAL)) { + if (is_mounted(_PATH_MOUNTED, next->path, MNTS_REAL)) { pthread_setcancelstate(cur_state, NULL); continue; } /* Don't touch submounts */ - if (master_find_submount(ap, next->mp)) { + if (master_find_submount(ap, next->path)) { pthread_setcancelstate(cur_state, NULL); continue; } @@ -413,7 +460,7 @@ void *expire_proc_indirect(void *arg) while (map) { mc = map->mc; cache_writelock(mc); - me = cache_lookup_distinct(mc, next->mp); + me = cache_lookup_distinct(mc, next->path); if (me) break; cache_unlock(mc); @@ -455,7 +502,7 @@ void *expire_proc_indirect(void *arg) * If the mount corresponds to an offset trigger then * the key is the path, otherwise it's the last component. */ - ind_key = strrchr(next->mp, '/'); + ind_key = strrchr(next->path, '/'); if (ind_key) ind_key++; @@ -468,7 +515,7 @@ void *expire_proc_indirect(void *arg) */ pthread_cleanup_push(master_source_lock_cleanup, ap->entry); master_source_readlock(ap->entry); - me = lookup_source_mapent(ap, next->mp, LKP_DISTINCT); + me = lookup_source_mapent(ap, next->path, LKP_DISTINCT); if (!me && ind_key) me = lookup_source_mapent(ap, ind_key, LKP_NORMAL); pthread_cleanup_pop(1); @@ -480,10 +527,10 @@ void *expire_proc_indirect(void *arg) cache_unlock(me->mc); } - debug(ap->logopt, "expire %s", next->mp); + debug(ap->logopt, "expire %s", next->path); pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state); - ret = ops->expire(ap->logopt, ioctlfd, next->mp, how); + ret = ops->expire(ap->logopt, ioctlfd, next->path, now); if (ret) left++; pthread_setcancelstate(cur_state, NULL); @@ -497,7 +544,7 @@ void *expire_proc_indirect(void *arg) pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state); retries = (count_mounts(ap, ap->path, ap->dev) + 1); while (retries--) { - ret = ops->expire(ap->logopt, ap->ioctlfd, ap->path, how); + ret = ops->expire(ap->logopt, ap->ioctlfd, ap->path, now); if (ret) left++; } @@ -505,14 +552,14 @@ void *expire_proc_indirect(void *arg) pthread_cleanup_pop(1); count = offsets = submnts = 0; - mnts = get_mnt_list(ap->path, 0); + mnts = get_mnt_list(_PROC_MOUNTS, ap->path, 0); pthread_cleanup_push(mnts_cleanup, mnts); /* Are there any real mounts left */ for (next = mnts; next; next = next->next) { - if (!(next->flags & MNTS_AUTOFS)) + if (strcmp(next->fs_type, "autofs")) count++; else { - if (next->flags & MNTS_INDIRECT) + if (strstr(next->opts, "indirect")) submnts++; else offsets++; @@ -521,7 +568,7 @@ void *expire_proc_indirect(void *arg) pthread_cleanup_pop(1); if (submnts) - debug(ap->logopt, + info(ap->logopt, "%d submounts remaining in %s", submnts, ap->path); /* @@ -529,7 +576,7 @@ void *expire_proc_indirect(void *arg) * words) the umounts are done by the time we reach here */ if (count) - debug(ap->logopt, "%d remaining in %s", count, ap->path); + info(ap->logopt, "%d remaining in %s", count, ap->path); ec.status = left; @@ -701,12 +748,6 @@ static void *do_mount_indirect(void *arg) pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state); - if (defaults_get_mount_verbose()) { - pid_t ppid = log_pidinfo(ap, mt.pid, "requestor"); - if (ppid > 0) - log_pidinfo(ap, ppid, "parent"); - } - len = ncat_path(buf, sizeof(buf), ap->path, mt.name, mt.len); if (!len) { crit(ap->logopt, "path to be mounted is to long"); diff --git a/daemon/lookup.c b/daemon/lookup.c index d9d3a4e..cb67e7d 100644 --- a/daemon/lookup.c +++ b/daemon/lookup.c @@ -64,10 +64,6 @@ static char *find_map_path(struct autofs_point *ap, struct map_source *map) char *search_path; struct stat st; - /* Absolute path, just return a copy */ - if (mname[0] == '/') - return strdup(mname); - /* * This is different to the way it is in amd. * autofs will always try to locate maps in AUTOFS_MAP_DIR @@ -377,27 +373,14 @@ static int read_file_source_instance(struct autofs_point *ap, struct map_source char src_prog[] = "program"; struct stat st; char *type, *format; - char *path; - if (map->argc < 1) { - error(ap->logopt, "invalid arguments for autofs_point"); - return NSS_STATUS_UNKNOWN; - } - - path = find_map_path(ap, map); - if (!path) - return NSS_STATUS_UNKNOWN; - - if (stat(path, &st) == -1) { - warn(ap->logopt, "file map %s not found", path); - free(path); + if (stat(map->argv[0], &st) == -1) { + warn(ap->logopt, "file map %s not found", map->argv[0]); return NSS_STATUS_NOTFOUND; } - if (!S_ISREG(st.st_mode)) { - free(path); + if (!S_ISREG(st.st_mode)) return NSS_STATUS_NOTFOUND; - } if (st.st_mode & __S_IEXEC) type = src_prog; @@ -408,23 +391,9 @@ static int read_file_source_instance(struct autofs_point *ap, struct map_source instance = master_find_source_instance(map, type, format, 0, NULL); if (!instance) { - const char **argv; - int argc; - - argc = map->argc; - argv = copy_argv(map->argc, map->argv); - if (!argv) { - error(ap->logopt, "failed to copy args"); - free(path); - return NSS_STATUS_UNKNOWN; - } - if (argv[0]) - free((char *) argv[0]); - argv[0] = path; - path = NULL; - + int argc = map->argc; + const char **argv = map->argv; instance = master_add_source_instance(map, type, format, age, argc, argv); - free_argv(argc, argv); if (!instance) return NSS_STATUS_UNAVAIL; instance->recurse = map->recurse; @@ -432,9 +401,6 @@ static int read_file_source_instance(struct autofs_point *ap, struct map_source } instance->stale = map->stale; - if (path) - free(path); - return do_read_map(ap, instance, age); } @@ -510,11 +476,16 @@ static int lookup_map_read_map(struct autofs_point *ap, static enum nsswitch_status read_map_source(struct nss_source *this, struct autofs_point *ap, struct map_source *map, time_t age) { + enum nsswitch_status result; + struct map_source tmap; + char *path; + if (strcasecmp(this->source, "files")) { return read_source_instance(ap, map, this->source, age); } /* + * autofs built-in map for nsswitch "files" is "file". * This is a special case as we need to append the * normal location to the map name. * note: It's invalid to specify a relative path. @@ -525,7 +496,50 @@ static enum nsswitch_status read_map_source(struct nss_source *this, return NSS_STATUS_NOTFOUND; } - return read_file_source_instance(ap, map, age); + this->source[4] = '\0'; + tmap.flags = map->flags; + tmap.type = this->source; + tmap.format = map->format; + tmap.name = map->name; + tmap.lookup = map->lookup; + tmap.mc = map->mc; + tmap.instance = map->instance; + tmap.exp_timeout = map->exp_timeout; + tmap.recurse = map->recurse; + tmap.depth = map->depth; + tmap.stale = map->stale; + tmap.argc = 0; + tmap.argv = NULL; + + path = find_map_path(ap, map); + if (!path) + return NSS_STATUS_UNKNOWN; + + if (map->argc >= 1) { + tmap.argc = map->argc; + tmap.argv = copy_argv(map->argc, map->argv); + if (!tmap.argv) { + error(ap->logopt, "failed to copy args"); + free(path); + return NSS_STATUS_UNKNOWN; + } + if (tmap.argv[0]) + free((char *) tmap.argv[0]); + tmap.argv[0] = path; + } else { + error(ap->logopt, "invalid arguments for autofs_point"); + free(path); + return NSS_STATUS_UNKNOWN; + } + + pthread_cleanup_push(argv_cleanup, &tmap); + result = read_file_source_instance(ap, &tmap, age); + pthread_cleanup_pop(1); + + if (!map->instance) + map->instance = tmap.instance; + + return result; } int lookup_nss_read_map(struct autofs_point *ap, struct map_source *source, time_t age) @@ -779,11 +793,16 @@ int lookup_ghost(struct autofs_point *ap, const char *root) /* Directory already exists? */ if (!ret) { + /* Shouldn't need this + me->dev = st.st_dev; + me->ino = st.st_ino; + */ + debug(ap->logopt, "me->dev %d me->ino %d", me->dev, me->ino); free(fullpath); goto next; } - ret = mkdir_path(fullpath, mp_mode); + ret = mkdir_path(fullpath, 0555); if (ret < 0 && errno != EEXIST) { char *estr = strerror_r(errno, buf, MAX_ERR_BUF); warn(ap->logopt, @@ -911,30 +930,17 @@ static int lookup_name_file_source_instance(struct autofs_point *ap, struct map_ time_t age = monotonic_time(NULL); struct stat st; char *type, *format; - char *path; if (*name == '/' && map->flags & MAP_FLAG_FORMAT_AMD) return lookup_amd_instance(ap, map, name, name_len); - if (map->argc < 1) { - error(ap->logopt, "invalid arguments for autofs_point"); - return NSS_STATUS_UNKNOWN; - } - - path = find_map_path(ap, map); - if (!path) - return NSS_STATUS_UNKNOWN; - - if (stat(path, &st) == -1) { + if (stat(map->argv[0], &st) == -1) { debug(ap->logopt, "file map not found"); - free(path); return NSS_STATUS_NOTFOUND; } - if (!S_ISREG(st.st_mode)) { - free(path); + if (!S_ISREG(st.st_mode)) return NSS_STATUS_NOTFOUND; - } if (st.st_mode & __S_IEXEC) type = src_prog; @@ -945,32 +951,15 @@ static int lookup_name_file_source_instance(struct autofs_point *ap, struct map_ instance = master_find_source_instance(map, type, format, 0, NULL); if (!instance) { - const char **argv; - int argc; - - argc = map->argc; - argv = copy_argv(map->argc, map->argv); - if (!argv) { - error(ap->logopt, "failed to copy args"); - free(path); - return NSS_STATUS_UNKNOWN; - } - if (argv[0]) - free((char *) argv[0]); - argv[0] = path; - path = NULL; - + int argc = map->argc; + const char **argv = map->argv; instance = master_add_source_instance(map, type, format, age, argc, argv); - free_argv(argc, argv); if (!instance) return NSS_STATUS_NOTFOUND; instance->recurse = map->recurse; instance->depth = map->depth; } - if (path) - free(path); - return do_lookup_mount(ap, instance, name, name_len); } @@ -1046,6 +1035,10 @@ static enum nsswitch_status lookup_map_name(struct nss_source *this, struct autofs_point *ap, struct map_source *map, const char *name, int name_len) { + enum nsswitch_status result; + struct map_source tmap; + char *path; + if (strcasecmp(this->source, "files")) return lookup_name_source_instance(ap, map, this->source, name, name_len); @@ -1062,38 +1055,49 @@ static enum nsswitch_status lookup_map_name(struct nss_source *this, return NSS_STATUS_NOTFOUND; } - return lookup_name_file_source_instance(ap, map, name, name_len); -} - -static struct map_source *lookup_get_map_source(struct master_mapent *entry) -{ - struct map_source *map = entry->maps; - struct stat st; - char *type; + this->source[4] = '\0'; + tmap.flags = map->flags; + tmap.type = this->source; + tmap.format = map->format; + tmap.name = map->name; + tmap.mc = map->mc; + tmap.instance = map->instance; + tmap.exp_timeout = map->exp_timeout; + tmap.recurse = map->recurse; + tmap.depth = map->depth; + tmap.argc = 0; + tmap.argv = NULL; - if (map->type || *map->argv[0] != '/') - return map; + path = find_map_path(ap, map); + if (!path) + return NSS_STATUS_UNKNOWN; - if (*(map->argv[0] + 1) == '/') - return map; + if (map->argc >= 1) { + tmap.argc = map->argc; + tmap.argv = copy_argv(map->argc, map->argv); + if (!tmap.argv) { + error(ap->logopt, "failed to copy args"); + free(path); + return NSS_STATUS_UNKNOWN; + } + if (tmap.argv[0]) + free((char *) tmap.argv[0]); + tmap.argv[0] = path; + } else { + error(ap->logopt, "invalid arguments for autofs_point"); + free(path); + return NSS_STATUS_UNKNOWN; + } - if (stat(map->argv[0], &st) == -1) - return NULL; + result = lookup_name_file_source_instance(ap, &tmap, name, name_len); - if (!S_ISREG(st.st_mode)) - return NULL; + if (!map->instance) + map->instance = tmap.instance; - if (st.st_mode & __S_IEXEC) - type = "program"; - else - type = "file"; + /* path is freed in free_argv */ + free_argv(tmap.argc, tmap.argv); - /* This is a file source with a path starting with "/". - * But file maps can be either plain text or executable - * so they use a map instance and the actual map source - * remains untouched. - */ - return master_find_source_instance(map, type, map->format, 0, NULL); + return result; } static void update_negative_cache(struct autofs_point *ap, struct map_source *source, const char *name) @@ -1129,14 +1133,11 @@ static void update_negative_cache(struct autofs_point *ap, struct map_source *so logmsg("key \"%s\" not found in map source(s).", name); } - /* Doesn't exist in any source, just add it somewhere. - * Also take care to use the same map source used by - * map reads and key lookups for the update. - */ + /* Doesn't exist in any source, just add it somewhere */ if (source) map = source; else - map = lookup_get_map_source(entry); + map = entry->maps; if (map) { time_t now = monotonic_time(NULL); int rv = CHE_FAIL; @@ -1382,21 +1383,15 @@ void lookup_prune_one_cache(struct autofs_point *ap, struct mapent_cache *mc, ti if (valid && valid->mc == mc) { /* * We've found a map entry that has been removed from - * the current cache so it isn't really valid. Set the - * mapent negative to prevent further mount requests - * using the cache entry. + * the current cache so it isn't really valid. */ - debug(ap->logopt, "removed map entry detected, mark negative"); - if (valid->mapent) { - free(valid->mapent); - valid->mapent = NULL; - } cache_unlock(valid->mc); valid = NULL; } if (!valid && - is_mounted(path, MNTS_REAL)) { - debug(ap->logopt, "prune posponed, %s mounted", path); + is_mounted(_PATH_MOUNTED, path, MNTS_REAL)) { + debug(ap->logopt, + "prune check posponed, %s mounted", path); free(key); free(path); continue; @@ -1418,7 +1413,7 @@ void lookup_prune_one_cache(struct autofs_point *ap, struct mapent_cache *mc, ti if (valid) cache_delete(mc, key); - else if (!is_mounted(path, MNTS_AUTOFS)) { + else if (!is_mounted(_PROC_MOUNTS, path, MNTS_AUTOFS)) { dev_t devid = ap->dev; status = CHE_FAIL; if (ap->type == LKP_DIRECT) diff --git a/daemon/module.c b/daemon/module.c index be96a82..b1a94f5 100644 --- a/daemon/module.c +++ b/daemon/module.c @@ -19,6 +19,41 @@ #include "automount.h" #include "nsswitch.h" +int load_autofs4_module(void) +{ + FILE *fp; + char buf[PATH_MAX]; + int ret; + + /* + * Check if module already loaded or compiled in. + * If both autofs v3 and v4 are coplied in and + * the v3 module registers first or the v4 module + * is an older version we will catch it at mount + * time. + */ + fp = open_fopen_r("/proc/filesystems"); + if (!fp) { + logerr("cannot open /proc/filesystems"); + return 0; + } + + while (fgets(buf, sizeof(buf), fp)) { + if (strstr(buf, "autofs")) { + fclose(fp); + return 1; + } + } + fclose(fp); + + ret = spawnl(LOGOPT_NONE, PATH_MODPROBE, PATH_MODPROBE, + "-q", FS_MODULE_NAME, NULL); + if (ret) + return 0; + + return 1; +} + int open_lookup(const char *name, const char *err_prefix, const char *mapfmt, int argc, const char *const *argv, struct lookup_mod **lookup) { diff --git a/daemon/spawn.c b/daemon/spawn.c index 7992c5a..fabe577 100644 --- a/daemon/spawn.c +++ b/daemon/spawn.c @@ -338,7 +338,6 @@ static int do_spawn(unsigned logopt, unsigned int wait, dup2(pipefd[1], STDOUT_FILENO); dup2(pipefd[1], STDERR_FILENO); close(pipefd[1]); - open_mutex_unlock(); /* what to mount must always be second last */ while (*pargv++) @@ -427,7 +426,7 @@ static int do_spawn(unsigned logopt, unsigned int wait, if (!is_bind) goto done; - if (is_mounted(argv[loc], MNTS_AUTOFS)) { + if (is_mounted(_PROC_MOUNTS, argv[loc], MNTS_AUTOFS)) { fprintf(stderr, "error: can't bind to an autofs mount\n"); close(STDOUT_FILENO); @@ -521,33 +520,22 @@ int spawnv(unsigned logopt, const char *prog, const char *const *argv) int spawnl(unsigned logopt, const char *prog, ...) { va_list arg; - int argc, ret; + int argc; char **argv, **p; - unsigned int argv_len; va_start(arg, prog); for (argc = 1; va_arg(arg, char *); argc++); va_end(arg); - argv_len = sizeof(char *) * (argc + 1); - argv = malloc(argv_len); - if (!argv) { - char buf[MAX_ERR_BUF]; - char *estr = strerror_r(errno, buf, sizeof(buf)); - crit(logopt, "malloc: %s", estr); + if (!(argv = alloca(sizeof(char *) * argc))) return -1; - } - memset(argv, 0, argv_len); va_start(arg, prog); p = argv; while ((*p++ = va_arg(arg, char *))); va_end(arg); - ret = do_spawn(logopt, -1, SPAWN_OPT_NONE, prog, (const char **) argv); - free(argv); - - return ret; + return do_spawn(logopt, -1, SPAWN_OPT_NONE, prog, (const char **) argv); } int spawn_mount(unsigned logopt, ...) @@ -558,16 +546,13 @@ int spawn_mount(unsigned logopt, ...) char prog[] = PATH_MOUNT; char arg0[] = PATH_MOUNT; char argn[] = "-n"; - char argvr[] = "-v"; /* In case we need to use the fake option to mount */ char arg_fake[] = "-f"; unsigned int options; unsigned int retries = MTAB_LOCK_RETRIES; int update_mtab = 1, ret, printed = 0; unsigned int wait = defaults_get_mount_wait(); - int verbose = defaults_get_mount_verbose(); char buf[PATH_MAX + 1]; - unsigned int argv_len; /* If we use mount locking we can't validate the location */ #ifdef ENABLE_MOUNT_LOCKING @@ -592,28 +577,19 @@ int spawn_mount(unsigned logopt, ...) } } - /* Alloc 2 extra slots in case we need to use the "-f" or "-v" options - * plus the NULL slot for end of args. - */ - argv_len = sizeof(char *) * (argc + 3); - argv = malloc(argv_len); - if (!argv) { - char buf[MAX_ERR_BUF]; - char *estr = strerror_r(errno, buf, sizeof(buf)); - crit(logopt, "malloc: %s", estr); + /* Alloc 1 extra slot in case we need to use the "-f" option */ + if (!(argv = alloca(sizeof(char *) * (argc + 2)))) return -1; - } - memset(argv, 0, argv_len); argv[0] = arg0; va_start(arg, logopt); - p = argv + 1; - if (!update_mtab) - *(p++) = argn; - if (verbose) - *(p++) = argvr; - + if (update_mtab) + p = argv + 1; + else { + argv[1] = argn; + p = argv + 2; + } while ((*p = va_arg(arg, char *))) { if (options == SPAWN_OPT_OPEN && !strcmp(*p, "-t")) { *(++p) = va_arg(arg, char *); @@ -678,7 +654,6 @@ int spawn_mount(unsigned logopt, ...) umount(argv[argc]); ret = MNT_FORCE_FAIL; } - free(argv); return ret; } @@ -707,7 +682,6 @@ int spawn_bind_mount(unsigned logopt, ...) int update_mtab = 1, ret, printed = 0; unsigned int wait = defaults_get_mount_wait(); char buf[PATH_MAX + 1]; - unsigned int argv_len; /* If we use mount locking we can't validate the location */ #ifdef ENABLE_MOUNT_LOCKING @@ -736,15 +710,8 @@ int spawn_bind_mount(unsigned logopt, ...) } } - argv_len = sizeof(char *) * (argc + 2); - argv = malloc(argv_len); - if (!argv) { - char buf[MAX_ERR_BUF]; - char *estr = strerror_r(errno, buf, sizeof(buf)); - crit(logopt, "malloc: %s", estr); + if (!(argv = alloca(sizeof(char *) * (argc + 2)))) return -1; - } - memset(argv, 0, argv_len); argv[0] = arg0; argv[1] = bind; @@ -806,7 +773,6 @@ int spawn_bind_mount(unsigned logopt, ...) umount(argv[argc]); ret = MNT_FORCE_FAIL; } - free(argv); return ret; } @@ -829,7 +795,6 @@ int spawn_umount(unsigned logopt, ...) int update_mtab = 1, ret, printed = 0; unsigned int wait = defaults_get_umount_wait(); char buf[PATH_MAX + 1]; - unsigned int argv_len; #ifdef ENABLE_MOUNT_LOCKING options = SPAWN_OPT_LOCK; @@ -855,15 +820,8 @@ int spawn_umount(unsigned logopt, ...) if (arg_c) argc++;; - argv_len = sizeof(char *) * (argc + 1); - argv = malloc(argv_len); - if (!argv) { - char buf[MAX_ERR_BUF]; - char *estr = strerror_r(errno, buf, sizeof(buf)); - crit(logopt, "malloc: %s", estr); + if (!(argv = alloca(sizeof(char *) * (argc + 1)))) return -1; - } - memset(argv, 0, argv_len); p = argv; *p++ = arg0; @@ -911,7 +869,6 @@ int spawn_umount(unsigned logopt, ...) "and /etc/mtab will differ"); ret = 0; } - free(argv); return ret; } diff --git a/daemon/state.c b/daemon/state.c index c6fe069..cf835e0 100644 --- a/daemon/state.c +++ b/daemon/state.c @@ -267,7 +267,7 @@ void expire_proc_cleanup(void *arg) return; } -static enum expire expire_proc(struct autofs_point *ap, int how) +static enum expire expire_proc(struct autofs_point *ap, int now) { pthread_t thid; struct expire_args *ea; @@ -295,7 +295,7 @@ static enum expire expire_proc(struct autofs_point *ap, int how) fatal(status); ea->ap = ap; - ea->how = how; + ea->when = now; ea->status = 1; if (ap->type == LKP_INDIRECT) @@ -350,7 +350,14 @@ static void do_readmap_cleanup(void *arg) return; } -static void do_readmap_mount(struct autofs_point *ap, +static void tree_mnts_cleanup(void *arg) +{ + struct mnt_list *mnts = (struct mnt_list *) arg; + tree_free_mnt_tree(mnts); + return; +} + +static void do_readmap_mount(struct autofs_point *ap, struct mnt_list *mnts, struct map_source *map, struct mapent *me, time_t now) { struct mapent_cache *nc; @@ -431,13 +438,13 @@ static void do_readmap_mount(struct autofs_point *ap, else ap->exp_runfreq = runfreq; } - } else if (!is_mounted(me->key, MNTS_REAL)) - do_umount_autofs_direct(ap, me); + } else if (!tree_is_mounted(mnts, me->key, MNTS_REAL)) + do_umount_autofs_direct(ap, mnts, me); else debug(ap->logopt, "%s is mounted", me->key); } else - do_mount_autofs_direct(ap, me, get_exp_timeout(ap, map)); + do_mount_autofs_direct(ap, mnts, me, get_exp_timeout(ap, map)); return; } @@ -448,6 +455,7 @@ static void *do_readmap(void *arg) struct map_source *map; struct mapent_cache *nc, *mc; struct readmap_args *ra; + struct mnt_list *mnts; int status; time_t now; @@ -491,6 +499,8 @@ static void *do_readmap(void *arg) struct mapent *me; unsigned int append_alarm = !ap->exp_runfreq; + mnts = tree_make_mnt_tree(_PROC_MOUNTS, "/"); + pthread_cleanup_push(tree_mnts_cleanup, mnts); nc = ap->entry->master->nc; cache_readlock(nc); pthread_cleanup_push(cache_lock_cleanup, nc); @@ -508,7 +518,7 @@ static void *do_readmap(void *arg) cache_readlock(mc); me = cache_enumerate(mc, NULL); while (me) { - do_readmap_mount(ap, map, me, now); + do_readmap_mount(ap, mnts, map, me, now); me = cache_enumerate(mc, me); } lookup_prune_one_cache(ap, map->mc, now); @@ -528,6 +538,7 @@ static void *do_readmap(void *arg) pthread_cleanup_pop(1); pthread_cleanup_pop(1); + pthread_cleanup_pop(1); } pthread_cleanup_pop(1); diff --git a/fedfs/Makefile b/fedfs/Makefile deleted file mode 100644 index dff749e..0000000 --- a/fedfs/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# -# Makefile for mount.fedfs -# - --include ../Makefile.conf -include ../Makefile.rules - -SRCS = mount.fedfs.c -HDRS = fedfs-getsrvinfo.h fedfs-gpl-boiler.h fedfs-nls.h \ - fedfs-token.h - -fedfs-getsrvinfo_OBJ = fedfs-getsrvinfo.o - -mount_fedfs_OBJ = mount.fedfs.o -fedfs-map-nfs4_OBJ = fedfs-map-nfs4.o - -version := $(shell cat ../.version) - -CFLAGS += -rdynamic $(DAEMON_CFLAGS) -D_GNU_SOURCE -I../include -CFLAGS += -DVERSION_STRING=\"$(version)\" -LDFLAGS += -rdynamic - -all: mount.fedfs fedfs-map-nfs4 - -mount.fedfs: $(mount_fedfs_OBJ) $(fedfs-getsrvinfo_OBJ) $(HDRS) - $(CC) -o mount.fedfs \ - $(mount_fedfs_OBJ) $(fedfs-getsrvinfo_OBJ) \ - $(LDFLAGS) $(LIBRESOLV) $(LIBS) - -fedfs-map-nfs4: $(fedfs-map-nfs4_OBJ) $(fedfs-getsrvinfo_OBJ) $(HDRS) - $(CC) -o fedfs-map-nfs4 \ - $(fedfs-map-nfs4_OBJ) $(fedfs-getsrvinfo_OBJ) \ - $(LDFLAGS) $(LIBRESOLV) $(LIBS) - -clean: - rm -f *.o *.s *~ mount.fedfs - -install: all - install -d -m 755 $(INSTALLROOT)$(sbindir) - install -c fedfs-map-nfs4 -m 755 $(INSTALLROOT)$(sbindir); \ - if ! test -x $(INSTALLROOT)$(sbindir)/mount.fedfs; \ - then \ - install -c mount.fedfs -m 755 $(INSTALLROOT)$(sbindir); \ - fi diff --git a/fedfs/fedfs-getsrvinfo.c b/fedfs/fedfs-getsrvinfo.c deleted file mode 100644 index 02ad16b..0000000 --- a/fedfs/fedfs-getsrvinfo.c +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright 2011 Oracle. All rights reserved. - * - * This file is part of fedfs-utils. - * - * fedfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * fedfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with fedfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "fedfs-getsrvinfo.h" - -/** - * Parsing overlay for DNS query result record header. Fields are - * in network byte order. - */ -struct rechdr { - uint16_t type; - uint16_t class; - uint32_t ttl; - uint16_t length; -} __attribute__((__packed__)); - -/** - * Parsing overlay for DNS query result SRV record data. Fields - * are in network byte order. - */ -struct srv { - uint16_t priority; - uint16_t weight; - uint16_t port; - unsigned char *target; -} __attribute__((__packed__)); - -/** - * Return C string matching error value of "status" - * - * @param status error status returned by getsrvinfo - * @return pointer to static NUL-terminated C string containing error message - */ -const char * -gsi_strerror(int status) -{ - static char buf[256]; - - switch (status) { - case ESI_SUCCESS: - return "Success"; - case ESI_NONAME: - return "Name not found"; - case ESI_AGAIN: - return "Temporary failure in name resolution"; - case ESI_FAIL: - return "Non-recoverable failure in name resolution"; - case ESI_NODATA: - return "No SRV record returned"; - case ESI_SERVICE: - return "Service is not available"; - case ESI_MEMORY: - return "Memory allocation failure"; - case ESI_SYSTEM: - snprintf(buf, sizeof(buf), "System error (%d): %s", - status, strerror(errno)); - return buf; - case ESI_PARSE: - return "Failed to parse server response"; - } - - snprintf(buf, sizeof(buf), "Unknown error (%d)", status); - return buf; -} - -/** - * Release a list of SRV records allocated by getsrvinfo() - * - * @param si pointer to first element of a list of struct srvinfo - * - */ -void freesrvinfo(struct srvinfo *si) -{ - struct srvinfo *tmp; - - while (si != NULL) { - tmp = si; - si = si->si_next; - free(tmp->si_target); - free(tmp); - } -} - -/** - * Ordering predicate for srvinfo lists - * - * @param a a srvinfo list element to compare - * @param b another srvinfo list element to compare - * @return true if "b" should fall later in the list than "a" - * - * See RFC 2782. The list is ordered as follows: - * - * o Lowest priority first. - * o In each priority class, highest weight first. - */ -static _Bool -srvinfo_is_after(const struct srvinfo *a, const struct srvinfo *b) -{ - if (a->si_priority > b->si_priority) - return true; - if (a->si_priority < b->si_priority) - return false; - - if (a->si_weight < b->si_weight) - return true; - return false; -} - -/** - * Insert a srvinfo element into a list - * - * @param head pointer to head of list of elements - * @param entry new list element to insert - * - */ -static void -insert_srvinfo(struct srvinfo **head, struct srvinfo *entry) -{ - entry->si_next = *head; - *head = entry; -} - -/** - * Insert a srvinfo element into a list, in order - * - * @param head pointer to head of list of elements - * @param entry new list element to insert - * - */ -static void -insert_srvinfo_sorted(struct srvinfo **head, struct srvinfo *entry) -{ - struct srvinfo *spot, *back; - - spot = *head; - back = NULL; - while (spot && srvinfo_is_after(spot, entry)) { - back = spot; - spot = spot->si_next; - } - - if (spot == (*head)) - insert_srvinfo(head, entry); - else { - insert_srvinfo(&spot, entry); - /* off the end of the list? */ - if (spot == entry) - back->si_next = entry; - } -} - -/** - * Retrieve list of SRV records from DNS service - * - * @param srvname NUL-terminated C string containing record type to look up - * @param domainname NUL-terminated C string containing domain name to look up - * @param si OUT: list of SRV record information retrieved - * @return zero on success, or an ESI_ status code describing the error - * - * Caller must free list of records using freesrvinfo(). - */ -int -getsrvinfo(const char *srvname, const char *domainname, struct srvinfo **si) -{ - unsigned char *msg, *eom, *comp_dn; - struct srvinfo *results; - unsigned short count, i; - int status, len; - char *exp_dn; - HEADER *hdr; - - msg = calloc(1, NS_MAXMSG); - exp_dn = calloc(1, NS_MAXDNAME); - if (msg == NULL || exp_dn == NULL) { - status = ESI_MEMORY; - goto out; - } - - _res.options |= RES_AAONLY; - len = res_querydomain(srvname, domainname, C_IN, T_SRV, msg, NS_MAXMSG); - if (len == -1) { - switch (h_errno) { - case HOST_NOT_FOUND: - status = ESI_NONAME; - break; - case TRY_AGAIN: - status = ESI_AGAIN; - break; - case NO_RECOVERY: - status = ESI_FAIL; - break; - case NO_DATA: - status = ESI_NODATA; - break; - default: - fprintf(stderr, "SRV query failed for %s.%s: %s\n", - srvname, domainname, hstrerror(h_errno)); - status = ESI_FAIL; - } - goto out; - } - - hdr = (HEADER *)msg; - count = ntohs(hdr->ancount); - if (count == 0) { - status = ESI_NODATA; - goto out; - } - eom = msg + len; - - comp_dn = &msg[HFIXEDSZ]; - comp_dn += dn_skipname(comp_dn, eom) + QFIXEDSZ; - - results = NULL; - for (i = 0; i < count; i++) { - struct srvinfo *new; - struct srv *record; - int l; - - l = dn_expand(msg, eom, comp_dn, exp_dn, NS_MAXDNAME); - if (l == -1) { - status = ESI_PARSE; - goto out_free; - } - comp_dn += l; - - record = (struct srv *)&comp_dn[10]; - comp_dn += 16; - - l = dn_expand(msg, eom, comp_dn, exp_dn, NS_MAXDNAME); - if (l == -1) { - status = ESI_PARSE; - goto out_free; - } - comp_dn += l; - - if (count == 1 && strcmp(exp_dn, ".") == 0) { - status = ESI_SERVICE; - goto out_free; - } - - new = calloc(1, sizeof(*new)); - if (new == NULL) { - status = ESI_MEMORY; - goto out; - } - - new->si_target = strdup(exp_dn); - if (new->si_target == NULL) { - free(new); - status = ESI_MEMORY; - goto out; - } - new->si_priority = ntohs(record->priority); - new->si_weight = ntohs(record->weight); - new->si_port = ntohs(record->port); - - insert_srvinfo_sorted(&results, new); - } - - status = ESI_SUCCESS; - *si = results; - -out: - free(exp_dn); - free(msg); - return status; - -out_free: - freesrvinfo(results); - goto out; -} diff --git a/fedfs/fedfs-getsrvinfo.h b/fedfs/fedfs-getsrvinfo.h deleted file mode 100644 index 1317035..0000000 --- a/fedfs/fedfs-getsrvinfo.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2011 Oracle. All rights reserved. - * - * This file is part of fedfs-utils. - * - * fedfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * fedfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with fedfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#ifndef _FEDFS_GETSRVINFO_H_ -#define _FEDFS_GETSRVINFO_H_ - -/** - * Single list element containing SRV record data - */ -struct srvinfo { - struct srvinfo *si_next; - char *si_target; - unsigned short si_priority; - unsigned short si_weight; - unsigned short si_port; -}; - -enum { - ESI_SUCCESS = 0, - ESI_NONAME = -2, - ESI_AGAIN = -3, - ESI_FAIL = -4, - ESI_NODATA = -5, - ESI_SERVICE = -8, - ESI_MEMORY = -10, - ESI_SYSTEM = -11, - ESI_PARSE = -1000, -}; - -int getsrvinfo(const char *srvname, const char *domainname, - struct srvinfo **si); -void freesrvinfo(struct srvinfo *si); -const char *gsi_strerror(int status); - -#endif /* !_FEDFS_GETSRVINFO_H_ */ diff --git a/fedfs/fedfs-gpl-boiler.h b/fedfs/fedfs-gpl-boiler.h deleted file mode 100644 index 1353e73..0000000 --- a/fedfs/fedfs-gpl-boiler.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2011 Oracle. All rights reserved. - * - * This file is part of fedfs-utils. - * - * fedfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * fedfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with fedfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#ifndef _GPL_BOILER_H_ -#define _GPL_BOILER_H_ - -#ifdef HAVE_CONFIG_H -#include -#endif - -/** - * GPLv2 boilerplate for usage messages - */ -static const char *fedfs_gpl_boilerplate = - "\nCopyright 2010, 2011, 2012, 2013 Oracle. " - "All rights reserved.\n\n" - "License GPLv2: " - "\n" - "This is free software. " - "You are free to change and redistribute it.\n" - "There is NO WARRANTY, to the extent permitted by law.\n"; - -#endif /* !_GPL_BOILER_H_ */ diff --git a/fedfs/fedfs-map-nfs4.c b/fedfs/fedfs-map-nfs4.c deleted file mode 100644 index 9f831cd..0000000 --- a/fedfs/fedfs-map-nfs4.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright 2011 Oracle. All rights reserved. - * - * This file is part of fedfs-utils. - * - * fedfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * fedfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with fedfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "fedfs-nls.h" -#include "fedfs-token.h" -#include "fedfs-getsrvinfo.h" -#include "fedfs-gpl-boiler.h" - -/** - * Name of SRV record containing NFSv4 FedFS root - */ -#define FEDFS_NFS_DOMAINROOT "_nfs-domainroot._tcp" - -/** - * Export pathname of NFSv4 FedFS root - */ -#define FEDFS_NFS_EXPORTPATH "/.domainroot" - -static char *progname; - -/** - * Display usage message - */ -static void -fedfs_map_usage(void) -{ - printf(_("\nUsage: %s [domain]\n\n"), progname); - - printf("%s", fedfs_gpl_boilerplate); -} - -/** - * Construct an NFSv4 map entry for "domainname" with one server - * - * @param si single-entry list of SRV records - * @param domainname NUL-terminated UTF-8 string containing name of FedFS domain - * @return command exit status - */ -static int fedfs_map_nfs4_oneserver(struct srvinfo *si, const char *domainname) -{ - printf("-fstype=nfs,vers=4,fg"); - if (si->si_port != 2049) - printf(",port=%u", si->si_port); - printf(" %s:%s/%s\n", si->si_target, FEDFS_NFS_EXPORTPATH, domainname); - return 0; -} - -/** - * Construct an NFSv4 map entry for "domainname" with multiple servers - * - * @param si list of SRV records for requested FedFS domain - * @param domainname NUL-terminated UTF-8 string containing name of FedFS domain - * @return command exit status - */ -static int fedfs_map_nfs4_replicas(struct srvinfo *si, const char *domainname) -{ - struct srvinfo *cur; - unsigned short port; - _Bool comma; - - /* - * Unfortunately our automounter can't handle a list of - * replicas where the various servers live on different - * ports from one another. - */ - port = si->si_port; - for (cur = si; cur != NULL; cur = cur->si_next) - if (cur->si_port != port) { - fprintf(stderr, _("%s: Replicas on different ports not supported\n"), - progname); - return 1; - } - - if (port != 2049) - printf("-fstype=nfs,vers=4,fg,port=%u ", port); - else - printf("-fstype=nfs,vers=4,fg "); - - /* - * Note that the export path is required to be indentical - * for all domain root servers for this domain. - */ - for (comma = false, cur = si; cur != NULL; cur = cur->si_next) { - if (comma) - printf(","); - printf("%s(%u)", cur->si_target, cur->si_weight); - comma = true; - } - printf(":%s/%s\n", FEDFS_NFS_EXPORTPATH, domainname); - - return 0; -} - -/** - * Construct an NFSv4 map entry for "domainname" - * - * @param domainname NUL-terminated UTF-8 string containing name of FedFS domain - * @return command exit status - */ -static int fedfs_map_nfs4(const char *domainname) -{ - struct srvinfo *cur, *si = NULL; - unsigned int count; - int error, result; - - result = 1; - error = getsrvinfo(FEDFS_NFS_DOMAINROOT, domainname, &si); - switch (error) { - case ESI_SUCCESS: - break; - case ESI_NONAME: - fprintf(stderr, _("%s: Domain name %s not found\n"), - progname, domainname); - goto out; - case ESI_SERVICE: - fprintf(stderr, _("%s: No FedFS domain root available for %s\n"), - progname, domainname); - goto out; - default: - fprintf(stderr, _("%s: Failed to resolve %s: %s\n"), - progname, domainname, gsi_strerror(error)); - goto out; - } - - for (count = 0, cur = si; cur != NULL; cur = cur->si_next) - count++; - if (count == 1) - result = fedfs_map_nfs4_oneserver(si, domainname); - else - result = fedfs_map_nfs4_replicas(si, domainname); - -out: - freesrvinfo(si); - return result; -} - -/** - * Program entry point - * - * @param argc count of command line arguments - * @param argv array of NUL-terminated C strings containing command line arguments - * @return program exit status - */ -int main(int argc, char *argv[]) -{ - (void)setlocale(LC_ALL, ""); - - progname = basename(argv[0]); - - if (argc != 2) { - fedfs_map_usage(); - return 1; - } - - if (strcmp(progname, "fedfs-map-nfs4") == 0) - return fedfs_map_nfs4(argv[1]); -#ifdef EXAMPLE - /* CIFS support might plug in here */ - else if (strcmp(progname, "fedfs-map-cifs") == 0) - return fedfs_map_cifs(argv[1]); -#endif - - fprintf(stderr, _("%s: Unsupported file system type\n"), progname); - return 1; -} diff --git a/fedfs/fedfs-nls.h b/fedfs/fedfs-nls.h deleted file mode 100644 index 92f968d..0000000 --- a/fedfs/fedfs-nls.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * From util-linux/include/nls.h (GPLv2) - */ - -#ifndef UTIL_LINUX_NLS_H -#define UTIL_LINUX_NLS_H - -int main(int argc, char *argv[]); - -#ifndef LOCALEDIR -#define LOCALEDIR "/usr/share/locale" -#endif - -#ifdef HAVE_LOCALE_H -# include -#else -# undef setlocale -# define setlocale(Category, Locale) ({}) /* empty */ -#endif - -#ifdef ENABLE_NLS -# include -# define _(Text) gettext (Text) -# ifdef gettext_noop -# define N_(String) gettext_noop (String) -# else -# define N_(String) (String) -# endif -#else -# undef bindtextdomain -# define bindtextdomain(Domain, Directory) /* empty */ -# undef textdomain -# define textdomain(Domain) /* empty */ -# define _(Text) (Text) -# define N_(Text) (Text) -#endif - -#endif /* UTIL_LINUX_NLS_H */ diff --git a/fedfs/fedfs-token.h b/fedfs/fedfs-token.h deleted file mode 100644 index 5651409..0000000 --- a/fedfs/fedfs-token.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2007 Oracle. All rights reserved. - * Copyright (C) 2007 Chuck Lever - * - * This file is part of fedfs-utils. - * - * fedfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * fedfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with fedfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#ifndef _FEDFS_UTILS_TOKEN_H -#define _FEDFS_UTILS_TOKEN_H - -#include - -/** - * Private tokenizer state object - */ -struct tokenizer; - -__attribute_malloc__ -struct tokenizer *tk_new_tokenizer(const char *string, - const char delimiter); -__attribute_malloc__ -char *tk_next_token(struct tokenizer *state); -void tk_free_tokenizer(struct tokenizer *state); -int tk_tokenizer_error(const struct tokenizer *state); - -#endif /* !_FEDFS_UTILS_TOKEN_H */ diff --git a/fedfs/mount.fedfs.c b/fedfs/mount.fedfs.c deleted file mode 100644 index bd43439..0000000 --- a/fedfs/mount.fedfs.c +++ /dev/null @@ -1,485 +0,0 @@ -/* - * Copyright 2011 Oracle. All rights reserved. - * - * This file is part of fedfs-utils. - * - * fedfs-utils is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 as - * published by the Free Software Foundation. - * - * fedfs-utils is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2.0 for more details. - * - * You should have received a copy of the GNU General Public License - * version 2.0 along with fedfs-utils. If not, see: - * - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "fedfs-nls.h" -#include "fedfs-getsrvinfo.h" -#include "fedfs-gpl-boiler.h" - -/** - * Top-level directory on client under which we mount NFSv4 domain roots - */ -#define FEDFS_NFS4_TLDIR "nfs4" - -/** - * Name of SRV record containing NFSv4 FedFS root - */ -#define FEDFS_NFS_DOMAINROOT "_nfs-domainroot._tcp" - -/** - * Export path of NFSv4 FedFS root - */ -#define FEDFS_NFS_EXPORTPATH "/.domainroot" - -/** - * Pathname to mount.nfs - */ -#define MOUNT_NFS_EXECUTABLE "/sbin/mount.nfs" - -/** - * Mount status values, lifted from util-linux - */ -enum { - EX_SUCCESS = 0, - EX_USAGE = 1, - EX_FAIL = 32, -}; - -static char *progname; -static int nomtab; -static int verbose; -static _Bool readonly; -static _Bool sloppy; -static _Bool fake; - -/** - * Short form command line options - */ -static const char fedfs_opts[] = "fhno:rsvVw"; - -/** - * Long form command line options - */ -static const struct option fedfs_longopts[] = -{ - { "fake", 0, NULL, 'f' }, - { "help", 0, NULL, 'h' }, - { "no-mtab", 0, NULL, 'n' }, - { "options", 1, NULL, 'o' }, - { "read-only", 0, NULL, 'r' }, - { "read-write", 0, NULL, 'w' }, - { "ro", 0, NULL, 'r' }, - { "rw", 0, NULL, 'w' }, - { "sloppy", 0, NULL, 's' }, - { "verbose", 0, NULL, 'v' }, - { "version", 0, NULL, 'V' }, - { NULL, 0, NULL, 0 } -}; - -/** - * Display mount.fedfs usage message - */ -static void -mount_usage(void) -{ - printf(_("\nUsage: %s remotedir localdir [-fhnrsvVw]\n\n"), progname); - printf(_("options:\n")); - printf(_("\t-f\t\tFake mount, do not actually mount\n")); - printf(_("\t-h\t\tPrint this help\n")); - printf(_("\t-n\t\tDo not update /etc/mtab\n")); - printf(_("\t-r\t\tMount file system readonly\n")); - printf(_("\t-s\t\tTolerate sloppy mount options\n")); - printf(_("\t-v\t\tVerbose\n")); - printf(_("\t-V\t\tPrint version\n")); - printf(_("\t-w\t\tMount file system read-write\n")); - - printf("%s", fedfs_gpl_boilerplate); -} - -/** - * Concatenate three strings - * - * @param s NUL-terminated C string - * @param t NUL-terminated C string - * @param u NUL-terminated C string - * @return pointer to NUL-terminated C string or NULL - * - * Caller must free the returned string with free(3). Always frees - * its first arg - typical use: s = xstrconcat3(s,t,u); - * - * Lifted from util-linux. - */ -static char * -xstrconcat3(char *s, const char *t, const char *u) -{ - _Bool free_s = true; - char *result; - - if (s == NULL) { - s = ""; - free_s = false; - } - if (t == NULL) - t = ""; - if (u == NULL) - u = ""; - result = malloc(strlen(s) + strlen(t) + strlen(u) + 1); - if (result == NULL) - goto out; - - strcpy(result, s); - strcat(result, t); - strcat(result, u); - -out: - if (free_s) - free(s); - return result; -} - -/** - * Exec mount.nfs - * - * @param server NUL-terminated C string containing name of NFS server - * @param port server port to use when mounting - * @param domainname NUL-terminated C string containing FedFS domain name - * @param export_path NUL-terminated C string containing server export path - * @param mounted_on_dir NUL-terminated C string containing local mounted-on directory - * @param text_options NUL-terminated C string containing user's mount options - * - */ -static void -exec_mount_nfs4(const char *server, unsigned short port, - const char *domainname, const char *export_path, - const char *mounted_on_dir, const char *text_options) -{ - static char special[2048]; - static char options[2048]; - char *args[16]; - int count = 0; - - snprintf(special, sizeof(special), "%s:%s/%s%s", server, - FEDFS_NFS_EXPORTPATH, domainname, export_path); - - if (text_options != NULL && strcmp(text_options, "") != 0) - snprintf(options, sizeof(options), "%s,vers=4,fg,port=%u", - text_options, port); - else - snprintf(options, sizeof(options), "vers=4,fg,port=%u", port); - - if (verbose) { - printf(_("%s: Special device: %s\n"), - progname, special); - printf(_("%s: Mounted-on directory: %s\n"), - progname, mounted_on_dir); - printf(_("%s: Mount options: %s\n"), - progname, options); - } - - args[count++] = MOUNT_NFS_EXECUTABLE; - args[count++] = special; - args[count++] = (char *)mounted_on_dir; - if (verbose) - args[count++] = "-v"; - if (fake) - args[count++] = "-f"; - if (nomtab) - args[count++] = "-n"; - if (readonly) - args[count++] = "-r"; - if (sloppy) - args[count++] = "-s"; - args[count++] = "-o"; - args[count++] = options; - - args[count] = NULL; - execv(args[0], args); -} - -/** - * Mount a FedFS domain root via NFSv4 - * - * @param domainname NUL-terminated C string containing FedFS domain name - * @param export_path NUL-terminated C string containing server export path - * @param mounted_on_dir NUL-terminated C string containing local mounted-on directory - * @param text_options NUL-terminated C string containing user's mount options - * @return exit status code from the mount.nfs command - * - * Construct the server:/export string and the mounted-on directory string - * based on the DNS SRV query results, then fork and exec mount.nfs to do - * the actual mount request. - */ -static int -nfs4_mount(const char *domainname, const char *export_path, - const char *mounted_on_dir, const char *text_options) -{ - struct srvinfo *tmp, *si = NULL; - int error, status; - - status = EX_FAIL; - - error = getsrvinfo(FEDFS_NFS_DOMAINROOT, domainname, &si); - switch (error) { - case ESI_SUCCESS: - break; - case ESI_NONAME: - fprintf(stderr, _("%s: Domain name %s not found\n"), - progname, domainname); - goto out; - case ESI_SERVICE: - fprintf(stderr, _("%s: No FedFS domain root available for %s\n"), - progname, domainname); - goto out; - default: - fprintf(stderr, _("%s: Failed to resolve %s: %s\n"), - progname, domainname, gsi_strerror(error)); - goto out; - } - - /* - * The srvinfo list is already in RFC 2782 sorted order. Try each - * SRV record once, in the foreground. Go with the first one that - * works. - */ - for (tmp = si; tmp != NULL; tmp = tmp->si_next) { - pid_t pid; - - pid = fork(); - switch (pid) { - case 0: - exec_mount_nfs4(tmp->si_target, tmp->si_port, - domainname, export_path, mounted_on_dir, - text_options); - /*NOTREACHED*/ - fprintf(stderr, _("%s: Failed to exec: %s\n"), - progname, strerror(errno)); - exit(EX_FAIL); - case -1: - fprintf(stderr, _("%s: Failed to fork: %s\n"), - progname, strerror(errno)); - goto out; - default: - waitpid(pid, &status, 0); - if (status == EX_SUCCESS) - goto out; - } - } - -out: - freesrvinfo(si); - return status; -} - -/** - * Try one mount request - * - * @param source NUL-terminated C string containing name of "special device" - * @param target NUL-terminated C string containing local mounted-on directory - * @param text_options NUL-terminated C string containing user's mount options - * @return an exit status code - * - * Parse the pathname in "source." It contains the file system protocol - * and FedFS domain name. Then pass these arguments to the appropriate - * mount helper subcommand. - */ -static int -try_mount(const char *source, const char *target, const char *text_options) -{ - char *global_name, *topdir, *domainname, *remaining; - int result; - - remaining = NULL; - result = EX_FAIL; - - global_name = strdup(source); - if (global_name == NULL) { - fprintf(stderr, _("%s: Unable to parse globally useful name\n"), - progname); - goto out; - } - - topdir = strtok(global_name, "/"); - if (topdir == NULL) { - fprintf(stderr, _("%s: Invalid globally useful name: %s\n"), - progname, source); - goto out; - } - if (verbose) - printf(_("%s: Top-level directory: %s\n"), - progname, topdir); - - domainname = strtok(NULL, "/"); - if (domainname == NULL) { - fprintf(stderr, _("%s: Missing domain name in globally " - "useful name: %s\n"), progname, source); - goto out; - } - if (verbose) - printf(_("%s: Domain name: %s\n"), - progname, domainname); - - remaining = strtok(NULL, "/"); - if (remaining == NULL) { - remaining = strdup("/"); - if (remaining == NULL) { - fprintf(stderr, _("%s: No memory\n"), progname); - goto out; - } - } else { - char *tmp; - - tmp = malloc(strlen(remaining) + 1); - if (tmp == NULL) { - fprintf(stderr, _("%s: No memory\n"), progname); - remaining = NULL; - goto out; - } - strcpy(tmp, "/"); - strcat(tmp, remaining); - remaining = tmp; - } - if (verbose) - printf(_("%s: Export path: %s\n"), - progname, remaining); - - if (strcmp(topdir, FEDFS_NFS4_TLDIR) == 0) - result = nfs4_mount(domainname, remaining, target, text_options); -#if 0 - /* example: SMB support plugs in here */ - else if (strcmp(topdir, FEDFS_SMB_TLDIR) == 0) - result = smb_mount(domainname, remaining, target, text_options); -#endif - else - fprintf(stderr, _("%s: Unrecognized file system protocol\n"), progname); - -out: - free(global_name); - free(remaining); - - return result; -} - -/** - * Program entry point - * - * @param argc count of command line arguments - * @param argv array of NUL-terminated C strings containing command line arguments - * @return program exit status - */ -int main(int argc, char *argv[]) -{ - char *source, *target, *text_options; - int c, mnt_err; - - (void)setlocale(LC_ALL, ""); - - progname = basename(argv[0]); - - if (argv[1] && argv[1][0] == '-') { - if(argv[1][1] == 'V') - printf("%s (VERSION_STRING)\n", progname); - else - mount_usage(); - exit(EX_SUCCESS); - } - - if (argc < 3) { - mount_usage(); - exit(EX_USAGE); - } - - source = argv[1]; - target = argv[2]; - - mnt_err = EX_USAGE; - text_options = NULL; - readonly = false; - sloppy = false; - fake = false; - argv[2] = argv[0]; /* so that getopt error messages are correct */ - while ((c = getopt_long(argc - 2, argv + 2, fedfs_opts, - fedfs_longopts, NULL)) != -1) { - switch (c) { - case 'f': - fake = true; - break; - case 'n': - ++nomtab; - break; - case 'o': - /* Ugh. */ - if (text_options != NULL) - text_options = xstrconcat3(text_options, ",", optarg); - else - text_options = strdup(optarg); - if (text_options == NULL) { - fprintf(stderr, _("%s: No memory\n"), progname); - goto out; - } - break; - case 'r': - readonly = true; - break; - case 's': - sloppy = true; - break; - case 'v': - ++verbose; - break; - case 'V': - printf("%s: (VERSION_STRING)\n", progname); - mnt_err = EX_SUCCESS; - goto out; - case 'w': - readonly = false; - break; - case 'h': - default: - mount_usage(); - goto out; - } - } - - /* Extra non-option words at the end are bogus... */ - if (optind != argc - 2) { - mount_usage(); - goto out; - } - - if (getuid() != 0 && geteuid() != 0) { - fprintf(stderr, _("%s: Not installed setuid - " - "\"user\" FedFS mounts are not supported\n"), progname); - mnt_err = EX_FAIL; - goto out; - } - - mnt_err = try_mount(source, target, text_options); - -out: - free(text_options); - exit(mnt_err); -} diff --git a/include/automount.h b/include/automount.h index b672471..2e2c2b0 100644 --- a/include/automount.h +++ b/include/automount.h @@ -52,10 +52,17 @@ #error Failed to locate umount(8)! #endif +#ifndef HAVE_MODPROBE +#error Failed to locate modprobe(8)! +#endif + #ifndef HAVE_LINUX_PROCFS #error Failed to verify existence of procfs filesystem! #endif +#define FS_MODULE_NAME "autofs4" +int load_autofs4_module(void); + /* The -s (sloppy) option to mount is good, if we have it... */ #ifdef HAVE_SLOPPY_MOUNT @@ -66,13 +73,6 @@ #define SLOPPY #endif -#define DAEMON_FLAGS_FOREGROUND 0x0001 -#define DAEMON_FLAGS_SYSTEMD_SERVICE 0x0002 -#define DAEMON_FLAGS_HAVE_GLOBAL_OPTIONS 0x0004 -#define DAEMON_FLAGS_GHOST 0x0008 -#define DAEMON_FLAGS_CHECK_DAEMON 0x0010 -#define DAEMON_FLAGS_DUMP_MAPS 0x0020 - #define AUTOFS_SUPER_MAGIC 0x00000187L #define SMB_SUPER_MAGIC 0x0000517BL #define CIFS_MAGIC_NUMBER 0xFF534D42L @@ -269,7 +269,6 @@ void reset_signals(void); int do_mount(struct autofs_point *ap, const char *root, const char *name, int name_len, const char *what, const char *fstype, const char *options); -extern unsigned int mp_mode; int mkdir_path(const char *path, mode_t mode); int rmdir_path(struct autofs_point *ap, const char *path, dev_t dev); @@ -549,16 +548,6 @@ struct kernel_mod_version { /* Read amd map even if it's not to be ghosted (browsable) */ #define MOUNT_FLAG_AMD_CACHE_ALL 0x0080 -/* Set mount propagation for bind mounts */ -#define MOUNT_FLAG_SLAVE 0x0100 -#define MOUNT_FLAG_PRIVATE 0x0200 - -/* Use strict expire semantics if requested and kernel supports it */ -#define MOUNT_FLAG_STRICTEXPIRE 0x0400 - -/* Indicator for applications to ignore the mount entry */ -#define MOUNT_FLAG_IGNORE 0x0800 - struct autofs_point { pthread_t thid; char *path; /* Mount point name */ @@ -606,14 +595,14 @@ void *expire_proc_indirect(void *); void *expire_proc_direct(void *); int expire_offsets_direct(struct autofs_point *ap, struct mapent *me, int now); int mount_autofs_indirect(struct autofs_point *ap, const char *root); -int do_mount_autofs_direct(struct autofs_point *ap, struct mapent *me, time_t timeout); +int do_mount_autofs_direct(struct autofs_point *ap, struct mnt_list *mnts, struct mapent *me, time_t timeout); int mount_autofs_direct(struct autofs_point *ap); int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, const char *root, const char *offset); void submount_signal_parent(struct autofs_point *ap, unsigned int success); void close_mount_fds(struct autofs_point *ap); int umount_autofs(struct autofs_point *ap, const char *root, int force); int umount_autofs_indirect(struct autofs_point *ap, const char *root); -int do_umount_autofs_direct(struct autofs_point *ap, struct mapent *me); +int do_umount_autofs_direct(struct autofs_point *ap, struct mnt_list *mnts, struct mapent *me); int umount_autofs_direct(struct autofs_point *ap); int umount_autofs_offset(struct autofs_point *ap, struct mapent *me); int handle_packet_expire_indirect(struct autofs_point *ap, autofs_packet_expire_indirect_t *pkt); diff --git a/include/config.h.in b/include/config.h.in index a487949..04873e8 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -48,15 +48,15 @@ /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H +/* define if you have MODPROBE */ +#undef HAVE_MODPROBE + /* define if you have MOUNT */ #undef HAVE_MOUNT /* define if you have MOUNT_NFS */ #undef HAVE_MOUNT_NFS -/* Define if using NIS+ */ -#undef HAVE_NISPLUS - /* define if the umount command supports the -c option */ #undef HAVE_NO_CANON_UMOUNT @@ -126,6 +126,9 @@ /* define if you have LEX */ #undef PATH_LEX +/* define if you have MODPROBE */ +#undef PATH_MODPROBE + /* define if you have MOUNT */ #undef PATH_MOUNT diff --git a/include/defaults.h b/include/defaults.h index 69263bf..b28fde3 100644 --- a/include/defaults.h +++ b/include/defaults.h @@ -27,7 +27,6 @@ #define DEFAULT_TIMEOUT "600" #define DEFAULT_MASTER_WAIT "10" #define DEFAULT_NEGATIVE_TIMEOUT "60" -#define DEFAULT_MOUNT_VERBOSE "0" #define DEFAULT_MOUNT_WAIT "-1" #define DEFAULT_UMOUNT_WAIT "12" #define DEFAULT_BROWSE_MODE "1" @@ -51,7 +50,6 @@ #define DEFAULT_USE_HOSTNAME_FOR_MOUNTS "0" #define DEFAULT_DISABLE_NOT_FOUND_MESSAGE "0" -#define DEFAULT_USE_IGNORE_MOUNT_OPTION "0" #define DEFAULT_SSS_MASTER_MAP_WAIT "0" #define DEFAULT_USE_MOUNT_REQUEST_LOG_ID "0" @@ -168,14 +166,12 @@ unsigned int defaults_get_ldap_timeout(void); unsigned int defaults_get_ldap_network_timeout(void); unsigned int defaults_get_mount_nfs_default_proto(void); unsigned int defaults_get_append_options(void); -unsigned int defaults_get_mount_verbose(void); unsigned int defaults_get_mount_wait(void); unsigned int defaults_get_umount_wait(void); const char *defaults_get_auth_conf_file(void); unsigned int defaults_get_map_hash_table_size(void); unsigned int defaults_use_hostname_for_mounts(void); unsigned int defaults_disable_not_found_message(void); -unsigned int defaults_get_use_ignore_mount_option(void); unsigned int defaults_get_sss_master_map_wait(void); unsigned int defaults_get_use_mount_request_log_id(void); diff --git a/include/log.h b/include/log.h index 69eed96..7a394cb 100644 --- a/include/log.h +++ b/include/log.h @@ -36,6 +36,7 @@ extern void set_log_debug_ap(struct autofs_point *ap); extern void set_mnt_logging(unsigned global_logopt); extern void open_log(void); +extern void log_to_syslog(void); extern void log_to_stderr(void); extern void log_info(unsigned int, const char* msg, ...); @@ -46,8 +47,6 @@ extern void log_crit(unsigned, const char* msg, ...); extern void log_debug(unsigned int, const char* msg, ...); extern void logmsg(const char* msg, ...); -extern pid_t log_pidinfo(struct autofs_point *ap, pid_t pid, char *label); - #define debug(opt, msg, args...) \ do { log_debug(opt, "%s: " msg, __FUNCTION__, ##args); } while (0) diff --git a/include/mounts.h b/include/mounts.h index c8fddf0..74b23db 100644 --- a/include/mounts.h +++ b/include/mounts.h @@ -35,9 +35,6 @@ #define MNTS_ALL 0x0001 #define MNTS_REAL 0x0002 #define MNTS_AUTOFS 0x0004 -#define MNTS_INDIRECT 0x0008 -#define MNTS_DIRECT 0x0010 -#define MNTS_OFFSET 0x0020 #define REMOUNT_SUCCESS 0x0000 #define REMOUNT_FAIL 0x0001 @@ -52,8 +49,11 @@ extern const unsigned int t_offset; struct mapent; struct mnt_list { - char *mp; - unsigned int flags; + char *path; + char *fs_name; + char *fs_type; + char *opts; + pid_t owner; /* * List operations ie. get_mnt_list. */ @@ -94,21 +94,22 @@ void free_amd_entry_list(struct list_head *entries); unsigned int query_kproto_ver(void); unsigned int get_kver_major(void); unsigned int get_kver_minor(void); -char *make_options_string(char *path, int pipefd, - const char *type, unsigned int flags); +char *make_options_string(char *path, int kernel_pipefd, const char *extra); char *make_mnt_name_string(char *path); int ext_mount_add(struct list_head *, const char *, unsigned int); int ext_mount_remove(struct list_head *, const char *); int ext_mount_inuse(const char *); -struct mnt_list *get_mnt_list(const char *path, int include); -int unlink_mount_tree(struct autofs_point *ap, const char *mp); +struct mnt_list *get_mnt_list(const char *table, const char *path, int include); +struct mnt_list *reverse_mnt_list(struct mnt_list *list); void free_mnt_list(struct mnt_list *list); -int is_mounted(const char *mp, unsigned int type); +int is_mounted(const char *table, const char *path, unsigned int type); +int has_fstab_option(const char *opt); void tree_free_mnt_tree(struct mnt_list *tree); -struct mnt_list *tree_make_mnt_tree(const char *path); +struct mnt_list *tree_make_mnt_tree(const char *table, const char *path); int tree_get_mnt_list(struct mnt_list *mnts, struct list_head *list, const char *path, int include); int tree_get_mnt_sublist(struct mnt_list *mnts, struct list_head *list, const char *path, int include); int tree_find_mnt_ents(struct mnt_list *mnts, struct list_head *list, const char *path); +int tree_is_mounted(struct mnt_list *mnts, const char *path, unsigned int type); void set_tsd_user_vars(unsigned int, uid_t, gid_t); const char *mount_type_str(unsigned int); void set_exp_timeout(struct autofs_point *ap, struct map_source *source, time_t timeout); diff --git a/include/replicated.h b/include/replicated.h index 95ff1f0..69ab780 100644 --- a/include/replicated.h +++ b/include/replicated.h @@ -26,9 +26,7 @@ #define NFS2_SUPPORTED 0x0010 #define NFS3_SUPPORTED 0x0020 #define NFS4_SUPPORTED 0x0040 -#define NFS_VERS_DEFAULT (NFS3_SUPPORTED) -#define NFS_VERS_MASK (NFS2_SUPPORTED|NFS3_SUPPORTED) -#define NFS4_VERS_DEFAULT (NFS4_SUPPORTED) +#define NFS_VERS_MASK (NFS3_SUPPORTED) #define NFS4_VERS_MASK (NFS4_SUPPORTED) #define NFS2_REQUESTED NFS2_SUPPORTED @@ -41,7 +39,6 @@ #define UDP_REQUESTED UDP_SUPPORTED #define TCP6_REQUESTED 0x0100 #define UDP6_REQUESTED 0x0200 -#define NFS_PROTO_DEFAULT (TCP_SUPPORTED|UDP_SUPPORTED) #define NFS_PROTO_MASK (TCP_SUPPORTED|UDP_SUPPORTED) #define NFS2_TCP_SUPPORTED NFS2_SUPPORTED @@ -60,7 +57,6 @@ struct host { char *name; - int ent_num; struct sockaddr *addr; size_t addr_len; unsigned int rr; @@ -74,7 +70,7 @@ struct host { }; void seed_random(void); -struct host *new_host(const char *, int, struct sockaddr *, size_t, +struct host *new_host(const char *, struct sockaddr *, size_t, unsigned int, unsigned int, unsigned int); void free_host_list(struct host **); int parse_location(unsigned, struct host **, const char *, unsigned int); diff --git a/include/state.h b/include/state.h index e3079c2..b44a353 100644 --- a/include/state.h +++ b/include/state.h @@ -55,7 +55,7 @@ struct expire_args { unsigned int signaled; struct autofs_point *ap; /* autofs mount we are working on */ enum states state; /* State prune or expire */ - unsigned int how; /* Normal, immediate expire ? */ + unsigned int when; /* Immediate expire ? */ int status; /* Return status */ }; diff --git a/lib/defaults.c b/lib/defaults.c index 1b27ffd..d20c190 100644 --- a/lib/defaults.c +++ b/lib/defaults.c @@ -68,7 +68,6 @@ #define NAME_MOUNT_NFS_DEFAULT_PROTOCOL "mount_nfs_default_protocol" #define NAME_APPEND_OPTIONS "append_options" -#define NAME_MOUNT_VERBOSE "mount_verbose" #define NAME_MOUNT_WAIT "mount_wait" #define NAME_UMOUNT_WAIT "umount_wait" #define NAME_AUTH_CONF_FILE "auth_conf_file" @@ -77,7 +76,6 @@ #define NAME_USE_HOSTNAME_FOR_MOUNTS "use_hostname_for_mounts" #define NAME_DISABLE_NOT_FOUND_MESSAGE "disable_not_found_message" -#define NAME_USE_IGNORE_MOUNT_OPTION "use_ignore_mount_option" #define NAME_SSS_MASTER_MAP_WAIT "sss_master_map_wait" #define NAME_USE_MOUNT_REQUEST_LOG_ID "use_mount_request_log_id" @@ -330,11 +328,6 @@ static int conf_load_autofs_defaults(void) if (ret == CFG_FAIL) goto error; - ret = conf_update(sec, NAME_MOUNT_VERBOSE, - DEFAULT_MOUNT_VERBOSE, CONF_ENV); - if (ret == CFG_FAIL) - goto error; - ret = conf_update(sec, NAME_MOUNT_WAIT, DEFAULT_MOUNT_WAIT, CONF_ENV); if (ret == CFG_FAIL) @@ -365,11 +358,6 @@ static int conf_load_autofs_defaults(void) if (ret == CFG_FAIL) goto error; - ret = conf_update(sec, NAME_USE_IGNORE_MOUNT_OPTION, - DEFAULT_USE_IGNORE_MOUNT_OPTION, CONF_ENV); - if (ret == CFG_FAIL) - goto error; - ret = conf_update(sec, NAME_SSS_MASTER_MAP_WAIT, DEFAULT_SSS_MASTER_MAP_WAIT, CONF_ENV); if (ret == CFG_FAIL) @@ -1219,12 +1207,12 @@ unsigned int defaults_read_config(unsigned int to_syslog) conf = open_fopen_r(DEFAULT_CONFIG_FILE); if (!conf) - message(to_syslog, "failed to open config %s", + message(to_syslog, "failed to to open config %s", DEFAULT_CONFIG_FILE); oldconf = open_fopen_r(OLD_CONFIG_FILE); - if (!oldconf && !conf) - message(to_syslog, "failed to open old config %s", + if (!oldconf) + message(to_syslog, "failed to to open old config %s", OLD_CONFIG_FILE); /* Neither config has been updated */ @@ -1793,17 +1781,6 @@ unsigned int defaults_get_append_options(void) return res; } -unsigned int defaults_get_mount_verbose(void) -{ - long res; - - res = conf_get_yesno(autofs_gbl_sec, NAME_MOUNT_VERBOSE); - if (res < 0) - res = atoi(DEFAULT_MOUNT_VERBOSE); - - return res; -} - unsigned int defaults_get_mount_wait(void) { long wait; @@ -1870,17 +1847,6 @@ unsigned int defaults_disable_not_found_message(void) return res; } -unsigned int defaults_get_use_ignore_mount_option(void) -{ - int res; - - res = conf_get_yesno(autofs_gbl_sec, NAME_USE_IGNORE_MOUNT_OPTION); - if (res < 0) - res = atoi(DEFAULT_USE_IGNORE_MOUNT_OPTION); - - return res; -} - unsigned int defaults_get_sss_master_map_wait(void) { int res; diff --git a/lib/log.c b/lib/log.c index 0cb47d7..1a0bc3f 100644 --- a/lib/log.c +++ b/lib/log.c @@ -44,8 +44,6 @@ static char *prepare_attempt_prefix(const char *msg) snprintf(buffer, ATTEMPT_ID_SIZE, "%02lx", *attempt_id); prefixed_msg = (char *) calloc(len, sizeof(char)); - if (!prefixed_msg) - return NULL; strcpy(prefixed_msg, buffer); strcat(prefixed_msg, "|"); strcat(prefixed_msg, msg); @@ -314,53 +312,44 @@ void open_log(void) return; } -void log_to_stderr(void) +void log_to_syslog(void) { - if (syslog_open) { - syslog_open = 0; - closelog(); - } + char buf[MAX_ERR_BUF]; + int nullfd; - logging_to_syslog = 0; + open_log(); - return; -} + /* Redirect all our file descriptors to /dev/null */ + nullfd = open("/dev/null", O_RDWR); + if (nullfd < 0) { + char *estr = strerror_r(errno, buf, MAX_ERR_BUF); + fprintf(stderr, "cannot open /dev/null: %s", estr); + exit(1); + } -pid_t log_pidinfo(struct autofs_point *ap, pid_t pid, char *label) { - char buf[PATH_MAX + 1] = ""; - FILE *statfile; + if (dup2(nullfd, STDIN_FILENO) < 0 || + dup2(nullfd, STDOUT_FILENO) < 0 || + dup2(nullfd, STDERR_FILENO) < 0) { + char *estr = strerror_r(errno, buf, MAX_ERR_BUF); + fprintf(stderr, + "redirecting file descriptors failed: %s", estr); + exit(1); + } - pid_t tgid, ppid; - int uid, euid, gid, egid; - char comm[64] = ""; + if (nullfd > 2) + close(nullfd); - sprintf(buf, "/proc/%d/status", pid); - statfile = fopen(buf, "r"); - if (statfile == NULL) { - info(ap->logopt, "pidinfo %s: failed to open %s", label, buf); - return -1; - } + return; +} - while (fgets(buf, sizeof(buf), statfile) != NULL) { - if (strncmp(buf, "Name:", 5) == 0) { - sscanf(buf, "Name:\t%s", (char *) &comm); - } else if (strncmp(buf, "Tgid:", 5) == 0) { - sscanf(buf, "Tgid:\t%d", (int *) &tgid); - } else if (strncmp(buf, "PPid:", 5) == 0) { - sscanf(buf, "PPid:\t%d", (int *) &ppid); - } else if (strncmp(buf, "Uid:", 4) == 0) { - sscanf(buf, - "Uid:\t%d\t%d", (int *) &uid, (int *) &euid); - } else if (strncmp(buf, "Gid:", 4) == 0) { - sscanf(buf, - "Gid:\t%d\t%d", (int *) &gid, (int *) &egid); - } +void log_to_stderr(void) +{ + if (syslog_open) { + syslog_open = 0; + closelog(); } - fclose(statfile); - info(ap->logopt, - "pidinfo %s: pid:%d comm:%s tgid:%d uid:%d euid:%d gid:%d egid:%d", - label, pid, comm, tgid, uid, euid, gid, egid); + logging_to_syslog = 0; - return ppid; + return; } diff --git a/lib/macros.c b/lib/macros.c index 5def26d..dfdca85 100644 --- a/lib/macros.c +++ b/lib/macros.c @@ -137,7 +137,6 @@ void macro_init(void) macro_init_done = 1; macro_unlock(); - free(local_domain); return; } diff --git a/lib/master.c b/lib/master.c index 55a6b01..76717d5 100644 --- a/lib/master.c +++ b/lib/master.c @@ -102,11 +102,8 @@ int master_add_autofs_point(struct master_mapent *entry, unsigned logopt, ap->exp_timeout = defaults_get_timeout(); ap->exp_runfreq = 0; ap->flags = 0; - - if (defaults_get_use_ignore_mount_option()) - ap->flags = MOUNT_FLAG_IGNORE; if (ghost) - ap->flags |= MOUNT_FLAG_GHOST; + ap->flags = MOUNT_FLAG_GHOST; if (nobind) ap->flags |= MOUNT_FLAG_NOBIND; @@ -158,7 +155,7 @@ void master_free_autofs_point(struct autofs_point *ap) ext_mount_remove(&entry->ext_mount, entry->fs); if (!list_empty(&entry->entries)) list_del(&entry->entries); - free_amd_entry(entry); + free(entry); } mounts_mutex_unlock(ap); @@ -925,7 +922,7 @@ void master_free_mapent(struct master_mapent *entry) return; } -struct master *master_new(const char *name, unsigned int timeout, unsigned int flags) +struct master *master_new(const char *name, unsigned int timeout, unsigned int ghost) { struct master *master; char *tmp; @@ -951,7 +948,7 @@ struct master *master_new(const char *name, unsigned int timeout, unsigned int f master->depth = 0; master->reading = 0; master->read_fail = 0; - master->default_ghost = flags & DAEMON_FLAGS_GHOST; + master->default_ghost = ghost; master->default_timeout = timeout; master->default_logging = defaults_get_logging(); master->logopt = master->default_logging; diff --git a/lib/master_parse.y b/lib/master_parse.y index f817f73..42e03c2 100644 --- a/lib/master_parse.y +++ b/lib/master_parse.y @@ -58,9 +58,6 @@ static char *format; static long timeout; static long negative_timeout; static unsigned symlnk; -static unsigned strictexpire; -static unsigned slave; -static unsigned private; static unsigned nobind; static unsigned ghost; extern unsigned global_selection_options; @@ -106,7 +103,6 @@ static int master_fprintf(FILE *, char *, ...); %token MAP %token OPT_TIMEOUT OPT_NTIMEOUT OPT_NOBIND OPT_NOGHOST OPT_GHOST OPT_VERBOSE %token OPT_DEBUG OPT_RANDOM OPT_USE_WEIGHT OPT_SYMLINK OPT_MODE -%token OPT_STRICTEXPIRE OPT_SLAVE OPT_PRIVATE %token COLON COMMA NL DDASH %type map %type options @@ -161,8 +157,6 @@ line: trim_maptype($2); - if (path) - free(path); path = master_strdup($1); if (!path) { master_error("memory allocation error"); @@ -172,16 +166,7 @@ line: if ((tmp = strchr($2, ','))) *tmp++ = '\0'; -#ifndef WITH_HESIOD - /* Map type or map type parser is hesiod */ - if (!strcmp($2, "hesiod") || (tmp && !strcmp(tmp, "hesiod"))) { - master_error("hesiod support not built in"); - local_free_vars(); - YYABORT; - } -#endif - if (type) - free(type); + type = master_strdup($2); if (!type) { master_error("memory allocation error"); @@ -189,8 +174,6 @@ line: YYABORT; } if (tmp) { - if (format) - free(format); format = master_strdup(tmp); if (!format) { master_error("memory allocation error"); @@ -207,9 +190,6 @@ line: | PATH OPT_DEBUG { master_notify($1); YYABORT; } | PATH OPT_TIMEOUT { master_notify($1); YYABORT; } | PATH OPT_SYMLINK { master_notify($1); YYABORT; } - | PATH OPT_STRICTEXPIRE { master_notify($1); YYABORT; } - | PATH OPT_SLAVE { master_notify($1); YYABORT; } - | PATH OPT_PRIVATE { master_notify($1); YYABORT; } | PATH OPT_NOBIND { master_notify($1); YYABORT; } | PATH OPT_GHOST { master_notify($1); YYABORT; } | PATH OPT_NOGHOST { master_notify($1); YYABORT; } @@ -224,8 +204,6 @@ line: mapspec: map { - if (local_argv) - free_argv(local_argc, (const char **) local_argv); local_argc = tmp_argc; local_argv = tmp_argv; tmp_argc = 0; @@ -233,8 +211,6 @@ mapspec: map } | map options { - if (local_argv) - free_argv(local_argc, (const char **) local_argv); local_argc = tmp_argc; local_argv = tmp_argv; tmp_argc = 0; @@ -312,8 +288,6 @@ map: PATH } | MAPHOSTS { - if (type) - free(type); type = master_strdup($1 + 1); if (!type) { local_free_vars(); @@ -328,8 +302,6 @@ map: PATH } | MAPNULL { - if (type) - free(type); type = master_strdup($1 + 1); if (!type) { local_free_vars(); @@ -338,8 +310,6 @@ map: PATH } | dnattrs { - if (type) - free(type); type = master_strdup("ldap"); if (!type) { local_free_vars(); @@ -361,16 +331,7 @@ map: PATH if ((tmp = strchr($1, ','))) *tmp++ = '\0'; -#ifndef WITH_HESIOD - /* Map type or map type parser is hesiod */ - if (!strcmp($1, "hesiod") || (tmp && !strcmp(tmp, "hesiod"))) { - master_error("hesiod support not built in"); - local_free_vars(); - YYABORT; - } -#endif - if (type) - free(type); + if (strcmp($1, "exec")) type = master_strdup($1); else @@ -381,8 +342,6 @@ map: PATH YYABORT; } if (tmp) { - if (format) - free(format); format = master_strdup(tmp); if (!format) { master_error("memory allocation error"); @@ -407,8 +366,6 @@ map: PATH if ((tmp = strchr($1, ','))) *tmp++ = '\0'; - if (type) - free(type); if (strcmp($1, "exec")) type = master_strdup($1); else @@ -419,8 +376,6 @@ map: PATH YYABORT; } if (tmp) { - if (format) - free(format); format = master_strdup(tmp); if (!format) { master_error("memory allocation error"); @@ -445,8 +400,6 @@ map: PATH if ((tmp = strchr($1, ','))) *tmp++ = '\0'; - if (type) - free(type); if (strcmp($1, "exec")) type = master_strdup($1); else @@ -457,8 +410,6 @@ map: PATH YYABORT; } if (tmp) { - if (format) - free(format); format = master_strdup(tmp); if (!format) { master_error("memory allocation error"); @@ -621,9 +572,6 @@ option: daemon_option daemon_option: OPT_TIMEOUT NUMBER { timeout = $2; } | OPT_NTIMEOUT NUMBER { negative_timeout = $2; } | OPT_SYMLINK { symlnk = 1; } - | OPT_STRICTEXPIRE { strictexpire = 1; } - | OPT_SLAVE { slave = 1; } - | OPT_PRIVATE { private = 1; } | OPT_NOBIND { nobind = 1; } | OPT_NOGHOST { ghost = 0; } | OPT_GHOST { ghost = 1; } @@ -696,9 +644,6 @@ static void local_init_vars(void) timeout = -1; negative_timeout = 0; symlnk = 0; - strictexpire = 0; - slave = 0; - private = 0; nobind = 0; ghost = defaults_get_browse_mode(); random_selection = global_selection_options & MOUNT_FLAG_RANDOM_SELECT; @@ -804,7 +749,6 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne struct map_source *source; unsigned int logopt = logging; unsigned int m_logopt = master->logopt; - size_t mp_len; int ret; local_init_vars(); @@ -819,10 +763,6 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne return 0; } - mp_len = strlen(path); - while (mp_len && path[--mp_len] == '/') - path[mp_len] = 0; - nc = master->nc; /* Add null map entries to the null map cache */ @@ -905,12 +845,6 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne entry->ap->flags |= MOUNT_FLAG_USE_WEIGHT_ONLY; if (symlnk) entry->ap->flags |= MOUNT_FLAG_SYMLINK; - if (strictexpire) - entry->ap->flags |= MOUNT_FLAG_STRICTEXPIRE; - if (slave) - entry->ap->flags |= MOUNT_FLAG_SLAVE; - if (private) - entry->ap->flags |= MOUNT_FLAG_PRIVATE; if (negative_timeout) entry->ap->negative_timeout = negative_timeout; if (mode && mode < LONG_MAX) diff --git a/lib/master_tok.l b/lib/master_tok.l index 7486710..41ac499 100644 --- a/lib/master_tok.l +++ b/lib/master_tok.l @@ -389,9 +389,6 @@ MODE (--mode{OPTWS}|--mode{OPTWS}={OPTWS}) -?symlink { return(OPT_SYMLINK); } -?nobind { return(OPT_NOBIND); } -?nobrowse { return(OPT_NOGHOST); } - -?slave { return(OPT_SLAVE); } - -?private { return(OPT_PRIVATE); } - -?strictexpire { return(OPT_STRICTEXPIRE); } -g|--ghost|-?browse { return(OPT_GHOST); } -v|--verbose { return(OPT_VERBOSE); } -d|--debug { return(OPT_DEBUG); } diff --git a/lib/mounts.c b/lib/mounts.c index 8f08b67..6fa304a 100644 --- a/lib/mounts.c +++ b/lib/mounts.c @@ -489,10 +489,8 @@ void add_std_amd_vars(struct substvar *sv) const struct substvar *v = macro_findvar(sv, "domain", 4); if (v && *v->val) { tmp = strdup(v->val); - if (tmp) { + if (tmp) macro_global_addvar("cluster", 7, tmp); - free(tmp); - } } } @@ -599,111 +597,43 @@ void free_amd_entry_list(struct list_head *entries) } } -static int cacl_max_options_len(unsigned int flags) -{ - unsigned int kver_major = get_kver_major(); - unsigned int kver_minor = get_kver_minor(); - int max_len; - - /* %d and %u are maximum lenght of 10 and mount type is maximum - * length of 9 (e. ",indirect"). - * The base temaplate is "fd=%d,pgrp=%u,minproto=5,maxproto=%d" - * plus the length of mount type plus 1 for the NULL. - */ - max_len = 79 + 1; - - if (kver_major < 5 || (kver_major == 5 && kver_minor < 4)) - goto out; - - /* maybe add ",strictexpire" */ - if (flags & MOUNT_FLAG_STRICTEXPIRE) - max_len += 13; - - if (kver_major == 5 && kver_minor < 5) - goto out; - - /* maybe add ",ignore" */ - if (flags & MOUNT_FLAG_IGNORE) - max_len += 7; -out: - return max_len; -} - /* * Make common autofs mount options string */ -char *make_options_string(char *path, int pipefd, - const char *type, unsigned int flags) +char *make_options_string(char *path, int pipefd, const char *extra) { - unsigned int kver_major = get_kver_major(); - unsigned int kver_minor = get_kver_minor(); char *options; - int max_len, len, new; - - max_len = cacl_max_options_len(flags); + int len; - options = malloc(max_len); + options = malloc(MAX_OPTIONS_LEN + 1); if (!options) { logerr("can't malloc options string"); return NULL; } - if (type) - len = snprintf(options, max_len, + if (extra) + len = snprintf(options, MAX_OPTIONS_LEN, options_template_extra, pipefd, (unsigned) getpgrp(), - AUTOFS_MAX_PROTO_VERSION, type); + AUTOFS_MAX_PROTO_VERSION, extra); else - len = snprintf(options, max_len, options_template, + len = snprintf(options, MAX_OPTIONS_LEN, options_template, pipefd, (unsigned) getpgrp(), AUTOFS_MAX_PROTO_VERSION); - if (len < 0) - goto error_out; - - if (len >= max_len) - goto truncated; - - if (kver_major < 5 || (kver_major == 5 && kver_minor < 4)) - goto out; - - /* maybe add ",strictexpire" */ - if (flags & MOUNT_FLAG_STRICTEXPIRE) { - new = snprintf(options + len, - max_len, "%s", ",strictexpire"); - if (new < 0) - goto error_out; - len += new; - if (len >= max_len) - goto truncated; + if (len >= MAX_OPTIONS_LEN) { + logerr("buffer to small for options - truncated"); + len = MAX_OPTIONS_LEN - 1; } - if (kver_major == 5 && kver_minor < 5) - goto out; - - /* maybe add ",ignore" */ - if (flags & MOUNT_FLAG_IGNORE) { - new = snprintf(options + len, - max_len, "%s", ",ignore"); - if (new < 0) - goto error_out; - len += new; - if (len >= max_len) - goto truncated; + if (len < 0) { + logerr("failed to malloc autofs mount options for %s", path); + free(options); + return NULL; } -out: options[len] = '\0'; - return options; -truncated: - logerr("buffer to small for options - truncated"); - len = max_len -1; - goto out; - -error_out: - logerr("error constructing mount options string for %s", path); - free(options); - return NULL; + return options; } char *make_mnt_name_string(char *path) @@ -785,12 +715,15 @@ int ext_mount_add(struct list_head *entry, const char *path, unsigned int umount } em = malloc(sizeof(struct ext_mount)); - if (!em) + if (!em) { + ret = -1; goto done; + } em->mountpoint = strdup(path); if (!em->mountpoint) { free(em); + ret = -1; goto done; } em->umount = umount; @@ -854,163 +787,10 @@ done: return ret; } -/* From glibc decode_name() */ -/* Since the values in a line are separated by spaces, a name cannot - * contain a space. Therefore some programs encode spaces in names - * by the strings "\040". We undo the encoding when reading an entry. - * The decoding happens in place. - */ -static char *local_decode_name(char *buf) -{ - char *rp = buf; - char *wp = buf; - - do { - if (rp[0] == '\\' && rp[1] == '0' && - rp[2] == '4' && rp[3] == '0') { - /* \040 is a SPACE. */ - *wp++ = ' '; - rp += 3; - } else if (rp[0] == '\\' && rp[1] == '0' && - rp[2] == '1' && rp[3] == '1') { - /* \011 is a TAB. */ - *wp++ = '\t'; - rp += 3; - } else if (rp[0] == '\\' && rp[1] == '0' && - rp[2] == '1' && rp[3] == '2') { - /* \012 is a NEWLINE. */ - *wp++ = '\n'; - rp += 3; - } else if (rp[0] == '\\' && rp[1] == '\\') { - /* - * We have to escape \\ to be able to represent - * all characters. - */ - *wp++ = '\\'; - rp += 1; - } else if (rp[0] == '\\' && rp[1] == '1' && - rp[2] == '3' && rp[3] == '4') { - /* \134 is also \\. */ - *wp++ = '\\'; - rp += 3; - } else - *wp++ = *rp; - } while (*rp++ != '\0'); - - return buf; -} - -/* From glibc getmntent_r() */ -static struct mntent * -local_getmntent_r(FILE *tab, struct mntent *mnt, char *buf, int size) -{ - char *cp, *head; - - do { - char *end_ptr; - - if (fgets(buf, size, tab) == NULL) - return 0; - - end_ptr = strchr(buf, '\n'); - if (end_ptr != NULL) { - while (end_ptr[-1] == ' ' || end_ptr[-1] == '\t') - end_ptr--; - *end_ptr = '\0'; - } else { - /* Whole line was not read. Do it now but forget it. */ - char tmp[1024]; - while (fgets(tmp, sizeof tmp, tab) != NULL) - if (strchr(tmp, '\n') != NULL) - break; - } - - head = buf + strspn(buf, " \t"); - /* skip empty lines and comment lines */ - } while (head[0] == '\0' || head[0] == '#'); - - cp = strsep(&head, " \t"); - mnt->mnt_fsname = cp != NULL ? local_decode_name(cp) : (char *) ""; - if (head) - head += strspn(head, " \t"); - cp = strsep(&head, " \t"); - mnt->mnt_dir = cp != NULL ? local_decode_name (cp) : (char *) ""; - if (head) - head += strspn(head, " \t"); - cp = strsep(&head, " \t"); - mnt->mnt_type = cp != NULL ? local_decode_name (cp) : (char *) ""; - if (head) - head += strspn (head, " \t"); - cp = strsep (&head, " \t"); - mnt->mnt_opts = cp != NULL ? local_decode_name (cp) : (char *) ""; - - /* autofs doesn't need freq or passno */ - - return mnt; -} - -int unlink_mount_tree(struct autofs_point *ap, const char *mp) -{ - FILE *tab; - struct mntent *mnt; - struct mntent mnt_wrk; - char buf[PATH_MAX * 3]; - unsigned int mp_len = strlen(mp); - int rv, ret = 1; - - tab = open_fopen_r(_PROC_MOUNTS); - if (!tab) { - char *estr = strerror_r(errno, buf, PATH_MAX - 1); - logerr("fopen: %s", estr); - return 0; - } - - while ((mnt = local_getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { - unsigned int mnt_dir_len; - int is_autofs; - - if (strncmp(mnt->mnt_dir, mp, mp_len)) - continue; - - mnt_dir_len = strlen(mnt->mnt_dir); - is_autofs = !strcmp(mnt->mnt_type, "autofs"); - - if (mnt_dir_len == mp_len && !is_autofs) { - ret = 0; - break; - } - - if (is_autofs) - rv = umount2(mnt->mnt_dir, MNT_DETACH); - else - rv = spawn_umount(ap->logopt, "-l", mnt->mnt_dir, NULL); - if (rv == -1) { - debug(ap->logopt, - "can't unlink %s from mount tree", mnt->mnt_dir); - - switch (errno) { - case EINVAL: - warn(ap->logopt, - "bad superblock or not mounted"); - break; - - case ENOENT: - case EFAULT: - ret = 0; - warn(ap->logopt, "bad path for mount"); - break; - } - } - } - fclose(tab); - - return ret; -} - /* * Get list of mounts under path in longest->shortest order */ -struct mnt_list *get_mnt_list(const char *path, int include) +struct mnt_list *get_mnt_list(const char *table, const char *path, int include) { FILE *tab; size_t pathlen = strlen(path); @@ -1019,27 +799,28 @@ struct mnt_list *get_mnt_list(const char *path, int include) struct mntent *mnt; struct mnt_list *ent, *mptr, *last; struct mnt_list *list = NULL; + char *pgrp; size_t len; if (!path || !pathlen || pathlen > PATH_MAX) return NULL; - tab = open_fopen_r(_PROC_MOUNTS); + tab = open_setmntent_r(table); if (!tab) { char *estr = strerror_r(errno, buf, PATH_MAX - 1); - logerr("fopen: %s", estr); + logerr("setmntent: %s", estr); return NULL; } - while ((mnt = local_getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { + while ((mnt = getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { len = strlen(mnt->mnt_dir); if ((!include && len <= pathlen) || strncmp(mnt->mnt_dir, path, pathlen) != 0) continue; - /* Not a subdirectory of requested mp? */ - /* mp_len == 1 => everything is subdir */ + /* Not a subdirectory of requested path ? */ + /* pathlen == 1 => everything is subdir */ if (pathlen > 1 && len > pathlen && mnt->mnt_dir[pathlen] != '/') continue; @@ -1055,7 +836,7 @@ struct mnt_list *get_mnt_list(const char *path, int include) mptr = list; last = NULL; while (mptr) { - if (len >= strlen(mptr->mp)) + if (len >= strlen(mptr->path)) break; last = mptr; mptr = mptr->next; @@ -1068,31 +849,73 @@ struct mnt_list *get_mnt_list(const char *path, int include) ent->next = mptr; - ent->mp = malloc(len + 1); - if (!ent->mp) { + ent->path = malloc(len + 1); + if (!ent->path) { + endmntent(tab); + free_mnt_list(list); + return NULL; + } + strcpy(ent->path, mnt->mnt_dir); + + ent->fs_name = malloc(strlen(mnt->mnt_fsname) + 1); + if (!ent->fs_name) { + endmntent(tab); + free_mnt_list(list); + return NULL; + } + strcpy(ent->fs_name, mnt->mnt_fsname); + + ent->fs_type = malloc(strlen(mnt->mnt_type) + 1); + if (!ent->fs_type) { endmntent(tab); free_mnt_list(list); return NULL; } - strcpy(ent->mp, mnt->mnt_dir); - - if (!strcmp(mnt->mnt_type, "autofs")) - ent->flags |= MNTS_AUTOFS; - - if (ent->flags & MNTS_AUTOFS) { - if (strstr(mnt->mnt_opts, "indirect")) - ent->flags |= MNTS_INDIRECT; - else if (strstr(mnt->mnt_opts, "direct")) - ent->flags |= MNTS_DIRECT; - else if (strstr(mnt->mnt_opts, "offset")) - ent->flags |= MNTS_OFFSET; + strcpy(ent->fs_type, mnt->mnt_type); + + ent->opts = malloc(strlen(mnt->mnt_opts) + 1); + if (!ent->opts) { + endmntent(tab); + free_mnt_list(list); + return NULL; + } + strcpy(ent->opts, mnt->mnt_opts); + + ent->owner = 0; + pgrp = strstr(mnt->mnt_opts, "pgrp="); + if (pgrp) { + char *end = strchr(pgrp, ','); + if (end) + *end = '\0'; + sscanf(pgrp, "pgrp=%d", &ent->owner); } } - fclose(tab); + endmntent(tab); return list; } +/* + * Reverse a list of mounts + */ +struct mnt_list *reverse_mnt_list(struct mnt_list *list) +{ + struct mnt_list *next, *last; + + if (!list) + return NULL; + + next = list; + last = NULL; + while (next) { + struct mnt_list *this = next; + next = this->next; + this->next = last; + last = this; + } + return last; +} + void free_mnt_list(struct mnt_list *list) { struct mnt_list *next; @@ -1106,33 +929,42 @@ void free_mnt_list(struct mnt_list *list) next = this->next; - if (this->mp) - free(this->mp); + if (this->path) + free(this->path); + + if (this->fs_name) + free(this->fs_name); + + if (this->fs_type) + free(this->fs_type); + + if (this->opts) + free(this->opts); free(this); } } -static int table_is_mounted(const char *mp, unsigned int type) +static int table_is_mounted(const char *table, const char *path, unsigned int type) { struct mntent *mnt; struct mntent mnt_wrk; char buf[PATH_MAX * 3]; - size_t mp_len = strlen(mp); + size_t pathlen = strlen(path); FILE *tab; int ret = 0; - if (!mp || !mp_len || mp_len >= PATH_MAX) + if (!path || !pathlen || pathlen >= PATH_MAX) return 0; - tab = open_fopen_r(_PROC_MOUNTS); + tab = open_setmntent_r(table); if (!tab) { char *estr = strerror_r(errno, buf, PATH_MAX - 1); - logerr("fopen: %s", estr); + logerr("setmntent: %s", estr); return 0; } - while ((mnt = local_getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { + while ((mnt = getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { size_t len = strlen(mnt->mnt_dir); if (type) { @@ -1149,17 +981,17 @@ static int table_is_mounted(const char *mp, unsigned int type) continue; } - if (mp_len == len && !strncmp(mp, mnt->mnt_dir, mp_len)) { + if (pathlen == len && !strncmp(path, mnt->mnt_dir, pathlen)) { ret = 1; break; } } - fclose(tab); + endmntent(tab); return ret; } -static int ioctl_is_mounted(const char *mp, unsigned int type) +static int ioctl_is_mounted(const char *table, const char *path, unsigned int type) { struct ioctl_ops *ops = get_ioctl_ops(); unsigned int mounted; @@ -1168,9 +1000,9 @@ static int ioctl_is_mounted(const char *mp, unsigned int type) /* If the ioctl fails fall back to the potentially resource * intensive mount table check. */ - ret = ops->ismountpoint(LOGOPT_NONE, -1, mp, &mounted); + ret = ops->ismountpoint(LOGOPT_NONE, -1, path, &mounted); if (ret == -1) - return table_is_mounted(mp, type); + return table_is_mounted(table, path, type); if (mounted) { switch (type) { @@ -1185,14 +1017,43 @@ static int ioctl_is_mounted(const char *mp, unsigned int type) return 0; } -int is_mounted(const char *mp, unsigned int type) +int is_mounted(const char *table, const char *path, unsigned int type) { struct ioctl_ops *ops = get_ioctl_ops(); if (ops->ismountpoint) - return ioctl_is_mounted(mp, type); + return ioctl_is_mounted(table, path, type); else - return table_is_mounted(mp, type); + return table_is_mounted(table, path, type); +} + +int has_fstab_option(const char *opt) +{ + struct mntent *mnt; + struct mntent mnt_wrk; + char buf[PATH_MAX * 3]; + FILE *tab; + int ret = 0; + + if (!opt) + return 0; + + tab = open_setmntent_r(_PATH_MNTTAB); + if (!tab) { + char *estr = strerror_r(errno, buf, PATH_MAX - 1); + logerr("setmntent: %s", estr); + return 0; + } + + while ((mnt = getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { + if (hasmntopt(mnt, opt)) { + ret = 1; + break; + } + } + endmntent(tab); + + return ret; } /* @@ -1227,19 +1088,30 @@ void tree_free_mnt_tree(struct mnt_list *tree) list_del(&this->self); - free(this->mp); + free(this->path); + free(this->fs_name); + free(this->fs_type); + + if (this->opts) + free(this->opts); free(this); } - free(tree->mp); + free(tree->path); + free(tree->fs_name); + free(tree->fs_type); + + if (tree->opts) + free(tree->opts); + free(tree); } /* * Make tree of system mounts in /proc/mounts. */ -struct mnt_list *tree_make_mnt_tree(const char *path) +struct mnt_list *tree_make_mnt_tree(const char *table, const char *path) { FILE *tab; struct mntent mnt_wrk; @@ -1247,19 +1119,20 @@ struct mnt_list *tree_make_mnt_tree(const char *path) struct mntent *mnt; struct mnt_list *ent, *mptr; struct mnt_list *tree = NULL; + char *pgrp; size_t plen; int eq; - tab = open_fopen_r(_PROC_MOUNTS); + tab = open_setmntent_r(table); if (!tab) { char *estr = strerror_r(errno, buf, PATH_MAX - 1); - logerr("fopen: %s", estr); + logerr("setmntent: %s", estr); return NULL; } plen = strlen(path); - while ((mnt = local_getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { + while ((mnt = getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { size_t len = strlen(mnt->mnt_dir); /* Not matching path */ @@ -1283,31 +1156,61 @@ struct mnt_list *tree_make_mnt_tree(const char *path) INIT_LIST_HEAD(&ent->entries); INIT_LIST_HEAD(&ent->sublist); - ent->mp = malloc(len + 1); - if (!ent->mp) { + ent->path = malloc(len + 1); + if (!ent->path) { endmntent(tab); free(ent); tree_free_mnt_tree(tree); return NULL; } - strcpy(ent->mp, mnt->mnt_dir); - - if (!strcmp(mnt->mnt_type, "autofs")) - ent->flags |= MNTS_AUTOFS; - - if (ent->flags & MNTS_AUTOFS) { - if (strstr(mnt->mnt_opts, "indirect")) - ent->flags |= MNTS_INDIRECT; - else if (strstr(mnt->mnt_opts, "direct")) - ent->flags |= MNTS_DIRECT; - else if (strstr(mnt->mnt_opts, "offset")) - ent->flags |= MNTS_OFFSET; + strcpy(ent->path, mnt->mnt_dir); + + ent->fs_name = malloc(strlen(mnt->mnt_fsname) + 1); + if (!ent->fs_name) { + free(ent->path); + free(ent); + endmntent(tab); + tree_free_mnt_tree(tree); + return NULL; + } + strcpy(ent->fs_name, mnt->mnt_fsname); + + ent->fs_type = malloc(strlen(mnt->mnt_type) + 1); + if (!ent->fs_type) { + free(ent->fs_name); + free(ent->path); + free(ent); + endmntent(tab); + tree_free_mnt_tree(tree); + return NULL; + } + strcpy(ent->fs_type, mnt->mnt_type); + + ent->opts = malloc(strlen(mnt->mnt_opts) + 1); + if (!ent->opts) { + free(ent->fs_type); + free(ent->fs_name); + free(ent->path); + free(ent); + endmntent(tab); + tree_free_mnt_tree(tree); + return NULL; + } + strcpy(ent->opts, mnt->mnt_opts); + + ent->owner = 0; + pgrp = strstr(mnt->mnt_opts, "pgrp="); + if (pgrp) { + char *end = strchr(pgrp, ','); + if (end) + *end = '\0'; + sscanf(pgrp, "pgrp=%d", &ent->owner); } mptr = tree; while (mptr) { - int elen = strlen(ent->mp); - int mlen = strlen(mptr->mp); + int elen = strlen(ent->path); + int mlen = strlen(mptr->path); if (elen < mlen) { if (mptr->left) { @@ -1327,7 +1230,7 @@ struct mnt_list *tree_make_mnt_tree(const char *path) } } - eq = strcmp(ent->mp, mptr->mp); + eq = strcmp(ent->path, mptr->path); if (eq < 0) { if (mptr->left) mptr = mptr->left; @@ -1351,7 +1254,7 @@ struct mnt_list *tree_make_mnt_tree(const char *path) if (!tree) tree = ent; } - fclose(tab); + endmntent(tab); return tree; } @@ -1367,7 +1270,7 @@ int tree_get_mnt_list(struct mnt_list *mnts, struct list_head *list, const char return 0; plen = strlen(path); - mlen = strlen(mnts->mp); + mlen = strlen(mnts->path); if (mlen < plen) return tree_get_mnt_list(mnts->right, list, path, include); else { @@ -1376,10 +1279,10 @@ int tree_get_mnt_list(struct mnt_list *mnts, struct list_head *list, const char tree_get_mnt_list(mnts->left, list, path, include); if ((!include && mlen <= plen) || - strncmp(mnts->mp, path, plen)) + strncmp(mnts->path, path, plen)) goto skip; - if (plen > 1 && mlen > plen && mnts->mp[plen] != '/') + if (plen > 1 && mlen > plen && mnts->path[plen] != '/') goto skip; INIT_LIST_HEAD(&mnts->list); @@ -1414,7 +1317,7 @@ int tree_get_mnt_sublist(struct mnt_list *mnts, struct list_head *list, const ch return 0; plen = strlen(path); - mlen = strlen(mnts->mp); + mlen = strlen(mnts->path); if (mlen < plen) return tree_get_mnt_sublist(mnts->right, list, path, include); else { @@ -1423,10 +1326,10 @@ int tree_get_mnt_sublist(struct mnt_list *mnts, struct list_head *list, const ch tree_get_mnt_sublist(mnts->left, list, path, include); if ((!include && mlen <= plen) || - strncmp(mnts->mp, path, plen)) + strncmp(mnts->path, path, plen)) goto skip; - if (plen > 1 && mlen > plen && mnts->mp[plen] != '/') + if (plen > 1 && mlen > plen && mnts->path[plen] != '/') goto skip; INIT_LIST_HEAD(&mnts->sublist); @@ -1458,7 +1361,7 @@ int tree_find_mnt_ents(struct mnt_list *mnts, struct list_head *list, const char return 0; plen = strlen(path); - mlen = strlen(mnts->mp); + mlen = strlen(mnts->path); if (mlen < plen) return tree_find_mnt_ents(mnts->right, list, path); else if (mlen > plen) @@ -1468,7 +1371,7 @@ int tree_find_mnt_ents(struct mnt_list *mnts, struct list_head *list, const char tree_find_mnt_ents(mnts->left, list, path); - if (!strcmp(mnts->mp, path)) { + if (!strcmp(mnts->path, path)) { INIT_LIST_HEAD(&mnts->entries); list_add(&mnts->entries, list); } @@ -1479,7 +1382,7 @@ int tree_find_mnt_ents(struct mnt_list *mnts, struct list_head *list, const char this = list_entry(p, struct mnt_list, self); - if (!strcmp(this->mp, path)) { + if (!strcmp(this->path, path)) { INIT_LIST_HEAD(&this->entries); list_add(&this->entries, list); } @@ -1494,6 +1397,50 @@ int tree_find_mnt_ents(struct mnt_list *mnts, struct list_head *list, const char return 0; } +int tree_is_mounted(struct mnt_list *mnts, const char *path, unsigned int type) +{ + struct ioctl_ops *ops = get_ioctl_ops(); + struct list_head *p; + struct list_head list; + int mounted = 0; + + if (ops->ismountpoint) + return ioctl_is_mounted(_PROC_MOUNTS, path, type); + + INIT_LIST_HEAD(&list); + + if (!tree_find_mnt_ents(mnts, &list, path)) + return 0; + + list_for_each(p, &list) { + struct mnt_list *mptr; + + mptr = list_entry(p, struct mnt_list, entries); + + if (type) { + unsigned int autofs_fs; + + autofs_fs = !strcmp(mptr->fs_type, "autofs"); + + if (type & MNTS_REAL) { + if (!autofs_fs) { + mounted = 1; + break; + } + } else if (type & MNTS_AUTOFS) { + if (autofs_fs) { + mounted = 1; + break; + } + } else { + mounted = 1; + break; + } + } + } + return mounted; +} + void set_tsd_user_vars(unsigned int logopt, uid_t uid, gid_t gid) { struct thread_stdenv_vars *tsv; @@ -2037,7 +1984,7 @@ void set_indirect_mount_tree_catatonic(struct autofs_point *ap) struct mapent_cache *mc; struct mapent *me; - if (!is_mounted(ap->path, MNTS_AUTOFS)) + if (!is_mounted(_PROC_MOUNTS, ap->path, MNTS_AUTOFS)) return; map = entry->maps; @@ -2101,7 +2048,7 @@ int umount_ent(struct autofs_point *ap, const char *path) * so that we do not try to call rmdir_path on the * directory. */ - if (!rv && is_mounted(path, MNTS_REAL)) { + if (!rv && is_mounted(_PATH_MOUNTED, path, MNTS_REAL)) { crit(ap->logopt, "the umount binary reported that %s was " "unmounted, but there is still something " @@ -2234,7 +2181,7 @@ int mount_multi_triggers(struct autofs_point *ap, struct mapent *me, */ if (ap->state == ST_READMAP && ap->flags & MOUNT_FLAG_REMOUNT) { if (oe->ioctlfd != -1 || - is_mounted(oe->key, MNTS_REAL)) { + is_mounted(_PROC_MOUNTS, oe->key, MNTS_REAL)) { char oe_root[PATH_MAX + 1]; strcpy(oe_root, root); strcat(oe_root, offset); @@ -2323,7 +2270,7 @@ int umount_multi_triggers(struct autofs_point *ap, struct mapent *me, char *root left += umount_multi_triggers(ap, oe, root, oe_base); if (oe->ioctlfd != -1 || - is_mounted(oe->key, MNTS_REAL)) { + is_mounted(_PROC_MOUNTS, oe->key, MNTS_REAL)) { left++; continue; } @@ -2366,10 +2313,10 @@ int umount_multi_triggers(struct autofs_point *ap, struct mapent *me, char *root * delete the offsets from the cache and we need to put * the offset triggers back. */ - if (is_mounted(root, MNTS_REAL)) { + if (is_mounted(_PATH_MOUNTED, root, MNTS_REAL)) { info(ap->logopt, "unmounting dir = %s", root); if (umount_ent(ap, root) && - is_mounted(root, MNTS_REAL)) { + is_mounted(_PATH_MOUNTED, root, MNTS_REAL)) { if (mount_multi_triggers(ap, me, root, strlen(root), "/") < 0) warn(ap->logopt, "failed to remount offset triggers"); @@ -2469,9 +2416,9 @@ int clean_stale_multi_triggers(struct autofs_point *ap, * ESTALE errors when attempting list the directory. */ if (oe->ioctlfd != -1 || - is_mounted(oe->key, MNTS_REAL)) { + is_mounted(_PROC_MOUNTS, oe->key, MNTS_REAL)) { if (umount_ent(ap, oe->key) && - is_mounted(oe->key, MNTS_REAL)) { + is_mounted(_PROC_MOUNTS, oe->key, MNTS_REAL)) { debug(ap->logopt, "offset %s has active mount, invalidate", oe->key); diff --git a/lib/parse_subs.c b/lib/parse_subs.c index 0ee00d5..db784a5 100644 --- a/lib/parse_subs.c +++ b/lib/parse_subs.c @@ -189,7 +189,6 @@ void free_selector(struct selector *selector) free(s->func.arg2); s = next; } - free(selector); return; } @@ -475,11 +474,9 @@ unsigned int get_network_proximity(const char *name) hints.ai_socktype = SOCK_DGRAM; hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG | AI_CANONNAME; - ni = NULL; ret = getaddrinfo(name_or_num, NULL, &hints, &ni); if (ret) { - logerr("hostname lookup for %s failed: %s", - name_or_num, gai_strerror(ret)); + logerr("getaddrinfo: %s", gai_strerror(ret)); return PROXIMITY_ERROR; } diff --git a/lib/rpc_subs.c b/lib/rpc_subs.c index 643b768..73097c9 100644 --- a/lib/rpc_subs.c +++ b/lib/rpc_subs.c @@ -183,7 +183,7 @@ static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, i in4_laddr.sin_addr.s_addr = htonl(INADDR_ANY); slen = sizeof(struct sockaddr_in); - if (!info->client && *fd == RPC_ANYSOCK) { + if (!info->client) { struct sockaddr *laddr; *fd = open_sock(addr->sa_family, type, proto); @@ -296,7 +296,7 @@ static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, i * it would bind to a reserved port, which has been shown to * exhaust the reserved port range in some situations. */ - if (!info->client && *fd == RPC_ANYSOCK) { + if (!info->client) { *fd = open_sock(addr->sa_family, type, proto); if (*fd < 0) { ret = -errno; @@ -389,7 +389,6 @@ static enum clnt_stat rpc_get_netid(const sa_family_t family, } *netid = nc_netid; - break; } endnetconfig(handle); free(nc_proto); @@ -691,12 +690,10 @@ static int create_client(struct conn_info *info, CLIENT **client) else hints.ai_socktype = SOCK_STREAM; - ai = NULL; ret = getaddrinfo(info->host, NULL, &hints, &ai); if (ret) { error(LOGOPT_ANY, - "hostname lookup for %s failed: %s", - info->host, gai_strerror(ret)); + "hostname lookup failed: %s", gai_strerror(ret)); goto out_close; } @@ -1096,9 +1093,9 @@ double monotonic_elapsed(struct timespec start, struct timespec end) double t1, t2; t1 = (double) start.tv_sec + - ((double) start.tv_nsec/(1000*1000*1000)); + (double) (start.tv_nsec/(1000*1000*1000)); t2 = (double) end.tv_sec + - ((double) end.tv_nsec/(1000*1000*1000)); + (double) (end.tv_nsec/(1000*1000*1000)); return t2 - t1; } diff --git a/man/auto.master.5.in b/man/auto.master.5.in index dace4a1..55a6acd 100644 --- a/man/auto.master.5.in +++ b/man/auto.master.5.in @@ -66,14 +66,6 @@ will process the map according to the specification described below for map entries. Indirect map entries must be unique in the master map so second and subsequent entries for an indirect mount point are ignored by .BR automount (8). -.TP -.B NOTE: -autofs currently does not collapse multiple slashes in paths, so it is -important to ensure paths used in maps are correct. If unnecessary multiple -slashes are present in a path it can lead to unexpected failures such as -an inability to expire automounts. An exception to this is a trailing slash -at the end of the automount point path in the master map which will be -removed if present. .SH "FORMAT" Master map entries have three fields separated by an arbitrary number of spaces or tabs. Lines beginning with # are comments. The first field @@ -199,26 +191,6 @@ entries only, either in the master map (so it effects all map entries) or with individual map entries. The option is ignored for direct mounts and non-root offest mount entries. .TP -.I "strictexpire" -Use a strict expire policy for this automount. Using this option means -that last use of autofs directory entries will not be updated during -path walks so that mounts in an automount won't be kept mounted by -applications scanning the mount tree. Note that this doesn't completely -resolve the problem of expired automounts being immediately re-mounted -due to application accesses triggered by the expire itself. -.TP -.I slave \fPor\fI private -This option allows mount propagation of bind mounts to be set to -either \fIslave\fP or \fIprivate\fP. This option may be needed when using -multi-mounts that have bind mounts that bind to a file system that is -propagation shared. This is becuase the bind mount will have the same -properties as its target which causes problems for offset mounts. When -this happens an unwanted offset mount is propagated back to the target -file system resulting in a deadlock when attempting to access the offset. -This option is a an autofs pseudo mount option that can be used in the -master map only. By default bind mounts will inherit the mount propagation -of the target file system. -.TP .I "\-r, \-\-random-multimount-selection" Enables the use of random selection when choosing a host from a list of replicated servers. This option is applied to this mount diff --git a/man/autofs.conf.5.in b/man/autofs.conf.5.in index 8dbc313..cd7fc2f 100644 --- a/man/autofs.conf.5.in +++ b/man/autofs.conf.5.in @@ -41,11 +41,6 @@ Set the default timeout for caching failed key lookups (program default 60). If the equivalent command line option is given it will override this setting. .TP -.B mount_verbose -.br -Use the verbose flag when spawning mount(8), and log some process info -about the requestor and its parent (program default "no"). -.TP .B mount_wait .br Set the default time to wait for a response from a spawned mount(8) @@ -151,13 +146,6 @@ That produces, IMHO, unnecessary noise in the log so a configuration option has been added to provide the ability to turn it off. The default is "no" to maintain the current behaviour. .TP -.B use_ignore_mount_option -.br -An option to enable the use of autofs pseudo option "disable". This option -is used as a hint to user space that the mount entry should be ommitted from -mount table listings. The default is "no" to avoid unexpected changes in -behaviour and so is an opt-in setting. -.TP .B sss_master_map_wait .br Set the time to wait and retry if sssd returns "no such entry" when starting diff --git a/man/automount.8 b/man/automount.8 index 525c460..1e15ecd 100644 --- a/man/automount.8 +++ b/man/automount.8 @@ -57,10 +57,6 @@ Define a global macro substitution variable. Global definitions are over-ridden macro definitions of the same name specified in mount entries. .TP -.I \-S, \-\-systemd-service -Used when running the automounter as a systemd service to ensure log entry -format is consistent with the log entry format when running as a daemon. -.TP .I "\-f, \-\-foreground" Run the daemon in the foreground and log to stderr instead of syslog." .TP diff --git a/modules/Makefile b/modules/Makefile index 0447559..d9ab06c 100644 --- a/modules/Makefile +++ b/modules/Makefile @@ -116,16 +116,6 @@ parse_amd.so: parse_amd.c amd_parse.tab.o amd_tok.o # # Ad hoc compilation rules for modules which need auxilliary libraries # -lookup_yp.so: lookup_yp.c - $(CC) $(SOLDFLAGS) $(CFLAGS) $(NSLCFLAGS) -o lookup_yp.so \ - lookup_yp.c $(LDFLAGS) $(AUTOFS_LIB) $(LIBS) $(NSLLIB) - $(STRIP) lookup_yp.so - -lookup_nisplus.so: lookup_nisplus.c - $(CC) $(SOLDFLAGS) $(CFLAGS) $(NSLCFLAGS) -o lookup_nisplus.so \ - lookup_nisplus.c $(LDFLAGS) $(AUTOFS_LIB) $(LIBS) $(NSLLIB) - $(STRIP) lookup_nisplus.so - lookup_hesiod.so: lookup_hesiod.c $(CC) $(SOLDFLAGS) $(CFLAGS) $(HESIOD_FLAGS) -o lookup_hesiod.so \ lookup_hesiod.c $(LDFLAGS) $(AUTOFS_LIB) $(LIBHESIOD) $(LIBRESOLV) $(LIBS) diff --git a/modules/amd_parse.y b/modules/amd_parse.y index 17fd9b2..1d72f19 100644 --- a/modules/amd_parse.y +++ b/modules/amd_parse.y @@ -401,7 +401,7 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE } | MNT_OPTION OPTION_ASSIGN options { - if (!match_mnt_option_options($1, opts)) { + if (!match_mnt_option_options($1, $3)) { amd_notify($1); YYABORT; } @@ -409,7 +409,7 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE } | MNT_OPTION OPTION_ASSIGN QUOTE options QUOTE { - if (!match_mnt_option_options($1, opts)) { + if (!match_mnt_option_options($1, $4)) { amd_notify($1); YYABORT; } @@ -574,13 +574,6 @@ static int match_map_option_map_type(char *map_option, char *type) !strcmp(map_type, "nisplus") || !strcmp(map_type, "ldap") || !strcmp(map_type, "hesiod")) { -#ifndef WITH_HESIOD - if (!strcmp(map_type, "hesiod")) { - amd_msg("hesiod support not built in"); - free(map_type); - return 0; - } -#endif amd_set_value(&entry.map_type, map_type); } else if (!strcmp(map_type, "exec")) { /* autofs uses "program" for "exec" map type */ @@ -829,13 +822,13 @@ static int make_selector(char *name, if (!value1) tmp = NULL; else { - tmp = amd_strdup(value1); + char *tmp = amd_strdup(value1); if (!tmp) goto error; } s->func.arg1 = tmp; } else if (s->sel->flags & SEL_FLAG_FUNC2) { - tmp = amd_strdup(value1); + char *tmp = amd_strdup(value1); if (!tmp) goto error; s->func.arg1 = tmp; diff --git a/modules/amd_tok.l b/modules/amd_tok.l index 36fc04b..cb1ebf7 100644 --- a/modules/amd_tok.l +++ b/modules/amd_tok.l @@ -95,7 +95,7 @@ V6MASK (12[0-8]|1[0-1][0-9]|[1-9][0-9]|[1-9]) FOPT (({QSTR}|{FSTR}|{MACRO})+) OPTS ({OSTR}(=({VSTR}|{MACRO})+)?) -SOPT ({SSTR}|{QSTR}|{MACRO}(\.|{SSTR}|{QSTR}|{MACRO})+) +SOPT (({SSTR}|{QSTR}|{MACRO})+) NOPT ({SSTR}|(({IP4ADDR}(\/{V4MASK})?)|({IP6ADDR}(\/{V6MASK})?))) MAPOPT (fs|type|maptype|pref|sublink|cache) diff --git a/modules/dclist.c b/modules/dclist.c index c34c3a9..4daa199 100644 --- a/modules/dclist.c +++ b/modules/dclist.c @@ -355,12 +355,9 @@ static char *getdnsdomainname(unsigned int logopt) hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; - ni = NULL; ret = getaddrinfo(name, NULL, &hints, &ni); if (ret) { - error(logopt, - "hostname lookup for %s failed: %s", - name, gai_strerror(ret)); + error(logopt, "hostname lookup failed: %s", gai_strerror(ret)); return NULL; } diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c index 911a34a..37810e1 100644 --- a/modules/lookup_ldap.c +++ b/modules/lookup_ldap.c @@ -1137,7 +1137,6 @@ int parse_ldap_config(unsigned logopt, struct lookup_context *ctxt) error(logopt, MODPREFIX "stat(2) failed with error %s.", strerror(errno)); - free(auth_conf); return 0; } @@ -1149,7 +1148,6 @@ int parse_ldap_config(unsigned logopt, struct lookup_context *ctxt) "Please make sure that it is owned by root, group " "is root, and the mode is 0600.", auth_conf); - free(auth_conf); return -1; } @@ -1184,11 +1182,9 @@ int parse_ldap_config(unsigned logopt, struct lookup_context *ctxt) goto out; } - if (!usetls || ctxt->port == LDAPS_PORT) { + if (!usetls || ctxt->port == LDAPS_PORT) use_tls = LDAP_TLS_DONT_USE; - if (usetls) - free(usetls); - } else { + else { if (!strcasecmp(usetls, "yes")) use_tls = LDAP_TLS_INIT; else if (!strcasecmp(usetls, "no")) @@ -1198,7 +1194,6 @@ int parse_ldap_config(unsigned logopt, struct lookup_context *ctxt) MODPREFIX "The usetls property must have value " "\"yes\" or \"no\"."); - free(usetls); ret = -1; goto out; } @@ -1226,7 +1221,6 @@ int parse_ldap_config(unsigned logopt, struct lookup_context *ctxt) MODPREFIX "The tlsrequired property must have value " "\"yes\" or \"no\"."); - free(tlsrequired); ret = -1; goto out; } @@ -1258,7 +1252,6 @@ int parse_ldap_config(unsigned logopt, struct lookup_context *ctxt) MODPREFIX "The authrequired property must have value " "\"yes\", \"no\", \"autodetect\", or \"simple\"."); - free(authrequired); ret = -1; goto out; } @@ -1345,7 +1338,6 @@ auth_fail: (void)get_property(logopt, root, "credentialcache", &client_cc); ctxt->auth_conf = auth_conf; - auth_conf = NULL; ctxt->use_tls = use_tls; ctxt->tls_required = tls_required; ctxt->auth_required = auth_required; @@ -1385,8 +1377,6 @@ auth_fail: } out: xmlFreeDoc(doc); - if (auth_conf) - free(auth_conf); if (fallback) return 0; @@ -1996,7 +1986,7 @@ int lookup_read_master(struct master *master, time_t age, void *context) } } else if (count == 1) { dec_len = decode_percent_hack(keyValue[0], &key); - if (dec_len <= 0) { + if (dec_len < 0) { error(logopt, MODPREFIX "invalid map key %s - ignoring", *keyValue); @@ -2004,7 +1994,7 @@ int lookup_read_master(struct master *master, time_t age, void *context) } } else { dec_len = decode_percent_hack(keyValue[0], &key); - if (dec_len <= 0) { + if (dec_len < 0) { error(logopt, MODPREFIX "invalid map key %s - ignoring", *keyValue); @@ -2014,7 +2004,7 @@ int lookup_read_master(struct master *master, time_t age, void *context) for (i = 1; i < count; i++) { char *k; dec_len = decode_percent_hack(keyValue[i], &k); - if (dec_len <= 0) { + if (dec_len < 0) { error(logopt, MODPREFIX "invalid map key %s - ignoring", *keyValue); @@ -2169,8 +2159,6 @@ static int decode_percent_hack(const char *name, char **key) *key = NULL; len = get_percent_decoded_len(name); - if (!len) - return 0; new = malloc(len + 1); if (!new) return -1; @@ -3010,9 +2998,6 @@ static int lookup_one(struct autofs_point *ap, struct map_source *source, attrs[1] = info; attrs[2] = NULL; - enc_key1 = NULL; - enc_key2 = NULL; - if (*qKey == '*' && qKey_len == 1) *qKey = '/'; else if (!strcasecmp(class, "nisObject")) { diff --git a/modules/lookup_sss.c b/modules/lookup_sss.c index 7859830..88ec169 100644 --- a/modules/lookup_sss.c +++ b/modules/lookup_sss.c @@ -786,9 +786,9 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void * * when we're starting up so just take the readlock in that */ if (ap->flags & MOUNT_FLAG_REMOUNT) - cache_readlock(mc); - else cache_writelock(mc); + else + cache_readlock(mc); me = cache_lookup(mc, key); /* Stale mapent => check for entry in alternate source or wildcard */ if (me && !me->mapent) { diff --git a/modules/mount_afs.c b/modules/mount_afs.c index ef4e04d..2a776bd 100644 --- a/modules/mount_afs.c +++ b/modules/mount_afs.c @@ -37,14 +37,10 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int char dest[PATH_MAX + 1]; size_t r_len = strlen(root); size_t d_len = r_len + name_len + 2; - void (*mountlog)(unsigned int, const char*, ...) = &log_debug; if (ap->flags & MOUNT_FLAG_REMOUNT) return 0; - if (defaults_get_mount_verbose()) - mountlog = &log_info; - if (d_len > PATH_MAX) return 1; @@ -57,7 +53,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int if (dest[strlen(dest)-1] == '/') dest[strlen(dest)-1] = '\0'; - mountlog(ap->logopt, MODPREFIX "mounting AFS %s -> %s", dest, what); + debug(ap->logopt, MODPREFIX "mounting AFS %s -> %s", dest, what); return symlink(what, dest); /* Try it. If it fails, return the error. */ } diff --git a/modules/mount_autofs.c b/modules/mount_autofs.c index 72e1aba..cd0631b 100644 --- a/modules/mount_autofs.c +++ b/modules/mount_autofs.c @@ -57,7 +57,6 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int nobind = ap->flags & MOUNT_FLAG_NOBIND; int ghost = ap->flags & MOUNT_FLAG_GHOST; int symlnk = ap->flags & MOUNT_FLAG_SYMLINK; - int strictexpire = ap->flags & MOUNT_FLAG_STRICTEXPIRE; time_t timeout = get_exp_timeout(ap, ap->entry->maps); unsigned logopt = ap->logopt; struct map_type_info *info; @@ -132,8 +131,6 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, ghost = 1; else if (_strncmp("symlink", cp, 7) == 0) symlnk = 1; - else if (_strncmp("strictexpire", cp, 12) == 0) - strictexpire = 1; else if (_strncmp("hosts", cp, 5) == 0) hosts = 1; else if (_strncmp("timeout=", cp, 8) == 0) { @@ -176,8 +173,6 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, nap->parent = ap; if (symlnk) nap->flags |= MOUNT_FLAG_SYMLINK; - if (strictexpire) - nap->flags |= MOUNT_FLAG_STRICTEXPIRE; if (hosts) argc = 0; diff --git a/modules/mount_bind.c b/modules/mount_bind.c index 9cba0d7..4864ea5 100644 --- a/modules/mount_bind.c +++ b/modules/mount_bind.c @@ -20,7 +20,6 @@ #include #include #include -#include #define MODULE_MOUNT #include "automount.h" @@ -81,14 +80,10 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int int err; int i, len; int symlnk = (*name != '/' && (ap->flags & MOUNT_FLAG_SYMLINK)); - void (*mountlog)(unsigned int, const char*, ...) = &log_debug; if (ap->flags & MOUNT_FLAG_REMOUNT) return 0; - if (defaults_get_mount_verbose()) - mountlog = &log_info; - /* Extract "symlink" pseudo-option which forces local filesystems * to be symlinked instead of bound. */ @@ -156,7 +151,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int debug(ap->logopt, MODPREFIX "calling mkdir_path %s", fullpath); - status = mkdir_path(fullpath, mp_mode); + status = mkdir_path(fullpath, 0555); if (status && errno != EEXIST) { char *estr = strerror_r(errno, buf, MAX_ERR_BUF); error(ap->logopt, @@ -168,9 +163,9 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int if (!status) existed = 0; - mountlog(ap->logopt, MODPREFIX - "calling mount --bind -o %s %s %s", - options, what, fullpath); + debug(ap->logopt, MODPREFIX + "calling mount --bind -o %s %s %s", + options, what, fullpath); err = spawn_bind_mount(ap->logopt, "-o", options, what, fullpath, NULL); @@ -188,29 +183,8 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int debug(ap->logopt, MODPREFIX "mounted %s type %s on %s", what, fstype, fullpath); + return 0; } - - if (ap->flags & (MOUNT_FLAG_SLAVE | MOUNT_FLAG_PRIVATE)) { - int flags = MS_SLAVE; - - if (ap->flags & MOUNT_FLAG_PRIVATE) - flags = MS_PRIVATE; - - /* The bind mount has succeeded but if the target - * mount is propagation shared propagation of child - * mounts (autofs offset mounts for example) back to - * the target of the bind mount must be avoided or - * autofs trigger mounts will deadlock. - */ - err = mount(NULL, fullpath, NULL, flags, NULL); - if (err) { - warn(ap->logopt, - "failed to set propagation for %s", - fullpath, root); - } - } - - return 0; } else { char *cp; char basepath[PATH_MAX]; @@ -229,7 +203,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int } else { debug(ap->logopt, MODPREFIX "calling mkdir_path %s", basepath); - if (mkdir_path(basepath, mp_mode) && errno != EEXIST) { + if (mkdir_path(basepath, 0555) && errno != EEXIST) { char *estr; estr = strerror_r(errno, buf, MAX_ERR_BUF); error(ap->logopt, @@ -245,7 +219,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int "failed to create symlink %s -> %s", fullpath, what); if ((ap->flags & MOUNT_FLAG_GHOST) && !status) { - if (mkdir_path(fullpath, mp_mode) && errno != EEXIST) { + if (mkdir_path(fullpath, 0555) && errno != EEXIST) { char *estr = strerror_r(errno, buf, MAX_ERR_BUF); error(ap->logopt, MODPREFIX "mkdir_path %s failed: %s", diff --git a/modules/mount_changer.c b/modules/mount_changer.c index 7d44a72..798f23b 100644 --- a/modules/mount_changer.c +++ b/modules/mount_changer.c @@ -87,7 +87,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int debug(ap->logopt, MODPREFIX "calling mkdir_path %s", fullpath); - status = mkdir_path(fullpath, mp_mode); + status = mkdir_path(fullpath, 0555); if (status && errno != EEXIST) { char *estr = strerror_r(errno, buf, MAX_ERR_BUF); error(ap->logopt, diff --git a/modules/mount_ext2.c b/modules/mount_ext2.c index eb28b06..90fc087 100644 --- a/modules/mount_ext2.c +++ b/modules/mount_ext2.c @@ -47,14 +47,10 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int int err, ro = 0; const char *fsck_prog; int len, status, existed = 1; - void (*mountlog)(unsigned int, const char*, ...) = &log_debug; if (ap->flags & MOUNT_FLAG_REMOUNT) return 0; - if (defaults_get_mount_verbose()) - mountlog = &log_info; - /* Root offset of multi-mount */ len = strlen(root); if (root[len - 1] == '/') { @@ -73,7 +69,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int debug(ap->logopt, MODPREFIX "calling mkdir_path %s", fullpath); - status = mkdir_path(fullpath, mp_mode); + status = mkdir_path(fullpath, 0555); if (status && errno != EEXIST) { char *estr = strerror_r(errno, buf, MAX_ERR_BUF); error(ap->logopt, @@ -125,15 +121,15 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int } if (options) { - mountlog(ap->logopt, MODPREFIX - "calling mount -t %s -o %s %s %s", - fstype, options, what, fullpath); + debug(ap->logopt, MODPREFIX + "calling mount -t %s -o %s %s %s", + fstype, options, what, fullpath); err = spawn_mount(ap->logopt, "-t", fstype, "-o", options, what, fullpath, NULL); } else { - mountlog(ap->logopt, - MODPREFIX "calling mount -t %s %s %s", - fstype, what, fullpath); + debug(ap->logopt, + MODPREFIX "calling mount -t %s %s %s", + fstype, what, fullpath); err = spawn_mount(ap->logopt, "-t", fstype, what, fullpath, NULL); } diff --git a/modules/mount_generic.c b/modules/mount_generic.c index cf53114..ae63787 100644 --- a/modules/mount_generic.c +++ b/modules/mount_generic.c @@ -46,14 +46,10 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int char buf[MAX_ERR_BUF]; int err; int len, status, existed = 1; - void (*mountlog)(unsigned int, const char*, ...) = &log_debug; if (ap->flags & MOUNT_FLAG_REMOUNT) return 0; - if (defaults_get_mount_verbose()) - mountlog = &log_info; - /* Root offset of multi-mount */ len = strlen(root); if (root[len - 1] == '/') { @@ -72,7 +68,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int debug(ap->logopt, MODPREFIX "calling mkdir_path %s", fullpath); - status = mkdir_path(fullpath, mp_mode); + status = mkdir_path(fullpath, 0555); if (status && errno != EEXIST) { char *estr = strerror_r(errno, buf, MAX_ERR_BUF); error(ap->logopt, @@ -84,15 +80,15 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int existed = 0; if (options && options[0]) { - mountlog(ap->logopt, - MODPREFIX "calling mount -t %s -o %s %s %s", - fstype, options, what, fullpath); + debug(ap->logopt, + MODPREFIX "calling mount -t %s -o %s %s %s", + fstype, options, what, fullpath); err = spawn_mount(ap->logopt, "-t", fstype, "-o", options, what, fullpath, NULL); } else { - mountlog(ap->logopt, MODPREFIX "calling mount -t %s %s %s", - fstype, what, fullpath); + debug(ap->logopt, MODPREFIX "calling mount -t %s %s %s", + fstype, what, fullpath); err = spawn_mount(ap->logopt, "-t", fstype, what, fullpath, NULL); } diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c index 4e3e703..bf712a9 100644 --- a/modules/mount_nfs.c +++ b/modules/mount_nfs.c @@ -77,24 +77,20 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int int port = -1; int ro = 0; /* Set if mount bind should be read-only */ int rdma = 0; - void (*mountlog)(unsigned int, const char*, ...) = &log_debug; if (ap->flags & MOUNT_FLAG_REMOUNT) return 0; - if (defaults_get_mount_verbose()) - mountlog = &log_info; - - mountlog(ap->logopt, - MODPREFIX "root=%s name=%s what=%s, fstype=%s, options=%s", - root, name, what, fstype, options); + debug(ap->logopt, + MODPREFIX "root=%s name=%s what=%s, fstype=%s, options=%s", + root, name, what, fstype, options); mount_default_proto = defaults_get_mount_nfs_default_proto(); - vers = NFS_VERS_DEFAULT | NFS_PROTO_DEFAULT; + vers = NFS_VERS_MASK | NFS_PROTO_MASK; if (strcmp(fstype, "nfs4") == 0) - vers = NFS4_VERS_DEFAULT | TCP_SUPPORTED; + vers = NFS4_VERS_MASK | TCP_SUPPORTED; else if (mount_default_proto == 4) - vers = vers | NFS4_VERS_DEFAULT; + vers = vers | NFS4_VERS_MASK; /* Extract "nosymlink" pseudo-option which stops local filesystems * from being symlinked. @@ -207,9 +203,9 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int if ((vers & NFS_PROTO_MASK) == 0) vers |= NFS_PROTO_MASK; - mountlog(ap->logopt, MODPREFIX - "nfs options=\"%s\", nobind=%d, nosymlink=%d, ro=%d", - nfsoptions, nobind, nosymlink, ro); + debug(ap->logopt, MODPREFIX + "nfs options=\"%s\", nobind=%d, nosymlink=%d, ro=%d", + nfsoptions, nobind, nosymlink, ro); } if (!parse_location(ap->logopt, &hosts, what, flags)) { @@ -240,7 +236,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int (vers & NFS4_VERS_MASK) != 0 && !(vers & UDP6_REQUESTED)) { unsigned int v4_probe_ok = 0; - struct host *tmp = new_host(hosts->name, 0, + struct host *tmp = new_host(hosts->name, hosts->addr, hosts->addr_len, hosts->proximity, hosts->weight, hosts->options); @@ -281,7 +277,7 @@ dont_probe: debug(ap->logopt, MODPREFIX "calling mkdir_path %s", fullpath); - status = mkdir_path(fullpath, mp_mode); + status = mkdir_path(fullpath, 0555); if (status && errno != EEXIST) { char *estr = strerror_r(errno, buf, MAX_ERR_BUF); error(ap->logopt, @@ -337,13 +333,7 @@ dont_probe: socklen_t len = INET6_ADDRSTRLEN; char n_buf[len + 1]; const char *n_addr; - n_addr = get_addr_string(this->addr, n_buf, len); - if (!n_addr) { - char *estr = strerror_r(errno, buf, MAX_ERR_BUF); - error(ap->logopt, "get_addr_string: %s", estr); - goto forced_fail; - } loc = malloc(strlen(n_addr) + strlen(this->path) + 4); if (!loc) { char *estr = strerror_r(errno, buf, MAX_ERR_BUF); @@ -383,18 +373,17 @@ dont_probe: } if (nfsoptions && *nfsoptions) { - mountlog(ap->logopt, - MODPREFIX "calling mount -t %s " SLOPPY - "-o %s %s %s", fstype, nfsoptions, loc, - fullpath); + debug(ap->logopt, + MODPREFIX "calling mount -t %s " SLOPPY + "-o %s %s %s", fstype, nfsoptions, loc, fullpath); err = spawn_mount(ap->logopt, "-t", fstype, SLOPPYOPT "-o", nfsoptions, loc, fullpath, NULL); } else { - mountlog(ap->logopt, - MODPREFIX "calling mount -t %s %s %s", - fstype, loc, fullpath); + debug(ap->logopt, + MODPREFIX "calling mount -t %s %s %s", + fstype, loc, fullpath); err = spawn_mount(ap->logopt, "-t", fstype, loc, fullpath, NULL); } diff --git a/modules/parse_amd.c b/modules/parse_amd.c index d7c5540..b40c1ad 100644 --- a/modules/parse_amd.c +++ b/modules/parse_amd.c @@ -231,29 +231,17 @@ static struct substvar *add_lookup_vars(struct autofs_point *ap, return list; } -static int match_my_name(struct autofs_point *ap, const char *name, struct substvar *sv) +static int match_my_name(unsigned int logopt, const char *name, struct substvar *sv) { struct addrinfo hints, *cni, *ni, *haddr; char host[NI_MAXHOST + 1], numeric[NI_MAXHOST + 1]; - unsigned int logopt = ap->logopt; const struct substvar *v; - char *exp_name = NULL; int rv = 0, ret; - if (!expand_selectors(ap, name, &exp_name, sv)) - exp_name = strdup(name); - if (!exp_name) { - error(logopt, - MODPREFIX "error: failed to alloc space for name"); - goto out; - } - v = macro_findvar(sv, "host", 4); if (v) { - if (!strcmp(v->val, exp_name)) { - rv = 1; - goto out; - } + if (!strcmp(v->val, name)) + return 1; } if (!v || !v->val) { @@ -269,24 +257,20 @@ static int match_my_name(struct autofs_point *ap, const char *name, struct subst hints.ai_socktype = SOCK_DGRAM; /* Get host canonical name */ - cni = NULL; ret = getaddrinfo(v->val, NULL, &hints, &cni); if (ret) { error(logopt, MODPREFIX - "hostname lookup for %s failed: %s\n", - v->val, gai_strerror(ret)); + "hostname lookup failed: %s\n", gai_strerror(ret)); goto out; } hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG | AI_CANONNAME; /* Resolve comparison name to its names and compare */ - ni = NULL; - ret = getaddrinfo(exp_name, NULL, &hints, &ni); + ret = getaddrinfo(name, NULL, &hints, &ni); if (ret) { error(logopt, MODPREFIX - "hostname lookup for %s failed: %s\n", - exp_name, gai_strerror(ret)); + "hostname lookup failed: %s\n", gai_strerror(ret)); freeaddrinfo(cni); goto out; } @@ -324,180 +308,18 @@ next: freeaddrinfo(ni); freeaddrinfo(cni); out: - if (exp_name) - free(exp_name); return rv; } -static int sel_strcmp(struct autofs_point *ap, - const struct substvar *v, struct selector *s, - struct substvar *sv) -{ - char *expand = NULL; - int ret = 0; - int res; - - res = expand_selectors(ap, s->comp.value, &expand, sv); - if (res) - res = strcmp(v->val, expand); - else - res = strcmp(v->val, s->comp.value); - - if (s->compare & SEL_COMP_EQUAL && !res) { - debug(ap->logopt, MODPREFIX - "matched selector %s(%s) == %s", - v->def, v->val, expand ? expand : s->comp.value); - ret = 1; - } else if (s->compare & SEL_COMP_NOTEQUAL && res) { - debug(ap->logopt, MODPREFIX - "matched selector %s(%s) != %s", - v->def, v->val, expand ? expand : s->comp.value); - ret = 1; - } else - debug(ap->logopt, MODPREFIX - "did not match selector %s(%s) %s %s", - v->def, v->val, - (s->compare & SEL_COMP_EQUAL ? "==" : "!="), - expand ? expand : s->comp.value); - - if (expand) - free(expand); - - return ret; -} - -static int sel_lstat(struct autofs_point *ap, - struct selector *s, struct substvar *sv) -{ - struct stat st; - char *expand = NULL; - int res, ret; - - /* Sould be OK to fail on any error here */ - res = expand_selectors(ap, s->func.arg1, &expand, sv); - if (res) - ret = !lstat(expand, &st); - else - ret = !lstat(s->func.arg1, &st); - - if (s->compare == SEL_COMP_NOT) - ret = !ret; - if (ret) - debug(ap->logopt, MODPREFIX - "matched selector %s(%s)", - s->sel->name, expand ? expand : s->func.arg1); - else - debug(ap->logopt, MODPREFIX - "did not match selector %s(%s)", - s->sel->name, expand ? expand : s->func.arg1); - if (expand) - free(expand); - - return ret; -} - -static int sel_in_network(struct autofs_point *ap, - struct selector *s, struct substvar *sv) -{ - char *expand = NULL; - int res, ret; - - res = expand_selectors(ap, s->func.arg1, &expand, sv); - if (!res) - ret = in_network(s->func.arg1); - else - ret = in_network(expand); - - if (s->compare == SEL_COMP_NOT) - ret = !ret; - if (ret) - debug(ap->logopt, MODPREFIX - "matched selector %s(%s)", - s->sel->name, expand ? expand : s->func.arg1); - else - debug(ap->logopt, MODPREFIX - "did not match selector %s(%s)", - s->sel->name, expand ? expand : s->func.arg1); - - if (expand) - free(expand); - - return ret; -} - -static int sel_netgrp(struct autofs_point *ap, - struct selector *s, struct substvar *sv) -{ - char *exp_arg1 = NULL, *exp_arg2 = NULL; - const struct substvar *v; - int res, ret = 0; - char *host; - - if (s->func.arg2) { - res = expand_selectors(ap, s->func.arg2, &exp_arg2, sv); - if (res) - host = exp_arg2; - else - host = s->func.arg2; - } else { - if (s->sel->selector == SEL_NETGRP) - v = macro_findvar(sv, "host", 4); - else - v = macro_findvar(sv, "hostd", 5); - if (!v || !*v->val) { - error(ap->logopt, MODPREFIX - "failed to get value of ${host}"); - goto out; - } - host = v->val; - } - - res = expand_selectors(ap, s->func.arg1, &exp_arg1, sv); - if (res) - ret = innetgr(exp_arg1, host, NULL, NULL); - else - ret = innetgr(s->func.arg1, host, NULL, NULL); - - if (s->compare == SEL_COMP_NOT) - ret = !ret; - if (ret) { - if (!s->func.arg2) - debug(ap->logopt, MODPREFIX - "matched selector %s(%s)", - s->sel->name, exp_arg1 ? exp_arg1 : s->func.arg1); - else - debug(ap->logopt, MODPREFIX - "matched selector %s(%s,%s)", s->sel->name, - exp_arg1 ? exp_arg1 : s->func.arg1, - exp_arg2 ? exp_arg2 : s->func.arg2); - } else { - if (!s->func.arg2) - debug(ap->logopt, MODPREFIX - "did not match selector %s(%s)", - s->sel->name, exp_arg1 ? exp_arg1 : s->func.arg1); - else - debug(ap->logopt, MODPREFIX - "did not match selector %s(%s,%s)", s->sel->name, - exp_arg1 ? exp_arg1 : s->func.arg1, - exp_arg2 ? exp_arg2 : s->func.arg2); - } -out: - if (exp_arg1) - free(exp_arg1); - if (exp_arg2) - free(exp_arg2); - - return ret; -} - -static int eval_selector(struct autofs_point *ap, +static int eval_selector(unsigned int logopt, struct amd_entry *this, struct substvar *sv) { struct selector *s = this->selector; - unsigned int logopt = ap->logopt; const struct substvar *v; unsigned int s_type; unsigned int v_type; + struct stat st; + char *host; int res, val, ret = 0; s_type = s->sel->flags & SEL_FLAGS_TYPE_MASK; @@ -515,7 +337,26 @@ static int eval_selector(struct autofs_point *ap, switch (v_type) { case SEL_FLAG_STR: - ret = sel_strcmp(ap, v, s, sv); + res = strcmp(v->val, s->comp.value); + if (s->compare & SEL_COMP_EQUAL && !res) { + debug(logopt, MODPREFIX + "matched selector %s(%s) == %s", + v->def, v->val, s->comp.value); + ret = 1; + break; + } else if (s->compare & SEL_COMP_NOTEQUAL && res) { + debug(logopt, MODPREFIX + "matched selector %s(%s) != %s", + v->def, v->val, s->comp.value); + ret = 1; + break; + } + + debug(logopt, MODPREFIX + "did not match selector %s(%s) %s %s", + v->def, v->val, + (s->compare & SEL_COMP_EQUAL ? "==" : "!="), + s->comp.value); break; case SEL_FLAG_NUM: @@ -591,7 +432,7 @@ static int eval_selector(struct autofs_point *ap, break; case SEL_XHOST: - ret = match_my_name(ap, s->func.arg1, sv); + ret = match_my_name(logopt, s->func.arg1, sv); if (s->compare == SEL_COMP_NOT) ret = !ret; if (ret) @@ -605,11 +446,32 @@ static int eval_selector(struct autofs_point *ap, break; case SEL_EXISTS: - ret = sel_lstat(ap, s, sv); + /* Sould be OK to fail on any error here */ + ret = !lstat(s->func.arg1, &st); + if (s->compare == SEL_COMP_NOT) + ret = !ret; + if (ret) + debug(logopt, MODPREFIX + "matched selector %s(%s)", + s->sel->name, s->func.arg1); + else + debug(logopt, MODPREFIX + "did not match selector %s(%s)", + s->sel->name, s->func.arg1); break; case SEL_IN_NETWORK: - ret = sel_in_network(ap, s, sv); + ret = in_network(s->func.arg1); + if (s->compare == SEL_COMP_NOT) + ret = !ret; + if (ret) + debug(logopt, MODPREFIX + "matched selector %s(%s)", + s->sel->name, s->func.arg1); + else + debug(logopt, MODPREFIX + "did not match selector %s(%s)", + s->sel->name, s->func.arg1); break; default: @@ -628,7 +490,43 @@ static int eval_selector(struct autofs_point *ap, switch (s->sel->selector) { case SEL_NETGRP: case SEL_NETGRPD: - ret = sel_netgrp(ap, s, sv); + if (s->func.arg2) + host = s->func.arg2; + else { + if (s->sel->selector == SEL_NETGRP) + v = macro_findvar(sv, "host", 4); + else + v = macro_findvar(sv, "hostd", 5); + if (!v || !*v->val) { + error(logopt, MODPREFIX + "failed to get value of ${host}"); + break; + } + host = v->val; + } + ret = innetgr(s->func.arg1, host, NULL, NULL); + if (s->compare == SEL_COMP_NOT) + ret = !ret; + if (ret) { + if (!s->func.arg2) + debug(logopt, MODPREFIX + "matched selector %s(%s)", + s->sel->name, s->func.arg1); + else + debug(logopt, MODPREFIX + "matched selector %s(%s,%s)", + s->sel->name, s->func.arg1, + s->func.arg2); + } else { + if (!s->func.arg2) + debug(logopt, MODPREFIX + "did not match selector %s(%s)", + s->sel->name, s->func.arg1); + else + debug(logopt, MODPREFIX + "did not match selector %s(%s,%s)", + s->sel->name, s->func.arg1, s->func.arg2); + } break; default: @@ -747,18 +645,6 @@ static void update_with_defaults(struct amd_entry *defaults, } } - if (!entry->sublink) { - if (defaults->sublink) { - tmp = strdup(defaults->sublink); - if (tmp) - entry->sublink = tmp; - } else { - v = macro_findvar(sv, "sublink", 2); - if (v) - entry->sublink = strdup(v->val); - } - } - return; } @@ -777,12 +663,10 @@ static char *normalize_hostname(unsigned int logopt, const char *host, hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; - ni = NULL; ret = getaddrinfo(host, NULL, &hints, &ni); if (ret) { error(logopt, MODPREFIX - "hostname lookup for %s failed: %s", - host, gai_strerror(ret)); + "hostname lookup failed: %s", gai_strerror(ret)); return NULL; } name = strdup(ni->ai_canonname); @@ -841,17 +725,6 @@ static struct substvar *expand_entry(struct autofs_point *ap, entry->rhost = host; } next: - if (entry->pref) { - if (expand_selectors(ap, entry->pref, &expand, sv)) { - debug(logopt, MODPREFIX - "pref expand(\"%s\") -> %s", - entry->pref, expand); - free(entry->pref); - entry->pref = expand; - } - sv = macro_addvar(sv, "pref", 4, entry->pref); - } - if (entry->sublink) { if (expand_selectors(ap, entry->sublink, &expand, sv)) { debug(logopt, MODPREFIX @@ -1094,8 +967,8 @@ static int do_auto_mount(struct autofs_point *ap, const char *name, static int do_link_mount(struct autofs_point *ap, const char *name, struct amd_entry *entry, unsigned int flags) { + char target[PATH_MAX + 1]; const char *opts = (entry->opts && *entry->opts) ? entry->opts : NULL; - char *target; int ret; if (entry->sublink) { @@ -1104,14 +977,14 @@ static int do_link_mount(struct autofs_point *ap, const char *name, "error: sublink option length is too long"); return 0; } - target = entry->sublink; + strcpy(target, entry->sublink); } else { if (strlen(entry->fs) > PATH_MAX) { error(ap->logopt, MODPREFIX "error: fs option length is too long"); return 0; } - target = entry->fs; + strcpy(target, entry->fs); } if (!(flags & CONF_AUTOFS_USE_LOFS)) @@ -1176,7 +1049,7 @@ static int do_generic_mount(struct autofs_point *ap, const char *name, * multiple times since they are outside of * the automount filesystem. */ - if (!is_mounted(entry->fs, MNTS_REAL)) { + if (!is_mounted(_PATH_MOUNTED, entry->fs, MNTS_REAL)) { ret = do_mount(ap, entry->fs, "/", 1, target, entry->type, opts); if (ret) @@ -1184,14 +1057,7 @@ static int do_generic_mount(struct autofs_point *ap, const char *name, umount = 1; } /* We have an external mount */ - if (!ext_mount_add(&entry->ext_mount, entry->fs, umount)) { - umount_ent(ap, entry->fs); - error(ap->logopt, MODPREFIX - "error: could not add external mount %s", - entry->fs); - ret = 1; - goto out; - } + ext_mount_add(&entry->ext_mount, entry->fs, umount); ret = do_link_mount(ap, name, entry, flags); } out: @@ -1210,7 +1076,7 @@ static int do_nfs_mount(struct autofs_point *ap, const char *name, if (strlen(entry->rhost) + strlen(entry->rfs) + 1 > PATH_MAX) { error(ap->logopt, MODPREFIX "error: rhost + rfs options length is too long"); - return 1; + return 0; } strcpy(target, entry->rhost); @@ -1226,7 +1092,7 @@ static int do_nfs_mount(struct autofs_point *ap, const char *name, target, entry->type, opts, mount_nfs->context); } else { - if (!is_mounted(entry->fs, MNTS_REAL)) { + if (!is_mounted(_PATH_MOUNTED, entry->fs, MNTS_REAL)) { ret = mount_nfs->mount_mount(ap, entry->fs, "/", 1, target, entry->type, opts, mount_nfs->context); @@ -1235,13 +1101,7 @@ static int do_nfs_mount(struct autofs_point *ap, const char *name, umount = 1; } /* We might be using an external mount */ - if (!ext_mount_add(&entry->ext_mount, entry->fs, umount)) { - umount_ent(ap, entry->fs); - error(ap->logopt, MODPREFIX - "error: could not add external mount %s", entry->fs); - ret = 1; - goto out; - } + ext_mount_add(&entry->ext_mount, entry->fs, umount); ret = do_link_mount(ap, name, entry, flags); } out: @@ -1426,12 +1286,9 @@ static int do_program_mount(struct autofs_point *ap, */ if (ext_mount_inuse(entry->fs)) { rv = 0; - /* An external mount with path entry->fs exists - * so ext_mount_add() won't fail. - */ ext_mount_add(&entry->ext_mount, entry->fs, 1); } else { - rv = mkdir_path(entry->fs, mp_mode); + rv = mkdir_path(entry->fs, 0555); if (rv && errno != EEXIST) { char buf[MAX_ERR_BUF]; char *estr; @@ -1445,19 +1302,17 @@ static int do_program_mount(struct autofs_point *ap, rv = spawnv(ap->logopt, prog, (const char * const *) argv); if (WIFEXITED(rv) && !WEXITSTATUS(rv)) { - if (ext_mount_add(&entry->ext_mount, entry->fs, 1)) { - rv = 0; - debug(ap->logopt, MODPREFIX - "%s: mounted %s", entry->type, entry->fs); - goto do_free; - } - umount_ent(ap, entry->fs); + rv = 0; + ext_mount_add(&entry->ext_mount, entry->fs, 1); + debug(ap->logopt, MODPREFIX + "%s: mounted %s", entry->type, entry->fs); + } else { + if (!ext_mount_inuse(entry->fs)) + rmdir_path(ap, entry->fs, ap->dev); + error(ap->logopt, MODPREFIX + "%s: failed to mount using: %s", + entry->type, entry->mount); } - - if (!ext_mount_inuse(entry->fs)) - rmdir_path(ap, entry->fs, ap->dev); - error(ap->logopt, MODPREFIX - "%s: failed to mount using %s", entry->type, entry->mount); } do_free: free_argv(argc, (const char **) argv); @@ -1854,7 +1709,7 @@ static void update_prefix(struct autofs_point *ap, return; } -static int match_selectors(struct autofs_point *ap, +static int match_selectors(unsigned int logopt, struct amd_entry *entry, struct substvar *sv) { struct selector *s = entry->selector; @@ -1862,7 +1717,7 @@ static int match_selectors(struct autofs_point *ap, /* No selectors, always match */ if (!s) { - debug(ap->logopt, MODPREFIX "no selectors found in location"); + debug(logopt, MODPREFIX "no selectors found in location"); return 1; } @@ -1870,7 +1725,7 @@ static int match_selectors(struct autofs_point *ap, /* All selectors must match */ while (s) { - ret = eval_selector(ap, entry, sv); + ret = eval_selector(logopt, entry, sv); if (!ret) break; s = s->next; @@ -1972,25 +1827,15 @@ struct amd_entry *make_default_entry(struct autofs_point *ap, if (amd_parse_list(ap, defaults, &dflts, &sv)) return NULL; defaults_entry = list_entry(dflts.next, struct amd_entry, list); + list_del_init(&defaults_entry->list); /* * If map type isn't given try to inherit from * parent. A NULL map type is valid and means * use configured nss sources. */ map_type = conf_amd_get_map_type(ap->path); - if (map_type) { - defaults_entry->map_type = map_type; -#ifndef HAVE_HESIOD - if (!strcmp(map_type, "hesiod")) { - warn(ap->logopt, MODPREFIX - "hesiod support not built in, " - "defaults map entry not set"); - defaults_entry = NULL; - } -#endif - } - if (defaults_entry) - list_del_init(&defaults_entry->list); + if (map_type) + defaults_entry->map_type = strdup(map_type); /* The list should now be empty .... */ free_amd_entry_list(&dflts); return defaults_entry; @@ -2040,7 +1885,7 @@ static struct amd_entry *select_default_entry(struct autofs_point *ap, if (!this->selector) continue; - if (match_selectors(ap, this, sv)) { + if (match_selectors(ap->logopt, this, sv)) { if (entry_default) { /*update_with_defaults(entry_default, this, sv);*/ free_amd_entry(entry_default); @@ -2116,20 +1961,8 @@ static struct amd_entry *get_defaults_entry(struct autofs_point *ap, * use configured nss sources. */ char *map_type = conf_amd_get_map_type(ap->path); - if (map_type) { - entry->map_type = map_type; -#ifndef HAVE_HESIOD - if (!strcmp(map_type, "hesiod")) { - warn(ap->logopt, MODPREFIX - "hesiod support not built in, " - "attempting to use internal " - "default"); - free_amd_entry(entry); - free(expand); - goto out; - } -#endif - } + if (map_type) + entry->map_type = strdup(map_type); } free(expand); } @@ -2259,7 +2092,6 @@ int parse_mount(struct autofs_point *ap, const char *name, list_del_init(&this->list); cur_defaults = this; update_with_defaults(defaults_entry, cur_defaults, sv); - debug(ap->logopt, "merged /defaults entry with defaults"); continue; } else if (this->flags & AMD_DEFAULTS_RESET) { struct amd_entry *nd, *new; @@ -2293,14 +2125,13 @@ int parse_mount(struct autofs_point *ap, const char *name, break; } - if (!match_selectors(ap, this, sv)) + if (!match_selectors(ap->logopt, this, sv)) continue; at_least_one = 1; - debug(ap->logopt, "update mount entry with defaults"); - update_with_defaults(cur_defaults, this, sv); debug(ap->logopt, "expand mount entry"); + update_with_defaults(cur_defaults, this, sv); sv = expand_entry(ap, this, flags, sv); sv = merge_entry_options(ap, this, sv); normalize_sublink(ap->logopt, this, sv); diff --git a/modules/parse_sun.c b/modules/parse_sun.c index 31c55af..536a9bc 100644 --- a/modules/parse_sun.c +++ b/modules/parse_sun.c @@ -161,18 +161,6 @@ int expandsunent(const char *src, char *dst, const char *key, } src = p + 1; } else { - /* If the '$' is folloed by a space or NULL it - * can't be a macro, and the value can't be - * quoted since '\' and '"' cases are handled - * in other cases, so treat the $ as a valid - * map entry character. - */ - if (isblank(*src) || !*src) { - if (dst) - *dst++ = ch; - len++; - break; - } p = src; while (isalnum(*p) || *p == '_') p++; @@ -213,11 +201,9 @@ int expandsunent(const char *src, char *dst, const char *key, *dst++ = *src; src++; } - if (*src) { + if (*src && dst) { len++; - if (dst) - *dst++ = *src; - src++; + *dst++ = *src++; } break; @@ -457,10 +443,8 @@ int parse_reinit(int argc, const char *const *argv, void **context) *new = default_context; - if (do_init(argc, argv, new)) { - free(new); + if (do_init(argc, argv, new)) return 1; - } kill_context(ctxt); @@ -1159,9 +1143,6 @@ static int mount_subtree(struct autofs_point *ap, struct mapent *me, const char *root; int ro_len; - myoptions = NULL; - ro_loc = NULL; - rv = parse_mapent(ro->mapent, options, &myoptions, &ro_loc, ap->logopt); if (!rv) { @@ -1543,9 +1524,6 @@ dont_expand: p += l; p = skipspace(p); - myoptions = NULL; - loc = NULL; - l = parse_mapent(p, options, &myoptions, &loc, ap->logopt); if (!l) { cache_delete_offset_list(mc, name); diff --git a/modules/replicated.c b/modules/replicated.c index cc8117a..3ac4c70 100644 --- a/modules/replicated.c +++ b/modules/replicated.c @@ -83,7 +83,7 @@ void seed_random(void) return; } -struct host *new_host(const char *name, int ent_num, +struct host *new_host(const char *name, struct sockaddr *addr, size_t addr_len, unsigned int proximity, unsigned int weight, unsigned int options) @@ -116,7 +116,6 @@ struct host *new_host(const char *name, int ent_num, memset(new, 0, sizeof(struct host)); new->name = tmp1; - new->ent_num = ent_num; new->addr_len = addr_len; new->addr = tmp2; new->proximity = proximity; @@ -715,7 +714,7 @@ done: int prune_host_list(unsigned logopt, struct host **list, unsigned int vers, int port) { - struct host *this, *last, *first, *prev; + struct host *this, *last, *first; struct host *new = NULL; unsigned int proximity, selected_version = 0; unsigned int v2_tcp_count, v3_tcp_count, v4_tcp_count; @@ -727,6 +726,12 @@ int prune_host_list(unsigned logopt, struct host **list, if (!*list) return 0; + /* If we're using the host name then there's no point probing + * avialability and respose time. + */ + if (defaults_use_hostname_for_mounts()) + return 1; + /* Use closest hosts to choose NFS version */ first = *list; @@ -872,18 +877,11 @@ int prune_host_list(unsigned logopt, struct host **list, first = last; this = first; - prev = NULL; while (this) { struct host *next = this->next; if (!this->name) { remove_host(list, this); add_host(&new, this); - } else if (defaults_use_hostname_for_mounts() && prev && - prev->ent_num == this->ent_num) { - /* When we use the hostname to mount, there is no - * point in probing every address it has, just one is - * enough. Skip the rest. - */ } else { status = get_supported_ver_and_cost(logopt, this, selected_version, port); @@ -891,7 +889,6 @@ int prune_host_list(unsigned logopt, struct host **list, this->version = selected_version; remove_host(list, this); add_host(&new, this); - prev = this; } } this = next; @@ -904,7 +901,7 @@ int prune_host_list(unsigned logopt, struct host **list, } static int add_new_host(struct host **list, - const char *host, int ent_num, unsigned int weight, + const char *host, unsigned int weight, struct addrinfo *host_addr, unsigned int rr, unsigned int options) { @@ -943,7 +940,7 @@ static int add_new_host(struct host **list, else return 0; - new = new_host(host, ent_num, host_addr->ai_addr, addr_len, prx, weight, options); + new = new_host(host, host_addr->ai_addr, addr_len, prx, weight, options); if (!new) return 0; @@ -956,7 +953,7 @@ static int add_new_host(struct host **list, return 1; } -static int add_host_addrs(struct host **list, const char *host, int ent_num, +static int add_host_addrs(struct host **list, const char *host, unsigned int weight, unsigned int options) { struct addrinfo hints, *ni, *this; @@ -985,14 +982,13 @@ static int add_host_addrs(struct host **list, const char *host, int ent_num, hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; - ni = NULL; ret = getaddrinfo(name, NULL, &hints, &ni); if (ret) goto try_name; this = ni; while (this) { - ret = add_new_host(list, host, ent_num, weight, this, 0, options); + ret = add_new_host(list, host, weight, this, 0, options); if (!ret) break; this = this->ai_next; @@ -1006,12 +1002,10 @@ try_name: hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; - ni = NULL; ret = getaddrinfo(name, NULL, &hints, &ni); if (ret) { - error(LOGOPT_ANY, - "hostname lookup for %s failed: %s", - name, gai_strerror(ret)); + error(LOGOPT_ANY, "hostname lookup failed: %s", + gai_strerror(ret)); free(name); return 0; } @@ -1033,7 +1027,7 @@ try_name: rr++; this = ni; while (this) { - ret = add_new_host(list, host, ent_num, weight, this, rr, options); + ret = add_new_host(list, host, weight, this, rr, options); if (!ret) break; this = this->ai_next; @@ -1126,7 +1120,6 @@ int parse_location(unsigned logopt, struct host **hosts, { char *str, *p, *delim; unsigned int empty = 1; - int ent_num = 1; if (!list) return 0; @@ -1184,7 +1177,7 @@ int parse_location(unsigned logopt, struct host **hosts, } if (p != delim) { - if (!add_host_addrs(hosts, p, ent_num, weight, options)) { + if (!add_host_addrs(hosts, p, weight, options)) { if (empty) { p = next; continue; @@ -1206,7 +1199,7 @@ int parse_location(unsigned logopt, struct host **hosts, *delim = '\0'; next = delim + 1; - if (!add_host_addrs(hosts, p, ent_num, weight, options)) { + if (!add_host_addrs(hosts, p, weight, options)) { p = next; continue; } @@ -1220,7 +1213,6 @@ int parse_location(unsigned logopt, struct host **hosts, return 0; } - ent_num++; p = next; } diff --git a/redhat/autofs.conf.default.in b/redhat/autofs.conf.default.in index bd52730..a72a79f 100644 --- a/redhat/autofs.conf.default.in +++ b/redhat/autofs.conf.default.in @@ -26,12 +26,6 @@ timeout = 300 # #negative_timeout = 60 # -# mount_verbose - use the -v flag when calling mount(8) and log some -# process information about the requestor and its -# parent. -# -#mount_verbose = no -# # mount_wait - time to wait for a response from mount(8). # Setting this timeout can cause problems when # mount would otherwise wait for a server that @@ -183,15 +177,6 @@ mount_nfs_default_protocol = 4 # #disable_not_found_message = "no" # -# use_ignore_mount_option - This option is used to enable the use of autofs -# pseudo option "disable". This option is used as a -# hint to user space that the mount entry should be -# ommitted from mount table listings. The default is -# "no" to avoid unexpected changes in behaviour and -# so is an opt-in setting. -# -#use_ignore_mount_option = no -# # sss_master_map_wait - When sssd is starting up it can sometimes return # "no such entry" for a short time until it has read # in the LDAP map information. Internal default is 0 diff --git a/samples/am-utils-ldap-id.txt b/samples/am-utils-ldap-id.txt deleted file mode 100644 index 33a9187..0000000 --- a/samples/am-utils-ldap-id.txt +++ /dev/null @@ -1,360 +0,0 @@ - - - - - - -INTERNET-DRAFT Leif Johansson -Intented Category: Experimental Stockholm University - - - - A directory (X.500 and LDAPv3) schema for Berkely automounter - - -1. Status of this Memo - - This memo describes a directory (LDAP or X.500) schema for storing amd (Berkely- - style automounter) mount info maps. The schema is currently beeing supported by - the (beta version of the) am-utils version 6 package [AMUTILS]. - -2. Overview and Rationale - - Directory services such as X.500 [X500] or LDAP [RFC2251] are a natural choice of - repository for amd mount map databases. All Object Identifiers in this document - are prefixed by amdSchema-id to be assigned later. The relation between this - schema and the automount schema elements in [HOWARD] are mostly superficial. The - model for the elements in [HOWARD] was the SUN automounter which has quite a - different syntax for mount maps. Furthermore the intended usage of this schema - differs from that of [HOWARD] in many respects. - -3. DSA requirements - - Directory servers implementing this schema SHOULD maintain the modifyTimestamp - operational attribute. If not the amdMapCacheTtl attribute SHOULD be set to 0 - indicating to clients that caching of map entries SHOULD be turned off. Clients - wishing to use the amdMap schema MAY use the modifyTimestamp information to set - the ttl for internal caching schemes. A value of 0 for the amdMapCacheTtl must - result in clients turning off any local caching. - -4. Syntax definitions - - The following attribute syntax is defined in this document: - - amdlocationlist - - This syntax represents a amd map value. This is the syntax expressed in BNF using - definitions from [RFC2252]: - - amdlocationlist = amdlocationselection | - amdlocationlist whsp "||" whsp amdlocationselection - - amdlocationselection = amdlocation | - amdlocationselection whsp amdlocation - - - - -Johansson [Page 1] - - - - - -Internet draft Berkeley AMD LDAP Schema 30 March 1998 - - - amdlocation = amdlocationinfo | - "-" amdlocationinfo | - "-" - - amdlocationinfo = seloropt | - amdlocationinfo ";" seloropt | - ";" - - seloropt = seletion | - optass - - selection = keystring "==" printablestring - keystring "!=" printablestring - - optass = keystring - - X.500 servers or LDAPv3 servers (supporting the binary attribute option) may use - the following syntax definition: - - AmdLocationList ::= SEQUENCE OF { - SEQUENCE OF { - location AmdLocation - } - } - - AmdLocation ::= SET OF { - CHOICE { - location [0] AmdLocationInfo - notlocation [1] AmdLocationInfo - not [2] NULL - } - } - - AmdLocationInfo ::= SET OF { - CHOICE { - selection [0] AmdSelection - option [1] AmdOption - } - } - - AmdSelection ::= CHOICE { - eq [0] AttributeAndValue - ne [1] AttributeAndValue - } - - AmdOption ::= AttributeAndValue - AttributeAndValue ::= SEQUENCE { - attribute IA5String - - - -Johansson [Page 2] - - - - - -Internet draft Berkeley AMD LDAP Schema 30 March 1998 - - - value IA5String - } - -5. Attribute types - - The following attribute types are defined in this document: - - amdMapName - amdMapCacheTtl - amdMapEntry - amdMapEntryKey - amdMapEntryValue - - amdSchema-a OBJECT IDENTIFIER ::= { amdSchema-id 1 } - - amdMapName ATTRIBUTE ::= { - WITH SYNTAX IA5String - EQUALITY MATCHING RULE caseIgoreExactMatch - --ID { amdSchema-a 1 } - DESCRIPTION - "This attribute is the symbolic and in the naming - context unique name of an amd map. This corresponds - in the case of a flat file database to the name of - the file or the mount-point of the map." - } - - - amdMapCacheTtl - ATTRIBUTE ::= { - WITH SYNTAX Integer - EQUALITY MATCHING RULE integerExactMatch - --ID { amdSchema-a 2 } - SINGLE VALUED - DESCRIPTION - "The maximum time-to-live for the entries in this - map. After this many milliseconds the map has to - be cleared from local caches and reloaded. A value - of 0 disables caching." - } - - amdMapEntry - ATTRIBUTE ::= { - WITH SYNTAX DistinguishedName - EQUALITY MATHCING RULE dNCaseIgnoreExactMatch - --ID { amdSchema-a 3 } - DESCRIPTION - "A multivalued attribute listing the distinguished - names of the amdMapEntries making up this amdMap - - - -Johansson [Page 3] - - - - - -Internet draft Berkeley AMD LDAP Schema 30 March 1998 - - - object." - } - - amdMapEntryKey ::= { - ATTRIBUTE ::= { - WITH SYNTAX IA5String - EQUALITY MATCHING RULE stringExactMatch - --ID { amdSchema-a 4 } - SINGLE VALUED - DESCRIPTION - "The value of this attribute is usually the name of - a mountpoint for this amdMapEntry." - } - - amdMapEntryValue ::= { - ATTRIBUTE ::= { - WITH SYNTAX AmdLocationList - --ID { amdSchema-a 5 } - DESCRIPTION - "This is the actual mount information for the amdMapEntry - using the syntax described above." - } - - amdMapEntryKey ::= { - ATTRIBUTE ::= { - WITH SYNTAX IA5String - EQUALITY MATCHING RULE stringExactMatch - --ID { amdSchema-a 4 } - SINGLE VALUED - DESCRIPTION - "The value of this attribute is usually the name of - a mountpoint for this amdMapEntry." - } - - amdMapEntryValue ::= { - ATTRIBUTE ::= { - WITH SYNTAX AmdLocationList - --ID { amdSchema-a 5 } - DESCRIPTION - "This is the actual mount information for the amdMapEntry - using the syntax described above." - } - -6. Object classes - - The following object classes are defined in this document: - - amdMap - - - -Johansson [Page 4] - - - - - -Internet draft Berkeley AMD LDAP Schema 30 March 1998 - - - amdMapEntry - - defined as follows: - - amdSchema-oc ::= { amdSchema-id 2 } - - amdMap OBJECT-CLASS ::= { - SUBCLASS OF { top } - KIND auxiliary - --ID { amdSchema-oc 1 } - MAY CONTAIN { amdMapCacheTtl , cn } - MUST CONTAIN { amdMapName , amdMapEntry } - } - - amdMapEntry OBJECT-CLASS ::= { - SUBCLASS OF { top } - KIND structural - --ID { amdSchema-oc 2 } - MUST CONTAIN { - amdMapName , - amdEntryKey , - amdEntryValue , - } MAY CONTAIN - { cn } DESCRIPTION "An entry of this - object class describes mount information relative to a - certain amdMap entry" - } - -7. Examples - - - -8. Security Considerations - - Due to the security problems posed by NFS care should be taken not to advertise - exported filesystems. Therefore it is often desirable to limit access to entries - carrying amd mount map information to those systems to which the corresponding - filesystems have been exported. - -9. References - - [AMUTILS] - am-utils homepage: http://shekel.cs.columbia.edu/~erez/am-utils.html - - [RFC2251] - M. Wahl, T. Howes, S. Kille, "Lightweight Directory Access - Protocol (v3)", RFC 2251, December 1997. - - - - -Johansson [Page 5] - - - - - -Internet draft Berkeley AMD LDAP Schema 30 March 1998 - - - [RFC2252] - M. Wahl, A. Coulbeck, T. Howes, S. Kille, "Lightweight Directory - Access Protocol (v3): Attribute Syntax Definitions", RFC 2252, - December 1997. - - [RFC2253] - M. Wahl, S. Kille, T. Howes, "Lightweight Directory Access - Protocol (v3): UTF-8 String Representation of Distinguished - Names", RFC 2253, December 1997. - - [HOWARD] - Luke Howard, "An Approach for Using LDAP as a Network - Information Service", draft-howard-nis-schema-??.txt, Internet - draft. - - [X500] - ITU something or other. - - - -Author's Address - - - Leif Johansson - Department of Mathematics - Stockholm University - S-106 91 Stockholm - SWEDEN - - Email: leifj AT matematik.su.se - - - - - - - - - - - - - - - - - - - - - -Johansson [Page 6] - - diff --git a/samples/am-utils-ldap.schema b/samples/am-utils-ldap.schema deleted file mode 100644 index 9594d2f..0000000 --- a/samples/am-utils-ldap.schema +++ /dev/null @@ -1,52 +0,0 @@ -# A schema for the Berkeley automounter (AMD) -# Authored by Erez Zadok and/or source maintainers -# Definition by Tim Colles -# Revised by Adam Morley - -# OID Base is 1.3.6.1.4.1.10180 -# -# Syntaxes are under 1.3.6.1.4.1.10180.3.175-199 -# Attribute types are under 1.3.6.1.4.1.10180.2.175-199 -# Object classes are under 1.3.6.1.4.1.10180.1.175-199 - -# Attribute Type Definitions - -attributetype ( 1.3.6.1.4.1.10180.2.175 - NAME 'amdmapTimestamp' - DESC 'Probably the time the map was last modified' - EQUALITY integerMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 - SINGLE-VALUE ) - -attributetype ( 1.3.6.1.4.1.10180.2.176 - NAME 'amdmapName' - DESC 'The symbolic name of the map, ie. map_name' - EQUALITY caseIgnoreMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 - SINGLE-VALUE ) - -attributetype ( 1.3.6.1.4.1.10180.2.177 - NAME 'amdmapKey' - DESC 'The key value for this entry' - EQUALITY caseIgnoreMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 - SINGLE-VALUE ) - -attributetype ( 1.3.6.1.4.1.10180.2.178 - NAME 'amdmapValue' - DESC 'The mount information for this entry' - EQUALITY caseIgnoreMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 - SINGLE-VALUE ) - -# Object Class Definitions - -objectclass ( 1.3.6.1.4.1.10180.1.175 NAME 'amdmapTimestamp' - SUP top STRUCTURAL - DESC 'Timestamp for an AMD map' - MUST ( cn $ amdmapName $ amdmapTimestamp ) ) - -objectclass ( 1.3.6.1.4.1.10180.1.176 NAME 'amdmap' - SUP top STRUCTURAL - DESC 'Defines an AMD map entry' - MUST ( cn $ amdmapName $ amdmapKey $ amdmapValue ) ) diff --git a/samples/auto.master b/samples/auto.master index 9a9968a..0f2c8ab 100644 --- a/samples/auto.master +++ b/samples/auto.master @@ -17,12 +17,6 @@ # +dir:/etc/auto.master.d # -# If you have fedfs set up and the related binaries, either -# built as part of autofs or installed from another package, -# uncomment this line to use the fedfs program map to access -# your fedfs mounts. -#/nfs4 /usr/sbin/fedfs-map-nfs4 nobind -# # Include central master map if it can be found using # nsswitch sources. # diff --git a/samples/autofs.conf.default.in b/samples/autofs.conf.default.in index 1f55709..2693a97 100644 --- a/samples/autofs.conf.default.in +++ b/samples/autofs.conf.default.in @@ -26,12 +26,6 @@ timeout = 300 # #negative_timeout = 60 # -# mount_verbose - use the -v flag when calling mount(8) and log some -# process information about the requestor and its -# parent. -# -#mount_verbose = no -# # mount_wait - time to wait for a response from mount(8). # Setting this timeout can cause problems when # mount would otherwise wait for a server that @@ -182,15 +176,6 @@ browse_mode = no # #disable_not_found_message = "no" # -# use_ignore_mount_option - This option is used to enable the use of autofs -# pseudo option "disable". This option is used as a -# hint to user space that the mount entry should be -# ommitted from mount table listings. The default is -# "no" to avoid unexpected changes in behaviour and -# so is an opt-in setting. -# -#use_ignore_mount_option = no -# # sss_master_map_wait - When sssd is starting up it can sometimes return # "no such entry" for a short time until it has read # in the LDAP map information. Internal default is 0 diff --git a/samples/autofs.service.in b/samples/autofs.service.in index 175a806..918fc93 100644 --- a/samples/autofs.service.in +++ b/samples/autofs.service.in @@ -1,12 +1,13 @@ [Unit] Description=Automounts filesystems on demand -After=network.target ypbind.service sssd.service network-online.target remote-fs.target rpc-statd.service rpcbind.service +After=network.target ypbind.service sssd.service network-online.target remote-fs.target Wants=network-online.target rpc-statd.service rpcbind.service [Service] -Type=notify +Type=forking +PIDFile=@@autofspiddir@@/autofs.pid EnvironmentFile=-@@autofsconfdir@@/autofs -ExecStart=@@sbindir@@/automount $OPTIONS --systemd-service --dont-check-daemon +ExecStart=@@sbindir@@/automount $OPTIONS --pid-file @@autofspiddir@@/autofs.pid ExecReload=/usr/bin/kill -HUP $MAINPID KillMode=process TimeoutSec=180 diff --git a/samples/rfc2307.schema b/samples/rfc2307.schema deleted file mode 100644 index e8b15ed..0000000 --- a/samples/rfc2307.schema +++ /dev/null @@ -1,37 +0,0 @@ -attributeType ( 1.3.6.1.1.1.1.31 - NAME 'automountMapName' - DESC 'automount Map Name' - EQUALITY caseExactIA5Match - SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE - X-ORIGIN 'user defined' ) - -attributeType ( 1.3.6.1.1.1.1.32 - NAME 'automountKey' - DESC 'Automount Key value' - EQUALITY caseExactIA5Match - SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE - X-ORIGIN 'user defined' ) - -attributeType ( 1.3.6.1.1.1.1.33 - NAME 'automountInformation' - DESC 'Automount information' - EQUALITY caseExactIA5Match - SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE - X-ORIGIN 'user defined' ) - -objectClass ( 1.3.6.1.1.1.2.16 - NAME 'automountMap' - DESC 'Automount Map information' - SUP top STRUCTURAL - MUST automountMapName - MAY description - X-ORIGIN 'user defined' ) - -objectClass ( 1.3.6.1.1.1.2.17 - NAME 'automount' - DESC 'Automount information' - SUP top STRUCTURAL - MUST ( automountKey $ automountInformation ) - MAY description - X-ORIGIN 'user defined' ) - diff --git a/samples/rfc2307bis.schema b/samples/rfc2307bis.schema deleted file mode 100644 index a626b3f..0000000 --- a/samples/rfc2307bis.schema +++ /dev/null @@ -1,310 +0,0 @@ -### -# Extracted from: http://tools.ietf.org/html/draft-howard-rfc2307bis-02 -### - -# Builtin -#attributeType ( 1.3.6.1.1.1.1.0 NAME 'uidNumber' -# DESC 'An integer uniquely identifying a user in an -# administrative domain' -# EQUALITY integerMatch -# ORDERING integerOrderingMatch -# SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 -# SINGLE-VALUE ) - -# Builtin -#attributeType ( 1.3.6.1.1.1.1.1 NAME 'gidNumber' -# DESC 'An integer uniquely identifying a group in an -# administrative domain' -# EQUALITY integerMatch -# ORDERING integerOrderingMatch -# SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 -# SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.2 NAME 'gecos' - DESC 'The GECOS field; the common name' - EQUALITY caseIgnoreMatch - SUBSTR caseIgnoreSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.3 NAME 'homeDirectory' - DESC 'The absolute path to the home directory' - EQUALITY caseExactIA5Match - SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.4 NAME 'loginShell' - DESC 'The path to the login shell' - EQUALITY caseExactIA5Match - SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.5 NAME 'shadowLastChange' - EQUALITY integerMatch - ORDERING integerOrderingMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.6 NAME 'shadowMin' - EQUALITY integerMatch - ORDERING integerOrderingMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.7 NAME 'shadowMax' - EQUALITY integerMatch - ORDERING integerOrderingMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.8 NAME 'shadowWarning' - EQUALITY integerMatch - ORDERING integerOrderingMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.9 NAME 'shadowInactive' - EQUALITY integerMatch - ORDERING integerOrderingMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.10 NAME 'shadowExpire' - EQUALITY integerMatch - ORDERING integerOrderingMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.11 NAME 'shadowFlag' - EQUALITY integerMatch - ORDERING integerOrderingMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.12 NAME 'memberUid' - EQUALITY caseExactMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) - -attributeType ( 1.3.6.1.1.1.1.13 NAME 'memberNisNetgroup' - EQUALITY caseExactMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) - -attributeType ( 1.3.6.1.1.1.1.14 NAME 'nisNetgroupTriple' - DESC 'Netgroup triple' - EQUALITY caseIgnoreMatch - SUBSTR caseIgnoreSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) - -attributeType ( 1.3.6.1.1.1.1.15 NAME 'ipServicePort' - DESC 'Service port number' - EQUALITY integerMatch - ORDERING integerOrderingMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.16 NAME 'ipServiceProtocol' - DESC 'Service protocol name' - EQUALITY caseIgnoreMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) - -attributeType ( 1.3.6.1.1.1.1.17 NAME 'ipProtocolNumber' - DESC 'IP protocol number' - EQUALITY integerMatch - ORDERING integerOrderingMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.18 NAME 'oncRpcNumber' - DESC 'ONC RPC number' - EQUALITY integerMatch - ORDERING integerOrderingMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.19 NAME 'ipHostNumber' - DESC 'IPv4 addresses as a dotted decimal omitting leading - zeros or IPv6 addresses as defined in RFC2373' - EQUALITY caseIgnoreIA5Match - SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) - -attributeType ( 1.3.6.1.1.1.1.20 NAME 'ipNetworkNumber' - DESC 'IP network omitting leading zeros, eg. 192.168' - EQUALITY caseIgnoreIA5Match - SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.21 NAME 'ipNetmaskNumber' - DESC 'IP netmask omitting leading zeros, eg. 255.255.255.0' - EQUALITY caseIgnoreIA5Match - SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.22 NAME 'macAddress' - DESC 'MAC address in maximal, colon separated hex - notation, eg. 00:00:92:90:ee:e2' - EQUALITY caseIgnoreIA5Match - SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) - -attributeType ( 1.3.6.1.1.1.1.23 NAME 'bootParameter' - DESC 'rpc.bootparamd parameter' - EQUALITY caseExactIA5Match - SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) - -attributeType ( 1.3.6.1.1.1.1.24 NAME 'bootFile' - DESC 'Boot image name' - EQUALITY caseExactIA5Match - SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) - -attributeType ( 1.3.6.1.1.1.1.26 NAME 'nisMapName' - DESC 'Name of a generic NIS map' - EQUALITY caseIgnoreMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{64} ) - -attributeType ( 1.3.6.1.1.1.1.27 NAME 'nisMapEntry' - DESC 'A generic NIS entry' - EQUALITY caseExactMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.28 NAME 'nisPublicKey' - DESC 'NIS public key' - EQUALITY octetStringMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.29 NAME 'nisSecretKey' - DESC 'NIS secret key' - EQUALITY octetStringMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.30 NAME 'nisDomain' - DESC 'NIS domain' - EQUALITY caseIgnoreIA5Match - SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} ) - -attributeType ( 1.3.6.1.1.1.1.31 NAME 'automountMapName' - DESC 'automount Map Name' - EQUALITY caseExactMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.32 NAME 'automountKey' - DESC 'Automount Key value' - EQUALITY caseExactMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 - SINGLE-VALUE ) - -attributeType ( 1.3.6.1.1.1.1.33 NAME 'automountInformation' - DESC 'Automount information' - EQUALITY caseExactMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 - SINGLE-VALUE ) - -objectClass ( 1.3.6.1.1.1.2.0 NAME 'posixAccount' SUP top AUXILIARY - DESC 'Abstraction of an account with POSIX attributes' - MUST ( cn $ uid $ uidNumber $ gidNumber $ homeDirectory ) - MAY ( userPassword $ loginShell $ gecos $ - description ) ) - -objectClass ( 1.3.6.1.1.1.2.1 NAME 'shadowAccount' SUP top AUXILIARY - DESC 'Additional attributes for shadow passwords' - MUST uid - MAY ( userPassword $ description $ - shadowLastChange $ shadowMin $ shadowMax $ - shadowWarning $ shadowInactive $ - shadowExpire $ shadowFlag ) ) - -objectClass ( 1.3.6.1.1.1.2.2 NAME 'posixGroup' SUP top AUXILIARY - DESC 'Abstraction of a group of accounts' - MUST gidNumber - MAY ( userPassword $ memberUid $ - description ) ) - -objectClass ( 1.3.6.1.1.1.2.3 NAME 'ipService' SUP top STRUCTURAL - DESC 'Abstraction an Internet Protocol service. - Maps an IP port and protocol (such as tcp or udp) - to one or more names; the distinguished value of - the cn attribute denotes the services canonical - name' - MUST ( cn $ ipServicePort $ ipServiceProtocol ) - MAY description ) - -objectClass ( 1.3.6.1.1.1.2.4 NAME 'ipProtocol' SUP top STRUCTURAL - DESC 'Abstraction of an IP protocol. Maps a protocol number - to one or more names. The distinguished value of the cn - attribute denotes the protocol canonical name' - MUST ( cn $ ipProtocolNumber ) - MAY description ) - -objectClass ( 1.3.6.1.1.1.2.5 NAME 'oncRpc' SUP top STRUCTURAL - DESC 'Abstraction of an Open Network Computing (ONC) - [RFC1057] Remote Procedure Call (RPC) binding. - This class maps an ONC RPC number to a name. - The distinguished value of the cn attribute denotes - the RPC service canonical name' - MUST ( cn $ oncRpcNumber ) - MAY description ) - -objectClass ( 1.3.6.1.1.1.2.6 NAME 'ipHost' SUP top AUXILIARY - DESC 'Abstraction of a host, an IP device. The distinguished - value of the cn attribute denotes the hosts canonical - name. Device SHOULD be used as a structural class' - MUST ( cn $ ipHostNumber ) - MAY ( userPassword $ l $ description $ - manager ) ) - -objectClass ( 1.3.6.1.1.1.2.7 NAME 'ipNetwork' SUP top STRUCTURAL - DESC 'Abstraction of a network. The distinguished value of - the cn attribute denotes the network canonical name' - MUST ipNetworkNumber - MAY ( cn $ ipNetmaskNumber $ l $ description $ manager ) ) - -objectClass ( 1.3.6.1.1.1.2.8 NAME 'nisNetgroup' SUP top STRUCTURAL - DESC 'Abstraction of a netgroup. May refer to other - netgroups' - MUST cn - MAY ( nisNetgroupTriple $ memberNisNetgroup $ description ) ) - -objectClass ( 1.3.6.1.1.1.2.9 NAME 'nisMap' SUP top STRUCTURAL - DESC 'A generic abstraction of a NIS map' - MUST nisMapName - MAY description ) - -objectClass ( 1.3.6.1.1.1.2.10 NAME 'nisObject' SUP top STRUCTURAL - DESC 'An entry in a NIS map' - MUST ( cn $ nisMapEntry $ nisMapName ) ) - -objectClass ( 1.3.6.1.1.1.2.11 NAME 'ieee802Device' SUP top AUXILIARY - DESC 'A device with a MAC address; device SHOULD be - used as a structural class' - MAY macAddress ) - -objectClass ( 1.3.6.1.1.1.2.12 NAME 'bootableDevice' SUP top AUXILIARY - DESC 'A device with boot parameters; device SHOULD be - used as a structural class' - MAY ( bootFile $ bootParameter ) ) - -objectClass ( 1.3.6.1.1.1.2.14 NAME 'nisKeyObject' SUP top AUXILIARY - DESC 'An object with a public and secret key' - MUST ( cn $ nisPublicKey $ nisSecretKey ) - MAY ( uidNumber $ description ) ) - -objectClass ( 1.3.6.1.1.1.2.15 NAME 'nisDomainObject' SUP top AUXILIARY - DESC 'Associates a NIS domain with a naming context' - MUST nisDomain ) - -objectClass ( 1.3.6.1.1.1.2.16 NAME 'automountMap' SUP top STRUCTURAL - MUST ( automountMapName ) - MAY description ) - -objectClass ( 1.3.6.1.1.1.2.17 NAME 'automount' SUP top STRUCTURAL - DESC 'Automount information' - MUST ( automountKey $ automountInformation ) - MAY description ) - -objectClass ( 1.3.6.1.1.1.2.18 NAME 'groupOfMembers' SUP top STRUCTURAL - DESC 'A group with members (DNs)' - MUST cn - MAY ( businessCategory $ seeAlso $ owner $ ou $ o $ - description $ member ) )