gsasl-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU gsasl branch, master, updated. gsasl-1-3-15-gc8fc8cd


From: Simon Josefsson
Subject: [SCM] GNU gsasl branch, master, updated. gsasl-1-3-15-gc8fc8cd
Date: Mon, 26 Oct 2009 15:14:25 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU gsasl".

http://git.savannah.gnu.org/cgit/gsasl.git/commit/?id=c8fc8cd6db2f4bdc6662a97807ffa21335c296f3

The branch, master has been updated
       via  c8fc8cd6db2f4bdc6662a97807ffa21335c296f3 (commit)
       via  e2bc487d1559dc86335dea4852c48359f859d3a5 (commit)
      from  b04aa9c4545b5f21fac136a83ddd7c1183f65b70 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c8fc8cd6db2f4bdc6662a97807ffa21335c296f3
Author: Simon Josefsson <address@hidden>
Date:   Mon Oct 26 16:14:18 2009 +0100

    Update gnulib files.

commit e2bc487d1559dc86335dea4852c48359f859d3a5
Author: Simon Josefsson <address@hidden>
Date:   Mon Oct 12 15:54:26 2009 +0200

    Add concept index nodes for iteration count and salt.

-----------------------------------------------------------------------

Summary of changes:
 doc/gsasl.texi        |    2 +
 gl/localcharset.c     |  154 ++++++++++++++++++++++++++++++-------------------
 gl/m4/fcntl_h.m4      |  108 ++++++++++++++++++++++++++++++++++
 gl/m4/gnulib-comp.m4  |    3 +-
 gl/m4/localcharset.m4 |    3 +-
 5 files changed, 208 insertions(+), 62 deletions(-)
 create mode 100644 gl/m4/fcntl_h.m4

diff --git a/doc/gsasl.texi b/doc/gsasl.texi
index 608c96f..7be82f2 100644
--- a/doc/gsasl.texi
+++ b/doc/gsasl.texi
@@ -1436,6 +1436,8 @@ instead.
 @item @code{GSASL_SCRAM_ITER}
 @item @code{GSASL_SCRAM_ITER}
 
address@hidden iteration count
address@hidden salt
 In the server, the application can set these properties to influence
 the hash iteration count and hash salt to use when deriving the
 password.  The default hash iteration count is 4096 and normally you
diff --git a/gl/localcharset.c b/gl/localcharset.c
index a7ca94c..d9ba6d0 100644
--- a/gl/localcharset.c
+++ b/gl/localcharset.c
@@ -23,6 +23,7 @@
 /* Specification.  */
 #include "localcharset.h"
 
+#include <fcntl.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <string.h>
@@ -44,6 +45,7 @@
 #endif
 
 #if !defined WIN32_NATIVE
+# include <unistd.h>
 # if HAVE_LANGINFO_CODESET
 #  include <langinfo.h>
 # else
@@ -75,6 +77,11 @@
 # include "configmake.h"
 #endif
 
+/* Define O_NOFOLLOW to 0 on platforms where it does not exist.  */
+#ifndef O_NOFOLLOW
+# define O_NOFOLLOW 0
+#endif
+
 #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined 
__EMX__ || defined __DJGPP__
   /* Win32, Cygwin, OS/2, DOS */
 # define ISSLASH(C) ((C) == '/' || (C) == '\\')
@@ -117,7 +124,6 @@ get_charset_aliases (void)
   if (cp == NULL)
     {
 #if !(defined DARWIN7 || defined VMS || defined WIN32_NATIVE || defined 
__CYGWIN__)
-      FILE *fp;
       const char *dir;
       const char *base = "charset.alias";
       char *file_name;
@@ -143,77 +149,105 @@ get_charset_aliases (void)
          }
       }
 
