~ubuntu-branches/ubuntu/precise/autofs5/precise

« back to all changes in this revision

Viewing changes to .pc/autofs-5.0.5-use-weight-only-for-server-selection.patch/lib/master_parse.y

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-07-03 14:35:46 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110703143546-nej26krjij0rf792
Tags: 5.0.6-0ubuntu1
* New upstream release:
  - Dropped upstream patches 
  - Refreshed debian/patches/17ld.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%{
2
 
/* ----------------------------------------------------------------------- *
3
 
 *   
4
 
 *  master_parser.y - master map buffer parser.
5
 
 *
6
 
 *   Copyright 2006 Ian Kent <raven@themaw.net>
7
 
 *
8
 
 *   This program is free software; you can redistribute it and/or modify
9
 
 *   it under the terms of the GNU General Public License as published by
10
 
 *   the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
11
 
 *   USA; either version 2 of the License, or (at your option) any later
12
 
 *   version.
13
 
 *   
14
 
 *   This program is distributed in the hope that it will be useful,
15
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
 *   GNU General Public License for more details.
18
 
 *
19
 
 * ----------------------------------------------------------------------- */
20
 
 
21
 
#include <stdio.h>
22
 
#include <string.h>
23
 
#include <stdlib.h>
24
 
#include <stdarg.h>
25
 
#include <ctype.h>
26
 
#include <sys/ioctl.h>
27
 
 
28
 
#include "automount.h"
29
 
#include "master.h"
30
 
 
31
 
#define MAX_ERR_LEN     512
32
 
 
33
 
extern struct master *master_list;
34
 
 
35
 
char **add_argv(int, char **, char *);
36
 
const char **copy_argv(int, const char **);
37
 
int free_argv(int, const char **);
38
 
 
39
 
extern FILE *master_in;
40
 
extern char *master_text;
41
 
extern int master_lex(void);
42
 
extern int master_lineno;
43
 
extern void master_set_scan_buffer(const char *);
44
 
 
45
 
static char *master_strdup(char *);
46
 
static void local_init_vars(void);
47
 
static void local_free_vars(void);
48
 
static void trim_maptype(char *);
49
 
static int add_multi_mapstr(void);
50
 
 
51
 
static int master_error(const char *s);
52
 
static int master_notify(const char *s);
53
 
static int master_msg(const char *s);
54
 
 
55
 
static char *path;
56
 
static char *type;
57
 
static char *format;
58
 
static long timeout;
59
 
static long negative_timeout;
60
 
static unsigned ghost;
61
 
extern unsigned global_random_selection;
62
 
static unsigned random_selection;
63
 
static char **tmp_argv;
64
 
static int tmp_argc;
65
 
static char **local_argv;
66
 
static int local_argc;
67
 
 
68
 
static char errstr[MAX_ERR_LEN];
69
 
 
70
 
static unsigned int verbose;
71
 
static unsigned int debug;
72
 
 
73
 
static int lineno;
74
 
 
75
 
#define YYDEBUG 0
76
 
 
77
 
#ifndef YYENABLE_NLS
78
 
#define YYENABLE_NLS 0
79
 
#endif
80
 
#ifndef YYLTYPE_IS_TRIVIAL
81
 
#define YYLTYPE_IS_TRIVIAL 0
82
 
#endif
83
 
 
84
 
#if YYDEBUG
85
 
static int master_fprintf(FILE *, char *, ...);
86
 
#undef YYFPRINTF
87
 
#define YYFPRINTF master_fprintf
88
 
#endif
89
 
 
90
 
%}
91
 
 
92
 
%union {
93
 
        char strtype[2048];
94
 
        int inttype;
95
 
        long longtype;
96
 
}
97
 
 
98
 
%token COMMENT
99
 
%token MAP
100
 
%token OPT_TIMEOUT OPT_NTIMEOUT OPT_NOGHOST OPT_GHOST OPT_VERBOSE
101
 
%token OPT_DEBUG OPT_RANDOM
102
 
%token COLON COMMA NL DDASH
103
 
%type <strtype> map
104
 
%type <strtype> options
105
 
%type <strtype> dn
106
 
%type <strtype> dnattrs
107
 
%type <strtype> dnattr
108
 
%type <strtype> option
109
 
%type <strtype> daemon_option
110
 
