]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 296533 via svnmerge from
authorTilghman Lesher <tilghman@meg.abyt.es>
Mon, 29 Nov 2010 07:28:44 +0000 (07:28 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Mon, 29 Nov 2010 07:28:44 +0000 (07:28 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.6.2

........
  r296533 | tilghman | 2010-11-29 01:27:09 -0600 (Mon, 29 Nov 2010) | 13 lines

  I love standards.  There are so many to choose from.  Except when there isn't one.

  Linux and *BSD disagree on the elements within the ucred structure.  Detect
  which one is in use on the system.

  (closes issue #18384)
   Reported by: bjm
   Patches:
         cred-diffs uploaded by bjm (license 473)
         20101127__issue18384__1.6.2.diff.txt uploaded by tilghman (license 14)
         20101127__issue18384__1.8.diff.txt uploaded by tilghman (license 14)
   Tested by: tilghman, bjm
........

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@296534 65c4cc65-6c06-0410-ace0-fbb531ad65f3

configure
configure.ac
include/asterisk/autoconfig.h.in
main/asterisk.c

index 614a37ac9852c90cd2de5ef5d49837656962136d..e5ca657cb892977d5b3e4b6b7b33232369a8d53e 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 293046 .
+# From configure.ac Revision: 294430 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.65 for asterisk trunk.
 #
@@ -12708,6 +12708,27 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+fi
+
+ac_fn_c_check_member "$LINENO" "struct ucred" "uid" "ac_cv_member_struct_ucred_uid" "#include <sys/socket.h>
+"
+if test "x$ac_cv_member_struct_ucred_uid" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_UCRED_UID 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_member "$LINENO" "struct ucred" "cr_uid" "ac_cv_member_struct_ucred_cr_uid" "#include <sys/socket.h>
+"
+if test "x$ac_cv_member_struct_ucred_cr_uid" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_UCRED_CR_UID 1
+_ACEOF
+
+
 fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5
index f591985875f289d71cd86d3ae3b8fc32ff88ce46..8a2a6a4a1bd7157c5fc7aae455bf94ba173da136 100644 (file)
@@ -486,6 +486,7 @@ AC_TYPE_OFF_T
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
 AC_CHECK_MEMBERS([struct stat.st_blksize])
+AC_CHECK_MEMBERS([struct ucred.uid, struct ucred.cr_uid], [], [], [#include <sys/socket.h>])
 AC_HEADER_TIME
 AC_STRUCT_TM
 AC_C_VOLATILE
index 430c4c0aacf86cbe372eb8c5237cb562f58cd90f..94dde0b31db693d9c69cb62b1432631ab66b6783 100644 (file)
 /* Define to 1 if `st_blksize' is a member of `struct stat'. */
 #undef HAVE_STRUCT_STAT_ST_BLKSIZE
 
+/* Define to 1 if `cr_uid' is a member of `struct ucred'. */
+#undef HAVE_STRUCT_UCRED_CR_UID
+
+/* Define to 1 if `uid' is a member of `struct ucred'. */
+#undef HAVE_STRUCT_UCRED_UID
+
 /* Define to 1 if you have the mISDN Supplemental Services library. */
 #undef HAVE_SUPPSERV
 
index 10e9b4ced6a3953846f15969140def0c29186e4b..e5c530a53be710abba30baf6cf037ec8c3519de2 100644 (file)
@@ -1202,12 +1202,18 @@ static int read_credentials(int fd, char *buffer, size_t size, struct console *c
                return result;
        }
 
-#if defined(SO_PEERCRED)
+#if defined(SO_PEERCRED) && (defined(HAVE_STRUCT_UCRED_UID) || defined(HAVE_STRUCT_UCRED_CR_UID))
        if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &len)) {
                return result;
        }
+#if defined(HAVE_STRUCT_UCRED_UID)
        uid = cred.uid;
        gid = cred.gid;
+#else /* defined(HAVE_STRUCT_UCRED_CR_UID) */
+       uid = cred.cr_uid;
+       gid = cred.cr_gid;
+#endif /* defined(HAVE_STRUCT_UCRED_UID) */
+
 #elif defined(HAVE_GETPEEREID)
        if (getpeereid(fd, &uid, &gid)) {
                return result;