-      if (file_name == NULL || (fp = fopen (file_name, "r")) == NULL)
-       /* Out of memory or file not found, treat it as empty.  */
+      if (file_name == NULL)
+       /* Out of memory.  Treat the file as empty.  */
        cp = "";
       else
        {
-         /* Parse the file's contents.  */
-         char *res_ptr = NULL;
-         size_t res_size = 0;
-
-         for (;;)
+         int fd;
+
+         /* Open the file.  Reject symbolic links on platforms that support
+            O_NOFOLLOW.  This is a security feature.  Without it, an attacker
+            could retrieve parts of the contents (namely, the tail of the
+            first line that starts with "* ") of an arbitrary file by placing
+            a symbolic link to that file under the name "charset.alias" in
+            some writable directory and defining the environment variable
+            CHARSETALIASDIR to point to that directory.  */
+         fd = open (file_name,
+                    O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0));
+         if (fd < 0)
+           /* File not found.  Treat it as empty.  */
+           cp = "";
+         else
            {
-             int c;
-             char buf1[50+1];
-             char buf2[50+1];
-             size_t l1, l2;
-             char *old_res_ptr;
-
-             c = getc (fp);
-             if (c == EOF)
-               break;
-             if (c == '\n' || c == ' ' || c == '\t')
-               continue;
-             if (c == '#')
-               {
-                 /* Skip comment, to end of line.  */
-                 do
-                   c = getc (fp);
-                 while (!(c == EOF || c == '\n'));
-                 if (c == EOF)
-                   break;
-                 continue;
-               }
-             ungetc (c, fp);
-             if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
-               break;
-             l1 = strlen (buf1);
-             l2 = strlen (buf2);
-             old_res_ptr = res_ptr;
-             if (res_size == 0)
+             FILE *fp;
+
+             fp = fdopen (fd, "r");
+             if (fp == NULL)
                {
-                 res_size = l1 + 1 + l2 + 1;
-                 res_ptr = (char *) malloc (res_size + 1);
+                 /* Out of memory.  Treat the file as empty.  */
+                 close (fd);
+                 cp = "";
                }
              else
                {
-                 res_size += l1 + 1 + l2 + 1;
-                 res_ptr = (char *) realloc (res_ptr, res_size + 1);
+                 /* Parse the file's contents.  */
+                 char *res_ptr = NULL;
+                 size_t res_size = 0;
+
+                 for (;;)
+                   {
+                     int c;
+                     char buf1[50+1];
+                     char buf2[50+1];
+                     size_t l1, l2;
+                     char *old_res_ptr;
+
+                     c = getc (fp);
+                     if (c == EOF)
+                       break;
+                     if (c == '\n' || c == ' ' || c == '\t')
+                       continue;
+                     if (c == '#')
+                       {
+                         /* Skip comment, to end of line.  */
+                         do
+                           c = getc (fp);
+                         while (!(c == EOF || c == '\n'));
+                         if (c == EOF)
+                           break;
+                         continue;
+                       }
+                     ungetc (c, fp);
+                     if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
+                       break;
+                     l1 = strlen (buf1);
+                     l2 = strlen (buf2);
+                     old_res_ptr = res_ptr;
+                     if (res_size == 0)
+                       {
+                         res_size = l1 + 1 + l2 + 1;
+                         res_ptr = (char *) malloc (res_size + 1);
+                       }
+                     else
+                       {
+                         res_size += l1 + 1 + l2 + 1;
+                         res_ptr = (char *) realloc (res_ptr, res_size + 1);
+                       }
+                     if (res_ptr == NULL)
+                       {
+                         /* Out of memory. */
+                         res_size = 0;
+                         if (old_res_ptr != NULL)
+                           free (old_res_ptr);
+                         break;
+                       }
+                     strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
+                     strcpy (res_ptr + res_size - (l2 + 1), buf2);
+                   }
+                 fclose (fp);
+                 if (res_size == 0)
+                   cp = "";
+                 else
+                   {
+                     *(res_ptr + res_size) = '\0';
+                     cp = res_ptr;
+                   }
                }
-             if (res_ptr == NULL)
-               {
-                 /* Out of memory. */
-                 res_size = 0;
-                 if (old_res_ptr != NULL)
-                   free (old_res_ptr);
-                 break;
-               }
-             strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
-             strcpy (res_ptr + res_size - (l2 + 1), buf2);
-           }
-         fclose (fp);
-         if (res_size == 0)
-           cp = "";
-         else
-           {
-             *(res_ptr + res_size) = '\0';
-             cp = res_ptr;
            }
-       }
 
-      if (file_name != NULL)
-       free (file_name);
+         free (file_name);
+       }
 
 #else
 