%type <strtype> mount_option
111
 
%token <strtype> PATH
112
 
%token <strtype> QUOTE
113
 
%token <strtype> NILL
114
 
%token <strtype> SPACE
115
 
%token <strtype> EQUAL
116
 
%token <strtype> MULTITYPE
117
 
%token <strtype> MAPTYPE
118
 
%token <strtype> DNSERVER
119
 
%token <strtype> DNATTR
120
 
%token <strtype> DNNAME
121
 
%token <strtype> MAPHOSTS
122
 
%token <strtype> MAPNULL
123
 
%token <strtype> MAPXFN
124
 
%token <strtype> MAPNAME
125
 
%token <longtype> NUMBER
126
 
%token <strtype> OPTION
127
 
 
128
 
%start file
129
 
 
130
 
%%
131
 
 
132
 
file: {
133
 
                master_lineno = 0;
134
 
#if YYDEBUG != 0
135
 
                master_debug = YYDEBUG;
136
 
#endif
137
 
        } line
138
 
        ;
139
 
 
140
 
line:
141
 
        | PATH mapspec
142
 
        {
143
 
                path = master_strdup($1);
144
 
                if (!path) {
145
 
                        local_free_vars();
146
 
                        YYABORT;
147
 
                }
148
 
        }
149
 
        | PATH MULTITYPE maplist
150
 
        {
151
 
                char *tmp = NULL;
152
 
 
153
 
                trim_maptype($2);
154
 
 
155
 
                path = master_strdup($1);
156
 
                if (!path) {
157
 
                        master_error("memory allocation error");
158
 
                        local_free_vars();
159
 
                        YYABORT;
160
 
                }
161
 
 
162
 
                if ((tmp = strchr($2, ',')))
163
 
                        *tmp++ = '\0';
164
 
 
165
 
                type = master_strdup($2);
166
 
                if (!type) {
167
 
                        master_error("memory allocation error");
168
 
                        local_free_vars();
169
 
                        YYABORT;
170
 
                }
171
 
                if (tmp) {
172
 
                        format = master_strdup(tmp);
173
 
                        if (!format) {
174
 
                                master_error("memory allocation error");
175
 
                                local_free_vars();
176
 
                                YYABORT;
177
 
                        }
178
 
                }
179
 
        }
180
 
        | PATH COLON { master_notify($1); YYABORT; }
181
 
        | PATH OPTION { master_notify($2); YYABORT; }
182
 
        | PATH NILL { master_notify($2); YYABORT; }
183
 
        | PATH OPT_RANDOM { master_notify($1); YYABORT; }
184
 
        | PATH OPT_DEBUG { master_notify($1); YYABORT; }
185
 
        | PATH OPT_TIMEOUT { master_notify($1); YYABORT; }
186
 
        | PATH OPT_GHOST { master_notify($1); YYABORT; }
187
 
        | PATH OPT_NOGHOST { master_notify($1); YYABORT; }
188
 
        | PATH OPT_VERBOSE { master_notify($1); YYABORT; }
189
 
        | PATH { master_notify($1); YYABORT; }
190
 
        | QUOTE { master_notify($1); YYABORT; }
191
 
        | OPTION { master_notify($1); YYABORT; }
192
 
        | NILL { master_notify($1); YYABORT; }
193
 
        | COMMENT { YYABORT; }
194
 
        ;
195
 
 
196
 
mapspec: map
197
 
        {
198
 
                local_argc = tmp_argc;
199
 
                local_argv = tmp_argv;
200
 
                tmp_argc = 0;
201
 
                tmp_argv = NULL;
202
 
        }
203
 
        | map options
204
 
        {
205
 
                local_argc = tmp_argc;
206
 
                local_argv = tmp_argv;
207
 
                tmp_argc = 0;
208
 
                tmp_argv = NULL;
209
 
        }
210
 
        ;
211
 
 
212
 
maplist: map
213
 
        {
214
 
                if (!add_multi_mapstr()) {
215
 
                        master_error("memory allocation error");
216
 
                        local_free_vars();
217
 
                        YYABORT;
218
 
                }
219
 
        }
220
 
        | map options
221
 
        {
222
 
                if (!add_multi_mapstr()) {
223
 
                        master_error("memory allocation error");
224
 
                        local_free_vars();
225
 
                        YYABORT;
226
 
                }
227
 
        }
