| File: | src/usr.sbin/ypldap/obj/parse.c |
| Warning: | line 944, column 13 Attempt to free released memory |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | #include <stdlib.h> | |||
| 2 | #include <string.h> | |||
| 3 | #define YYBYACC1 1 | |||
| 4 | #define YYMAJOR1 1 | |||
| 5 | #define YYMINOR9 9 | |||
| 6 | #define YYLEXyylex() yylex() | |||
| 7 | #define YYEMPTY-1 -1 | |||
| 8 | #define yyclearin(yychar=(-1)) (yychar=(YYEMPTY-1)) | |||
| 9 | #define yyerrok(yyerrflag=0) (yyerrflag=0) | |||
| 10 | #define YYRECOVERING()(yyerrflag!=0) (yyerrflag!=0) | |||
| 11 | #define YYPREFIX"yy" "yy" | |||
| 12 | #line 27 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 13 | #include <sys/types.h> | |||
| 14 | #include <sys/time.h> | |||
| 15 | #include <sys/queue.h> | |||
| 16 | #include <sys/tree.h> | |||
| 17 | #include <sys/socket.h> | |||
| 18 | #include <sys/stat.h> | |||
| 19 | ||||
| 20 | #include <netinet/in.h> | |||
| 21 | #include <arpa/inet.h> | |||
| 22 | ||||
| 23 | #include <ctype.h> | |||
| 24 | #include <err.h> | |||
| 25 | #include <errno(*__errno()).h> | |||
| 26 | #include <event.h> | |||
| 27 | #include <fcntl.h> | |||
| 28 | #include <limits.h> | |||
| 29 | #include <netdb.h> | |||
| 30 | #include <pwd.h> | |||
| 31 | #include <stdarg.h> | |||
| 32 | #include <stdio.h> | |||
| 33 | #include <stdlib.h> | |||
| 34 | #include <string.h> | |||
| 35 | #include <syslog.h> | |||
| 36 | #include <tls.h> | |||
| 37 | #include <unistd.h> | |||
| 38 | ||||
| 39 | #include "ypldap.h" | |||
| 40 | ||||
| 41 | TAILQ_HEAD(files, file)struct files { struct file *tqh_first; struct file **tqh_last ; } files = TAILQ_HEAD_INITIALIZER(files){ ((void*)0), &(files).tqh_first }; | |||
| 42 | static struct file { | |||
| 43 | TAILQ_ENTRY(file)struct { struct file *tqe_next; struct file **tqe_prev; } entry; | |||
| 44 | FILE *stream; | |||
| 45 | char *name; | |||
| 46 | size_t ungetpos; | |||
| 47 | size_t ungetsize; | |||
| 48 | u_char *ungetbuf; | |||
| 49 | int eof_reached; | |||
| 50 | int lineno; | |||
| 51 | int errors; | |||
| 52 | } *file, *topfile; | |||
| 53 | struct file *pushfile(const char *, int); | |||
| 54 | int popfile(void); | |||
| 55 | int check_file_secrecy(int, const char *); | |||
| 56 | int yyparse(void); | |||
| 57 | int yylex(void); | |||
| 58 | int yyerror(const char *, ...) | |||
| 59 | __attribute__((__format__ (printf, 1, 2))) | |||
| 60 | __attribute__((__nonnull__ (1))); | |||
| 61 | int kw_cmp(const void *, const void *); | |||
| 62 | int lookup(char *); | |||
| 63 | int igetc(void); | |||
| 64 | int lgetc(int); | |||
| 65 | void lungetc(int); | |||
| 66 | int findeol(void); | |||
| 67 | ||||
| 68 | TAILQ_HEAD(symhead, sym)struct symhead { struct sym *tqh_first; struct sym **tqh_last ; } symhead = TAILQ_HEAD_INITIALIZER(symhead){ ((void*)0), &(symhead).tqh_first }; | |||
| 69 | struct sym { | |||
| 70 | TAILQ_ENTRY(sym)struct { struct sym *tqe_next; struct sym **tqe_prev; } entry; | |||
| 71 | int used; | |||
| 72 | int persist; | |||
| 73 | char *nam; | |||
| 74 | char *val; | |||
| 75 | }; | |||
| 76 | int symset(const char *, const char *, int); | |||
| 77 | char *symget(const char *); | |||
| 78 | ||||
| 79 | struct env *conf = NULL((void*)0); | |||
| 80 | struct idm *idm = NULL((void*)0); | |||
| 81 | static int errors = 0; | |||
| 82 | ||||
| 83 | typedef struct { | |||
| 84 | union { | |||
| 85 | int64_t number; | |||
| 86 | char *string; | |||
| 87 | } v; | |||
| 88 | int lineno; | |||
| 89 | } YYSTYPE; | |||
| 90 | ||||
| 91 | #line 92 "parse.c" | |||
| 92 | #define SERVER257 257 | |||
| 93 | #define FILTER258 258 | |||
| 94 | #define ATTRIBUTE259 259 | |||
| 95 | #define BASEDN260 260 | |||
| 96 | #define BINDDN261 261 | |||
| 97 | #define GROUPDN262 262 | |||
| 98 | #define BINDCRED263 263 | |||
| 99 | #define MAPS264 264 | |||
| 100 | #define CHANGE265 265 | |||
| 101 | #define DOMAIN266 266 | |||
| 102 | #define PROVIDE267 267 | |||
| 103 | #define USER268 268 | |||
| 104 | #define GROUP269 269 | |||
| 105 | #define TO270 270 | |||
| 106 | #define EXPIRE271 271 | |||
| 107 | #define HOME272 272 | |||
| 108 | #define SHELL273 273 | |||
| 109 | #define GECOS274 274 | |||
| 110 | #define UID275 275 | |||
| 111 | #define GID276 276 | |||
| 112 | #define INTERVAL277 277 | |||
| 113 | #define PASSWD278 278 | |||
| 114 | #define NAME279 279 | |||
| 115 | #define FIXED280 280 | |||
| 116 | #define LIST281 281 | |||
| 117 | #define GROUPNAME282 282 | |||
| 118 | #define GROUPPASSWD283 283 | |||
| 119 | #define GROUPGID284 284 | |||
| 120 | #define MAP285 285 | |||
| 121 | #define INCLUDE286 286 | |||
| 122 | #define DIRECTORY287 287 | |||
| 123 | #define CLASS288 288 | |||
| 124 | #define PORT289 289 | |||
| 125 | #define ERROR290 290 | |||
| 126 | #define GROUPMEMBERS291 291 | |||
| 127 | #define LDAPS292 292 | |||
| 128 | #define TLS293 293 | |||
| 129 | #define CAFILE294 294 | |||
| 130 | #define STRING295 295 | |||
| 131 | #define NUMBER296 296 | |||
| 132 | #define YYERRCODE256 256 | |||
| 133 | const short yylhs[] = | |||
| 134 | { -1, | |||
| 135 | 0, 0, 0, 0, 0, 0, 0, 9, 10, 10, | |||
| 136 | 5, 6, 3, 3, 3, 1, 1, 2, 2, 2, | |||
| 137 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |||
| 138 | 2, 11, 11, 11, 11, 11, 11, 11, 11, 4, | |||
| 139 | 4, 4, 12, 7, 8, 8, 8, 8, 13, 13, | |||
| 140 | }; | |||
| 141 | const short yylen[] = | |||
| 142 | { 2, | |||
| 143 | 0, 2, 3, 3, 3, 3, 3, 2, 2, 0, | |||
| 144 | 2, 3, 2, 2, 0, 1, 1, 1, 1, 1, | |||
| 145 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |||
| 146 | 1, 2, 2, 2, 2, 3, 5, 4, 5, 0, | |||
| 147 | 1, 1, 0, 9, 2, 2, 3, 2, 3, 2, | |||
| 148 | }; | |||
| 149 | const short yydefred[] = | |||
| 150 | { 1, | |||
| 151 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, | |||
| 152 | 0, 0, 0, 0, 7, 46, 0, 45, 11, 0, | |||
| 153 | 48, 0, 3, 4, 5, 6, 47, 0, 0, 12, | |||
| 154 | 13, 14, 41, 42, 43, 0, 0, 0, 0, 9, | |||
| 155 | 0, 0, 0, 0, 0, 16, 17, 0, 0, 0, | |||
| 156 | 0, 0, 23, 24, 26, 27, 25, 20, 21, 19, | |||
| 157 | 18, 28, 29, 30, 22, 31, 0, 34, 32, 35, | |||
| 158 | 33, 0, 0, 0, 50, 44, 0, 0, 0, 0, | |||
| 159 | 36, 0, 49, 0, 38, 0, 8, 37, 39, | |||
| 160 | }; | |||
| 161 | const short yydgoto[] = | |||
| 162 | { 1, | |||
| 163 | 50, 67, 29, 35, 11, 12, 13, 14, 83, 39, | |||
| 164 | 51, 36, 52, | |||
| 165 | }; | |||
| 166 | const short yysindex[] = | |||
| 167 | { 0, | |||
| 168 | -10, -4, -271, -260, -270, -266, -253, -252, -17, 0, | |||
| 169 | 35, 38, 39, 41, 0, 0, -241, 0, 0, -233, | |||
| 170 | 0, -236, 0, 0, 0, 0, 0, -287, -273, 0, | |||
| 171 | 0, 0, 0, 0, 0, -63, 51, 51, -228, 0, | |||
| 172 | -261, -232, -231, -230, -229, 0, 0, -197, -261, -191, | |||
| 173 | 51, -123, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 174 | 0, 0, 0, 0, 0, 0, -196, 0, 0, 0, | |||
| 175 | 0, -261, -195, -225, 0, 0, 61, -198, -222, -194, | |||
| 176 | 0, 51, 0, -221, 0, -220, 0, 0, 0,}; | |||
| 177 | const short yyrindex[] = | |||
| 178 | { 0, | |||
| 179 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 180 | 0, 0, 0, 0, 0, 0, 0, 0, 0, -122, | |||
| 181 | 0, 0, 0, 0, 0, 0, 0, 0, -46, 0, | |||
| 182 | 0, 0, 0, 0, 0, 0, -223, -118, 0, 0, | |||
| 183 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 184 | -118, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 185 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 186 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 187 | 0, -118, 0, 0, 0, 0, 0, 0, 0,}; | |||
| 188 | const short yygindex[] = | |||
| 189 | { 0, | |||
| 190 | 0, -44, 0, 0, 0, 0, 0, 0, 0, -35, | |||
| 191 | 26, 0, 0, | |||
| 192 | }; | |||
| 193 | #define YYTABLESIZE285 285 | |||
| 194 | const short yytable[] = | |||
| 195 | { 10, | |||
| 196 | 15, 76, 40, 53, 73, 15, 10, 31, 32, 54, | |||
| 197 | 55, 56, 57, 58, 59, 75, 60, 61, 33, 34, | |||
| 198 | 62, 63, 64, 16, 17, 18, 65, 79, 19, 66, | |||
| 199 | 41, 42, 43, 44, 45, 10, 10, 10, 10, 10, | |||
| 200 | 46, 20, 21, 22, 23, 10, 87, 24, 25, 47, | |||
| 201 | 26, 48, 49, 27, 10, 28, 10, 10, 30, 37, | |||
| 202 | 38, 72, 68, 69, 70, 71, 74, 78, 80, 81, | |||
| 203 | 82, 84, 85, 88, 89, 86, 40, 77, 0, 0, | |||
| 204 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 205 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 206 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 207 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 208 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 209 | 0, 0, 0, 0, 0, 41, 42, 43, 44, 45, | |||
| 210 | 10, 10, 10, 10, 10, 46, 0, 0, 0, 0, | |||
| 211 | 10, 0, 0, 0, 47, 0, 48, 49, 0, 10, | |||
| 212 | 0, 10, 10, 0, 0, 0, 0, 0, 0, 15, | |||
| 213 | 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 214 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 215 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 216 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 217 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 218 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 219 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 220 | 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, | |||
| 221 | 0, 0, 0, 0, 0, 3, 4, 0, 0, 0, | |||
| 222 | 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, | |||
| 223 | 0, 0, 0, 0, 0, 6, 7, 0, 0, 0, | |||
| 224 | 0, 0, 0, 8, 9, | |||
| 225 | }; | |||
| 226 | const short yycheck[] = | |||
| 227 | { 10, | |||
| 228 | 123, 125, 38, 265, 49, 10, 125, 295, 296, 271, | |||
| 229 | 272, 273, 274, 275, 276, 51, 278, 279, 292, 293, | |||
| 230 | 282, 283, 284, 295, 285, 296, 288, 72, 295, 291, | |||
| 231 | 259, 260, 261, 262, 263, 259, 260, 261, 262, 263, | |||
| 232 | 269, 295, 295, 61, 10, 269, 82, 10, 10, 278, | |||
| 233 | 10, 280, 281, 295, 278, 289, 280, 281, 295, 123, | |||
| 234 | 10, 259, 295, 295, 295, 295, 258, 264, 264, 295, | |||
| 235 | 10, 270, 295, 295, 295, 270, 123, 52, -1, -1, | |||
| 236 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 237 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 238 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 239 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 240 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 241 | -1, -1, -1, -1, -1, 259, 260, 261, 262, 263, | |||
| 242 | 259, 260, 261, 262, 263, 269, -1, -1, -1, -1, | |||
| 243 | 269, -1, -1, -1, 278, -1, 280, 281, -1, 278, | |||
| 244 | -1, 280, 281, -1, -1, -1, -1, -1, -1, 292, | |||
| 245 | 293, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 246 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 247 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 248 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 249 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 250 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 251 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 252 | -1, -1, -1, -1, -1, 256, -1, -1, -1, -1, | |||
| 253 | -1, -1, -1, -1, -1, 266, 267, -1, -1, -1, | |||
| 254 | -1, -1, -1, -1, -1, -1, 277, -1, -1, -1, | |||
| 255 | -1, -1, -1, -1, -1, 286, 287, -1, -1, -1, | |||
| 256 | -1, -1, -1, 294, 295, | |||
| 257 | }; | |||
| 258 | #define YYFINAL1 1 | |||
| 259 | #ifndef YYDEBUG0 | |||
| 260 | #define YYDEBUG0 0 | |||
| 261 | #endif | |||
| 262 | #define YYMAXTOKEN296 296 | |||
| 263 | #if YYDEBUG0 | |||
| 264 | const char * const yyname[] = | |||
| 265 | { | |||
| 266 | "end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
| 267 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'='",0,0,0,0,0,0,0, | |||
| 268 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
| 269 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
| 270 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
| 271 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
| 272 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"SERVER", | |||
| 273 | "FILTER","ATTRIBUTE","BASEDN","BINDDN","GROUPDN","BINDCRED","MAPS","CHANGE", | |||
| 274 | "DOMAIN","PROVIDE","USER","GROUP","TO","EXPIRE","HOME","SHELL","GECOS","UID", | |||
| 275 | "GID","INTERVAL","PASSWD","NAME","FIXED","LIST","GROUPNAME","GROUPPASSWD", | |||
| 276 | "GROUPGID","MAP","INCLUDE","DIRECTORY","CLASS","PORT","ERROR","GROUPMEMBERS", | |||
| 277 | "LDAPS","TLS","CAFILE","STRING","NUMBER", | |||
| 278 | }; | |||
| 279 | const char * const yyrule[] = | |||
| 280 | {"$accept : grammar", | |||
| 281 | "grammar :", | |||
| 282 | "grammar : grammar '\\n'", | |||
| 283 | "grammar : grammar include '\\n'", | |||
| 284 | "grammar : grammar varset '\\n'", | |||
| 285 | "grammar : grammar directory '\\n'", | |||
| 286 | "grammar : grammar main '\\n'", | |||
| 287 | "grammar : grammar error '\\n'", | |||
| 288 | "nl : '\\n' optnl", | |||
| 289 | "optnl : '\\n' optnl", | |||
| 290 | "optnl :", | |||
| 291 | "include : INCLUDE STRING", | |||
| 292 | "varset : STRING '=' STRING", | |||
| 293 | "port : PORT STRING", | |||
| 294 | "port : PORT NUMBER", | |||
| 295 | "port :", | |||
| 296 | "opcode : GROUP", | |||
| 297 | "opcode : PASSWD", | |||
| 298 | "attribute : NAME", | |||
| 299 | "attribute : PASSWD", | |||
| 300 | "attribute : UID", | |||
| 301 | "attribute : GID", | |||
| 302 | "attribute : CLASS", | |||
| 303 | "attribute : CHANGE", | |||
| 304 | "attribute : EXPIRE", | |||
| 305 | "attribute : GECOS", | |||
| 306 | "attribute : HOME", | |||
| 307 | "attribute : SHELL", | |||
| 308 | "attribute : GROUPNAME", | |||
| 309 | "attribute : GROUPPASSWD", | |||
| 310 | "attribute : GROUPGID", | |||
| 311 | "attribute : GROUPMEMBERS", | |||
| 312 | "diropt : BINDDN STRING", | |||
| 313 | "diropt : BINDCRED STRING", | |||
| 314 | "diropt : BASEDN STRING", | |||
| 315 | "diropt : GROUPDN STRING", | |||
| 316 | "diropt : opcode FILTER STRING", | |||
| 317 | "diropt : ATTRIBUTE attribute MAPS TO STRING", | |||
| 318 | "diropt : FIXED ATTRIBUTE attribute STRING", | |||
| 319 | "diropt : LIST attribute MAPS TO STRING", | |||
| 320 | "ssl :", | |||
| 321 | "ssl : LDAPS", | |||
| 322 | "ssl : TLS", | |||
| 323 | "$$1 :", | |||
| 324 | "directory : DIRECTORY STRING port ssl $$1 '{' optnl diropts '}'", | |||
| 325 | "main : INTERVAL NUMBER", | |||
| 326 | "main : DOMAIN STRING", | |||
| 327 | "main : PROVIDE MAP STRING", | |||
| 328 | "main : CAFILE STRING", | |||
| 329 | "diropts : diropts diropt nl", | |||
| 330 | "diropts : diropt optnl", | |||
| 331 | }; | |||
| 332 | #endif | |||
| 333 | #ifdef YYSTACKSIZE10000 | |||
| 334 | #undef YYMAXDEPTH10000 | |||
| 335 | #define YYMAXDEPTH10000 YYSTACKSIZE10000 | |||
| 336 | #else | |||
| 337 | #ifdef YYMAXDEPTH10000 | |||
| 338 | #define YYSTACKSIZE10000 YYMAXDEPTH10000 | |||
| 339 | #else | |||
| 340 | #define YYSTACKSIZE10000 10000 | |||
| 341 | #define YYMAXDEPTH10000 10000 | |||
| 342 | #endif | |||
| 343 | #endif | |||
| 344 | #define YYINITSTACKSIZE200 200 | |||
| 345 | /* LINTUSED */ | |||
| 346 | int yydebug; | |||
| 347 | int yynerrs; | |||
| 348 | int yyerrflag; | |||
| 349 | int yychar; | |||
| 350 | short *yyssp; | |||
| 351 | YYSTYPE *yyvsp; | |||
| 352 | YYSTYPE yyval; | |||
| 353 | YYSTYPE yylval; | |||
| 354 | short *yyss; | |||
| 355 | short *yysslim; | |||
| 356 | YYSTYPE *yyvs; | |||
| 357 | unsigned int yystacksize; | |||
| 358 | int yyparse(void); | |||
| 359 | #line 418 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 360 | ||||
| 361 | struct keywords { | |||
| 362 | const char *k_name; | |||
| 363 | int k_val; | |||
| 364 | }; | |||
| 365 | ||||
| 366 | int | |||
| 367 | yyerror(const char *fmt, ...) | |||
| 368 | { | |||
| 369 | va_list ap; | |||
| 370 | char *msg; | |||
| 371 | ||||
| 372 | file->errors++; | |||
| 373 | va_start(ap, fmt)__builtin_va_start(ap, fmt); | |||
| 374 | if (vasprintf(&msg, fmt, ap) == -1) | |||
| 375 | fatalx("yyerror vasprintf"); | |||
| 376 | va_end(ap)__builtin_va_end(ap); | |||
| 377 | logit(LOG_CRIT2, "%s:%d: %s", file->name, yylval.lineno, msg); | |||
| 378 | free(msg); | |||
| 379 | return (0); | |||
| 380 | } | |||
| 381 | ||||
| 382 | int | |||
| 383 | kw_cmp(const void *k, const void *e) | |||
| 384 | { | |||
| 385 | return (strcmp(k, ((const struct keywords *)e)->k_name)); | |||
| 386 | } | |||
| 387 | ||||
| 388 | int | |||
| 389 | lookup(char *s) | |||
| 390 | { | |||
| 391 | /* this has to be sorted always */ | |||
| 392 | static const struct keywords keywords[] = { | |||
| 393 | { "attribute", ATTRIBUTE259 }, | |||
| 394 | { "basedn", BASEDN260 }, | |||
| 395 | { "bindcred", BINDCRED263 }, | |||
| 396 | { "binddn", BINDDN261 }, | |||
| 397 | { "cafile", CAFILE294 }, | |||
| 398 | { "change", CHANGE265 }, | |||
| 399 | { "class", CLASS288 }, | |||
| 400 | { "directory", DIRECTORY287 }, | |||
| 401 | { "domain", DOMAIN266 }, | |||
| 402 | { "expire", EXPIRE271 }, | |||
| 403 | { "filter", FILTER258 }, | |||
| 404 | { "fixed", FIXED280 }, | |||
| 405 | { "gecos", GECOS274 }, | |||
| 406 | { "gid", GID276 }, | |||
| 407 | { "group", GROUP269 }, | |||
| 408 | { "groupdn", GROUPDN262 }, | |||
| 409 | { "groupgid", GROUPGID284 }, | |||
| 410 | { "groupmembers", GROUPMEMBERS291 }, | |||
| 411 | { "groupname", GROUPNAME282 }, | |||
| 412 | { "grouppasswd", GROUPPASSWD283 }, | |||
| 413 | { "home", HOME272 }, | |||
| 414 | { "include", INCLUDE286 }, | |||
| 415 | { "interval", INTERVAL277 }, | |||
| 416 | { "ldaps", LDAPS292 }, | |||
| 417 | { "list", LIST281 }, | |||
| 418 | { "map", MAP285 }, | |||
| 419 | { "maps", MAPS264 }, | |||
| 420 | { "name", NAME279 }, | |||
| 421 | { "passwd", PASSWD278 }, | |||
| 422 | { "port", PORT289 }, | |||
| 423 | { "provide", PROVIDE267 }, | |||
| 424 | { "server", SERVER257 }, | |||
| 425 | { "shell", SHELL273 }, | |||
| 426 | { "tls", TLS293 }, | |||
| 427 | { "to", TO270 }, | |||
| 428 | { "uid", UID275 }, | |||
| 429 | { "user", USER268 }, | |||
| 430 | }; | |||
| 431 | const struct keywords *p; | |||
| 432 | ||||
| 433 | p = bsearch(s, keywords, sizeof(keywords)/sizeof(keywords[0]), | |||
| 434 | sizeof(keywords[0]), kw_cmp); | |||
| 435 | ||||
| 436 | if (p) | |||
| 437 | return (p->k_val); | |||
| 438 | else | |||
| 439 | return (STRING295); | |||
| 440 | } | |||
| 441 | ||||
| 442 | #define START_EXPAND1 1 | |||
| 443 | #define DONE_EXPAND2 2 | |||
| 444 | ||||
| 445 | static int expanding; | |||
| 446 | ||||
| 447 | int | |||
| 448 | igetc(void) | |||
| 449 | { | |||
| 450 | int c; | |||
| 451 | ||||
| 452 | while (1) { | |||
| 453 | if (file->ungetpos > 0) | |||
| 454 | c = file->ungetbuf[--file->ungetpos]; | |||
| 455 | else | |||
| 456 | c = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget (file->stream) : (int)(*(file->stream)->_p++)) : (getc )(file->stream)); | |||
| 457 | ||||
| 458 | if (c == START_EXPAND1) | |||
| 459 | expanding = 1; | |||
| 460 | else if (c == DONE_EXPAND2) | |||
| 461 | expanding = 0; | |||
| 462 | else | |||
| 463 | break; | |||
| 464 | } | |||
| 465 | return (c); | |||
| 466 | } | |||
| 467 | ||||
| 468 | int | |||
| 469 | lgetc(int quotec) | |||
| 470 | { | |||
| 471 | int c, next; | |||
| 472 | ||||
| 473 | if (quotec) { | |||
| 474 | if ((c = igetc()) == EOF(-1)) { | |||
| 475 | yyerror("reached end of file while parsing " | |||
| 476 | "quoted string"); | |||
| 477 | if (file == topfile || popfile() == EOF(-1)) | |||
| 478 | return (EOF(-1)); | |||
| 479 | return (quotec); | |||
| 480 | } | |||
| 481 | return (c); | |||
| 482 | } | |||
| 483 | ||||
| 484 | while ((c = igetc()) == '\\') { | |||
| 485 | next = igetc(); | |||
| 486 | if (next != '\n') { | |||
| 487 | c = next; | |||
| 488 | break; | |||
| 489 | } | |||
| 490 | yylval.lineno = file->lineno; | |||
| 491 | file->lineno++; | |||
| 492 | } | |||
| 493 | ||||
| 494 | if (c == EOF(-1)) { | |||
| 495 | /* | |||
| 496 | * Fake EOL when hit EOF for the first time. This gets line | |||
| 497 | * count right if last line in included file is syntactically | |||
| 498 | * invalid and has no newline. | |||
| 499 | */ | |||
| 500 | if (file->eof_reached == 0) { | |||
| 501 | file->eof_reached = 1; | |||
| 502 | return ('\n'); | |||
| 503 | } | |||
| 504 | while (c == EOF(-1)) { | |||
| 505 | if (file == topfile || popfile() == EOF(-1)) | |||
| 506 | return (EOF(-1)); | |||
| 507 | c = igetc(); | |||
| 508 | } | |||
| 509 | } | |||
| 510 | return (c); | |||
| 511 | } | |||
| 512 | ||||
| 513 | void | |||
| 514 | lungetc(int c) | |||
| 515 | { | |||
| 516 | if (c == EOF(-1)) | |||
| 517 | return; | |||
| 518 | ||||
| 519 | if (file->ungetpos >= file->ungetsize) { | |||
| 520 | void *p = reallocarray(file->ungetbuf, file->ungetsize, 2); | |||
| 521 | if (p == NULL((void*)0)) | |||
| 522 | err(1, "lungetc"); | |||
| 523 | file->ungetbuf = p; | |||
| 524 | file->ungetsize *= 2; | |||
| 525 | } | |||
| 526 | file->ungetbuf[file->ungetpos++] = c; | |||
| 527 | } | |||
| 528 | ||||
| 529 | int | |||
| 530 | findeol(void) | |||
| 531 | { | |||
| 532 | int c; | |||
| 533 | ||||
| 534 | /* skip to either EOF or the first real EOL */ | |||
| 535 | while (1) { | |||
| 536 | c = lgetc(0); | |||
| 537 | if (c == '\n') { | |||
| 538 | file->lineno++; | |||
| 539 | break; | |||
| 540 | } | |||
| 541 | if (c == EOF(-1)) | |||
| 542 | break; | |||
| 543 | } | |||
| 544 | return (ERROR290); | |||
| 545 | } | |||
| 546 | ||||
| 547 | int | |||
| 548 | yylex(void) | |||
| 549 | { | |||
| 550 | char buf[8096]; | |||
| 551 | char *p, *val; | |||
| 552 | int quotec, next, c; | |||
| 553 | int token; | |||
| 554 | ||||
| 555 | top: | |||
| 556 | p = buf; | |||
| 557 | while ((c = lgetc(0)) == ' ' || c == '\t') | |||
| 558 | ; /* nothing */ | |||
| 559 | ||||
| 560 | yylval.lineno = file->lineno; | |||
| 561 | if (c == '#') | |||
| 562 | while ((c = lgetc(0)) != '\n' && c != EOF(-1)) | |||
| 563 | ; /* nothing */ | |||
| 564 | if (c == '$' && !expanding) { | |||
| 565 | while (1) { | |||
| 566 | if ((c = lgetc(0)) == EOF(-1)) | |||
| 567 | return (0); | |||
| 568 | ||||
| 569 | if (p + 1 >= buf + sizeof(buf) - 1) { | |||
| 570 | yyerror("string too long"); | |||
| 571 | return (findeol()); | |||
| 572 | } | |||
| 573 | if (isalnum(c) || c == '_') { | |||
| 574 | *p++ = c; | |||
| 575 | continue; | |||
| 576 | } | |||
| 577 | *p = '\0'; | |||
| 578 | lungetc(c); | |||
| 579 | break; | |||
| 580 | } | |||
| 581 | val = symget(buf); | |||
| 582 | if (val == NULL((void*)0)) { | |||
| 583 | yyerror("macro '%s' not defined", buf); | |||
| 584 | return (findeol()); | |||
| 585 | } | |||
| 586 | p = val + strlen(val) - 1; | |||
| 587 | lungetc(DONE_EXPAND2); | |||
| 588 | while (p >= val) { | |||
| 589 | lungetc((unsigned char)*p); | |||
| 590 | p--; | |||
| 591 | } | |||
| 592 | lungetc(START_EXPAND1); | |||
| 593 | goto top; | |||
| 594 | } | |||
| 595 | ||||
| 596 | switch (c) { | |||
| 597 | case '\'': | |||
| 598 | case '"': | |||
| 599 | quotec = c; | |||
| 600 | while (1) { | |||
| 601 | if ((c = lgetc(quotec)) == EOF(-1)) | |||
| 602 | return (0); | |||
| 603 | if (c == '\n') { | |||
| 604 | file->lineno++; | |||
| 605 | continue; | |||
| 606 | } else if (c == '\\') { | |||
| 607 | if ((next = lgetc(quotec)) == EOF(-1)) | |||
| 608 | return (0); | |||
| 609 | if (next == quotec || next == ' ' || | |||
| 610 | next == '\t') | |||
| 611 | c = next; | |||
| 612 | else if (next == '\n') { | |||
| 613 | file->lineno++; | |||
| 614 | continue; | |||
| 615 | } else | |||
| 616 | lungetc(next); | |||
| 617 | } else if (c == quotec) { | |||
| 618 | *p = '\0'; | |||
| 619 | break; | |||
| 620 | } else if (c == '\0') { | |||
| 621 | yyerror("syntax error"); | |||
| 622 | return (findeol()); | |||
| 623 | } | |||
| 624 | if (p + 1 >= buf + sizeof(buf) - 1) { | |||
| 625 | yyerror("string too long"); | |||
| 626 | return (findeol()); | |||
| 627 | } | |||
| 628 | *p++ = c; | |||
| 629 | } | |||
| 630 | yylval.v.string = strdup(buf); | |||
| 631 | if (yylval.v.string == NULL((void*)0)) | |||
| 632 | err(1, "%s", __func__); | |||
| 633 | return (STRING295); | |||
| 634 | } | |||
| 635 | ||||
| 636 | #define allowed_to_end_number(x)(isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=') \ | |||
| 637 | (isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=') | |||
| 638 | ||||
| 639 | if (c == '-' || isdigit(c)) { | |||
| 640 | do { | |||
| 641 | *p++ = c; | |||
| 642 | if ((size_t)(p-buf) >= sizeof(buf)) { | |||
| 643 | yyerror("string too long"); | |||
| 644 | return (findeol()); | |||
| 645 | } | |||
| 646 | } while ((c = lgetc(0)) != EOF(-1) && isdigit(c)); | |||
| 647 | lungetc(c); | |||
| 648 | if (p == buf + 1 && buf[0] == '-') | |||
| 649 | goto nodigits; | |||
| 650 | if (c == EOF(-1) || allowed_to_end_number(c)(isspace(c) || c == ')' || c ==',' || c == '/' || c == '}' || c == '=')) { | |||
| 651 | const char *errstr = NULL((void*)0); | |||
| 652 | ||||
| 653 | *p = '\0'; | |||
| 654 | yylval.v.number = strtonum(buf, LLONG_MIN(-9223372036854775807LL -1LL), | |||
| 655 | LLONG_MAX9223372036854775807LL, &errstr); | |||
| 656 | if (errstr) { | |||
| 657 | yyerror("\"%s\" invalid number: %s", | |||
| 658 | buf, errstr); | |||
| 659 | return (findeol()); | |||
| 660 | } | |||
| 661 | return (NUMBER296); | |||
| 662 | } else { | |||
| 663 | nodigits: | |||
| 664 | while (p > buf + 1) | |||
| 665 | lungetc((unsigned char)*--p); | |||
| 666 | c = (unsigned char)*--p; | |||
| 667 | if (c == '-') | |||
| 668 | return (c); | |||
| 669 | } | |||
| 670 | } | |||
| 671 | ||||
| 672 | #define allowed_in_string(x)(isalnum(x) || (ispunct(x) && x != '(' && x != ')' && x != '{' && x != '}' && x != '<' && x != '>' && x != '!' && x != '=' && x != '#' && x != ',')) \ | |||
| 673 | (isalnum(x) || (ispunct(x) && x != '(' && x != ')' && \ | |||
| 674 | x != '{' && x != '}' && x != '<' && x != '>' && \ | |||
| 675 | x != '!' && x != '=' && x != '#' && \ | |||
| 676 | x != ',')) | |||
| 677 | ||||
| 678 | if (isalnum(c) || c == ':' || c == '_') { | |||
| 679 | do { | |||
| 680 | *p++ = c; | |||
| 681 | if ((size_t)(p-buf) >= sizeof(buf)) { | |||
| 682 | yyerror("string too long"); | |||
| 683 | return (findeol()); | |||
| 684 | } | |||
| 685 | } while ((c = lgetc(0)) != EOF(-1) && (allowed_in_string(c)(isalnum(c) || (ispunct(c) && c != '(' && c != ')' && c != '{' && c != '}' && c != '<' && c != '>' && c != '!' && c != '=' && c != '#' && c != ',')))); | |||
| 686 | lungetc(c); | |||
| 687 | *p = '\0'; | |||
| 688 | if ((token = lookup(buf)) == STRING295) | |||
| 689 | if ((yylval.v.string = strdup(buf)) == NULL((void*)0)) | |||
| 690 | err(1, "%s", __func__); | |||
| 691 | return (token); | |||
| 692 | } | |||
| 693 | if (c == '\n') { | |||
| 694 | yylval.lineno = file->lineno; | |||
| 695 | file->lineno++; | |||
| 696 | } | |||
| 697 | if (c == EOF(-1)) | |||
| 698 | return (0); | |||
| 699 | return (c); | |||
| 700 | } | |||
| 701 | ||||
| 702 | int | |||
| 703 | check_file_secrecy(int fd, const char *fname) | |||
| 704 | { | |||
| 705 | struct stat st; | |||
| 706 | ||||
| 707 | if (fstat(fd, &st)) { | |||
| 708 | log_warn("cannot stat %s", fname); | |||
| 709 | return (-1); | |||
| 710 | } | |||
| 711 | if (st.st_uid != 0 && st.st_uid != getuid()) { | |||
| 712 | log_warnx("%s: owner not root or current user", fname); | |||
| 713 | return (-1); | |||
| 714 | } | |||
| 715 | if (st.st_mode & (S_IWGRP0000020 | S_IXGRP0000010 | S_IRWXO0000007)) { | |||
| 716 | log_warnx("%s: group writable or world read/writable", fname); | |||
| 717 | return (-1); | |||
| 718 | } | |||
| 719 | return (0); | |||
| 720 | } | |||
| 721 | ||||
| 722 | struct file * | |||
| 723 | pushfile(const char *name, int secret) | |||
| 724 | { | |||
| 725 | struct file *nfile; | |||
| 726 | ||||
| 727 | if ((nfile = calloc(1, sizeof(struct file))) == NULL((void*)0)) { | |||
| 728 | log_warn("%s", __func__); | |||
| 729 | return (NULL((void*)0)); | |||
| 730 | } | |||
| 731 | if ((nfile->name = strdup(name)) == NULL((void*)0)) { | |||
| 732 | log_warn("%s", __func__); | |||
| 733 | free(nfile); | |||
| 734 | return (NULL((void*)0)); | |||
| 735 | } | |||
| 736 | if ((nfile->stream = fopen(nfile->name, "r")) == NULL((void*)0)) { | |||
| 737 | log_warn("%s: %s", __func__, nfile->name); | |||
| 738 | free(nfile->name); | |||
| 739 | free(nfile); | |||
| 740 | return (NULL((void*)0)); | |||
| 741 | } else if (secret && | |||
| 742 | check_file_secrecy(fileno(nfile->stream)(!__isthreaded ? ((nfile->stream)->_file) : (fileno)(nfile ->stream)), nfile->name)) { | |||
| 743 | fclose(nfile->stream); | |||
| 744 | free(nfile->name); | |||
| 745 | free(nfile); | |||
| 746 | return (NULL((void*)0)); | |||
| 747 | } | |||
| 748 | nfile->lineno = TAILQ_EMPTY(&files)(((&files)->tqh_first) == ((void*)0)) ? 1 : 0; | |||
| 749 | nfile->ungetsize = 16; | |||
| 750 | nfile->ungetbuf = malloc(nfile->ungetsize); | |||
| 751 | if (nfile->ungetbuf == NULL((void*)0)) { | |||
| 752 | log_warn("%s", __func__); | |||
| 753 | fclose(nfile->stream); | |||
| 754 | free(nfile->name); | |||
| 755 | free(nfile); | |||
| 756 | return (NULL((void*)0)); | |||
| 757 | } | |||
| 758 | TAILQ_INSERT_TAIL(&files, nfile, entry)do { (nfile)->entry.tqe_next = ((void*)0); (nfile)->entry .tqe_prev = (&files)->tqh_last; *(&files)->tqh_last = (nfile); (&files)->tqh_last = &(nfile)->entry .tqe_next; } while (0); | |||
| 759 | return (nfile); | |||
| 760 | } | |||
| 761 | ||||
| 762 | int | |||
| 763 | popfile(void) | |||
| 764 | { | |||
| 765 | struct file *prev; | |||
| 766 | ||||
| 767 | if ((prev = TAILQ_PREV(file, files, entry)(*(((struct files *)((file)->entry.tqe_prev))->tqh_last ))) != NULL((void*)0)) | |||
| 768 | prev->errors += file->errors; | |||
| 769 | ||||
| 770 | TAILQ_REMOVE(&files, file, entry)do { if (((file)->entry.tqe_next) != ((void*)0)) (file)-> entry.tqe_next->entry.tqe_prev = (file)->entry.tqe_prev ; else (&files)->tqh_last = (file)->entry.tqe_prev; *(file)->entry.tqe_prev = (file)->entry.tqe_next; ; ; } while (0); | |||
| 771 | fclose(file->stream); | |||
| 772 | free(file->name); | |||
| 773 | free(file->ungetbuf); | |||
| 774 | free(file); | |||
| 775 | file = prev; | |||
| 776 | return (file ? 0 : EOF(-1)); | |||
| 777 | } | |||
| 778 | ||||
| 779 | int | |||
| 780 | parse_config(struct env *x_conf, const char *filename, int opts) | |||
| 781 | { | |||
| 782 | struct sym *sym, *next; | |||
| 783 | ||||
| 784 | conf = x_conf; | |||
| 785 | bzero(conf, sizeof(*conf)); | |||
| 786 | ||||
| 787 | TAILQ_INIT(&conf->sc_idms)do { (&conf->sc_idms)->tqh_first = ((void*)0); (& conf->sc_idms)->tqh_last = &(&conf->sc_idms) ->tqh_first; } while (0); | |||
| 788 | conf->sc_conf_tv.tv_sec = DEFAULT_INTERVAL600; | |||
| 789 | conf->sc_conf_tv.tv_usec = 0; | |||
| 790 | conf->sc_cafile = strdup(tls_default_ca_cert_file()); | |||
| 791 | if (conf->sc_cafile == NULL((void*)0)) { | |||
| 792 | log_warn("%s", __func__); | |||
| 793 | return (-1); | |||
| 794 | } | |||
| 795 | ||||
| 796 | errors = 0; | |||
| 797 | ||||
| 798 | if ((file = pushfile(filename, 1)) == NULL((void*)0)) { | |||
| 799 | return (-1); | |||
| 800 | } | |||
| 801 | topfile = file; | |||
| 802 | ||||
| 803 | /* | |||
| 804 | * parse configuration | |||
| 805 | */ | |||
| 806 | setservent(1); | |||
| 807 | yyparse(); | |||
| 808 | endservent(); | |||
| 809 | errors = file->errors; | |||
| 810 | popfile(); | |||
| 811 | ||||
| 812 | /* Free macros and check which have not been used. */ | |||
| 813 | TAILQ_FOREACH_SAFE(sym, &symhead, entry, next)for ((sym) = ((&symhead)->tqh_first); (sym) != ((void* )0) && ((next) = ((sym)->entry.tqe_next), 1); (sym ) = (next)) { | |||
| 814 | if ((opts & YPLDAP_OPT_VERBOSE0x01) && !sym->used) | |||
| 815 | fprintf(stderr(&__sF[2]), "warning: macro '%s' not " | |||
| 816 | "used\n", sym->nam); | |||
| 817 | if (!sym->persist) { | |||
| 818 | free(sym->nam); | |||
| 819 | free(sym->val); | |||
| 820 | TAILQ_REMOVE(&symhead, sym, entry)do { if (((sym)->entry.tqe_next) != ((void*)0)) (sym)-> entry.tqe_next->entry.tqe_prev = (sym)->entry.tqe_prev; else (&symhead)->tqh_last = (sym)->entry.tqe_prev; *(sym)->entry.tqe_prev = (sym)->entry.tqe_next; ; ; } while (0); | |||
| 821 | free(sym); | |||
| 822 | } | |||
| 823 | } | |||
| 824 | ||||
| 825 | if (errors) { | |||
| 826 | return (-1); | |||
| 827 | } | |||
| 828 | ||||
| 829 | return (0); | |||
| 830 | } | |||
| 831 | ||||
| 832 | int | |||
| 833 | symset(const char *nam, const char *val, int persist) | |||
| 834 | { | |||
| 835 | struct sym *sym; | |||
| 836 | ||||
| 837 | TAILQ_FOREACH(sym, &symhead, entry)for((sym) = ((&symhead)->tqh_first); (sym) != ((void*) 0); (sym) = ((sym)->entry.tqe_next)) { | |||
| 838 | if (strcmp(nam, sym->nam) == 0) | |||
| 839 | break; | |||
| 840 | } | |||
| 841 | ||||
| 842 | if (sym != NULL((void*)0)) { | |||
| 843 | if (sym->persist == 1) | |||
| 844 | return (0); | |||
| 845 | else { | |||
| 846 | free(sym->nam); | |||
| 847 | free(sym->val); | |||
| 848 | TAILQ_REMOVE(&symhead, sym, entry)do { if (((sym)->entry.tqe_next) != ((void*)0)) (sym)-> entry.tqe_next->entry.tqe_prev = (sym)->entry.tqe_prev; else (&symhead)->tqh_last = (sym)->entry.tqe_prev; *(sym)->entry.tqe_prev = (sym)->entry.tqe_next; ; ; } while (0); | |||
| 849 | free(sym); | |||
| 850 | } | |||
| 851 | } | |||
| 852 | if ((sym = calloc(1, sizeof(*sym))) == NULL((void*)0)) | |||
| 853 | return (-1); | |||
| 854 | ||||
| 855 | sym->nam = strdup(nam); | |||
| 856 | if (sym->nam == NULL((void*)0)) { | |||
| 857 | free(sym); | |||
| 858 | return (-1); | |||
| 859 | } | |||
| 860 | sym->val = strdup(val); | |||
| 861 | if (sym->val == NULL((void*)0)) { | |||
| 862 | free(sym->nam); | |||
| 863 | free(sym); | |||
| 864 | return (-1); | |||
| 865 | } | |||
| 866 | sym->used = 0; | |||
| 867 | sym->persist = persist; | |||
| 868 | TAILQ_INSERT_TAIL(&symhead, sym, entry)do { (sym)->entry.tqe_next = ((void*)0); (sym)->entry.tqe_prev = (&symhead)->tqh_last; *(&symhead)->tqh_last = (sym); (&symhead)->tqh_last = &(sym)->entry.tqe_next ; } while (0); | |||
| 869 | return (0); | |||
| 870 | } | |||
| 871 | ||||
| 872 | int | |||
| 873 | cmdline_symset(char *s) | |||
| 874 | { | |||
| 875 | char *sym, *val; | |||
| 876 | int ret; | |||
| 877 | ||||
| 878 | if ((val = strrchr(s, '=')) == NULL((void*)0)) | |||
| 879 | return (-1); | |||
| 880 | sym = strndup(s, val - s); | |||
| 881 | if (sym == NULL((void*)0)) | |||
| 882 | errx(1, "%s: strndup", __func__); | |||
| 883 | ret = symset(sym, val + 1, 1); | |||
| 884 | free(sym); | |||
| 885 | ||||
| 886 | return (ret); | |||
| 887 | } | |||
| 888 | ||||
| 889 | char * | |||
| 890 | symget(const char *nam) | |||
| 891 | { | |||
| 892 | struct sym *sym; | |||
| 893 | ||||
| 894 | TAILQ_FOREACH(sym, &symhead, entry)for((sym) = ((&symhead)->tqh_first); (sym) != ((void*) 0); (sym) = ((sym)->entry.tqe_next)) { | |||
| 895 | if (strcmp(nam, sym->nam) == 0) { | |||
| 896 | sym->used = 1; | |||
| 897 | return (sym->val); | |||
| 898 | } | |||
| 899 | } | |||
| 900 | return (NULL((void*)0)); | |||
| 901 | } | |||
| 902 | #line 895 "parse.c" | |||
| 903 | /* allocate initial stack or double stack size, up to YYMAXDEPTH */ | |||
| 904 | static int yygrowstack(void) | |||
| 905 | { | |||
| 906 | unsigned int newsize; | |||
| 907 | long sslen; | |||
| 908 | short *newss; | |||
| 909 | YYSTYPE *newvs; | |||
| 910 | ||||
| 911 | if ((newsize = yystacksize) == 0) | |||
| 912 | newsize = YYINITSTACKSIZE200; | |||
| 913 | else if (newsize >= YYMAXDEPTH10000) | |||
| 914 | return -1; | |||
| 915 | else if ((newsize *= 2) > YYMAXDEPTH10000) | |||
| 916 | newsize = YYMAXDEPTH10000; | |||
| 917 | sslen = yyssp - yyss; | |||
| 918 | #ifdef SIZE_MAX0xffffffffffffffffUL | |||
| 919 | #define YY_SIZE_MAX0xffffffffffffffffUL SIZE_MAX0xffffffffffffffffUL | |||
| 920 | #else | |||
| 921 | #define YY_SIZE_MAX0xffffffffffffffffUL 0xffffffffU | |||
| 922 | #endif | |||
| 923 | if (newsize && YY_SIZE_MAX0xffffffffffffffffUL / newsize < sizeof *newss) | |||
| 924 | goto bail; | |||
| 925 | newss = (short *)realloc(yyss, newsize * sizeof *newss); | |||
| 926 | if (newss == NULL((void*)0)) | |||
| 927 | goto bail; | |||
| 928 | yyss = newss; | |||
| 929 | yyssp = newss + sslen; | |||
| 930 | if (newsize
| |||
| 931 | goto bail; | |||
| 932 | newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs); | |||
| 933 | if (newvs == NULL((void*)0)) | |||
| 934 | goto bail; | |||
| 935 | yyvs = newvs; | |||
| 936 | yyvsp = newvs + sslen; | |||
| 937 | yystacksize = newsize; | |||
| 938 | yysslim = yyss + newsize - 1; | |||
| 939 | return 0; | |||
| 940 | bail: | |||
| 941 | if (yyss
| |||
| 942 | free(yyss); | |||
| 943 | if (yyvs) | |||
| 944 | free(yyvs); | |||
| ||||
| 945 | yyss = yyssp = NULL((void*)0); | |||
| 946 | yyvs = yyvsp = NULL((void*)0); | |||
| 947 | yystacksize = 0; | |||
| 948 | return -1; | |||
| 949 | } | |||
| 950 | ||||
| 951 | #define YYABORTgoto yyabort goto yyabort | |||
| 952 | #define YYREJECTgoto yyabort goto yyabort | |||
| 953 | #define YYACCEPTgoto yyaccept goto yyaccept | |||
| 954 | #define YYERRORgoto yyerrlab goto yyerrlab | |||
| 955 | int | |||
| 956 | yyparse(void) | |||
| 957 | { | |||
| 958 | int yym, yyn, yystate; | |||
| 959 | #if YYDEBUG0 | |||
| 960 | const char *yys; | |||
| 961 | ||||
| 962 | if ((yys = getenv("YYDEBUG"))) | |||
| 963 | { | |||
| 964 | yyn = *yys; | |||
| 965 | if (yyn >= '0' && yyn <= '9') | |||
| 966 | yydebug = yyn - '0'; | |||
| 967 | } | |||
| 968 | #endif /* YYDEBUG */ | |||
| 969 | ||||
| 970 | yynerrs = 0; | |||
| 971 | yyerrflag = 0; | |||
| 972 | yychar = (-1); | |||
| 973 | ||||
| 974 | if (yyss == NULL((void*)0) && yygrowstack()) goto yyoverflow; | |||
| ||||
| 975 | yyssp = yyss; | |||
| 976 | yyvsp = yyvs; | |||
| 977 | *yyssp = yystate = 0; | |||
| 978 | ||||
| 979 | yyloop: | |||
| 980 | if ((yyn = yydefred[yystate]) != 0) goto yyreduce; | |||
| 981 | if (yychar < 0) | |||
| 982 | { | |||
| 983 | if ((yychar = yylex()) < 0) yychar = 0; | |||
| 984 | #if YYDEBUG0 | |||
| 985 | if (yydebug) | |||
| 986 | { | |||
| 987 | yys = 0; | |||
| 988 | if (yychar <= YYMAXTOKEN296) yys = yyname[yychar]; | |||
| 989 | if (!yys) yys = "illegal-symbol"; | |||
| 990 | printf("%sdebug: state %d, reading %d (%s)\n", | |||
| 991 | YYPREFIX"yy", yystate, yychar, yys); | |||
| 992 | } | |||
| 993 | #endif | |||
| 994 | } | |||
| 995 | if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && | |||
| 996 | yyn <= YYTABLESIZE285 && yycheck[yyn] == yychar) | |||
| 997 | { | |||
| 998 | #if YYDEBUG0 | |||
| 999 | if (yydebug) | |||
| 1000 | printf("%sdebug: state %d, shifting to state %d\n", | |||
| 1001 | YYPREFIX"yy", yystate, yytable[yyn]); | |||
| 1002 | #endif | |||
| 1003 | if (yyssp >= yysslim && yygrowstack()) | |||
| 1004 | { | |||
| 1005 | goto yyoverflow; | |||
| 1006 | } | |||
| 1007 | *++yyssp = yystate = yytable[yyn]; | |||
| 1008 | *++yyvsp = yylval; | |||
| 1009 | yychar = (-1); | |||
| 1010 | if (yyerrflag > 0) --yyerrflag; | |||
| 1011 | goto yyloop; | |||
| 1012 | } | |||
| 1013 | if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && | |||
| 1014 | yyn <= YYTABLESIZE285 && yycheck[yyn] == yychar) | |||
| 1015 | { | |||
| 1016 | yyn = yytable[yyn]; | |||
| 1017 | goto yyreduce; | |||
| 1018 | } | |||
| 1019 | if (yyerrflag) goto yyinrecovery; | |||
| 1020 | #if defined(__GNUC__4) | |||
| 1021 | goto yynewerror; | |||
| 1022 | #endif | |||
| 1023 | yynewerror: | |||
| 1024 | yyerror("syntax error"); | |||
| 1025 | #if defined(__GNUC__4) | |||
| 1026 | goto yyerrlab; | |||
| 1027 | #endif | |||
| 1028 | yyerrlab: | |||
| 1029 | ++yynerrs; | |||
| 1030 | yyinrecovery: | |||
| 1031 | if (yyerrflag < 3) | |||
| 1032 | { | |||
| 1033 | yyerrflag = 3; | |||
| 1034 | for (;;) | |||
| 1035 | { | |||
| 1036 | if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE256) >= 0 && | |||
| 1037 | yyn <= YYTABLESIZE285 && yycheck[yyn] == YYERRCODE256) | |||
| 1038 | { | |||
| 1039 | #if YYDEBUG0 | |||
| 1040 | if (yydebug) | |||
| 1041 | printf("%sdebug: state %d, error recovery shifting\ | |||
| 1042 | to state %d\n", YYPREFIX"yy", *yyssp, yytable[yyn]); | |||
| 1043 | #endif | |||
| 1044 | if (yyssp >= yysslim && yygrowstack()) | |||
| 1045 | { | |||
| 1046 | goto yyoverflow; | |||
| 1047 | } | |||
| 1048 | *++yyssp = yystate = yytable[yyn]; | |||
| 1049 | *++yyvsp = yylval; | |||
| 1050 | goto yyloop; | |||
| 1051 | } | |||
| 1052 | else | |||
| 1053 | { | |||
| 1054 | #if YYDEBUG0 | |||
| 1055 | if (yydebug) | |||
| 1056 | printf("%sdebug: error recovery discarding state %d\n", | |||
| 1057 | YYPREFIX"yy", *yyssp); | |||
| 1058 | #endif | |||
| 1059 | if (yyssp <= yyss) goto yyabort; | |||
| 1060 | --yyssp; | |||
| 1061 | --yyvsp; | |||
| 1062 | } | |||
| 1063 | } | |||
| 1064 | } | |||
| 1065 | else | |||
| 1066 | { | |||
| 1067 | if (yychar == 0) goto yyabort; | |||
| 1068 | #if YYDEBUG0 | |||
| 1069 | if (yydebug) | |||
| 1070 | { | |||
| 1071 | yys = 0; | |||
| 1072 | if (yychar <= YYMAXTOKEN296) yys = yyname[yychar]; | |||
| 1073 | if (!yys) yys = "illegal-symbol"; | |||
| 1074 | printf("%sdebug: state %d, error recovery discards token %d (%s)\n", | |||
| 1075 | YYPREFIX"yy", yystate, yychar, yys); | |||
| 1076 | } | |||
| 1077 | #endif | |||
| 1078 | yychar = (-1); | |||
| 1079 | goto yyloop; | |||
| 1080 | } | |||
| 1081 | yyreduce: | |||
| 1082 | #if YYDEBUG0 | |||
| 1083 | if (yydebug) | |||
| 1084 | printf("%sdebug: state %d, reducing by rule %d (%s)\n", | |||
| 1085 | YYPREFIX"yy", yystate, yyn, yyrule[yyn]); | |||
| 1086 | #endif | |||
| 1087 | yym = yylen[yyn]; | |||
| 1088 | if (yym) | |||
| 1089 | yyval = yyvsp[1-yym]; | |||
| 1090 | else | |||
| 1091 | memset(&yyval, 0, sizeof yyval); | |||
| 1092 | switch (yyn) | |||
| 1093 | { | |||
| 1094 | case 7: | |||
| 1095 | #line 125 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1096 | { file->errors++; } | |||
| 1097 | break; | |||
| 1098 | case 11: | |||
| 1099 | #line 136 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1100 | { | |||
| 1101 | struct file *nfile; | |||
| 1102 | ||||
| 1103 | if ((nfile = pushfile(yyvsp[0].v.string, 1)) == NULL((void*)0)) { | |||
| 1104 | yyerror("failed to include file %s", yyvsp[0].v.string); | |||
| 1105 | free(yyvsp[0].v.string); | |||
| 1106 | YYERRORgoto yyerrlab; | |||
| 1107 | } | |||
| 1108 | free(yyvsp[0].v.string); | |||
| 1109 | ||||
| 1110 | file = nfile; | |||
| 1111 | lungetc('\n'); | |||
| 1112 | } | |||
| 1113 | break; | |||
| 1114 | case 12: | |||
| 1115 | #line 151 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1116 | { | |||
| 1117 | char *s = yyvsp[-2].v.string; | |||
| 1118 | while (*s++) { | |||
| 1119 | if (isspace((unsigned char)*s)) { | |||
| 1120 | yyerror("macro name cannot contain " | |||
| 1121 | "whitespace"); | |||
| 1122 | free(yyvsp[-2].v.string); | |||
| 1123 | free(yyvsp[0].v.string); | |||
| 1124 | YYERRORgoto yyerrlab; | |||
| 1125 | } | |||
| 1126 | } | |||
| 1127 | if (symset(yyvsp[-2].v.string, yyvsp[0].v.string, 0) == -1) | |||
| 1128 | fatal("cannot store variable"); | |||
| 1129 | free(yyvsp[-2].v.string); | |||
| 1130 | free(yyvsp[0].v.string); | |||
| 1131 | } | |||
| 1132 | break; | |||
| 1133 | case 13: | |||
| 1134 | #line 169 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1135 | { | |||
| 1136 | struct servent *servent; | |||
| 1137 | ||||
| 1138 | servent = getservbyname(yyvsp[0].v.string, "tcp"); | |||
| 1139 | if (servent == NULL((void*)0)) { | |||
| 1140 | yyerror("port %s is invalid", yyvsp[0].v.string); | |||
| 1141 | free(yyvsp[0].v.string); | |||
| 1142 | YYERRORgoto yyerrlab; | |||
| 1143 | } | |||
| 1144 | yyval.v.number = ntohs(servent->s_port)(__uint16_t)(__builtin_constant_p(servent->s_port) ? (__uint16_t )(((__uint16_t)(servent->s_port) & 0xffU) << 8 | ((__uint16_t)(servent->s_port) & 0xff00U) >> 8) : __swap16md(servent->s_port)); | |||
| 1145 | free(yyvsp[0].v.string); | |||
| 1146 | } | |||
| 1147 | break; | |||
| 1148 | case 14: | |||
| 1149 | #line 181 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1150 | { | |||
| 1151 | if (yyvsp[0].v.number <= 0 || yyvsp[0].v.number > (int)USHRT_MAX(32767 *2 +1)) { | |||
| 1152 | yyerror("invalid port: %lld", yyvsp[0].v.number); | |||
| 1153 | YYERRORgoto yyerrlab; | |||
| 1154 | } | |||
| 1155 | yyval.v.number = yyvsp[0].v.number; | |||
| 1156 | } | |||
| 1157 | break; | |||
| 1158 | case 15: | |||
| 1159 | #line 188 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1160 | { | |||
| 1161 | yyval.v.number = 0; | |||
| 1162 | } | |||
| 1163 | break; | |||
| 1164 | case 16: | |||
| 1165 | #line 193 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1166 | { yyval.v.number = 0; } | |||
| 1167 | break; | |||
| 1168 | case 17: | |||
| 1169 | #line 194 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1170 | { yyval.v.number = 1; } | |||
| 1171 | break; | |||
| 1172 | case 18: | |||
| 1173 | #line 198 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1174 | { yyval.v.number = 0; } | |||
| 1175 | break; | |||
| 1176 | case 19: | |||
| 1177 | #line 199 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1178 | { yyval.v.number = 1; } | |||
| 1179 | break; | |||
| 1180 | case 20: | |||
| 1181 | #line 200 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1182 | { yyval.v.number = 2; } | |||
| 1183 | break; | |||
| 1184 | case 21: | |||
| 1185 | #line 201 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1186 | { yyval.v.number = 3; } | |||
| 1187 | break; | |||
| 1188 | case 22: | |||
| 1189 | #line 202 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1190 | { yyval.v.number = 4; } | |||
| 1191 | break; | |||
| 1192 | case 23: | |||
| 1193 | #line 203 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1194 | { yyval.v.number = 5; } | |||
| 1195 | break; | |||
| 1196 | case 24: | |||
| 1197 | #line 204 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1198 | { yyval.v.number = 6; } | |||
| 1199 | break; | |||
| 1200 | case 25: | |||
| 1201 | #line 205 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1202 | { yyval.v.number = 7; } | |||
| 1203 | break; | |||
| 1204 | case 26: | |||
| 1205 | #line 206 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1206 | { yyval.v.number = 8; } | |||
| 1207 | break; | |||
| 1208 | case 27: | |||
| 1209 | #line 207 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1210 | { yyval.v.number = 9; } | |||
| 1211 | break; | |||
| 1212 | case 28: | |||
| 1213 | #line 208 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1214 | { yyval.v.number = 10; } | |||
| 1215 | break; | |||
| 1216 | case 29: | |||
| 1217 | #line 209 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1218 | { yyval.v.number = 11; } | |||
| 1219 | break; | |||
| 1220 | case 30: | |||
| 1221 | #line 210 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1222 | { yyval.v.number = 12; } | |||
| 1223 | break; | |||
| 1224 | case 31: | |||
| 1225 | #line 211 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1226 | { yyval.v.number = 13; } | |||
| 1227 | break; | |||
| 1228 | case 32: | |||
| 1229 | #line 214 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1230 | { | |||
| 1231 | idm->idm_flags |= F_NEEDAUTH0x00400000; | |||
| 1232 | if (strlcpy(idm->idm_binddn, yyvsp[0].v.string, | |||
| 1233 | sizeof(idm->idm_binddn)) >= | |||
| 1234 | sizeof(idm->idm_binddn)) { | |||
| 1235 | yyerror("directory binddn truncated"); | |||
| 1236 | free(yyvsp[0].v.string); | |||
| 1237 | YYERRORgoto yyerrlab; | |||
| 1238 | } | |||
| 1239 | free(yyvsp[0].v.string); | |||
| 1240 | } | |||
| 1241 | break; | |||
| 1242 | case 33: | |||
| 1243 | #line 225 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1244 | { | |||
| 1245 | idm->idm_flags |= F_NEEDAUTH0x00400000; | |||
| 1246 | if (strlcpy(idm->idm_bindcred, yyvsp[0].v.string, | |||
| 1247 | sizeof(idm->idm_bindcred)) >= | |||
| 1248 | sizeof(idm->idm_bindcred)) { | |||
| 1249 | yyerror("directory bindcred truncated"); | |||
| 1250 | free(yyvsp[0].v.string); | |||
| 1251 | YYERRORgoto yyerrlab; | |||
| 1252 | } | |||
| 1253 | free(yyvsp[0].v.string); | |||
| 1254 | } | |||
| 1255 | break; | |||
| 1256 | case 34: | |||
| 1257 | #line 236 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1258 | { | |||
| 1259 | if (strlcpy(idm->idm_basedn, yyvsp[0].v.string, | |||
| 1260 | sizeof(idm->idm_basedn)) >= | |||
| 1261 | sizeof(idm->idm_basedn)) { | |||
| 1262 | yyerror("directory basedn truncated"); | |||
| 1263 | free(yyvsp[0].v.string); | |||
| 1264 | YYERRORgoto yyerrlab; | |||
| 1265 | } | |||
| 1266 | free(yyvsp[0].v.string); | |||
| 1267 | } | |||
| 1268 | break; | |||
| 1269 | case 35: | |||
| 1270 | #line 246 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1271 | { | |||
| 1272 | if(strlcpy(idm->idm_groupdn, yyvsp[0].v.string, | |||
| 1273 | sizeof(idm->idm_groupdn)) >= | |||
| 1274 | sizeof(idm->idm_groupdn)) { | |||
| 1275 | yyerror("directory groupdn truncated"); | |||
| 1276 | free(yyvsp[0].v.string); | |||
| 1277 | YYERRORgoto yyerrlab; | |||
| 1278 | } | |||
| 1279 | free(yyvsp[0].v.string); | |||
| 1280 | } | |||
| 1281 | break; | |||
| 1282 | case 36: | |||
| 1283 | #line 256 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1284 | { | |||
| 1285 | if (strlcpy(idm->idm_filters[yyvsp[-2].v.number], yyvsp[0].v.string, | |||
| 1286 | sizeof(idm->idm_filters[yyvsp[-2].v.number])) >= | |||
| 1287 | sizeof(idm->idm_filters[yyvsp[-2].v.number])) { | |||
| 1288 | yyerror("filter truncated"); | |||
| 1289 | free(yyvsp[0].v.string); | |||
| 1290 | YYERRORgoto yyerrlab; | |||
| 1291 | } | |||
| 1292 | free(yyvsp[0].v.string); | |||
| 1293 | } | |||
| 1294 | break; | |||
| 1295 | case 37: | |||
| 1296 | #line 266 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1297 | { | |||
| 1298 | if (strlcpy(idm->idm_attrs[yyvsp[-3].v.number], yyvsp[0].v.string, | |||
| 1299 | sizeof(idm->idm_attrs[yyvsp[-3].v.number])) >= | |||
| 1300 | sizeof(idm->idm_attrs[yyvsp[-3].v.number])) { | |||
| 1301 | yyerror("attribute truncated"); | |||
| 1302 | free(yyvsp[0].v.string); | |||
| 1303 | YYERRORgoto yyerrlab; | |||
| 1304 | } | |||
| 1305 | free(yyvsp[0].v.string); | |||
| 1306 | } | |||
| 1307 | break; | |||
| 1308 | case 38: | |||
| 1309 | #line 276 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1310 | { | |||
| 1311 | if (strlcpy(idm->idm_attrs[yyvsp[-1].v.number], yyvsp[0].v.string, | |||
| 1312 | sizeof(idm->idm_attrs[yyvsp[-1].v.number])) >= | |||
| 1313 | sizeof(idm->idm_attrs[yyvsp[-1].v.number])) { | |||
| 1314 | yyerror("attribute truncated"); | |||
| 1315 | free(yyvsp[0].v.string); | |||
| 1316 | YYERRORgoto yyerrlab; | |||
| 1317 | } | |||
| 1318 | idm->idm_flags |= F_FIXED_ATTR(yyvsp[-1].v.number)(1<<yyvsp[-1].v.number); | |||
| 1319 | free(yyvsp[0].v.string); | |||
| 1320 | } | |||
| 1321 | break; | |||
| 1322 | case 39: | |||
| 1323 | #line 287 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1324 | { | |||
| 1325 | if (strlcpy(idm->idm_attrs[yyvsp[-3].v.number], yyvsp[0].v.string, | |||
| 1326 | sizeof(idm->idm_attrs[yyvsp[-3].v.number])) >= | |||
| 1327 | sizeof(idm->idm_attrs[yyvsp[-3].v.number])) { | |||
| 1328 | yyerror("attribute truncated"); | |||
| 1329 | free(yyvsp[0].v.string); | |||
| 1330 | YYERRORgoto yyerrlab; | |||
| 1331 | } | |||
| 1332 | idm->idm_list |= F_LIST(yyvsp[-3].v.number)(1<<yyvsp[-3].v.number); | |||
| 1333 | free(yyvsp[0].v.string); | |||
| 1334 | } | |||
| 1335 | break; | |||
| 1336 | case 40: | |||
| 1337 | #line 300 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1338 | { yyval.v.number = 0; } | |||
| 1339 | break; | |||
| 1340 | case 41: | |||
| 1341 | #line 301 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1342 | { yyval.v.number = F_SSL0x00100000; } | |||
| 1343 | break; | |||
| 1344 | case 42: | |||
| 1345 | #line 302 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1346 | { yyval.v.number = F_STARTTLS0x00800000; } | |||
| 1347 | break; | |||
| 1348 | case 43: | |||
| 1349 | #line 305 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1350 | { | |||
| 1351 | if ((idm = calloc(1, sizeof(*idm))) == NULL((void*)0)) | |||
| 1352 | fatal(NULL((void*)0)); | |||
| 1353 | idm->idm_id = conf->sc_maxid++; | |||
| 1354 | ||||
| 1355 | if (strlcpy(idm->idm_name, yyvsp[-2].v.string, | |||
| 1356 | sizeof(idm->idm_name)) >= | |||
| 1357 | sizeof(idm->idm_name)) { | |||
| 1358 | yyerror("attribute truncated"); | |||
| 1359 | free(yyvsp[-2].v.string); | |||
| 1360 | YYERRORgoto yyerrlab; | |||
| 1361 | } | |||
| 1362 | free(yyvsp[-2].v.string); | |||
| 1363 | ||||
| 1364 | idm->idm_port = yyvsp[-1].v.number; | |||
| 1365 | ||||
| 1366 | if (yyvsp[0].v.number != 0) { | |||
| 1367 | if (tls_init()) { | |||
| 1368 | yyerror("tls init failed"); | |||
| 1369 | YYERRORgoto yyerrlab; | |||
| 1370 | } | |||
| 1371 | ||||
| 1372 | idm->idm_flags |= yyvsp[0].v.number; | |||
| 1373 | idm->idm_tls_config = tls_config_new(); | |||
| 1374 | if (idm->idm_tls_config == NULL((void*)0)) { | |||
| 1375 | yyerror("tls config failed"); | |||
| 1376 | YYERRORgoto yyerrlab; | |||
| 1377 | } | |||
| 1378 | ||||
| 1379 | if (tls_config_set_protocols( | |||
| 1380 | idm->idm_tls_config, | |||
| 1381 | TLS_PROTOCOLS_ALL((1 << 1)|(1 << 2)| (1 << 3)|(1 << 4) )) == -1) { | |||
| 1382 | yyerror("tls set protocols failed: %s", | |||
| 1383 | tls_config_error( | |||
| 1384 | idm->idm_tls_config)); | |||
| 1385 | tls_config_free(idm->idm_tls_config); | |||
| 1386 | idm->idm_tls_config = NULL((void*)0); | |||
| 1387 | YYERRORgoto yyerrlab; | |||
| 1388 | } | |||
| 1389 | if (tls_config_set_ciphers(idm->idm_tls_config, | |||
| 1390 | "compat") == -1) { | |||
| 1391 | yyerror("tls set ciphers failed: %s", | |||
| 1392 | tls_config_error( | |||
| 1393 | idm->idm_tls_config)); | |||
| 1394 | tls_config_free(idm->idm_tls_config); | |||
| 1395 | idm->idm_tls_config = NULL((void*)0); | |||
| 1396 | YYERRORgoto yyerrlab; | |||
| 1397 | } | |||
| 1398 | ||||
| 1399 | if (tls_config_set_ca_file(idm->idm_tls_config, | |||
| 1400 | conf->sc_cafile) == -1) { | |||
| 1401 | yyerror("tls set CA bundle failed: %s", | |||
| 1402 | tls_config_error( | |||
| 1403 | idm->idm_tls_config)); | |||
| 1404 | tls_config_free(idm->idm_tls_config); | |||
| 1405 | idm->idm_tls_config = NULL((void*)0); | |||
| 1406 | YYERRORgoto yyerrlab; | |||
| 1407 | } | |||
| 1408 | } | |||
| 1409 | ||||
| 1410 | } | |||
| 1411 | break; | |||
| 1412 | case 44: | |||
| 1413 | #line 365 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1414 | { | |||
| 1415 | TAILQ_INSERT_TAIL(&conf->sc_idms, idm, idm_entry)do { (idm)->idm_entry.tqe_next = ((void*)0); (idm)->idm_entry .tqe_prev = (&conf->sc_idms)->tqh_last; *(&conf ->sc_idms)->tqh_last = (idm); (&conf->sc_idms)-> tqh_last = &(idm)->idm_entry.tqe_next; } while (0); | |||
| 1416 | idm = NULL((void*)0); | |||
| 1417 | } | |||
| 1418 | break; | |||
| 1419 | case 45: | |||
| 1420 | #line 371 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1421 | { | |||
| 1422 | conf->sc_conf_tv.tv_sec = yyvsp[0].v.number; | |||
| 1423 | conf->sc_conf_tv.tv_usec = 0; | |||
| 1424 | } | |||
| 1425 | break; | |||
| 1426 | case 46: | |||
| 1427 | #line 375 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1428 | { | |||
| 1429 | if (strlcpy(conf->sc_domainname, yyvsp[0].v.string, | |||
| 1430 | sizeof(conf->sc_domainname)) >= | |||
| 1431 | sizeof(conf->sc_domainname)) { | |||
| 1432 | yyerror("domainname truncated"); | |||
| 1433 | free(yyvsp[0].v.string); | |||
| 1434 | YYERRORgoto yyerrlab; | |||
| 1435 | } | |||
| 1436 | free(yyvsp[0].v.string); | |||
| 1437 | } | |||
| 1438 | break; | |||
| 1439 | case 47: | |||
| 1440 | #line 385 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1441 | { | |||
| 1442 | if (strcmp(yyvsp[0].v.string, "passwd.byname") == 0) | |||
| 1443 | conf->sc_flags |= YPMAP_PASSWD_BYNAME0x00000001; | |||
| 1444 | else if (strcmp(yyvsp[0].v.string, "passwd.byuid") == 0) | |||
| 1445 | conf->sc_flags |= YPMAP_PASSWD_BYUID0x00000002; | |||
| 1446 | else if (strcmp(yyvsp[0].v.string, "master.passwd.byname") == 0) | |||
| 1447 | conf->sc_flags |= YPMAP_MASTER_PASSWD_BYNAME0x00000004; | |||
| 1448 | else if (strcmp(yyvsp[0].v.string, "master.passwd.byuid") == 0) | |||
| 1449 | conf->sc_flags |= YPMAP_MASTER_PASSWD_BYUID0x00000008; | |||
| 1450 | else if (strcmp(yyvsp[0].v.string, "group.byname") == 0) | |||
| 1451 | conf->sc_flags |= YPMAP_GROUP_BYNAME0x00000010; | |||
| 1452 | else if (strcmp(yyvsp[0].v.string, "group.bygid") == 0) | |||
| 1453 | conf->sc_flags |= YPMAP_GROUP_BYGID0x00000020; | |||
| 1454 | else if (strcmp(yyvsp[0].v.string, "netid.byname") == 0) | |||
| 1455 | conf->sc_flags |= YPMAP_NETID_BYNAME0x00000040; | |||
| 1456 | else { | |||
| 1457 | yyerror("unsupported map type: %s", yyvsp[0].v.string); | |||
| 1458 | free(yyvsp[0].v.string); | |||
| 1459 | YYERRORgoto yyerrlab; | |||
| 1460 | } | |||
| 1461 | free(yyvsp[0].v.string); | |||
| 1462 | } | |||
| 1463 | break; | |||
| 1464 | case 48: | |||
| 1465 | #line 407 "/usr/src/usr.sbin/ypldap/parse.y" | |||
| 1466 | { | |||
| 1467 | free(conf->sc_cafile); | |||
| 1468 | conf->sc_cafile = yyvsp[0].v.string; | |||
| 1469 | } | |||
| 1470 | break; | |||
| 1471 | #line 1464 "parse.c" | |||
| 1472 | } | |||
| 1473 | yyssp -= yym; | |||
| 1474 | yystate = *yyssp; | |||
| 1475 | yyvsp -= yym; | |||
| 1476 | yym = yylhs[yyn]; | |||
| 1477 | if (yystate == 0 && yym == 0) | |||
| 1478 | { | |||
| 1479 | #if YYDEBUG0 | |||
| 1480 | if (yydebug) | |||
| 1481 | printf("%sdebug: after reduction, shifting from state 0 to\ | |||
| 1482 | state %d\n", YYPREFIX"yy", YYFINAL1); | |||
| 1483 | #endif | |||
| 1484 | yystate = YYFINAL1; | |||
| 1485 | *++yyssp = YYFINAL1; | |||
| 1486 | *++yyvsp = yyval; | |||
| 1487 | if (yychar < 0) | |||
| 1488 | { | |||
| 1489 | if ((yychar = yylex()) < 0) yychar = 0; | |||
| 1490 | #if YYDEBUG0 | |||
| 1491 | if (yydebug) | |||
| 1492 | { | |||
| 1493 | yys = 0; | |||
| 1494 | if (yychar <= YYMAXTOKEN296) yys = yyname[yychar]; | |||
| 1495 | if (!yys) yys = "illegal-symbol"; | |||
| 1496 | printf("%sdebug: state %d, reading %d (%s)\n", | |||
| 1497 | YYPREFIX"yy", YYFINAL1, yychar, yys); | |||
| 1498 | } | |||
| 1499 | #endif | |||
| 1500 | } | |||
| 1501 | if (yychar == 0) goto yyaccept; | |||
| 1502 | goto yyloop; | |||
| 1503 | } | |||
| 1504 | if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && | |||
| 1505 | yyn <= YYTABLESIZE285 && yycheck[yyn] == yystate) | |||
| 1506 | yystate = yytable[yyn]; | |||
| 1507 | else | |||
| 1508 | yystate = yydgoto[yym]; | |||
| 1509 | #if YYDEBUG0 | |||
| 1510 | if (yydebug) | |||
| 1511 | printf("%sdebug: after reduction, shifting from state %d \ | |||
| 1512 | to state %d\n", YYPREFIX"yy", *yyssp, yystate); | |||
| 1513 | #endif | |||
| 1514 | if (yyssp >= yysslim && yygrowstack()) | |||
| 1515 | { | |||
| 1516 | goto yyoverflow; | |||
| 1517 | } | |||
| 1518 | *++yyssp = yystate; | |||
| 1519 | *++yyvsp = yyval; | |||
| 1520 | goto yyloop; | |||
| 1521 | yyoverflow: | |||
| 1522 | yyerror("yacc stack overflow"); | |||
| 1523 | yyabort: | |||
| 1524 | if (yyss) | |||
| 1525 | free(yyss); | |||
| 1526 | if (yyvs) | |||
| 1527 | free(yyvs); | |||
| 1528 | yyss = yyssp = NULL((void*)0); | |||
| 1529 | yyvs = yyvsp = NULL((void*)0); | |||
| 1530 | yystacksize = 0; | |||
| 1531 | return (1); | |||
| 1532 | yyaccept: | |||
| 1533 | if (yyss) | |||
| 1534 | free(yyss); | |||
| 1535 | if (yyvs) | |||
| 1536 | free(yyvs); | |||
| 1537 | yyss = yyssp = NULL((void*)0); | |||
| 1538 | yyvs = yyvsp = NULL((void*)0); | |||
| 1539 | yystacksize = 0; | |||
| 1540 | return (0); | |||
| 1541 | } |