diff --git a/gl/m4/fcntl_h.m4 b/gl/m4/fcntl_h.m4
new file mode 100644
index 0000000..223fa48
--- /dev/null
+++ b/gl/m4/fcntl_h.m4
@@ -0,0 +1,108 @@
+# serial 6
+# Configure fcntl.h.
+dnl Copyright (C) 2006, 2007, 2009 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.
+
+dnl Written by Paul Eggert.
+
+AC_DEFUN([gl_FCNTL_H],
+[
+  AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
+  AC_REQUIRE([gl_FCNTL_O_FLAGS])
+  gl_CHECK_NEXT_HEADERS([fcntl.h])
+  FCNTL_H='fcntl.h'
+  AC_SUBST([FCNTL_H])
+])
+
+# Test whether the flags O_NOATIME and O_NOFOLLOW actually work.
+# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise.
+# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise.
+AC_DEFUN([gl_FCNTL_O_FLAGS],
+[
+  dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+  AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
+    [AC_RUN_IFELSE(
+       [AC_LANG_PROGRAM(
+         [[#include <sys/types.h>
+          #include <sys/stat.h>
+          #include <unistd.h>
+          #include <fcntl.h>
+          #ifndef O_NOATIME
+           #define O_NOATIME 0
+          #endif
+          #ifndef O_NOFOLLOW
+           #define O_NOFOLLOW 0
+          #endif
+          static int const constants[] =
+           {
+             O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
+             O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
+           };
+         ]],
+         [[
+           int status = !constants;
+           {
+             static char const sym[] = "conftest.sym";
+             if (symlink (".", sym) != 0
+                 || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
+               status |= 32;
+             unlink (sym);
+           }
+           {
+             static char const file[] = "confdefs.h";
+             int fd = open (file, O_RDONLY | O_NOATIME);
+             char c;
+             struct stat st0, st1;
+             if (fd < 0
+                 || fstat (fd, &st0) != 0
+                 || sleep (1) != 0
+                 || read (fd, &c, 1) != 1
+                 || close (fd) != 0
+                 || stat (file, &st1) != 0
+                 || st0.st_atime != st1.st_atime)
+               status |= 64;
+           }
+           return status;]])],
+       [gl_cv_header_working_fcntl_h=yes],
+       [case $? in #(
+       32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
+       64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
+       96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
+        *) gl_cv_header_working_fcntl_h='no';;
+       esac],
+       [gl_cv_header_working_fcntl_h=cross-compiling])])
+
+  case $gl_cv_header_working_fcntl_h in #(
+  *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
+  *) ac_val=1;;
+  esac
+  AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
+    [Define to 1 if O_NOATIME works.])
+
+  case $gl_cv_header_working_fcntl_h in #(
+  *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
+  *) ac_val=1;;
+  esac
+  AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
+    [Define to 1 if O_NOFOLLOW works.])
+])
+
+AC_DEFUN([gl_FCNTL_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
+  
GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_FCNTL_H_DEFAULTS],
+[
+  GNULIB_OPEN=0;    AC_SUBST([GNULIB_OPEN])
+  GNULIB_OPENAT=0;  AC_SUBST([GNULIB_OPENAT])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_OPENAT=1;    AC_SUBST([HAVE_OPENAT])
+  REPLACE_OPEN=0;   AC_SUBST([REPLACE_OPEN])
+  REPLACE_OPENAT=0; AC_SUBST([REPLACE_OPENAT])
+])
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index f269795..99fc4f3 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -288,7 +288,7 @@ AC_SUBST([LTALLOCA])
   gt_TYPE_WINT_T
   gl_SYS_IOCTL_H
   AC_PROG_MKDIR_P
-  AC_CHECK_FUNCS([shutdown])
+  AC_CHECK_FUNCS_ONCE([shutdown])
   gl_FUNC_UNSETENV
   gl_STDLIB_MODULE_INDICATOR([unsetenv])
   abs_aux_dir=`cd "$ac_aux_dir"; pwd`
@@ -520,6 +520,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/exitfail.m4
   m4/extensions.m4
   m4/fclose.m4
+  m4/fcntl_h.m4
   m4/float_h.m4
   m4/fseeko.m4
   m4/getaddrinfo.m4
diff --git a/gl/m4/localcharset.m4 b/gl/m4/localcharset.m4
index e960104..90b9403 100644
--- a/gl/m4/localcharset.m4
+++ b/gl/m4/localcharset.m4
@@ -1,4 +1,4 @@
-# localcharset.m4 serial 6
+# localcharset.m4 serial 7
 dnl Copyright (C) 2002, 2004, 2006, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,6 +8,7 @@ AC_DEFUN([gl_LOCALCHARSET],
 [
   dnl Prerequisites of lib/localcharset.c.
   AC_REQUIRE([AM_LANGINFO_CODESET])
+  AC_REQUIRE([gl_FCNTL_O_FLAGS])
   AC_CHECK_DECLS_ONCE([getc_unlocked])
 
   dnl Prerequisites of the lib/Makefile.am snippet.


hooks/post-receive
-- 
GNU gsasl




reply via email to

[Prev in Thread] Current Thread [Next in Thread]