228
 
        | maplist DDASH map
229
 
        {
230
 
                local_argc++;
231
 
                local_argv = add_argv(local_argc, local_argv, "--");
232
 
                if (!local_argv) {
233
 
                        master_error("memory allocation error");
234
 
                        local_free_vars();
235
 
                        YYABORT;
236
 
                }
237
 
                if (!add_multi_mapstr()) {
238
 
                        master_error("memory allocation error");
239
 
                        local_free_vars();
240
 
                        YYABORT;
241
 
                }
242
 
        }
243
 
        | maplist DDASH map options
244
 
        {
245
 
                local_argc++;
246
 
                local_argv = add_argv(local_argc, local_argv, "--");
247
 
                if (!local_argv) {
248
 
                        master_error("memory allocation error");
249
 
                        local_free_vars();
250
 
                        YYABORT;
251
 
                }
252
 
                if (!add_multi_mapstr()) {
253
 
                        master_error("memory allocation error");
254
 
                        local_free_vars();
255
 
                        YYABORT;
256
 
                }
257
 
        }
258
 
        ;
259
 
 
260
 
map:    PATH
261
 
        {
262
 
                tmp_argc++;
263
 
                tmp_argv = add_argv(tmp_argc, tmp_argv, $1);
264
 
                if (!tmp_argv) {
265
 
                        master_error("memory allocation error");
266
 
                        local_free_vars();
267
 
                        YYABORT;
268
 
                }
269
 
        }
270
 
        | MAPNAME
271
 
        {
272
 
                tmp_argc++;
273
 
                tmp_argv = add_argv(tmp_argc, tmp_argv, $1);
274
 
                if (!tmp_argv) {
275
 
                        master_error("memory allocation error");
276
 
                        local_free_vars();
277
 
                        YYABORT;
278
 
                }
279
 
        }
280
 
        | MAPHOSTS
281
 
        {
282
 
                type = master_strdup($1 + 1);
283
 
                if (!type) {
284
 
                        local_free_vars();
285
 
                        YYABORT;
286
 
                }
287
 
        }
288
 
        | MAPXFN
289
 
        {
290
 
                master_notify($1);
291
 
                master_msg("X/Open Federated Naming service not supported");
292
 
                YYABORT;
293
 
        }
294
 
        | MAPNULL
295
 
        {
296
 
                type = master_strdup($1 + 1);
297
 
                if (!type) {
298
 
                        local_free_vars();
299
 
                        YYABORT;
300
 
                }
301
 
        }
302
 
        | dnattrs
303
 
        {
304
 
                type = master_strdup("ldap");
305
 
                if (!type) {
306
 
                        local_free_vars();
307
 
                        YYABORT;
308
 
                }
309
 
                tmp_argc++;
310
 
                tmp_argv = add_argv(tmp_argc, tmp_argv, $1);
311
 
                if (!tmp_argv) {
312
 
                        master_error("memory allocation error");
313
 
                        local_free_vars();
314
 
                        YYABORT;
315
 
                }
316
 
        }
317
 
        | MAPTYPE PATH
318
 
        {
319
 
                char *tmp = NULL;
320
 
 
321
 
                trim_maptype($1);
322
 
 
323
 
                if ((tmp = strchr($1, ',')))
324
 
                        *tmp++ = '\0';
325
 
 
326
 
                type = master_strdup($1);
327
 
                if (!type) {
328
 
                        master_error("memory allocation error");
329
 
                        local_free_vars();
330
 
                        YYABORT;
331
 
                }
332
 
                if (tmp) {
333
 
                        format = master_strdup(tmp);
334
 
                        if (!format) {
335
 
                                master_error("memory allocation error");
336
 
                                local_free_vars();
337
 
                                YYABORT;
338
 
                        }
339
 
                }
340
 
                tmp_argc++;
341
 
                tmp_argv = add_argv(tmp_argc, tmp_argv, $2);
342
 
                if (!tmp_argv) {
343
 
                        master_error("memory allocation error");
344
 
                        local_free_vars();
345
 
                        YYABORT;
346
 
                }
347
 
        }
348
 
        | MAPTYPE MAPNAME
