diff --git a/open-vm-tools/configure.ac b/open-vm-tools/configure.ac index 112fc3b3c..19fee1072 100644 --- a/open-vm-tools/configure.ac +++ b/open-vm-tools/configure.ac @@ -1169,6 +1169,7 @@ AC_CHECK_FUNCS( AC_CHECK_FUNCS([ecvt]) AC_CHECK_FUNCS([fcvt]) +AC_CHECK_FUNCS([getifaddrs getauxval issetugid __secure_getenv]) AC_CHECK_FUNC([mkdtemp], [have_mkdtemp=yes]) @@ -1378,10 +1379,13 @@ fi ### AC_CHECK_HEADERS([crypt.h]) +AC_CHECK_HEADERS([ifaddrs.h]) AC_CHECK_HEADERS([inttypes.h]) AC_CHECK_HEADERS([stdint.h]) AC_CHECK_HEADERS([stdlib.h]) AC_CHECK_HEADERS([wchar.h]) +AC_CHECK_HEADERS([net/if.h]) +AC_CHECK_HEADERS([sys/auxv.h]) AC_CHECK_HEADERS([sys/inttypes.h]) AC_CHECK_HEADERS([sys/io.h]) AC_CHECK_HEADERS([sys/param.h]) # Required to make the sys/user.h check work correctly on FreeBSD @@ -1441,6 +1445,7 @@ AC_TYPE_OFF_T AC_TYPE_PID_T AC_TYPE_SIZE_T AC_CHECK_MEMBERS([struct stat.st_rdev]) +AC_CHECK_MEMBERS([struct timespec.tv_sec],[],[],[[#include ]]) AC_HEADER_TIME AC_STRUCT_TM AC_C_VOLATILE @@ -1451,7 +1456,17 @@ AC_C_VOLATILE ### General flags / actions CFLAGS="$CFLAGS -Wall" -CFLAGS="$CFLAGS -Werror" +AC_ARG_ENABLE( + werror, + AS_HELP_STRING( + [--disable-werror], + [disable compilation with -Werror]), + [enable_werror="$enableval"], + [enable_werror="yes"]) + +if test "$enable_werror" = "yes"; then + CFLAGS="$CFLAGS -Werror" +fi # -Wno-unknown-pragmas is due to gcc not understanding '#pragma ident' # in Xlib.h on OpenSolaris. diff --git a/open-vm-tools/lib/asyncsocket/asyncsocket.c b/open-vm-tools/lib/asyncsocket/asyncsocket.c index efddf99b3..13286d058 100644 --- a/open-vm-tools/lib/asyncsocket/asyncsocket.c +++ b/open-vm-tools/lib/asyncsocket/asyncsocket.c @@ -87,7 +87,7 @@ #include "random.h" #include "asyncsocket.h" #include "asyncSocketBase.h" -#include "poll.h" +#include "vm_poll.h" #include "log.h" #include "err.h" #include "hostinfo.h" diff --git a/open-vm-tools/lib/err/errPosix.c b/open-vm-tools/lib/err/errPosix.c index c81b4c13f..a34e81904 100644 --- a/open-vm-tools/lib/err/errPosix.c +++ b/open-vm-tools/lib/err/errPosix.c @@ -63,11 +63,13 @@ ErrErrno2String(Err_Number errorNumber, // IN { char *p; -#if defined(__linux__) && !defined(__ANDROID__) +#if defined(__GLIBC__) p = strerror_r(errorNumber, buf, bufSize); #else - p = strerror(errorNumber); -#endif + if (strerror_r(errorNumber, buf, bufSize) != 0) + snprintf(buf, bufSize, "unknown error %i", errorNumber); + p = buf; +#endif /* defined __GLIBC__ */ ASSERT(p != NULL); return p; } diff --git a/open-vm-tools/lib/file/fileIOPosix.c b/open-vm-tools/lib/file/fileIOPosix.c index 82c0aa18e..47dc41379 100644 --- a/open-vm-tools/lib/file/fileIOPosix.c +++ b/open-vm-tools/lib/file/fileIOPosix.c @@ -198,7 +198,7 @@ static AlignedPool alignedPool; * are not available in any header file. */ -#if defined(__linux__) && !defined(__ANDROID__) +#if defined(__linux__) && defined(__GLIBC__) #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64) /* * We want preadv/pwritev. But due to FOB=64, the symbols are -64. diff --git a/open-vm-tools/lib/hgfsServer/hgfsServer.c b/open-vm-tools/lib/hgfsServer/hgfsServer.c index 98f5b3f06..b436f0c7e 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServer.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServer.c @@ -51,7 +51,7 @@ #include "hgfsDirNotify.h" #include "hgfsThreadpool.h" #include "userlock.h" -#include "poll.h" +#include "vm_poll.h" #include "mutexRankLib.h" #include "vm_basic_asm.h" #include "unicodeOperations.h" diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c b/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c index 63c4e65f0..87d419a7b 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c @@ -105,11 +105,13 @@ typedef struct DirectoryEntry { #endif /* - * ALLPERMS (mode 07777) and ACCESSPERMS (mode 0777) are not defined in the - * Solaris version of . + * ALLPERMS (mode 07777) and ACCESSPERMS (mode 0777) are not specified in + * POSIX. */ -#ifdef sun +#ifndef ACCESSPERMS # define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) +#endif +#ifndef ALLPERMS # define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) #endif diff --git a/open-vm-tools/lib/include/asyncsocket.h b/open-vm-tools/lib/include/asyncsocket.h index 16f9fbb00..95bc39f1f 100644 --- a/open-vm-tools/lib/include/asyncsocket.h +++ b/open-vm-tools/lib/include/asyncsocket.h @@ -171,7 +171,7 @@ typedef struct AsyncSocket AsyncSocket; * Or the client can specify its favorite poll class and locking behavior. * Use of IVmdbPoll is only supported for regular sockets and for Attach. */ -#include "poll.h" +#include "vm_poll.h" struct IVmdbPoll; typedef struct AsyncSocketPollParams { int flags; /* Default 0, only POLL_FLAG_NO_BULL is valid */ diff --git a/open-vm-tools/lib/include/guest_os.h b/open-vm-tools/lib/include/guest_os.h index 5825cfa85..85f9d7a9a 100644 --- a/open-vm-tools/lib/include/guest_os.h +++ b/open-vm-tools/lib/include/guest_os.h @@ -295,6 +295,7 @@ Bool Gos_InSetArray(uint32 gos, const uint32 *set); /* Linux */ #define STR_OS_ALMA_LINUX "almaLinux" #define STR_OS_AMAZON_LINUX "amazonlinux" +#define STR_OS_ALPINE "Alpine" #define STR_OS_ANNVIX "Annvix" #define STR_OS_ARCH "Arch" #define STR_OS_ARKLINUX "Arklinux" diff --git a/open-vm-tools/lib/include/hgfsUtil.h b/open-vm-tools/lib/include/hgfsUtil.h index 609f4c000..a3a022d42 100644 --- a/open-vm-tools/lib/include/hgfsUtil.h +++ b/open-vm-tools/lib/include/hgfsUtil.h @@ -53,13 +53,7 @@ # include # endif # include "vm_basic_types.h" -# if !defined _STRUCT_TIMESPEC && \ - !defined _TIMESPEC_DECLARED && \ - !defined __timespec_defined && \ - !defined sun && \ - !defined __FreeBSD__ && \ - !__APPLE__ && \ - !defined _WIN32 +# if !defined HAVE_STRUCT_TIMESPEC_TV_SEC struct timespec { time_t tv_sec; long tv_nsec; diff --git a/open-vm-tools/lib/include/pollImpl.h b/open-vm-tools/lib/include/pollImpl.h index 46442e556..8bc669970 100644 --- a/open-vm-tools/lib/include/pollImpl.h +++ b/open-vm-tools/lib/include/pollImpl.h @@ -44,7 +44,7 @@ #define INCLUDE_ALLOW_USERLEVEL #include "includeCheck.h" -#include "poll.h" +#include "vm_poll.h" #include "vm_basic_asm.h" #if defined(__cplusplus) diff --git a/open-vm-tools/lib/include/poll.h b/open-vm-tools/lib/include/vm_poll.h similarity index 100% rename from open-vm-tools/lib/include/poll.h rename to open-vm-tools/lib/include/vm_poll.h diff --git a/open-vm-tools/lib/misc/hostinfoPosix.c b/open-vm-tools/lib/misc/hostinfoPosix.c index ab9271744..c11286ee7 100644 --- a/open-vm-tools/lib/misc/hostinfoPosix.c +++ b/open-vm-tools/lib/misc/hostinfoPosix.c @@ -201,6 +201,7 @@ typedef struct { static const DistroInfo distroArray[] = { { "ALT", "/etc/altlinux-release" }, + { "Alpine", "/etc/alpine-release" }, { "Annvix", "/etc/annvix-release" }, { "Arch", "/etc/arch-release" }, { "Arklinux", "/etc/arklinux-release" }, @@ -1254,6 +1255,7 @@ HostinfoSetSuseShortName(const ShortNameSet *entry, // IN: static const ShortNameSet shortNameArray[] = { /* Long distro name Short distro name Short name set function */ { "almalinux", STR_OS_ALMA_LINUX, HostinfoGenericSetShortName }, +{ "alpine", STR_OS_ALPINE, HostinfoGenericSetShortName}, { "amazon", NULL, HostinfoSetAmazonShortName }, { "annvix", STR_OS_ANNVIX, HostinfoGenericSetShortName }, { "arch", STR_OS_ARCH, HostinfoGenericSetShortName }, diff --git a/open-vm-tools/lib/misc/idLinux.c b/open-vm-tools/lib/misc/idLinux.c index 1bb86f483..41c670cfc 100644 --- a/open-vm-tools/lib/misc/idLinux.c +++ b/open-vm-tools/lib/misc/idLinux.c @@ -27,12 +27,9 @@ #include #include #include -#ifdef __linux__ -#if defined(__GLIBC__) && \ - (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16)) +#ifdef HAVE_SYS_AUXV_H #include #endif -#endif #ifdef __APPLE__ #include #include @@ -1025,31 +1022,32 @@ Id_EndSuperUser(uid_t uid) // IN: static Bool IdIsSetUGid(void) { -#if defined(__ANDROID__) - /* Android does not have a secure_getenv, so be conservative. */ - return TRUE; -#else /* * We use __secure_getenv, which returns NULL if the binary is - * setuid or setgid. Alternatives include, + * setuid or setgid, when issetugid or getauxval(AT_SECURE) is not + * available. Alternatives include, * - * a) getauxval(AT_SECURE); not available until glibc 2.16. - * b) __libc_enable_secure; may not be exported. + * a) issetugid(); not (yet?) available in glibc. + * b) getauxval(AT_SECURE); not available until glibc 2.16. + * c) __libc_enable_secure; may not be exported. * - * Use (a) when we are based on glibc 2.16, or newer. + * Use (b) when we are based on glibc 2.16, or newer. */ -#if defined(__GLIBC__) && \ - (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16)) +#if HAVE_ISSETUGID + return issetugid(); +#elif HAVE_GETAUXVAL return getauxval(AT_SECURE) != 0; -#else +#elif HAVE___SECURE_GETENV static const char envName[] = "VMW_SETUGID_TEST"; if (setenv(envName, "1", TRUE) == -1) { return TRUE; /* Conservative */ } return __secure_getenv(envName) == NULL; -#endif +#else + /* Android does not have a secure_getenv, so be conservative. */ + return TRUE; #endif } #endif diff --git a/open-vm-tools/lib/nicInfo/nicInfoPosix.c b/open-vm-tools/lib/nicInfo/nicInfoPosix.c index de57a4a90..7a132eee7 100644 --- a/open-vm-tools/lib/nicInfo/nicInfoPosix.c +++ b/open-vm-tools/lib/nicInfo/nicInfoPosix.c @@ -35,9 +35,13 @@ #include #include #include -#if defined(__FreeBSD__) || defined(__APPLE__) +#if HAVE_SYS_SYSCTL_H # include +#endif +#if HAVE_IFADDRS_H # include +#endif +#if HAVE_NET_IF_H # include #endif #ifndef NO_DNET @@ -499,10 +503,7 @@ GuestInfoGetNicInfo(unsigned int maxIPv4Routes, * ****************************************************************************** */ -#if defined(__FreeBSD__) || \ - defined(__APPLE__) || \ - defined(USERWORLD) || \ - (defined(__linux__) && defined(NO_DNET)) +#if defined(NO_DNET) && defined(HAVE_GETIFADDRS) char * GuestInfoGetPrimaryIP(void) diff --git a/open-vm-tools/lib/rpcIn/rpcin.c b/open-vm-tools/lib/rpcIn/rpcin.c index 8b1fe759d..f22fcd402 100644 --- a/open-vm-tools/lib/rpcIn/rpcin.c +++ b/open-vm-tools/lib/rpcIn/rpcin.c @@ -57,7 +57,7 @@ #if defined(VMTOOLS_USE_VSOCKET) # include -# include "poll.h" +# include "vm_poll.h" # include "asyncsocket.h" # include "vmci_defs.h" #include "dataMap.h" diff --git a/open-vm-tools/services/plugins/dndcp/dnd/dndLinux.c b/open-vm-tools/services/plugins/dndcp/dnd/dndLinux.c index 219065f74..b5b7e6203 100644 --- a/open-vm-tools/services/plugins/dndcp/dnd/dndLinux.c +++ b/open-vm-tools/services/plugins/dndcp/dnd/dndLinux.c @@ -53,7 +53,7 @@ #define DND_ROOTDIR_PERMS (S_IRWXU | S_IRWXG | S_IRWXO) #define DND_STAGINGDIR_PERMS (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) -#ifdef sun +#ifndef ACCESSPERMS #define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) #endif #ifdef __ANDROID__ @@ -62,7 +62,6 @@ */ #define NO_SETMNTENT #define NO_ENDMNTENT -#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) #endif diff --git a/open-vm-tools/services/plugins/vix/vixTools.c b/open-vm-tools/services/plugins/vix/vixTools.c index 103ed10dc..bde740218 100644 --- a/open-vm-tools/services/plugins/vix/vixTools.c +++ b/open-vm-tools/services/plugins/vix/vixTools.c @@ -66,7 +66,7 @@ #include #endif -#if defined(sun) || defined(__FreeBSD__) || defined(__APPLE__) +#ifdef HAVE_SYS_STAT_H #include #endif diff --git a/open-vm-tools/vgauth/common/VGAuthLog.c b/open-vm-tools/vgauth/common/VGAuthLog.c index fb4261efc..1b29536ee 100644 --- a/open-vm-tools/vgauth/common/VGAuthLog.c +++ b/open-vm-tools/vgauth/common/VGAuthLog.c @@ -210,7 +210,7 @@ LogErrorPosixCodeV(int code, g_vsnprintf(buf, sizeof buf, fmt, args); buf[sizeof buf - 1] = '\0'; -#ifdef sun +#if !defined(__GLIBC__) strerror_r(code, errMsg, sizeof errMsg); g_warning("[function %s, file %s, line %d], %s, [errno = %d], %s\n", func, file, line, buf, code, errMsg); diff --git a/open-vm-tools/vmhgfs-fuse/file.c b/open-vm-tools/vmhgfs-fuse/file.c index e56d621db..43259cf6f 100644 --- a/open-vm-tools/vmhgfs-fuse/file.c +++ b/open-vm-tools/vmhgfs-fuse/file.c @@ -547,7 +547,7 @@ static int HgfsDoRead(HgfsHandle handle, // IN: Handle for this file char *buf, // OUT: Buffer to copy data into size_t count, // IN: Number of bytes to read - loff_t offset) // IN: Offset at which to read + off64_t offset) // IN: Offset at which to read { HgfsReq *req; HgfsOp opUsed; @@ -708,11 +708,11 @@ ssize_t HgfsRead(struct fuse_file_info *fi, // IN: File info struct char *buf, // OUT: User buffer to copy data into size_t count, // IN: Number of bytes to read - loff_t offset) // IN: Offset at which to read + off64_t offset) // IN: Offset at which to read { int result = 0; char *buffer = buf; - loff_t curOffset = offset; + off64_t curOffset = offset; size_t nextCount, remainingCount = count; uint32 maxIOSize = HgfsMaxIOSize(); @@ -769,7 +769,7 @@ static int HgfsDoWrite(HgfsHandle handle, // IN: Handle for the file const char *buf, // IN: Buffer containing data size_t count, // IN: Number of bytes to write - loff_t offset) // IN: Offset to begin writing at + off64_t offset) // IN: Offset to begin writing at { HgfsReq *req; int result = 0; @@ -893,11 +893,11 @@ ssize_t HgfsWrite(struct fuse_file_info *fi, // IN: File info structure const char *buf, // OUT: User buffer to copy data into size_t count, // IN: Number of bytes to read - loff_t offset) // IN: Offset at which to read + off64_t offset) // IN: Offset at which to read { int result; const char *buffer = buf; - loff_t curOffset = offset; + off64_t curOffset = offset; size_t nextCount, remainingCount = count; ssize_t bytesWritten = 0; uint32 maxIOSize = HgfsMaxIOSize(); diff --git a/open-vm-tools/vmhgfs-fuse/fsutil.c b/open-vm-tools/vmhgfs-fuse/fsutil.c index fe4e4e83a..ccc755d75 100644 --- a/open-vm-tools/vmhgfs-fuse/fsutil.c +++ b/open-vm-tools/vmhgfs-fuse/fsutil.c @@ -694,7 +694,7 @@ HgfsStatusConvertToLinux(HgfsStatus hgfsStatus) // IN: Status code to convert unsigned long HgfsCalcBlockSize(uint64 tsize) { - loff_t used = (tsize + 511) >> 9; + off64_t used = (tsize + 511) >> 9; return (used > ULONG_MAX) ? ULONG_MAX : used; } diff --git a/open-vm-tools/vmhgfs-fuse/fsutil.h b/open-vm-tools/vmhgfs-fuse/fsutil.h index 34b6d489a..a75cff82f 100644 --- a/open-vm-tools/vmhgfs-fuse/fsutil.h +++ b/open-vm-tools/vmhgfs-fuse/fsutil.h @@ -32,10 +32,6 @@ #include "hgfsProto.h" #include -#if defined(__FreeBSD__) || defined(__SOLARIS__) || defined(__APPLE__) -typedef long long loff_t; -#endif - /* * Struct used to pass around attributes. * These aren't just the attributes seen in HgfsAttr[V2]; we add a filename @@ -73,7 +69,7 @@ ssize_t HgfsWrite(struct fuse_file_info *fi, const char *buf, size_t count, - loff_t offset); + off64_t offset); int HgfsRename(const char* from, const char* to); @@ -93,7 +89,7 @@ ssize_t HgfsRead(struct fuse_file_info *fi, char *buf, size_t count, - loff_t offset); + off64_t offset); int HgfsSetattr(const char* path,