- add missing "multi" map support.
- add multi map nsswitch lookup.
This commit is contained in:
parent
20ded2bb32
commit
64001bdc26
531
autofs-5.0.2-add-missing-multi-support.patch
Normal file
531
autofs-5.0.2-add-missing-multi-support.patch
Normal file
@ -0,0 +1,531 @@
|
||||
diff --git a/daemon/lookup.c b/daemon/lookup.c
|
||||
index 06fcecc..70b9e02 100644
|
||||
--- a/daemon/lookup.c
|
||||
+++ b/daemon/lookup.c
|
||||
@@ -456,8 +456,12 @@ int lookup_nss_read_map(struct autofs_point *ap, struct map_source *source, time
|
||||
}
|
||||
|
||||
if (map->type) {
|
||||
- debug(ap->logopt,
|
||||
- "reading map %s %s", map->type, map->argv[0]);
|
||||
+ if (!strncmp(map->type, "multi", 5))
|
||||
+ debug(ap->logopt, "reading multi map");
|
||||
+ else
|
||||
+ debug(ap->logopt,
|
||||
+ "reading map %s %s",
|
||||
+ map->type, map->argv[0]);
|
||||
result = do_read_map(ap, map, age);
|
||||
map = map->next;
|
||||
continue;
|
||||
diff --git a/include/automount.h b/include/automount.h
|
||||
index 85e6e9c..106ed0a 100644
|
||||
--- a/include/automount.h
|
||||
+++ b/include/automount.h
|
||||
@@ -192,6 +192,7 @@ char *cache_get_offset(const char *prefix, char *offset, int start, struct list_
|
||||
/* Utility functions */
|
||||
|
||||
char **add_argv(int argc, char **argv, char *str);
|
||||
+char **append_argv(int argc1, char **argv1, int argc2, char **argv2);
|
||||
const char **copy_argv(int argc, const char **argv);
|
||||
int compare_argv(int argc1, const char **argv1, int argc2, const char **argv2);
|
||||
int free_argv(int argc, const char **argv);
|
||||
diff --git a/lib/args.c b/lib/args.c
|
||||
index 9e35388..fbfb004 100644
|
||||
--- a/lib/args.c
|
||||
+++ b/lib/args.c
|
||||
@@ -62,6 +62,45 @@ char **add_argv(int argc, char **argv, char *str)
|
||||
return vector;
|
||||
}
|
||||
|
||||
+char **append_argv(int argc1, char **argv1, int argc2, char **argv2)
|
||||
+{
|
||||
+ char **vector;
|
||||
+ size_t vector_size;
|
||||
+ int len, i, j;
|
||||
+
|
||||
+ len = argc1 + argc2;
|
||||
+ vector_size = (len + 1) * sizeof(char *);
|
||||
+ vector = (char **) realloc(argv1, vector_size);
|
||||
+ if (!vector) {
|
||||
+ free_argv(argc1, (const char **) argv1);
|
||||
+ free_argv(argc2, (const char **) argv2);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ for (i = argc1, j = 0; i <= len; i++, j++) {
|
||||
+ if (argv2[j]) {
|
||||
+ vector[i] = strdup(argv2[j]);
|
||||
+ if (!vector[i]) {
|
||||
+ error(LOGOPT_ANY, "failed to strdup arg");
|
||||
+ break;
|
||||
+ }
|
||||
+ } else
|
||||
+ vector[i] = NULL;
|
||||
+ }
|
||||
+
|
||||
+ if (i < len) {
|
||||
+ free_argv(len, (const char **) vector);
|
||||
+ free_argv(argc2, (const char **) argv2);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ vector[len] = NULL;
|
||||
+
|
||||
+ free_argv(argc2, (const char **) argv2);
|
||||
+
|
||||
+ return vector;
|
||||
+}
|
||||
+
|
||||
const char **copy_argv(int argc, const char **argv)
|
||||
{
|
||||
char **vector;
|
||||
diff --git a/lib/master_parse.y b/lib/master_parse.y
|
||||
index 8d2be02..f9cba05 100644
|
||||
--- a/lib/master_parse.y
|
||||
+++ b/lib/master_parse.y
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
+#include <ctype.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "automount.h"
|
||||
@@ -44,6 +45,7 @@ extern void master_set_scan_buffer(const char *);
|
||||
static char *master_strdup(char *);
|
||||
static void local_init_vars(void);
|
||||
static void local_free_vars(void);
|
||||
+static int add_multi_mapstr(void);
|
||||
|
||||
static int master_error(const char *s);
|
||||
static int master_notify(const char *s);
|
||||
@@ -53,6 +55,8 @@ static char *type;
|
||||
static char *format;
|
||||
static long timeout;
|
||||
static unsigned ghost;
|
||||
+static char **tmp_argv;
|
||||
+static int tmp_argc;
|
||||
static char **local_argv;
|
||||
static int local_argc;
|
||||
|
||||
@@ -89,7 +93,7 @@ static int master_fprintf(FILE *, char *, ...);
|
||||
%token COMMENT
|
||||
%token MAP
|
||||
%token OPT_TIMEOUT OPT_NOGHOST OPT_GHOST OPT_VERBOSE OPT_DEBUG
|
||||
-%token COLON COMMA NL
|
||||
+%token COLON COMMA NL DDASH
|
||||
%type <strtype> map
|
||||
%type <strtype> options
|
||||
%type <strtype> dn
|
||||
@@ -103,6 +107,7 @@ static int master_fprintf(FILE *, char *, ...);
|
||||
%token <strtype> NILL
|
||||
%token <strtype> SPACE
|
||||
%token <strtype> EQUAL
|
||||
+%token <strtype> MULTITYPE
|
||||
%token <strtype> MAPTYPE
|
||||
%token <strtype> DNSERVER
|
||||
%token <strtype> DNATTR
|
||||
@@ -126,7 +131,7 @@ file: {
|
||||
;
|
||||
|
||||
line:
|
||||
- | PATH map
|
||||
+ | PATH mapspec
|
||||
{
|
||||
path = master_strdup($1);
|
||||
if (!path) {
|
||||
@@ -134,14 +139,49 @@ line:
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
- | PATH map options
|
||||
+ | PATH MULTITYPE maplist
|
||||
{
|
||||
+ char *tmp;
|
||||
+
|
||||
+ tmp = strchr($2, ':');
|
||||
+ if (tmp)
|
||||
+ *tmp = '\0';
|
||||
+ else {
|
||||
+ int len = strlen($2);
|
||||
+ while (len-- && isblank($2[len]))
|
||||
+ $2[len] = '\0';
|
||||
+ if (len < 4) {
|
||||
+ master_notify($2);
|
||||
+ local_free_vars();
|
||||
+ YYABORT;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
path = master_strdup($1);
|
||||
if (!path) {
|
||||
+ master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
}
|
||||
- }
|
||||
+
|
||||
+ if ((tmp = strchr($2, ',')))
|
||||
+ *tmp++ = '\0';
|
||||
+
|
||||
+ type = master_strdup($2);
|
||||
+ if (!type) {
|
||||
+ master_error("memory allocation error");
|
||||
+ local_free_vars();
|
||||
+ YYABORT;
|
||||
+ }
|
||||
+ if (tmp) {
|
||||
+ format = master_strdup(tmp);
|
||||
+ if (!format) {
|
||||
+ master_error("memory allocation error");
|
||||
+ local_free_vars();
|
||||
+ YYABORT;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
| PATH COLON { master_notify($1); YYABORT; }
|
||||
| PATH OPTION { master_notify($2); YYABORT; }
|
||||
| PATH NILL { master_notify($2); YYABORT; }
|
||||
@@ -157,25 +197,89 @@ line:
|
||||
| COMMENT { YYABORT; }
|
||||
;
|
||||
|
||||
-map: PATH
|
||||
+mapspec: map
|
||||
+ {
|
||||
+ local_argc = tmp_argc;
|
||||
+ local_argv = tmp_argv;
|
||||
+ tmp_argc = 0;
|
||||
+ tmp_argv = NULL;
|
||||
+ }
|
||||
+ | map options
|
||||
+ {
|
||||
+ local_argc = tmp_argc;
|
||||
+ local_argv = tmp_argv;
|
||||
+ tmp_argc = 0;
|
||||
+ tmp_argv = NULL;
|
||||
+ }
|
||||
+ ;
|
||||
+
|
||||
+maplist: map
|
||||
+ {
|
||||
+ if (!add_multi_mapstr()) {
|
||||
+ master_error("memory allocation error");
|
||||
+ local_free_vars();
|
||||
+ YYABORT;
|
||||
+ }
|
||||
+ }
|
||||
+ | map options
|
||||
+ {
|
||||
+ if (!add_multi_mapstr()) {
|
||||
+ master_error("memory allocation error");
|
||||
+ local_free_vars();
|
||||
+ YYABORT;
|
||||
+ }
|
||||
+ }
|
||||
+ | maplist DDASH map
|
||||
{
|
||||
local_argc++;
|
||||
- local_argv = add_argv(local_argc, local_argv, $1);
|
||||
+ local_argv = add_argv(local_argc, local_argv, "--");
|
||||
if (!local_argv) {
|
||||
master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
}
|
||||
+ if (!add_multi_mapstr()) {
|
||||
+ master_error("memory allocation error");
|
||||
+ local_free_vars();
|
||||
+ YYABORT;
|
||||
+ }
|
||||
}
|
||||
- | MAPNAME
|
||||
+ | maplist DDASH map options
|
||||
{
|
||||
local_argc++;
|
||||
- local_argv = add_argv(local_argc, local_argv, $1);
|
||||
+ local_argv = add_argv(local_argc, local_argv, "--");
|
||||
if (!local_argv) {
|
||||
master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
}
|
||||
+ if (!add_multi_mapstr()) {
|
||||
+ master_error("memory allocation error");
|
||||
+ local_free_vars();
|
||||
+ YYABORT;
|
||||
+ }
|
||||
+ }
|
||||
+ ;
|
||||
+
|
||||
+map: PATH
|
||||
+ {
|
||||
+ tmp_argc++;
|
||||
+ tmp_argv = add_argv(tmp_argc, tmp_argv, $1);
|
||||
+ if (!tmp_argv) {
|
||||
+ master_error("memory allocation error");
|
||||
+ local_free_vars();
|
||||
+ YYABORT;
|
||||
+ }
|
||||
+ }
|
||||
+ | MAPNAME
|
||||
+ {
|
||||
+ tmp_argc++;
|
||||
+ tmp_argv = add_argv(tmp_argc, tmp_argv, $1);
|
||||
+ if (!tmp_argv) {
|
||||
+ master_error("memory allocation error");
|
||||
+ local_free_vars();
|
||||
+ YYABORT;
|
||||
+ }
|
||||
}
|
||||
| MAPHOSTS
|
||||
{
|
||||
@@ -200,9 +304,9 @@ map: PATH
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
}
|
||||
- local_argc++;
|
||||
- local_argv = add_argv(local_argc, local_argv, $1);
|
||||
- if (!local_argv) {
|
||||
+ tmp_argc++;
|
||||
+ tmp_argv = add_argv(tmp_argc, tmp_argv, $1);
|
||||
+ if (!tmp_argv) {
|
||||
master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
@@ -227,9 +331,9 @@ map: PATH
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
- local_argc++;
|
||||
- local_argv = add_argv(local_argc, local_argv, $3);
|
||||
- if (!local_argv) {
|
||||
+ tmp_argc++;
|
||||
+ tmp_argv = add_argv(tmp_argc, tmp_argv, $3);
|
||||
+ if (!tmp_argv) {
|
||||
master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
@@ -254,9 +358,9 @@ map: PATH
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
- local_argc++;
|
||||
- local_argv = add_argv(local_argc, local_argv, $3);
|
||||
- if (!local_argv) {
|
||||
+ tmp_argc++;
|
||||
+ tmp_argv = add_argv(tmp_argc, tmp_argv, $3);
|
||||
+ if (!tmp_argv) {
|
||||
master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
@@ -281,25 +385,25 @@ map: PATH
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
- local_argc++;
|
||||
- local_argv = add_argv(local_argc, local_argv, $3);
|
||||
- if (!local_argv) {
|
||||
+ tmp_argc++;
|
||||
+ tmp_argv = add_argv(tmp_argc, tmp_argv, $3);
|
||||
+ if (!tmp_argv) {
|
||||
master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
}
|
||||
/* Add back the type for lookup_ldap.c to handle ldaps */
|
||||
- if (*local_argv[0]) {
|
||||
- tmp = malloc(strlen(type) + strlen(local_argv[0]) + 2);
|
||||
+ if (*tmp_argv[0]) {
|
||||
+ tmp = malloc(strlen(type) + strlen(tmp_argv[0]) + 2);
|
||||
if (!tmp) {
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
}
|
||||
strcpy(tmp, type);
|
||||
strcat(tmp, ":");
|
||||
- strcat(tmp, local_argv[0]);
|
||||
- free(local_argv[0]);
|
||||
- local_argv[0] = tmp;
|
||||
+ strcat(tmp, tmp_argv[0]);
|
||||
+ free(tmp_argv[0]);
|
||||
+ tmp_argv[0] = tmp;
|
||||
}
|
||||
}
|
||||
;
|
||||
@@ -441,9 +545,9 @@ daemon_option: OPT_TIMEOUT NUMBER { timeout = $2; }
|
||||
|
||||
mount_option: OPTION
|
||||
{
|
||||
- local_argc++;
|
||||
- local_argv = add_argv(local_argc, local_argv, $1);
|
||||
- if (!local_argv) {
|
||||
+ tmp_argc++;
|
||||
+ tmp_argv = add_argv(tmp_argc, tmp_argv, $1);
|
||||
+ if (!tmp_argv) {
|
||||
master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
@@ -494,6 +598,8 @@ static void local_init_vars(void)
|
||||
debug = 0;
|
||||
timeout = -1;
|
||||
ghost = defaults_get_browse_mode();
|
||||
+ tmp_argv = NULL;
|
||||
+ tmp_argc = 0;
|
||||
local_argv = NULL;
|
||||
local_argc = 0;
|
||||
}
|
||||
@@ -509,8 +615,62 @@ static void local_free_vars(void)
|
||||
if (format)
|
||||
free(format);
|
||||
|
||||
- if (local_argv)
|
||||
+ if (local_argv) {
|
||||
free_argv(local_argc, (const char **) local_argv);
|
||||
+ local_argv = NULL;
|
||||
+ local_argc = 0;
|
||||
+ }
|
||||
+
|
||||
+ if (tmp_argv) {
|
||||
+ free_argv(tmp_argc, (const char **) tmp_argv);
|
||||
+ tmp_argv = NULL;
|
||||
+ tmp_argc = 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int add_multi_mapstr(void)
|
||||
+{
|
||||
+ /* We need the individual map types for a multi map */
|
||||
+ if (!type) {
|
||||
+ if (tmp_argc > 0 && *tmp_argv[0] == '/')
|
||||
+ type = strdup("file");
|
||||
+ else
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ if (format) {
|
||||
+ char *tmp = realloc(type, strlen(type) + strlen(format) + 2);
|
||||
+ if (!tmp)
|
||||
+ return 0;
|
||||
+ type = tmp;
|
||||
+ strcat(type, ",");
|
||||
+ strcat(type, format);
|
||||
+ free(format);
|
||||
+ format = NULL;
|
||||
+ }
|
||||
+
|
||||
+ local_argc++;
|
||||
+ local_argv = add_argv(local_argc, local_argv, type);
|
||||
+ if (!local_argv) {
|
||||
+ free(type);
|
||||
+ type = NULL;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ local_argv = append_argv(local_argc, local_argv, tmp_argc, tmp_argv);
|
||||
+ if (!local_argv) {
|
||||
+ free(type);
|
||||
+ type = NULL;
|
||||
+ return 0;
|
||||
+ }
|
||||
+ local_argc += tmp_argc;
|
||||
+
|
||||
+ tmp_argc = 0;
|
||||
+ tmp_argv = NULL;
|
||||
+ free(type);
|
||||
+ type = NULL;
|
||||
+
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
void master_init_scan(void)
|
||||
diff --git a/lib/master_tok.l b/lib/master_tok.l
|
||||
index ee2a4eb..0548de1 100644
|
||||
--- a/lib/master_tok.l
|
||||
+++ b/lib/master_tok.l
|
||||
@@ -27,6 +27,7 @@ static void master_echo(void); /* forward definition */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
+#include <ctype.h>
|
||||
#include "master_parse.tab.h"
|
||||
|
||||
/*
|
||||
@@ -110,7 +111,9 @@ DNATTRSTR {AT_CN}|{AT_NMN}|{AT_AMN}|{AT_OU}|{AT_DC}|{AT_O}|{AT_C}
|
||||
DNNAMESTR ([[:alnum:]_.\-]+)
|
||||
|
||||
INTMAP (-hosts|-null)
|
||||
-MTYPE ((file|program|yp|nis|nisplus|ldap|ldaps|hesiod|userdir)(,(sun|hesiod))?)
|
||||
+MULTI ((multi)(,(sun|hesiod))?[\:]?{OPTWS})
|
||||
+MULTISEP ([\-]{2}[[:blank:]]+)
|
||||
+MTYPE ((file|program|yp|nis|nisplus|ldap|ldaps|hesiod|userdir)(,(sun|hesiod))?)
|
||||
|
||||
|
||||
OPTTOUT (-t{OPTWS}|-t{OPTWS}={OPTWS}|--timeout{OPTWS}|--timeout{OPTWS}={OPTWS})
|
||||
@@ -184,11 +187,18 @@ OPTTOUT (-t{OPTWS}|-t{OPTWS}={OPTWS}|--timeout{OPTWS}|--timeout{OPTWS}={OPTWS})
|
||||
<MAPSTR>{
|
||||
{OPTWS}\\\n{OPTWS} {}
|
||||
|
||||
+ {MULTI} {
|
||||
+ strcpy(master_lval.strtype, master_text);
|
||||
+ return(MULTITYPE);
|
||||
+ }
|
||||
+
|
||||
{MTYPE}/":" {
|
||||
strcpy(master_lval.strtype, master_text);
|
||||
return(MAPTYPE);
|
||||
}
|
||||
|
||||
+ {MULTISEP} { return(DDASH); }
|
||||
+
|
||||
":" { return(COLON); }
|
||||
|
||||
"-hosts" {
|
||||
@@ -298,6 +308,11 @@ OPTTOUT (-t{OPTWS}|-t{OPTWS}={OPTWS}|--timeout{OPTWS}|--timeout{OPTWS}={OPTWS})
|
||||
<OPTSTR>{
|
||||
{OPTWS}\\\n{OPTWS} {}
|
||||
|
||||
+ {MULTISEP} {
|
||||
+ BEGIN(MAPSTR);
|
||||
+ return(DDASH);
|
||||
+ }
|
||||
+
|
||||
{OPTTOUT} { return(OPT_TIMEOUT); }
|
||||
|
||||
{NUMBER} {
|
||||
diff --git a/modules/lookup_multi.c b/modules/lookup_multi.c
|
||||
index 00ab28e..38ca36c 100644
|
||||
--- a/modules/lookup_multi.c
|
||||
+++ b/modules/lookup_multi.c
|
||||
@@ -45,7 +45,7 @@ int lookup_init(const char *my_mapfmt, int argc, const char *const *argv, void *
|
||||
struct lookup_context *ctxt;
|
||||
char buf[MAX_ERR_BUF];
|
||||
char *map, *mapfmt;
|
||||
- int i, j, an;
|
||||
+ int i, an;
|
||||
char *estr;
|
||||
|
||||
ctxt = malloc(sizeof(struct lookup_context));
|
||||
@@ -73,7 +73,7 @@ int lookup_init(const char *my_mapfmt, int argc, const char *const *argv, void *
|
||||
|
||||
memcpy(ctxt->argl, argv, (argc + 1) * sizeof(const char *));
|
||||
|
||||
- for (i = j = an = 0; ctxt->argl[an]; an++) {
|
||||
+ for (i = an = 0; ctxt->argl[an]; an++) {
|
||||
if (ctxt->m[i].argc == 0) {
|
||||
ctxt->m[i].argv = &ctxt->argl[an];
|
||||
}
|
||||
@@ -100,9 +100,12 @@ int lookup_init(const char *my_mapfmt, int argc, const char *const *argv, void *
|
||||
if (!(ctxt->m[i].mod = open_lookup(map, MODPREFIX,
|
||||
mapfmt ? mapfmt : my_mapfmt,
|
||||
ctxt->m[i].argc - 1,
|
||||
- ctxt->m[i].argv + 1)))
|
||||
+ ctxt->m[i].argv + 1))) {
|
||||
error(LOGOPT_ANY, MODPREFIX "error opening module");
|
||||
+ free(map);
|
||||
goto error_out;
|
||||
+ }
|
||||
+ free(map);
|
||||
}
|
||||
|
||||
*context = ctxt;
|
||||
458
autofs-5.0.2-add-multi-nsswitch-lookup.patch
Normal file
458
autofs-5.0.2-add-multi-nsswitch-lookup.patch
Normal file
@ -0,0 +1,458 @@
|
||||
diff --git a/lib/master_parse.y b/lib/master_parse.y
|
||||
index f9cba05..ab2895d 100644
|
||||
--- a/lib/master_parse.y
|
||||
+++ b/lib/master_parse.y
|
||||
@@ -45,6 +45,7 @@ extern void master_set_scan_buffer(const char *);
|
||||
static char *master_strdup(char *);
|
||||
static void local_init_vars(void);
|
||||
static void local_free_vars(void);
|
||||
+static void trim_maptype(char *);
|
||||
static int add_multi_mapstr(void);
|
||||
|
||||
static int master_error(const char *s);
|
||||
@@ -141,21 +142,9 @@ line:
|
||||
}
|
||||
| PATH MULTITYPE maplist
|
||||
{
|
||||
- char *tmp;
|
||||
-
|
||||
- tmp = strchr($2, ':');
|
||||
- if (tmp)
|
||||
- *tmp = '\0';
|
||||
- else {
|
||||
- int len = strlen($2);
|
||||
- while (len-- && isblank($2[len]))
|
||||
- $2[len] = '\0';
|
||||
- if (len < 4) {
|
||||
- master_notify($2);
|
||||
- local_free_vars();
|
||||
- YYABORT;
|
||||
- }
|
||||
- }
|
||||
+ char *tmp = NULL;
|
||||
+
|
||||
+ trim_maptype($2);
|
||||
|
||||
path = master_strdup($1);
|
||||
if (!path) {
|
||||
@@ -312,81 +301,93 @@ map: PATH
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
- | MAPTYPE COLON PATH
|
||||
+ | MAPTYPE PATH
|
||||
{
|
||||
char *tmp = NULL;
|
||||
|
||||
+ trim_maptype($1);
|
||||
+
|
||||
if ((tmp = strchr($1, ',')))
|
||||
*tmp++ = '\0';
|
||||
|
||||
type = master_strdup($1);
|
||||
if (!type) {
|
||||
+ master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
}
|
||||
if (tmp) {
|
||||
format = master_strdup(tmp);
|
||||
if (!format) {
|
||||
+ master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
tmp_argc++;
|
||||
- tmp_argv = add_argv(tmp_argc, tmp_argv, $3);
|
||||
+ tmp_argv = add_argv(tmp_argc, tmp_argv, $2);
|
||||
if (!tmp_argv) {
|
||||
master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
- | MAPTYPE COLON MAPNAME
|
||||
+ | MAPTYPE MAPNAME
|
||||
{
|
||||
char *tmp = NULL;
|
||||
|
||||
+ trim_maptype($1);
|
||||
+
|
||||
if ((tmp = strchr($1, ',')))
|
||||
*tmp++ = '\0';
|
||||
|
||||
type = master_strdup($1);
|
||||
if (!type) {
|
||||
+ master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
}
|
||||
if (tmp) {
|
||||
format = master_strdup(tmp);
|
||||
if (!format) {
|
||||
+ master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
tmp_argc++;
|
||||
- tmp_argv = add_argv(tmp_argc, tmp_argv, $3);
|
||||
+ tmp_argv = add_argv(tmp_argc, tmp_argv, $2);
|
||||
if (!tmp_argv) {
|
||||
master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
- | MAPTYPE COLON dn
|
||||
+ | MAPTYPE dn
|
||||
{
|
||||
char *tmp = NULL;
|
||||
|
||||
+ trim_maptype($1);
|
||||
+
|
||||
if ((tmp = strchr($1, ',')))
|
||||
*tmp++ = '\0';
|
||||
|
||||
type = master_strdup($1);
|
||||
if (!type) {
|
||||
+ master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
}
|
||||
if (tmp) {
|
||||
format = master_strdup(tmp);
|
||||
if (!format) {
|
||||
+ master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
tmp_argc++;
|
||||
- tmp_argv = add_argv(tmp_argc, tmp_argv, $3);
|
||||
+ tmp_argv = add_argv(tmp_argc, tmp_argv, $2);
|
||||
if (!tmp_argv) {
|
||||
master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
@@ -396,6 +397,7 @@ map: PATH
|
||||
if (*tmp_argv[0]) {
|
||||
tmp = malloc(strlen(type) + strlen(tmp_argv[0]) + 2);
|
||||
if (!tmp) {
|
||||
+ master_error("memory allocation error");
|
||||
local_free_vars();
|
||||
YYABORT;
|
||||
}
|
||||
@@ -628,33 +630,47 @@ static void local_free_vars(void)
|
||||
}
|
||||
}
|
||||
|
||||
-static int add_multi_mapstr(void)
|
||||
+static void trim_maptype(char *type)
|
||||
{
|
||||
- /* We need the individual map types for a multi map */
|
||||
- if (!type) {
|
||||
- if (tmp_argc > 0 && *tmp_argv[0] == '/')
|
||||
- type = strdup("file");
|
||||
- else
|
||||
- return 0;
|
||||
+ char *tmp;
|
||||
+
|
||||
+ tmp = strchr(type, ':');
|
||||
+ if (tmp)
|
||||
+ *tmp = '\0';
|
||||
+ else {
|
||||
+ int len = strlen(type);
|
||||
+ while (len-- && isblank(type[len]))
|
||||
+ type[len] = '\0';
|
||||
}
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+static int add_multi_mapstr(void)
|
||||
+{
|
||||
+ if (type) {
|
||||
+ /* If type given and format is non-null add it back */
|
||||
+ if (format) {
|
||||
+ int len = strlen(type) + strlen(format) + 2;
|
||||
+ char *tmp = realloc(type, len);
|
||||
+ if (!tmp)
|
||||
+ return 0;
|
||||
+ type = tmp;
|
||||
+ strcat(type, ",");
|
||||
+ strcat(type, format);
|
||||
+ free(format);
|
||||
+ format = NULL;
|
||||
+ }
|
||||
|
||||
- if (format) {
|
||||
- char *tmp = realloc(type, strlen(type) + strlen(format) + 2);
|
||||
- if (!tmp)
|
||||
+ local_argc++;
|
||||
+ local_argv = add_argv(local_argc, local_argv, type);
|
||||
+ if (!local_argv) {
|
||||
+ free(type);
|
||||
+ type = NULL;
|
||||
return 0;
|
||||
- type = tmp;
|
||||
- strcat(type, ",");
|
||||
- strcat(type, format);
|
||||
- free(format);
|
||||
- format = NULL;
|
||||
- }
|
||||
+ }
|
||||
|
||||
- local_argc++;
|
||||
- local_argv = add_argv(local_argc, local_argv, type);
|
||||
- if (!local_argv) {
|
||||
free(type);
|
||||
type = NULL;
|
||||
- return 0;
|
||||
}
|
||||
|
||||
local_argv = append_argv(local_argc, local_argv, tmp_argc, tmp_argv);
|
||||
@@ -667,8 +683,6 @@ static int add_multi_mapstr(void)
|
||||
|
||||
tmp_argc = 0;
|
||||
tmp_argv = NULL;
|
||||
- free(type);
|
||||
- type = NULL;
|
||||
|
||||
return 1;
|
||||
}
|
||||
diff --git a/lib/master_tok.l b/lib/master_tok.l
|
||||
index 0548de1..9bfeefa 100644
|
||||
--- a/lib/master_tok.l
|
||||
+++ b/lib/master_tok.l
|
||||
@@ -111,9 +111,9 @@ DNATTRSTR {AT_CN}|{AT_NMN}|{AT_AMN}|{AT_OU}|{AT_DC}|{AT_O}|{AT_C}
|
||||
DNNAMESTR ([[:alnum:]_.\-]+)
|
||||
|
||||
INTMAP (-hosts|-null)
|
||||
-MULTI ((multi)(,(sun|hesiod))?[\:]?{OPTWS})
|
||||
+MULTI ((multi)(,(sun|hesiod))?(:{OPTWS}|{WS}))
|
||||
MULTISEP ([\-]{2}[[:blank:]]+)
|
||||
-MTYPE ((file|program|yp|nis|nisplus|ldap|ldaps|hesiod|userdir)(,(sun|hesiod))?)
|
||||
+MTYPE ((file|program|yp|nis|nisplus|ldap|ldaps|hesiod|userdir)(,(sun|hesiod))?(:{OPTWS}|{WS}))
|
||||
|
||||
|
||||
OPTTOUT (-t{OPTWS}|-t{OPTWS}={OPTWS}|--timeout{OPTWS}|--timeout{OPTWS}={OPTWS})
|
||||
@@ -192,7 +192,7 @@ OPTTOUT (-t{OPTWS}|-t{OPTWS}={OPTWS}|--timeout{OPTWS}|--timeout{OPTWS}={OPTWS})
|
||||
return(MULTITYPE);
|
||||
}
|
||||
|
||||
- {MTYPE}/":" {
|
||||
+ {MTYPE} {
|
||||
strcpy(master_lval.strtype, master_text);
|
||||
return(MAPTYPE);
|
||||
}
|
||||
diff --git a/modules/lookup_multi.c b/modules/lookup_multi.c
|
||||
index 38ca36c..8fa94ae 100644
|
||||
--- a/modules/lookup_multi.c
|
||||
+++ b/modules/lookup_multi.c
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
+#include <sys/stat.h>
|
||||
|
||||
#define MODULE_LOOKUP
|
||||
#include "automount.h"
|
||||
@@ -28,7 +29,7 @@
|
||||
|
||||
struct module_info {
|
||||
int argc;
|
||||
- const char *const *argv;
|
||||
+ const char **argv;
|
||||
struct lookup_mod *mod;
|
||||
};
|
||||
|
||||
@@ -40,11 +41,105 @@ struct lookup_context {
|
||||
|
||||
int lookup_version = AUTOFS_LOOKUP_VERSION; /* Required by protocol */
|
||||
|
||||
+static struct lookup_mod *nss_open_lookup(const char *format, int argc, const char **argv)
|
||||
+{
|
||||
+ struct list_head nsslist;
|
||||
+ struct list_head *head, *p;
|
||||
+ struct lookup_mod *mod;
|
||||
+ char buf[MAX_ERR_BUF], *estr;
|
||||
+
|
||||
+ if (!argv || !argv[0])
|
||||
+ return NULL;
|
||||
+
|
||||
+ if (*argv[0] == '/')
|
||||
+ return open_lookup("file", MODPREFIX, format, argc, argv);
|
||||
+
|
||||
+ if (!strncmp(argv[0], "file", 4) ||
|
||||
+ !strncmp(argv[0], "yp", 2) ||
|
||||
+ !strncmp(argv[0], "nisplus", 7) ||
|
||||
+ !strncmp(argv[0], "nis", 3) ||
|
||||
+ !strncmp(argv[0], "ldaps", 5) ||
|
||||
+ !strncmp(argv[0], "ldap", 4)) {
|
||||
+ const char *fmt = strchr(argv[0], ',');
|
||||
+ if (fmt)
|
||||
+ fmt++;
|
||||
+ else
|
||||
+ fmt = format;
|
||||
+ return open_lookup(argv[0], MODPREFIX, fmt, argc -1, argv + 1);
|
||||
+ }
|
||||
+
|
||||
+ INIT_LIST_HEAD(&nsslist);
|
||||
+
|
||||
+ if (nsswitch_parse(&nsslist)) {
|
||||
+ if (!list_empty(&nsslist))
|
||||
+ free_sources(&nsslist);
|
||||
+ error(LOGOPT_ANY, "can't to read name service switch config.");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ head = &nsslist;
|
||||
+ list_for_each(p, head) {
|
||||
+ struct nss_source *this;
|
||||
+
|
||||
+ this = list_entry(p, struct nss_source, list);
|
||||
+
|
||||
+ if (!strcmp(this->source, "files")) {
|
||||
+ char src_file[] = "file";
|
||||
+ char src_prog[] = "program";
|
||||
+ struct stat st;
|
||||
+ char *type, *path, *save_argv0;
|
||||
+
|
||||
+ path = malloc(strlen(AUTOFS_MAP_DIR) + strlen(argv[0]) + 2);
|
||||
+ if (!path) {
|
||||
+ estr = strerror_r(errno, buf, MAX_ERR_BUF);
|
||||
+ crit(LOGOPT_ANY, MODPREFIX "error: %s", estr);
|
||||
+ free_sources(&nsslist);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ strcpy(path, AUTOFS_MAP_DIR);
|
||||
+ strcat(path, "/");
|
||||
+ strcat(path, argv[0]);
|
||||
+
|
||||
+ if (stat(path, &st) == -1 || !S_ISREG(st.st_mode)) {
|
||||
+ free(path);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (st.st_mode & __S_IEXEC)
|
||||
+ type = src_prog;
|
||||
+ else
|
||||
+ type = src_file;
|
||||
+
|
||||
+ save_argv0 = (char *) argv[0];
|
||||
+ argv[0] = path;
|
||||
+
|
||||
+ mod = open_lookup(type, MODPREFIX, format, argc, argv);
|
||||
+ if (mod) {
|
||||
+ free_sources(&nsslist);
|
||||
+ free(save_argv0);
|
||||
+ return mod;
|
||||
+ }
|
||||
+
|
||||
+ argv[0] = save_argv0;
|
||||
+ free(path);
|
||||
+ }
|
||||
+
|
||||
+ mod = open_lookup(this->source, MODPREFIX, format, argc, argv);
|
||||
+ if (mod) {
|
||||
+ free_sources(&nsslist);
|
||||
+ return mod;
|
||||
+ }
|
||||
+ }
|
||||
+ free_sources(&nsslist);
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
int lookup_init(const char *my_mapfmt, int argc, const char *const *argv, void **context)
|
||||
{
|
||||
struct lookup_context *ctxt;
|
||||
char buf[MAX_ERR_BUF];
|
||||
- char *map, *mapfmt;
|
||||
+ char **args;
|
||||
int i, an;
|
||||
char *estr;
|
||||
|
||||
@@ -73,39 +168,42 @@ int lookup_init(const char *my_mapfmt, int argc, const char *const *argv, void *
|
||||
|
||||
memcpy(ctxt->argl, argv, (argc + 1) * sizeof(const char *));
|
||||
|
||||
+ args = NULL;
|
||||
for (i = an = 0; ctxt->argl[an]; an++) {
|
||||
if (ctxt->m[i].argc == 0) {
|
||||
- ctxt->m[i].argv = &ctxt->argl[an];
|
||||
+ args = (char **) &ctxt->argl[an];
|
||||
}
|
||||
if (!strcmp(ctxt->argl[an], "--")) {
|
||||
ctxt->argl[an] = NULL;
|
||||
+ if (!args) {
|
||||
+ crit(LOGOPT_ANY,
|
||||
+ MODPREFIX "error assigning map args");
|
||||
+ goto error_out;
|
||||
+ }
|
||||
+ ctxt->m[i].argv = copy_argv(ctxt->m[i].argc, (const char **) args);
|
||||
+ if (!ctxt->m[i].argv)
|
||||
+ goto nomem;
|
||||
+ args = NULL;
|
||||
i++;
|
||||
} else {
|
||||
ctxt->m[i].argc++;
|
||||
}
|
||||
}
|
||||
|
||||
- for (i = 0; i < ctxt->n; i++) {
|
||||
- if (!ctxt->m[i].argv[0]) {
|
||||
- crit(LOGOPT_ANY, MODPREFIX "missing module name");
|
||||
- goto error_out;
|
||||
- }
|
||||
- map = strdup(ctxt->m[i].argv[0]);
|
||||
- if (!map)
|
||||
+ /* catch the last one */
|
||||
+ if (args) {
|
||||
+ ctxt->m[i].argv = copy_argv(ctxt->m[i].argc, (const char **) args);
|
||||
+ if (!ctxt->m[i].argv)
|
||||
goto nomem;
|
||||
+ }
|
||||
|
||||
- if ((mapfmt = strchr(map, ',')))
|
||||
- *(mapfmt++) = '\0';
|
||||
-
|
||||
- if (!(ctxt->m[i].mod = open_lookup(map, MODPREFIX,
|
||||
- mapfmt ? mapfmt : my_mapfmt,
|
||||
- ctxt->m[i].argc - 1,
|
||||
- ctxt->m[i].argv + 1))) {
|
||||
+ for (i = 0; i < ctxt->n; i++) {
|
||||
+ ctxt->m[i].mod = nss_open_lookup(my_mapfmt,
|
||||
+ ctxt->m[i].argc, ctxt->m[i].argv);
|
||||
+ if (!ctxt->m[i].mod) {
|
||||
error(LOGOPT_ANY, MODPREFIX "error opening module");
|
||||
- free(map);
|
||||
goto error_out;
|
||||
}
|
||||
- free(map);
|
||||
}
|
||||
|
||||
*context = ctxt;
|
||||
@@ -116,9 +214,12 @@ nomem:
|
||||
crit(LOGOPT_ANY, MODPREFIX "error: %s", estr);
|
||||
error_out:
|
||||
if (ctxt) {
|
||||
- for (i = 0; i < ctxt->n; i++)
|
||||
+ for (i = 0; i < ctxt->n; i++) {
|
||||
if (ctxt->m[i].mod)
|
||||
close_lookup(ctxt->m[i].mod);
|
||||
+ if (ctxt->m[i].argv)
|
||||
+ free_argv(ctxt->m[i].argc, ctxt->m[i].argv);
|
||||
+ }
|
||||
if (ctxt->m)
|
||||
free(ctxt->m);
|
||||
if (ctxt->argl)
|
||||
@@ -188,6 +289,8 @@ int lookup_done(void *context)
|
||||
for (i = 0; i < ctxt->n; i++) {
|
||||
if (ctxt->m[i].mod)
|
||||
rv = rv || close_lookup(ctxt->m[i].mod);
|
||||
+ if (ctxt->m[i].argv)
|
||||
+ free_argv(ctxt->m[i].argc, ctxt->m[i].argv);
|
||||
}
|
||||
free(ctxt->argl);
|
||||
free(ctxt->m);
|
||||
10
autofs.spec
10
autofs.spec
@ -4,7 +4,7 @@
|
||||
Summary: A tool for automatically mounting and unmounting filesystems
|
||||
Name: autofs
|
||||
Version: 5.0.2
|
||||
Release: 2
|
||||
Release: 3
|
||||
Epoch: 1
|
||||
License: GPL
|
||||
Group: System Environment/Daemons
|
||||
@ -12,6 +12,8 @@ URL: http://wiki.autofs.net/
|
||||
Source: ftp://ftp.kernel.org/pub/linux/daemons/autofs/v5/autofs-%{version}.tar.bz2
|
||||
Patch0: autofs-5.0.2-add-krb5-include.patch
|
||||
Patch1: autofs-5.0.2-bad-proto-init.patch
|
||||
Patch2: autofs-5.0.2-add-missing-multi-support.patch
|
||||
Patch3: autofs-5.0.2-add-multi-nsswitch-lookup.patch
|
||||
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: autoconf, hesiod-devel, openldap-devel, bison, flex, libxml2-devel, cyrus-sasl-devel, openssl-devel
|
||||
Conflicts: kernel < 2.6.17
|
||||
@ -55,6 +57,8 @@ inkludera nätfilsystem, CD-ROM, floppydiskar, och så vidare.
|
||||
echo %{version}-%{release} > .version
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
|
||||
%build
|
||||
#CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir}
|
||||
@ -107,6 +111,10 @@ fi
|
||||
%{_libdir}/autofs/
|
||||
|
||||
%changelog
|
||||
* Mon Jun 25 2007 Ian Kent <ikent@redhat.com> - 5.0.2-3
|
||||
- add missing "multi" map support.
|
||||
- add multi map nsswitch lookup.
|
||||
|
||||
* Wed Jun 20 2007 Ian Kent <ikent@redhat.com> - 5.0.2-2
|
||||
- include krb5.h in lookup_ldap.h (some openssl doesn't implicitly include it).
|
||||
- correct initialization of local var in parse_server_string.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user