common.c (274500) | common.c (279741) |
---|---|
1/*- 2 * Copyright (c) 2014 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Edward Tomasz Napierala under sponsorship 6 * from the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 15 unchanged lines hidden (view full) --- 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 */ 30 31#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2014 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Edward Tomasz Napierala under sponsorship 6 * from the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 15 unchanged lines hidden (view full) --- 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 */ 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: stable/10/usr.sbin/autofs/common.c 274500 2014-11-14 10:56:33Z trasz $"); | 32__FBSDID("$FreeBSD: stable/10/usr.sbin/autofs/common.c 279741 2015-03-07 19:32:19Z trasz $"); |
33 34#include <sys/types.h> 35#include <sys/time.h> 36#include <sys/ioctl.h> 37#include <sys/param.h> 38#include <sys/linker.h> 39#include <sys/mount.h> 40#include <sys/socket.h> --- 452 unchanged lines hidden (view full) --- 493 494 assert(n->n_key != NULL); 495 if (strcmp(n->n_key, "/-") != 0) 496 return (false); 497 498 return (true); 499} 500 | 33 34#include <sys/types.h> 35#include <sys/time.h> 36#include <sys/ioctl.h> 37#include <sys/param.h> 38#include <sys/linker.h> 39#include <sys/mount.h> 40#include <sys/socket.h> --- 452 unchanged lines hidden (view full) --- 493 494 assert(n->n_key != NULL); 495 if (strcmp(n->n_key, "/-") != 0) 496 return (false); 497 498 return (true); 499} 500 |
501bool 502node_has_wildcards(const struct node *n) 503{ 504 const struct node *child; 505 506 TAILQ_FOREACH(child, &n->n_children, n_next) { 507 if (strcmp(child->n_key, "*") == 0) 508 return (true); 509 } 510 511 return (false); 512} 513 |
|
501static void 502node_expand_maps(struct node *n, bool indirect) 503{ 504 struct node *child, *tmp; 505 506 TAILQ_FOREACH_SAFE(child, &n->n_children, n_next, tmp) { 507 if (node_is_direct_map(child)) { 508 if (indirect) --- 12 unchanged lines hidden (view full) --- 521 522 if (indirect) { 523 log_debugx("map \"%s\" is an indirect map, parsing", 524 child->n_map); 525 } else { 526 log_debugx("map \"%s\" is a direct map, parsing", 527 child->n_map); 528 } | 514static void 515node_expand_maps(struct node *n, bool indirect) 516{ 517 struct node *child, *tmp; 518 519 TAILQ_FOREACH_SAFE(child, &n->n_children, n_next, tmp) { 520 if (node_is_direct_map(child)) { 521 if (indirect) --- 12 unchanged lines hidden (view full) --- 534 535 if (indirect) { 536 log_debugx("map \"%s\" is an indirect map, parsing", 537 child->n_map); 538 } else { 539 log_debugx("map \"%s\" is a direct map, parsing", 540 child->n_map); 541 } |
529 parse_map(child, child->n_map, NULL); | 542 parse_map(child, child->n_map, NULL, NULL); |
530 } 531} 532 533static void 534node_expand_direct_maps(struct node *n) 535{ 536 537 node_expand_maps(n, false); --- 453 unchanged lines hidden (view full) --- 991 if (error != 0) 992 log_errx(1, "failed to handle remote map \"%s\"", map); 993 994 node_expand_includes(parent, false); 995 node_expand_direct_maps(parent); 996} 997 998void | 543 } 544} 545 546static void 547node_expand_direct_maps(struct node *n) 548{ 549 550 node_expand_maps(n, false); --- 453 unchanged lines hidden (view full) --- 1004 if (error != 0) 1005 log_errx(1, "failed to handle remote map \"%s\"", map); 1006 1007 node_expand_includes(parent, false); 1008 node_expand_direct_maps(parent); 1009} 1010 1011void |
999parse_map(struct node *parent, const char *map, const char *key) | 1012parse_map(struct node *parent, const char *map, const char *key, 1013 bool *wildcards) |
1000{ 1001 char *path = NULL; 1002 int error, ret; 1003 bool executable; 1004 1005 assert(map != NULL); 1006 assert(map[0] != '\0'); 1007 1008 log_debugx("parsing map \"%s\"", map); 1009 | 1014{ 1015 char *path = NULL; 1016 int error, ret; 1017 bool executable; 1018 1019 assert(map != NULL); 1020 assert(map[0] != '\0'); 1021 1022 log_debugx("parsing map \"%s\"", map); 1023 |
1010 if (map[0] == '-') | 1024 if (wildcards != NULL) 1025 *wildcards = false; 1026 1027 if (map[0] == '-') { 1028 if (wildcards != NULL) 1029 *wildcards = true; |
1011 return (parse_special_map(parent, map, key)); | 1030 return (parse_special_map(parent, map, key)); |
1031 } |
|
1012 1013 if (map[0] == '/') { 1014 path = checked_strdup(map); 1015 } else { 1016 ret = asprintf(&path, "%s/%s", AUTO_MAP_PREFIX, map); 1017 if (ret < 0) 1018 log_err(1, "asprintf"); 1019 log_debugx("map \"%s\" maps to \"%s\"", map, path); --- 10 unchanged lines hidden (view full) --- 1030 } 1031 } 1032 1033 executable = file_is_executable(path); 1034 1035 if (executable) { 1036 log_debugx("map \"%s\" is executable", map); 1037 | 1032 1033 if (map[0] == '/') { 1034 path = checked_strdup(map); 1035 } else { 1036 ret = asprintf(&path, "%s/%s", AUTO_MAP_PREFIX, map); 1037 if (ret < 0) 1038 log_err(1, "asprintf"); 1039 log_debugx("map \"%s\" maps to \"%s\"", map, path); --- 10 unchanged lines hidden (view full) --- 1050 } 1051 } 1052 1053 executable = file_is_executable(path); 1054 1055 if (executable) { 1056 log_debugx("map \"%s\" is executable", map); 1057 |
1058 if (wildcards != NULL) 1059 *wildcards = true; 1060 |
|
1038 if (key != NULL) { 1039 yyin = auto_popen(path, key, NULL); 1040 } else { 1041 yyin = auto_popen(path, NULL); 1042 } 1043 assert(yyin != NULL); 1044 } else { 1045 yyin = fopen(path, "r"); --- 141 unchanged lines hidden --- | 1061 if (key != NULL) { 1062 yyin = auto_popen(path, key, NULL); 1063 } else { 1064 yyin = auto_popen(path, NULL); 1065 } 1066 assert(yyin != NULL); 1067 } else { 1068 yyin = fopen(path, "r"); --- 141 unchanged lines hidden --- |