[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
chdir-safer: port to mingw
From: |
Bruno Haible |
Subject: |
chdir-safer: port to mingw |
Date: |
Sun, 20 Apr 2008 09:29:21 +0200 |
User-agent: |
KMail/1.5.4 |
Hi Jim,
While trying to compile all of gnulib on mingw, this module caused a
compilation error:
chdir-safer.c: In function `chdir_no_follow':
chdir-safer.c:60: error: `ELOOP' undeclared (first use in this function)
chdir-safer.c:60: error: (Each undeclared identifier is reported only once
chdir-safer.c:60: error: for each function it appears in.)
make[3]: *** [chdir-safer.o] Error 1
mingw does not have ELOOP, since that platform does not have symbolic
links. But on a platform without symbolic links, the main test done by
chdir_no_follow is not necessary. Such platforms can be recognized
through the absence of the readlink() function (see also
doc/posix-functions/readlink.texi).
Here is a proposed patch:
2008-04-20 Bruno Haible <address@hidden>
Port chdir-safer to mingw.
* lib/chdir-safer.c (chdir_no_follow): Don't test for a symlink on
platforms without readlink().
* m4/chdir-safer.m4 (gl_CHDIR_SAFER): Test for readlink function.
--- lib/chdir-safer.c.orig 2008-04-20 09:22:10.000000000 +0200
+++ lib/chdir-safer.c 2008-04-20 09:21:20.000000000 +0200
@@ -1,6 +1,6 @@
/* much like chdir(2), but safer
- Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -43,6 +43,7 @@
if (fd < 0)
return -1;
+#if HAVE_READLINK /* only on platforms which have symbolic links */
/* If open follows symlinks, lstat DIR and fstat FD to ensure that
they are the same file; if they are different files, set errno to
ELOOP (the same value that open uses for symlinks with
@@ -62,6 +63,7 @@
}
}
}
+#endif
if (result == 0)
result = fchdir (fd);
--- m4/chdir-safer.m4.orig 2008-04-20 09:22:10.000000000 +0200
+++ m4/chdir-safer.m4 2008-04-20 09:20:02.000000000 +0200
@@ -1,5 +1,5 @@
-#serial 3
-dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+#serial 4
+dnl Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -7,4 +7,5 @@
AC_DEFUN([gl_CHDIR_SAFER],
[
AC_LIBOBJ([chdir-safer])
+ AC_CHECK_FUNCS_ONCE([readlink])
])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- chdir-safer: port to mingw,
Bruno Haible <=