Fixes for Cygwin: Use local swab() impl, and tweak policy update test-harness test path handling -- it was prepending a path variable that's always empty, but we were also using absolute paths so we didn't notice elsewhere, though we were using paths of the form //foo/bar/baz. Leading double slashes are significant on Cygwin since they're used to denote UNC paths, so tests failed there & uncovered this problem

This commit is contained in:
Brian Cox 2017-09-08 11:58:19 -07:00
parent 078bf28164
commit 2a3d69e8c9
6 changed files with 45 additions and 13 deletions

View File

@ -102,6 +102,9 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `swab' function. */
#undef HAVE_SWAB
/* Define to 1 if you have the <syslog.h> header file. */
#undef HAVE_SYSLOG_H
@ -135,6 +138,9 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <sys/unistd.h> header file. */
#undef HAVE_SYS_UNISTD_H
/* Define to 1 if you have the <sys/ustat.h> header file. */
#undef HAVE_SYS_USTAT_H

26
configure vendored
View File

@ -5569,7 +5569,20 @@ fi
done
for ac_header in unistd.h syslog.h langinfo.h sys/statfs.h sys/select.h
for ac_header in unistd.h sys/unistd.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in syslog.h langinfo.h sys/statfs.h sys/select.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@ -6182,6 +6195,17 @@ _ACEOF
fi
done
for ac_func in swab
do :
ac_fn_c_check_func "$LINENO" "swab" "ac_cv_func_swab"
if test "x$ac_cv_func_swab" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SWAB 1
_ACEOF
fi
done
for ac_header in fcntl.h
do :

View File

@ -99,7 +99,8 @@ AC_CHECK_HEADERS(sys/mount.h,,,
#endif
]])
AC_CHECK_HEADERS(sys/ustat.h sys/sysmacros.h sys/syslog.h sys/socket.h)
AC_CHECK_HEADERS(unistd.h syslog.h langinfo.h sys/statfs.h sys/select.h)
AC_CHECK_HEADERS(unistd.h sys/unistd.h)
AC_CHECK_HEADERS(syslog.h langinfo.h sys/statfs.h sys/select.h)
AC_CHECK_HEADERS(signum.h bits/signum.h, break )
AC_CHECK_HEADERS(stdarg.h varargs.h, break )
AC_CHECK_HEADERS(sys/utsname.h memory.h)
@ -143,6 +144,7 @@ dnl Checks for standard functions
dnl #############################
AC_CHECK_FUNCS(strftime gethostname gethostid)
AC_CHECK_FUNCS(mkstemp mktemp, break)
AC_CHECK_FUNCS(swab)
dnl check for posix_fadvise
AC_CHECK_HEADERS(fcntl.h, [AC_CHECK_FUNCS(posix_fadvise)])

View File

@ -303,7 +303,7 @@
#define SUPPORTS_POSIX_SIGNALS (!IS_DOS_DJGPP)
#define SUPPORTS_NETWORKING (!IS_SORTIX && !IS_DOS_DJGPP)
#define SUPPORTS_SYSLOG (HAVE_SYSLOG_H && !IS_SKYOS && !IS_RISCOS)
#define NEEDS_SWAB_IMPL (IS_SYLLABLE || IS_ANDROID || IS_SORTIX)
#define NEEDS_SWAB_IMPL (IS_CYGWIN || IS_SYLLABLE || IS_ANDROID || IS_SORTIX)
#define USES_MBLEN (!IS_ANDROID && !IS_AROS)
#define USES_DEVICE_PATH (IS_AROS || IS_DOS_DJGPP)
#define ICONV_CONST_SOURCE (IS_MINIX)

View File

@ -56,31 +56,31 @@ POLICY_END
######################################################################
# CreateFile -- create a file with the specified contents
#
# input: path -- path to the file; relative to $root
# input: path -- *absolute* path to the file
# contents -- string to put in the file
#
sub CreateFile
{
my ($path, $contents) = @_;
system( "echo $contents > $root/$path" );
system( "echo $contents > $path" );
$? && die "Create file failed for $root/$path\n";
$? && die "Create file failed for $path\n";
}
######################################################################
# RemoveFile -- removes the named file
# RemoveFile -- removes the named file by absolute path
#
sub RemoveFile
{
my ($path) = @_;
if( -e "$root/$path" )
if( -e $path )
{
system( "rm -f $root/$path" );
system( "rm -f $path" );
}
$? && die "Remove file failed for $root/$path\n";
$? && die "Remove file failed for $path\n";
}

View File

@ -34,8 +34,6 @@
//
#include "stdtwadmin.h"
#include <unistd.h>
#include "twadmincl.h"
#include "twadminstrings.h"
#include "keygeneration.h"
@ -63,8 +61,10 @@
#include "twcrypto/crypto.h"
#include "core/displayencoder.h"
#include <unistd.h>
//Provide a swab() impl. from glibc, for platforms that don't have one
#if NEEDS_SWAB_IMPL
#if !HAVE_SWAB || NEEDS_SWAB_IMPL
void swab (const void *bfrom, void *bto, ssize_t n)
{
const char *from = (const char *) bfrom;