common.c (270405) | common.c (270406) |
---|---|
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: head/usr.sbin/autofs/common.c 270405 2014-08-23 11:51:46Z trasz $"); | 32__FBSDID("$FreeBSD: head/usr.sbin/autofs/common.c 270406 2014-08-23 12:00:45Z 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> --- 810 unchanged lines hidden (view full) --- 851 "in %s, line %d", map, lineno); 852 } 853 break; 854 } 855 } 856 } 857} 858 | 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> --- 810 unchanged lines hidden (view full) --- 851 "in %s, line %d", map, lineno); 852 } 853 break; 854 } 855 } 856 } 857} 858 |
859/* 860 * Parse output of a special map called without argument. This is just 861 * a list of keys. 862 */ 863static void 864parse_map_keys_yyin(struct node *parent, const char *map) 865{ 866 char *key = NULL; 867 int ret; 868 869 lineno = 1; 870 871 for (;;) { 872 ret = yylex(); 873 874 if (ret == NEWLINE) 875 continue; 876 877 if (ret == 0) { 878 /* 879 * End of file. 880 */ 881 break; 882 } 883 884 key = checked_strdup(yytext); 885 node_new(parent, key, NULL, NULL, map, lineno); 886 } 887} 888 |
|
859static bool 860file_is_executable(const char *path) 861{ 862 struct stat sb; 863 int error; 864 865 error = stat(path, &sb); 866 if (error != 0) --- 10 unchanged lines hidden (view full) --- 877static void 878parse_special_map(struct node *parent, const char *map, const char *key) 879{ 880 char *path; 881 int error, ret; 882 883 assert(map[0] == '-'); 884 | 889static bool 890file_is_executable(const char *path) 891{ 892 struct stat sb; 893 int error; 894 895 error = stat(path, &sb); 896 if (error != 0) --- 10 unchanged lines hidden (view full) --- 907static void 908parse_special_map(struct node *parent, const char *map, const char *key) 909{ 910 char *path; 911 int error, ret; 912 913 assert(map[0] == '-'); 914 |
885 if (key == NULL) { 886 log_debugx("skipping map %s due to forced -nobrowse", map); 887 return; 888 } 889 | |
890 /* 891 * +1 to skip leading "-" in map name. 892 */ 893 ret = asprintf(&path, "%s/special_%s", AUTO_SPECIAL_PREFIX, map + 1); 894 if (ret < 0) 895 log_err(1, "asprintf"); 896 897 yyin = auto_popen(path, key, NULL); 898 assert(yyin != NULL); 899 | 915 /* 916 * +1 to skip leading "-" in map name. 917 */ 918 ret = asprintf(&path, "%s/special_%s", AUTO_SPECIAL_PREFIX, map + 1); 919 if (ret < 0) 920 log_err(1, "asprintf"); 921 922 yyin = auto_popen(path, key, NULL); 923 assert(yyin != NULL); 924 |
900 parse_map_yyin(parent, map, key); | 925 if (key == NULL) { 926 parse_map_keys_yyin(parent, map); 927 } else { 928 parse_map_yyin(parent, map, key); 929 } |
901 902 error = auto_pclose(yyin); 903 yyin = NULL; 904 if (error != 0) 905 log_errx(1, "failed to handle special map \"%s\"", map); 906 907 node_expand_includes(parent, false); 908 node_expand_direct_maps(parent); --- 229 unchanged lines hidden --- | 930 931 error = auto_pclose(yyin); 932 yyin = NULL; 933 if (error != 0) 934 log_errx(1, "failed to handle special map \"%s\"", map); 935 936 node_expand_includes(parent, false); 937 node_expand_direct_maps(parent); --- 229 unchanged lines hidden --- |