349
 
        {
350
 
                char *tmp = NULL;
351
 
 
352
 
                trim_maptype($1);
353
 
 
354
 
                if ((tmp = strchr($1, ',')))
355
 
                        *tmp++ = '\0';
356
 
 
357
 
                type = master_strdup($1);
358
 
                if (!type) {
359
 
                        master_error("memory allocation error");
360
 
                        local_free_vars();
361
 
                        YYABORT;
362
 
                }
363
 
                if (tmp) {
364
 
                        format = master_strdup(tmp);
365
 
                        if (!format) {
366
 
                                master_error("memory allocation error");
367
 
                                local_free_vars();
368
 
                                YYABORT;
369
 
                        }
370
 
                }
371
 
                tmp_argc++;
372
 
                tmp_argv = add_argv(tmp_argc, tmp_argv, $2);
373
 
                if (!tmp_argv) {
374
 
                        master_error("memory allocation error");
375
 
                        local_free_vars();
376
 
                        YYABORT;
377
 
                }
378
 
        }
379
 
        | MAPTYPE dn
380
 
        {
381
 
                char *tmp = NULL;
382
 
 
383
 
                trim_maptype($1);
384
 
 
385
 
                if ((tmp = strchr($1, ',')))
386
 
                        *tmp++ = '\0';
387
 
 
388
 
                type = master_strdup($1);
389
 
                if (!type) {
390
 
                        master_error("memory allocation error");
391
 
                        local_free_vars();
392
 
                        YYABORT;
393
 
                }
394
 
                if (tmp) {
395
 
                        format = master_strdup(tmp);
396
 
                        if (!format) {
397
 
                                master_error("memory allocation error");
398
 
                                local_free_vars();
399
 
                                YYABORT;
400
 
                        }
401
 
                }
402
 
                tmp_argc++;
403
 
                tmp_argv = add_argv(tmp_argc, tmp_argv, $2);
404
 
                if (!tmp_argv) {
405
 
                        master_error("memory allocation error");
406
 
                        local_free_vars();
407
 
                        YYABORT;
408
 
                }
409
 
                /* Add back the type for lookup_ldap.c to handle ldaps */
410
 
                if (*tmp_argv[0]) {
411
 
                        tmp = malloc(strlen(type) + strlen(tmp_argv[0]) + 2);
412
 
                        if (!tmp) {
413
 
                                master_error("memory allocation error");
414
 
                                local_free_vars();
415
 
                                YYABORT;
416
 
                        }
417
 
                        strcpy(tmp, type);
418
 
                        strcat(tmp, ":");
419
 
                        strcat(tmp, tmp_argv[0]);
420
 
                        free(tmp_argv[0]);
421
 
                        tmp_argv[0] = tmp;
422
 
                }
423
 
        }
424
 
        ;
425
 
 
426
 
dn:     DNSERVER dnattrs
427
 
        {
428
 
                strcpy($$, $1);
429
 
                strcat($$, $2);
430
 
        }
431
 
        | dnattrs
432
 
        {
433
 
                strcpy($$, $1);
434
 
        }
435
 
        |
436
 
        {
437
 
                master_notify("syntax error in dn");
438
 
                YYABORT;
439
 
        }
440
 
        ;
441
 
 
442
 
dnattrs: DNATTR EQUAL DNNAME
443
 
        {
444
 
                if (strcasecmp($1, "cn") &&
445
 
                    strcasecmp($1, "ou") &&
446
 
                    strcasecmp($1, "automountMapName") &&
447
 
                    strcasecmp($1, "nisMapName")) {
448
 
                        strcpy(errstr, $1);
449
 
                        strcat(errstr, "=");
450
 
                        strcat(errstr, $3);
451
 
                        master_notify(errstr);
452
 
                        YYABORT;
453
 
                }
454
 
                strcpy($$, $1);
455
 
                strcat($$, "=");
456
 
                strcat($$, $3);
457
 
        }
458
 
        | DNATTR EQUAL DNNAME COMMA dnattr
459
 
        {
460
 
                if (strcasecmp($1, "cn") &&
461
 
                    strcasecmp($1, "ou") &&
462
 
                    strcasecmp($1, "automountMapName") &&
463
 
                    strcasecmp($1, "nisMapName")) {
464
 
                        strcpy(errstr, $1);
465
 
                        strcat(errstr, "=");
466
 
                        strcat(errstr, $3);
467
 
                        master_notify(errstr);
468
 
                        YYABORT;
469
 
                }
470
 
                strcpy($$, $1);
471
 
                strcat($$, "=");
472
 
                strcat($$, $3);
473
 
                strcat($$, ",");
474
 
                strcat($$, $5);
475
 
        }
