stored with the contents. This could lead to incorrect output
if the sudoers file had different alias types with the same name.
Normal parsing (ie: not in '-l' mode) is unaffected.
+
+365) Now include strcasecmp() for those without it.
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-Additionally, lsearch.c, fnmatch.c, getcwd.c, snprintf.c and fnmatch.3 bear
-the following UCB license:
+Additionally, lsearch.c, fnmatch.c, getcwd.c, snprintf.c, strcasecmp.c
+and fnmatch.3 bear the following UCB license:
/*
- * Copyright (c) 1989, 1990, 1991, 1993, 1994
+ * Copyright (c) 1987, 1989, 1990, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
SRCS = alloc.c alloca.c check.c fileops.c find_path.c fnmatch.c getcwd.c \
getspwuid.c goodpath.c interfaces.c lex.yy.c lsearch.c logging.c \
- parse.c parse.lex parse.yacc putenv.c snprintf.c strerror.c sudo.c \
- sudo.tab.c sudo_setenv.c testsudoers.c tgetpass.c utime.c version.c \
- visudo.c $(AUTH_SRCS)
+ parse.c parse.lex parse.yacc putenv.c snprintf.c strcasecmp.c \
+ strerror.c sudo.c sudo.tab.c sudo_setenv.c testsudoers.c tgetpass.c \
+ utime.c version.c visudo.c $(AUTH_SRCS)
AUTH_SRCS = auth/afs.c auth/aix_auth.c auth/dce.c auth/fwtk.c auth/kerb4.c \
auth/kerb5.c auth/pam.c auth/passwd.c auth/rfc1938.c \
lsearch.o: lsearch.c config.h compat.h emul/search.h
putenv.o: putenv.c config.h compat.h
snprintf.o: snprintf.c config.h compat.h
+strcasecmp.o: strcasecmp.c config.h
strerror.o: strerror.c config.h
utime.o: utime.c config.h pathnames.h compat.h emul/utime.h
;;
esac
-for ac_func in strchr strrchr memchr memcpy memset sysconf sigaction tzset strcasecmp seteuid ftruncate
+for ac_func in strchr strrchr memchr memcpy memset sysconf sigaction tzset seteuid ftruncate
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:5487: checking for $ac_func" >&5
LIBOBJS="$LIBOBJS fnmatch.o"
fi
-for ac_func in strerror
+for ac_func in strerror strcasecmp
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:6451: checking for $ac_func" >&5
dnl
dnl Function checks
dnl
-AC_CHECK_FUNCS(strchr strrchr memchr memcpy memset sysconf sigaction tzset strcasecmp seteuid ftruncate)
+AC_CHECK_FUNCS(strchr strrchr memchr memcpy memset sysconf sigaction tzset seteuid ftruncate)
if test -n "$SECUREWARE"; then
AC_CHECK_FUNCS(bigcrypt)
AC_CHECK_FUNCS(set_auth_parameters)
AC_CHECK_FUNC(utime, AC_DEFINE(HAVE_UTIME)
SUDO_FUNC_UTIME_POSIX, LIBOBJS="$LIBOBJS utime.o")
SUDO_FUNC_FNMATCH(AC_DEFINE(HAVE_FNMATCH), LIBOBJS="$LIBOBJS fnmatch.o")
-AC_REPLACE_FUNCS(strerror)
+AC_REPLACE_FUNCS(strerror strcasecmp)
AC_CHECK_FUNC(snprintf, AC_DEFINE(HAVE_SNPRINTF), NEED_SNPRINTF=1)
AC_CHECK_FUNC(vsnprintf, AC_DEFINE(HAVE_VSNPRINTF), NEED_SNPRINTF=1)
AC_CHECK_FUNC(asprintf, AC_DEFINE(HAVE_ASPRINTF), NEED_SNPRINTF=1)
#include "emul/search.h"
#endif /* HAVE_LSEARCH */
-#ifndef HAVE_STRCASECMP
-#define strcasecmp(a,b) strcmp(a,b)
-#endif /* !HAVE_STRCASECMP */
-
#ifndef lint
static const char rcsid[] = "$Sudo$";
#endif /* lint */
--- /dev/null
+/*
+ * Copyright (c) 1987, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)strcasecmp.c 8.1 (Berkeley) 6/4/93
+ */
+
+#include "config.h"
+
+#ifndef lint
+static const char rcsid[] = "$Sudo$";
+#endif /* lint */
+
+/*
+ * This array is designed for mapping upper and lower case letter
+ * together for a case independent comparison. The mappings are
+ * based upon ascii character sequences.
+ */
+static const unsigned char charmap[] = {
+ '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
+ '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
+ '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
+ '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
+ '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
+ '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
+ '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
+ '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
+ '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
+ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
+ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
+ '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
+ '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
+ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
+ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
+ '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
+ '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
+ '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
+ '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
+ '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
+ '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
+ '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
+ '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
+ '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
+ '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
+ '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
+ '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
+ '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
+ '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
+ '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
+ '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
+ '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
+};
+
+int
+strcasecmp(s1, s2)
+ const char *s1, *s2;
+{
+ const unsigned char *cm = charmap,
+ *us1 = (const unsigned char *)s1,
+ *us2 = (const unsigned char *)s2;
+
+ while (cm[*us1] == cm[*us2++])
+ if (*us1++ == '\0')
+ return (0);
+ return (cm[*us1] - cm[*--us2]);
+}
+
+int
+strncasecmp(s1, s2, n)
+ const char *s1, *s2;
+ size_t n;
+{
+
+ if (n != 0) {
+ const unsigned char *cm = charmap,
+ *us1 = (const unsigned char *)s1,
+ *us2 = (const unsigned char *)s2;
+
+ do {
+ if (cm[*us1] != cm[*us2++])
+ return (cm[*us1] - cm[*--us2]);
+ if (*us1++ == '\0')
+ break;
+ } while (--n != 0);
+ }
+ return (0);
+}
#include "emul/search.h"
#endif /* HAVE_LSEARCH */
-#ifndef HAVE_STRCASECMP
-#define strcasecmp(a,b) strcmp(a,b)
-#endif /* !HAVE_STRCASECMP */
-
#ifndef lint
static const char rcsid[] = "$Sudo$";
#endif /* lint */
}
parse_error = TRUE;
}
-#line 211 "./parse.yacc"
+#line 207 "./parse.yacc"
typedef union {
char *string;
int BOOLEAN;
struct sudo_command command;
int tok;
} YYSTYPE;
-#line 235 "sudo.tab.c"
+#line 231 "sudo.tab.c"
#define COMMAND 257
#define ALIAS 258
#define NTWKADDR 259
short *yysslim;
YYSTYPE *yyvs;
int yystacksize;
-#line 769 "./parse.yacc"
+#line 765 "./parse.yacc"
#define MOREALIASES (32)
aliasinfo *aliases = NULL;
if (printmatches == TRUE)
expand_match_list();
}
-#line 890 "sudo.tab.c"
+#line 886 "sudo.tab.c"
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
#if defined(__cplusplus) || __STDC__
static int yygrowstack(void)
switch (yyn)
{
case 3:
-#line 256 "./parse.yacc"
+#line 252 "./parse.yacc"
{ ; }
break;
case 4:
-#line 258 "./parse.yacc"
+#line 254 "./parse.yacc"
{ yyerrok; }
break;
case 5:
-#line 259 "./parse.yacc"
+#line 255 "./parse.yacc"
{ push; }
break;
case 6:
-#line 259 "./parse.yacc"
+#line 255 "./parse.yacc"
{
while (top && user_matches != TRUE)
pop;
}
break;
case 7:
-#line 264 "./parse.yacc"
+#line 260 "./parse.yacc"
{ ; }
break;
case 8:
-#line 266 "./parse.yacc"
+#line 262 "./parse.yacc"
{ ; }
break;
case 9:
-#line 268 "./parse.yacc"
+#line 264 "./parse.yacc"
{ ; }
break;
case 10:
-#line 270 "./parse.yacc"
+#line 266 "./parse.yacc"
{ ; }
break;
case 13:
-#line 278 "./parse.yacc"
+#line 274 "./parse.yacc"
{
/*
* We already did a push if necessary in
}
break;
case 14:
-#line 290 "./parse.yacc"
+#line 286 "./parse.yacc"
{
if (yyvsp[0].BOOLEAN != -1)
host_matches = yyvsp[0].BOOLEAN;
}
break;
case 15:
-#line 294 "./parse.yacc"
+#line 290 "./parse.yacc"
{
if (yyvsp[0].BOOLEAN != -1)
host_matches = ! yyvsp[0].BOOLEAN;
}
break;
case 16:
-#line 299 "./parse.yacc"
+#line 295 "./parse.yacc"
{
yyval.BOOLEAN = TRUE;
}
break;
case 17:
-#line 302 "./parse.yacc"
+#line 298 "./parse.yacc"
{
if (addr_matches(yyvsp[0].string))
yyval.BOOLEAN = TRUE;
}
break;
case 18:
-#line 309 "./parse.yacc"
+#line 305 "./parse.yacc"
{
if (netgr_matches(yyvsp[0].string, user_host, NULL))
yyval.BOOLEAN = TRUE;
}
break;
case 19:
-#line 316 "./parse.yacc"
+#line 312 "./parse.yacc"
{
if (strcasecmp(user_shost, yyvsp[0].string) == 0)
yyval.BOOLEAN = TRUE;
}
break;
case 20:
-#line 323 "./parse.yacc"
+#line 319 "./parse.yacc"
{
if (strcasecmp(user_host, yyvsp[0].string) == 0)
yyval.BOOLEAN = TRUE;
}
break;
case 21:
-#line 330 "./parse.yacc"
+#line 326 "./parse.yacc"
{
aliasinfo *aip = find_alias(yyvsp[0].string, HOST_ALIAS);
}
break;
case 24:
-#line 358 "./parse.yacc"
+#line 354 "./parse.yacc"
{
/*
* Push the entry onto the stack if it is worth
}
break;
case 25:
-#line 380 "./parse.yacc"
+#line 376 "./parse.yacc"
{
if (yyvsp[0].BOOLEAN != -1)
cmnd_matches = yyvsp[0].BOOLEAN;
}
break;
case 26:
-#line 384 "./parse.yacc"
+#line 380 "./parse.yacc"
{
if (printmatches == TRUE) {
if (in_alias == TRUE)
}
break;
case 27:
-#line 392 "./parse.yacc"
+#line 388 "./parse.yacc"
{
if (yyvsp[0].BOOLEAN != -1)
cmnd_matches = ! yyvsp[0].BOOLEAN;
}
break;
case 28:
-#line 398 "./parse.yacc"
+#line 394 "./parse.yacc"
{
if (printmatches == TRUE && host_matches == TRUE &&
user_matches == TRUE) {
}
break;
case 29:
-#line 421 "./parse.yacc"
+#line 417 "./parse.yacc"
{ ; }
break;
case 32:
-#line 428 "./parse.yacc"
+#line 424 "./parse.yacc"
{
if (yyvsp[0].BOOLEAN != -1)
runas_matches = yyvsp[0].BOOLEAN;
}
break;
case 33:
-#line 432 "./parse.yacc"
+#line 428 "./parse.yacc"
{
if (printmatches == TRUE) {
if (in_alias == TRUE)
}
break;
case 34:
-#line 440 "./parse.yacc"
+#line 436 "./parse.yacc"
{
if (yyvsp[0].BOOLEAN != -1)
runas_matches = ! yyvsp[0].BOOLEAN;
}
break;
case 35:
-#line 445 "./parse.yacc"
+#line 441 "./parse.yacc"
{
if (printmatches == TRUE) {
if (in_alias == TRUE)
}
break;
case 36:
-#line 459 "./parse.yacc"
+#line 455 "./parse.yacc"
{
if (printmatches == TRUE) {
if (in_alias == TRUE)
}
break;
case 37:
-#line 473 "./parse.yacc"
+#line 469 "./parse.yacc"
{
if (printmatches == TRUE) {
if (in_alias == TRUE)
}
break;
case 38:
-#line 487 "./parse.yacc"
+#line 483 "./parse.yacc"
{
aliasinfo *aip = find_alias(yyvsp[0].string, RUNAS_ALIAS);
}
break;
case 39:
-#line 516 "./parse.yacc"
+#line 512 "./parse.yacc"
{
if (printmatches == TRUE) {
if (in_alias == TRUE)
}
break;
case 40:
-#line 528 "./parse.yacc"
+#line 524 "./parse.yacc"
{
/* Inherit NOPASSWD/PASSWD status. */
if (printmatches == TRUE && host_matches == TRUE &&
}
break;
case 41:
-#line 538 "./parse.yacc"
+#line 534 "./parse.yacc"
{
no_passwd = TRUE;
if (printmatches == TRUE && host_matches == TRUE &&
}
break;
case 42:
-#line 544 "./parse.yacc"
+#line 540 "./parse.yacc"
{
no_passwd = FALSE;
if (printmatches == TRUE && host_matches == TRUE &&
}
break;
case 43:
-#line 552 "./parse.yacc"
+#line 548 "./parse.yacc"
{
if (printmatches == TRUE) {
if (in_alias == TRUE)
}
break;
case 44:
-#line 569 "./parse.yacc"
+#line 565 "./parse.yacc"
{
aliasinfo *aip;
}
break;
case 45:
-#line 598 "./parse.yacc"
+#line 594 "./parse.yacc"
{
if (printmatches == TRUE) {
if (in_alias == TRUE) {
}
break;
case 48:
-#line 630 "./parse.yacc"
+#line 626 "./parse.yacc"
{ push; }
break;
case 49:
-#line 630 "./parse.yacc"
+#line 626 "./parse.yacc"
{
if ((host_matches != -1 || pedantic) &&
!add_alias(yyvsp[-3].string, HOST_ALIAS, host_matches))
}
break;
case 54:
-#line 646 "./parse.yacc"
+#line 642 "./parse.yacc"
{
push;
if (printmatches == TRUE) {
}
break;
case 55:
-#line 655 "./parse.yacc"
+#line 651 "./parse.yacc"
{
if ((cmnd_matches != -1 || pedantic) &&
!add_alias(yyvsp[-3].string, CMND_ALIAS, cmnd_matches))
}
break;
case 56:
-#line 667 "./parse.yacc"
+#line 663 "./parse.yacc"
{ ; }
break;
case 60:
-#line 675 "./parse.yacc"
+#line 671 "./parse.yacc"
{
push;
if (printmatches == TRUE) {
}
break;
case 61:
-#line 684 "./parse.yacc"
+#line 680 "./parse.yacc"
{
if ((runas_matches != -1 || pedantic) &&
!add_alias(yyvsp[-3].string, RUNAS_ALIAS, runas_matches))
}
break;
case 64:
-#line 700 "./parse.yacc"
+#line 696 "./parse.yacc"
{ push; }
break;
case 65:
-#line 700 "./parse.yacc"
+#line 696 "./parse.yacc"
{
if ((user_matches != -1 || pedantic) &&
!add_alias(yyvsp[-3].string, USER_ALIAS, user_matches))
}
break;
case 66:
-#line 709 "./parse.yacc"
+#line 705 "./parse.yacc"
{ ; }
break;
case 68:
-#line 713 "./parse.yacc"
+#line 709 "./parse.yacc"
{
if (yyvsp[0].BOOLEAN != -1)
user_matches = yyvsp[0].BOOLEAN;
}
break;
case 69:
-#line 717 "./parse.yacc"
+#line 713 "./parse.yacc"
{
if (yyvsp[0].BOOLEAN != -1)
user_matches = ! yyvsp[0].BOOLEAN;
}
break;
case 70:
-#line 722 "./parse.yacc"
+#line 718 "./parse.yacc"
{
if (strcmp(yyvsp[0].string, user_name) == 0)
yyval.BOOLEAN = TRUE;
}
break;
case 71:
-#line 729 "./parse.yacc"
+#line 725 "./parse.yacc"
{
if (usergr_matches(yyvsp[0].string, user_name))
yyval.BOOLEAN = TRUE;
}
break;
case 72:
-#line 736 "./parse.yacc"
+#line 732 "./parse.yacc"
{
if (netgr_matches(yyvsp[0].string, NULL, user_name))
yyval.BOOLEAN = TRUE;
}
break;
case 73:
-#line 743 "./parse.yacc"
+#line 739 "./parse.yacc"
{
aliasinfo *aip = find_alias(yyvsp[0].string, USER_ALIAS);
}
break;
case 74:
-#line 763 "./parse.yacc"
+#line 759 "./parse.yacc"
{
yyval.BOOLEAN = TRUE;
}
break;
-#line 1676 "sudo.tab.c"
+#line 1672 "sudo.tab.c"
}
yyssp -= yym;
yystate = *yyssp;