=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/sudo/Attic/toke.l,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- src/usr.bin/sudo/Attic/toke.l 2008/11/24 15:13:35 1.2 +++ src/usr.bin/sudo/Attic/toke.l 2009/04/11 11:48:06 1.3 @@ -55,7 +55,7 @@ #include #ifndef lint -__unused static const char rcsid[] = "$Sudo: toke.l,v 1.27 2008/11/24 00:41:36 millert Exp $"; +__unused static const char rcsid[] = "$Sudo: toke.l,v 1.29 2009/02/21 21:49:19 millert Exp $"; #endif /* lint */ extern YYSTYPE yylval; @@ -467,12 +467,12 @@ LEXTRACE("\n\t"); } /* throw away EOL after \ */ -#([^\n0-9-].*)?\n { +#(-[^\n0-9].*|[^\n0-9-].*)?\n { BEGIN INITIAL; ++sudolineno; LEXTRACE("\n"); return(COMMENT); - } /* return comments */ + } /* comment, not uid/gid */ <*>. { LEXTRACE("ERROR "); @@ -671,22 +671,43 @@ char *base; { char *cp, *ep, *path; - int len; + int len = 0, subst = 0; + size_t shost_len = 0; /* Pull out path from #include line. */ cp = base + sizeof("#include"); while (isblank((unsigned char) *cp)) cp++; ep = cp; - while (*ep != '\0' && !isspace((unsigned char) *ep)) + while (*ep != '\0' && !isspace((unsigned char) *ep)) { + if (ep[0] == '%' && ep[1] == 'h') { + shost_len = strlen(user_shost); + len += shost_len - 2; + subst = 1; + } ep++; + } /* Make a copy of path and return it. */ - len = (int)(ep - cp); + len += (int)(ep - cp); if ((path = malloc(len + 1)) == NULL) yyerror("unable to allocate memory"); - memcpy(path, cp, len); - path[len] = '\0'; + if (subst) { + /* substitute for %h */ + char *pp = path; + while (cp < ep) { + if (cp[0] == '%' && cp[1] == 'h') { + memcpy(pp, user_shost, shost_len); + pp += shost_len; + cp += 2; + } + *pp++ = *cp++; + } + *pp = '\0'; + } else { + memcpy(path, cp, len); + path[len] = '\0'; + } /* Push any excess characters (e.g. comment, newline) back to the lexer */ if (*ep != '\0')