Index: libexec/rc/rc.d/automount =================================================================== --- libexec/rc/rc.d/automount +++ libexec/rc/rc.d/automount @@ -18,8 +18,15 @@ automount_start() { + local master_flags="" + for master in ${autofs_masters}; do + case ${master} in + /*) master_flags="${master_flags} -m ${master}" ;; + *) master_flags="${master_flags} -m /etc/autofs/master_${master}" ;; + esac + done - /usr/sbin/automount ${automount_flags} + /usr/sbin/automount ${automount_flags} ${master_flags} } automount_stop() Index: usr.sbin/autofs/automount.c =================================================================== --- usr.sbin/autofs/automount.c +++ usr.sbin/autofs/automount.c @@ -313,7 +313,7 @@ usage_automount(void) { - fprintf(stderr, "usage: automount [-D name=value][-o opts][-Lcfuv]\n"); + fprintf(stderr, "usage: automount [-D name=value][-m master][-o opts][-Lcfuv]\n"); exit(1); } @@ -324,6 +324,8 @@ int ch, debug = 0, show_maps = 0; char *options = NULL; bool do_unmount = false, force_unmount = false, flush = false; + const char **masters; + size_t nmasters; /* * Note that in automount(8), the only purpose of variable @@ -331,7 +333,13 @@ */ defined_init(); - while ((ch = getopt(argc, argv, "D:Lfco:uv")) != -1) { + /* Allocate an array for at most argc master files + NULL. */ + if ((masters = malloc((argc + 1) * sizeof(char *))) == NULL) + log_err(1, "malloc"); + masters[0] = AUTO_MASTER_PATH; + nmasters = 1; + + while ((ch = getopt(argc, argv, "D:Lfcm:o:uv")) != -1) { switch (ch) { case 'D': defined_parse_and_add(optarg); @@ -345,6 +353,9 @@ case 'f': force_unmount = true; break; + case 'm': + masters[nmasters++] = optarg; + break; case 'o': options = concat(options, ',', optarg); break; @@ -363,6 +374,9 @@ if (argc != 0) usage_automount(); + /* Terminate list of masters. */ + masters[nmasters] = NULL; + if (force_unmount && !do_unmount) usage_automount(); @@ -379,7 +393,7 @@ } root = node_new_root(); - parse_master(root, AUTO_MASTER_PATH); + parse_master(root, masters); if (show_maps) { if (show_maps > 1) { Index: usr.sbin/autofs/common.h =================================================================== --- usr.sbin/autofs/common.h +++ usr.sbin/autofs/common.h @@ -90,7 +90,7 @@ int node_expand_defined(struct node *root); void node_expand_indirect_maps(struct node *n); void node_print(const struct node *n, const char *cmdline_options); -void parse_master(struct node *root, const char *path); +void parse_master(struct node *root, const char **paths); void parse_map(struct node *parent, const char *map, const char *args, bool *wildcards); char *defined_expand(const char *string); Index: usr.sbin/autofs/common.c =================================================================== --- usr.sbin/autofs/common.c +++ usr.sbin/autofs/common.c @@ -1154,22 +1154,27 @@ } void -parse_master(struct node *root, const char *master) +parse_master(struct node *root, const char **masters) { + const char * master; - log_debugx("parsing auto_master file at \"%s\"", master); + while (*masters) { + master = *masters++; - yyin = fopen(master, "r"); - if (yyin == NULL) - err(1, "unable to open %s", master); + log_debugx("parsing auto_master file at \"%s\"", master); - parse_master_yyin(root, master); + yyin = fopen(master, "r"); + if (yyin == NULL) + err(1, "unable to open %s", master); - fclose(yyin); - yyin = NULL; + parse_master_yyin(root, master); - log_debugx("done parsing \"%s\"", master); + fclose(yyin); + yyin = NULL; + log_debugx("done parsing \"%s\"", master); + } + node_expand_includes(root, true); node_expand_direct_maps(root); }