476
 
        | DNNAME
477
 
        {
478
 
                /* Matches map in old style syntax ldap:server:map */
479
 
                strcpy($$, $1);
480
 
        }
481
 
        | DNATTR
482
 
        {
483
 
                master_notify($1);
484
 
                YYABORT;
485
 
        }
486
 
        ;
487
 
 
488
 
dnattr: DNATTR EQUAL DNNAME
489
 
        {
490
 
                if (!strcasecmp($1, "automountMapName") ||
491
 
                    !strcasecmp($1, "nisMapName")) {
492
 
                        strcpy(errstr, $1);
493
 
                        strcat(errstr, "=");
494
 
                        strcat(errstr, $3);
495
 
                        master_notify(errstr);
496
 
                        YYABORT;
497
 
                }
498
 
                strcpy($$, $1);
499
 
                strcat($$, "=");
500
 
                strcat($$, $3);
501
 
        }
502
 
        | DNATTR EQUAL DNNAME COMMA dnattr
503
 
        {
504
 
                if (!strcasecmp($1, "automountMapName") ||
505
 
                    !strcasecmp($1, "nisMapName")) {
506
 
                        strcpy(errstr, $1);
507
 
                        strcat(errstr, "=");
508
 
                        strcat(errstr, $3);
509
 
                        master_notify(errstr);
510
 
                        YYABORT;
511
 
                }
512
 
                strcpy($$, $1);
513
 
                strcat($$, "=");
514
 
                strcat($$, $3);
515
 
                strcat($$, ",");
516
 
                strcat($$, $5);
517
 
        }
518
 
        | DNATTR
519
 
        {
520
 
                master_notify($1);
521
 
                YYABORT;
522
 
        }
523
 
        | DNNAME
524
 
        {
525
 
                master_notify($1);
526
 
                YYABORT;
527
 
        }
528
 
        ;
529
 
 
530
 
options: option {}
531
 
        | options COMMA option {}
532
 
        | options option {}
533
 
        | options COMMA COMMA option
534
 
        {
535
 
                master_notify($1);
536
 
                YYABORT;
537
 
        }
538
 
        | options EQUAL
539
 
        {
540
 
                master_notify($1);
541
 
                YYABORT;
542
 
        }
543
 
        ;
544
 
 
545
 
option: daemon_option
546
 
        | mount_option {}
547
 
        | error
548
 
        {
549
 
                master_notify("bogus option");
550
 
                YYABORT;
551
 
        }
552
 
        ;
553
 
 
554
 
daemon_option: OPT_TIMEOUT NUMBER { timeout = $2; }
555
 
        | OPT_NTIMEOUT NUMBER { negative_timeout = $2; }
556
 
        | OPT_NOGHOST   { ghost = 0; }
557
 
        | OPT_GHOST     { ghost = 1; }
558
 
        | OPT_VERBOSE   { verbose = 1; }
559
 
        | OPT_DEBUG     { debug = 1; }
560
 
        | OPT_RANDOM    { random_selection = 1; }
561
 
        ;
562
 
 
563
 
mount_option: OPTION
564
 
        {
565
 
                tmp_argc++;
566
 
                tmp_argv = add_argv(tmp_argc, tmp_argv, $1);
567
 
                if (!tmp_argv) {
568
 
                        master_error("memory allocation error");
569
 
                        local_free_vars();
570
 
                        YYABORT;
571
 
                }
572
 
        }
573
 
        ;
574
 
%%
575
 
 
576
 
#if YYDEBUG
577
 
static int master_fprintf(FILE *f, char *msg, ...)
578
 
{
579
 
        va_list ap;
580
 
        va_start(ap, msg);
581
 
        vsyslog(LOG_DEBUG, msg, ap);
582
 
        va_end(ap);
583
 
        return 1;
584
 
}
585
 
#endif
586
 
 
587
 
static char *master_strdup(char *str)
588
 
