write-any-file: Don't reference an undefined function on native Windows.
authorBruno Haible <bruno@clisp.org>
Tue, 27 Aug 2024 20:50:05 +0000 (22:50 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 27 Aug 2024 20:50:05 +0000 (22:50 +0200)
* m4/write-any-file.m4 (): Remove test for <priv.h>, obsolete since
2009-05-03. Test for geteuid.
* lib/write-any-file.c (geteuid): Define a fallback.

ChangeLog
lib/write-any-file.c
m4/write-any-file.m4

index ff7162d1277dfac52a1deb8d1f7c533f039d8f74..767f51f9d3d3938df6e5cc359f123b3eb39d245f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-08-27  Bruno Haible  <bruno@clisp.org>
+
+       write-any-file: Don't reference an undefined function on native Windows.
+       * m4/write-any-file.m4 (): Remove test for <priv.h>, obsolete since
+       2009-05-03. Test for geteuid.
+       * lib/write-any-file.c (geteuid): Define a fallback.
+
 2024-08-27  Bruno Haible  <bruno@clisp.org>
 
        mkdir-p: Don't reference an undefined function on native Windows.
index 27ca2c47c55741fcbe7cebe2a77d67fef0eb8d8c..d1f98471a962fee52a53680448843b81fe7f93c8 100644 (file)
 
 #include <config.h>
 
+/* Specification.  */
 #include "write-any-file.h"
+
+#include <unistd.h>
+
 #include "priv-set.h"
 #include "root-uid.h"
 
-#include <unistd.h>
+/* mingw and MSVC 9 lack geteuid, so setup a dummy value.  */
+#if !HAVE_GETEUID
+# define geteuid() ROOT_UID
+#endif
 
 /* Return true if we know that we can write any file, including
    writing directories.  */
index 50e5aa0c2a813fab6e7403e3696d51faec00b74f..621d9b9e4146b80d40b20ac5236bb1a644f7079d 100644 (file)
@@ -1,5 +1,5 @@
 # write-any-file.m4
-# serial 1
+# serial 2
 dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -11,5 +11,5 @@ dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_WRITE_ANY_FILE],
 [
-  AC_CHECK_HEADERS_ONCE([priv.h])
+  AC_CHECK_FUNCS_ONCE([geteuid])
 ])