diff --git a/Build.sh b/Build.sh index 2c27855..f82c820 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.560 2012/05/04 21:57:36 tg Exp $' +srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.561 2012/05/04 22:04:58 tg Exp $' #- # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012 @@ -502,6 +502,7 @@ BSD/OS) ;; Coherent) oswarn="; it has major issues" + add_cppflags -DMKSH__NO_SYMLINK check_categories="$check_categories nosymlink" add_cppflags -DMKSH__NO_SETEUGID ;; @@ -1408,7 +1409,7 @@ else #define EXTERN #define MKSH_INCLUDES_ONLY #include "sh.h" - __RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.560 2012/05/04 21:57:36 tg Exp $"); + __RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.561 2012/05/04 22:04:58 tg Exp $"); int main(void) { printf("Hello, World!\n"); return (0); } EOF case $cm in diff --git a/eval.c b/eval.c index c71c66f..0573ab2 100644 --- a/eval.c +++ b/eval.c @@ -23,7 +23,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.117 2012/04/22 21:50:31 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.118 2012/05/04 22:05:00 tg Exp $"); /* * string expansion @@ -1437,7 +1437,7 @@ globit(XString *xs, /* dest string */ struct stat lstatb, statb; int stat_done = 0; /* -1: failed, 1 ok */ - if (lstat(Xstring(*xs, xp), &lstatb) < 0) + if (mksh_lstat(Xstring(*xs, xp), &lstatb) < 0) return; /* * special case for systems which strip trailing diff --git a/funcs.c b/funcs.c index 145e1da..2880527 100644 --- a/funcs.c +++ b/funcs.c @@ -38,7 +38,7 @@ #endif #endif -__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.216 2012/05/04 21:47:01 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.217 2012/05/04 22:05:00 tg Exp $"); #if HAVE_KILLPG /* @@ -2943,7 +2943,11 @@ test_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2, /* -h or -L */ case TO_FILSYM: +#ifdef MKSH__NO_SYMLINK + return (0); +#else return (lstat(opnd1, &b1) == 0 && S_ISLNK(b1.st_mode)); +#endif /* -S */ case TO_FILSOCK: diff --git a/misc.c b/misc.c index 965ed14..f117530 100644 --- a/misc.c +++ b/misc.c @@ -30,7 +30,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.190 2012/05/04 21:57:38 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.191 2012/05/04 22:05:02 tg Exp $"); /* type bits for unsigned char */ unsigned char chtypes[UCHAR_MAX + 1]; @@ -1389,7 +1389,7 @@ do_realpath(const char *upath) *xp = '\0'; /* lstat the current output, see if it's a symlink */ - if (lstat(Xstring(xs, xp), &sb)) { + if (mksh_lstat(Xstring(xs, xp), &sb)) { /* lstat failed */ if (errno == ENOENT) { /* because the pathname does not exist */ @@ -1406,6 +1406,7 @@ do_realpath(const char *upath) goto notfound; } +#ifndef MKSH__NO_SYMLINK /* check if we encountered a symlink? */ if (S_ISLNK(sb.st_mode)) { /* reached maximum recursion depth? */ @@ -1456,6 +1457,7 @@ do_realpath(const char *upath) } } } +#endif /* otherwise (no symlink) merely go on */ } diff --git a/sh.h b/sh.h index 283d206..965bfb1 100644 --- a/sh.h +++ b/sh.h @@ -152,7 +152,7 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.555 2012/05/04 21:47:03 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.556 2012/05/04 22:05:02 tg Exp $"); #endif #define MKSH_VERSION "R40 2012/04/27" @@ -358,6 +358,14 @@ extern int __cdecl setegid(gid_t); #define mksh_TIME(tv) gettimeofday(&(tv), NULL) #endif +#ifdef MKSH__NO_SYMLINK +#undef S_ISLNK +#define S_ISLNK(m) (/* CONSTCOND */ 0) +#define mksh_lstat stat +#else +#define mksh_lstat lstat +#endif + /* remove redundancies */ #if defined(MirBSD) && (MirBSD >= 0x08A8) && !defined(MKSH_OPTSTATIC)