{
589
 
        char *tmp;
590
 
 
591
 
        tmp = strdup(str);
592
 
        if (!tmp)
593
 
                master_error("memory allocation error");
594
 
        return tmp;
595
 
}
596
 
 
597
 
static int master_error(const char *s)
598
 
{
599
 
        logmsg("%s while parsing map.", s);
600
 
        return 0;
601
 
}
602
 
 
603
 
static int master_notify(const char *s)
604
 
{
605
 
        logmsg("syntax error in map near [ %s ]", s);
606
 
        return(0);
607
 
}
608
 
 
609
 
static int master_msg(const char *s)
610
 
{
611
 
        logmsg("%s", s);
612
 
        return 0;
613
 
}
614
 
 
615
 
static void local_init_vars(void)
616
 
{
617
 
        path = NULL;
618
 
        type = NULL;
619
 
        format = NULL;
620
 
        verbose = 0;
621
 
        debug = 0;
622
 
        timeout = -1;
623
 
        negative_timeout = 0;
624
 
        ghost = defaults_get_browse_mode();
625
 
        random_selection = global_random_selection;
626
 
        tmp_argv = NULL;
627
 
        tmp_argc = 0;
628
 
        local_argv = NULL;
629
 
        local_argc = 0;
630
 
}
631
 
 
632
 
static void local_free_vars(void)
633
 
{
634
 
        if (path)
635
 
                free(path);
636
 
 
637
 
        if (type)
638
 
                free(type);
639
 
 
640
 
        if (format)
641
 
                free(format);
642
 
 
643
 
        if (local_argv) {
644
 
                free_argv(local_argc, (const char **) local_argv);
645
 
                local_argv = NULL;
646
 
                local_argc = 0;
647
 
        }
648
 
 
649
 
        if (tmp_argv) {
650
 
                free_argv(tmp_argc, (const char **) tmp_argv);
651
 
                tmp_argv = NULL;
652
 
                tmp_argc = 0;
653
 
        }
654
 
}
655
 
 
656
 
static void trim_maptype(char *type)
657
 
{
658
 
        char *tmp;
659
 
 
660
 
        tmp = strchr(type, ':');
661
 
        if (tmp)
662
 
                *tmp = '\0';
663
 
        else {
664
 
                int len = strlen(type);
665
 
                while (len-- && isblank(type[len]))
666
 
                        type[len] = '\0';
667
 
        }
668
 
        return;
669
 
}
670
 
 
671
 
static int add_multi_mapstr(void)
672
 
{
673
 
        if (type) {
674
 
                /* If type given and format is non-null add it back */
675
 
                if (format) {
676
 
                        int len = strlen(type) + strlen(format) + 2;
677
 
                        char *tmp = realloc(type, len);
678
 
                        if (!tmp)
679
 
                                return 0;
680
 
                        type = tmp;
681
 
                        strcat(type, ",");
682
 
                        strcat(type, format);
683
 
                        free(format);
684
 
                        format = NULL;
685
 
                }
686
 
 
687
 
                local_argc++;
688
 
                local_argv = add_argv(local_argc, local_argv, type);
689
 
                if (!local_argv) {
690
 
                        free(type);
691
 
                        type = NULL;
692
 
                        return 0;
693
 
                }
694
 
 
695
 
                free(type);
696
 
                type = NULL;
697
 
        }
698
 
 
699
 
        local_argv = append_argv(local_argc, local_argv, tmp_argc, tmp_argv);
700
 
        if (!local_argv) {
701
 
                free(type);
702
 
                type = NULL;
703
 
                return 0;
704
 
        }
705
 
        local_argc += tmp_argc;
706
 
 
707
 
        tmp_argc = 0;
708
 
        tmp_argv = NULL;
709
 
 
710
 
        return 1;
711
 
}
712
 
 
713
 
void master_init_scan(void)
714
 
{
715
 
        lineno = 0;
716
 
}
717
 
 
718
 
int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigned int logging, time_t age)
719
 
{
720
 
        struct master *master = master_list;
721
 
        struct mapent_cache *nc;
722
 
        struct master_mapent *entry, *new;
723
 
        struct map_source *source;
724
 
        unsigned int logopt = logging;
725
 
        unsigned int m_logopt = master->logopt;
726
 
        int ret;
727
 
 
728
 
        local_init_vars();
729
 
 
730
 
        lineno++;
731
 
 
732
 
        master_set_scan_buffer(buffer);
733
 
 
734
 
        ret = master_parse();
735
 
        if (ret != 0) {
736
 
                local_free_vars();
737
 
                return 0;
738
 
        }
739
 
 
740
 
        nc = master->nc;
741
 
 
742
 
        /* Add null map entries to the null map cache */
743
 
        if (type && !strcmp(type, "null")) {
744
 
                cache_update(nc, NULL, path, NULL, lineno);
745
 
                local_free_vars();
746
 
                return 1;
747
 
        }
748
 
 
749
 
        /* Ignore all subsequent matching nulled entries */
750
 
        if (cache_lookup_distinct(nc, path)) {
751
 
                local_free_vars();
752
 
                return 1;
753
 
        }
754
 
 
755
 
        if (debug || verbose) {
756
 
                logopt = (debug ? LOGOPT_DEBUG : 0);
757
 
                logopt |= (verbose ? LOGOPT_VERBOSE : 0);
758
 
        }
759
 
 
760
 
        if (timeout < 0)
761
 
                timeout = default_timeout;
762
 
 
763
 
        new = NULL;
764
 
        entry = master_find_mapent(master, path);
765
 
        if (!entry) {
766
 
                new = master_new_mapent(master, path, age);
767
 
                if (!new) {
768
 
                        local_free_vars();
769
 
                        return 0;
770
 
                }
771
 
                entry = new;
772
 
        } else {
773
 
                if (entry->age && entry->age == age) {
774
 
                        if (strcmp(path, "/-")) {
775
 
                                info(m_logopt,
776
 
                                    "ignoring duplicate indirect mount %s",
777
 
                                     path);
778
 
                                local_free_vars();
779
 
                                return 0;
780
 
                        }
781
 
                }
782
 
        }
783
 
 
784
 
        if (!entry->ap) {
785
 
                ret = master_add_autofs_point(entry, timeout, logopt, ghost, 0);
786
 
                if (!ret) {
787
 
                        error(m_logopt, "failed to add autofs_point");
788
 
                        if (new)
789
 
                                master_free_mapent(new);
790
 
                        local_free_vars();
791
 
                        return 0;
792
 
                }
793
 
        } else {
794
 
                struct ioctl_ops *ops = get_ioctl_ops();
795
 
                struct autofs_point *ap = entry->ap;
796
 
                time_t tout = timeout;
797
 
 
798
 
                /*
799
 
                 * Second and subsequent instances of a mount point
800
 
                 * use the ghost, log and timeout of the first
801
 
                 */
802
 
                if (entry->age < age) {
803
 
                        ap->exp_timeout = timeout;
804
 
                        ap->exp_runfreq = (ap->exp_timeout + CHECK_RATIO - 1) / CHECK_RATIO;
805
 
                        if (ap->ioctlfd != -1 && ap->type == LKP_INDIRECT)
806
 
                                ops->timeout(ap->logopt, ap->ioctlfd, &tout);
807
 
                }
808
 
        }
809
 
        if (random_selection)
810
 
                entry->ap->flags |= MOUNT_FLAG_RANDOM_SELECT;
811
 
        if (negative_timeout)
812
 
                entry->ap->negative_timeout = negative_timeout;
813
 
 
814
 
/*
815
 
        source = master_find_map_source(entry, type, format,
816
 
                                        local_argc, (const char **) local_argv); 
817
 
        if (!source)
818
 
                source = master_add_map_source(entry, type, format, age, 
819
 
                                        local_argc, (const char **) local_argv);
820
 
        else
821
 
                source->age = age;
822
 
*/
823
 
        source = master_add_map_source(entry, type, format, age, 
824
 
                                        local_argc, (const char **) local_argv);
825
 
        if (!source) {
826
 
                error(m_logopt, "failed to add source");
827
 
                if (new)
828
 
                        master_free_mapent(new);
829
 
                local_free_vars();
830
 
                return 0;
831
 
        }
832
 
 
833
 
        source->master_line = lineno;
834
 
 
835
 
        entry->age = age;
836
 
        entry->current = NULL;
837
 
 
838
 
        if (new)
839
 
                master_add_mapent(master, entry);
840
 
 
841
 
        local_free_vars();
842
 
 
843
 
        return 1;
844
 
}
845