Commit a7621c92 authored by Bruce Momjian's avatar Bruce Momjian

Update SCM_CREDS for Net/Free/BSD-OS. Add configure checks.

parent 0c585f75
# Macros that test various C library quirks # Macros that test various C library quirks
# $Header: /cvsroot/pgsql/config/c-library.m4,v 1.8 2001/01/22 23:28:50 tgl Exp $ # $Header: /cvsroot/pgsql/config/c-library.m4,v 1.9 2001/09/07 19:52:53 momjian Exp $
# PGAC_VAR_INT_TIMEZONE # PGAC_VAR_INT_TIMEZONE
...@@ -99,6 +99,54 @@ HAVE_POSIX_SIGNALS=$pgac_cv_func_posix_signals ...@@ -99,6 +99,54 @@ HAVE_POSIX_SIGNALS=$pgac_cv_func_posix_signals
AC_SUBST(HAVE_POSIX_SIGNALS)])# PGAC_FUNC_POSIX_SIGNALS AC_SUBST(HAVE_POSIX_SIGNALS)])# PGAC_FUNC_POSIX_SIGNALS
# PGAC_STRUCT_CMSGCRED
# --------------------
# Check if `struct cmsgcred' exists. Define HAVE_STRUCT_CMSGCRED if so.
AC_DEFUN([PGAC_STRUCT_CMSGCRED],
[AC_CACHE_CHECK(for struct cmsgcred, pgac_cv_struct_cmsgcred,
[AC_TRY_COMPILE([#include <sys/param.h>
#include <sys/socket.h>
#include <sys/ucred.h>],
[struct cmsgcred sockcred;],
[pgac_cv_struct_cmsgcred=yes],
[pgac_cv_struct_cmsgcred=no])])
if test x"$pgac_cv_struct_cmsgcred" = xyes ; then
AC_DEFINE(HAVE_STRUCT_CMSGCRED, 1, [Set to 1 if you have `struct cmsgcred'])
fi])# PGAC_STRUCT_CMSGCRED
# PGAC_STRUCT_FCRED
# -----------------
# Check if `struct fcred' exists. Define HAVE_STRUCT_FCRED if so.
AC_DEFUN([PGAC_STRUCT_FCRED],
[AC_CACHE_CHECK(for struct fcred, pgac_cv_struct_fcred,
[AC_TRY_COMPILE([#include <sys/param.h>
#include <sys/socket.h>
#include <sys/ucred.h>],
[struct fcred sockcred;],
[pgac_cv_struct_fcred=yes],
[pgac_cv_struct_fcred=no])])
if test x"$pgac_cv_struct_fcred" = xyes ; then
AC_DEFINE(HAVE_STRUCT_FCRED, 1, [Set to 1 if you have `struct fcred'])
fi])# PGAC_STRUCT_FCRED
# PGAC_STRUCT_SOCKCRED
# --------------------
# Check if `struct sockcred' exists. Define HAVE_STRUCT_SOCKCRED if so.
AC_DEFUN([PGAC_STRUCT_SOCKCRED],
[AC_CACHE_CHECK(for struct sockcred, pgac_cv_struct_sockcred,
[AC_TRY_COMPILE([#include <sys/param.h>
#include <sys/socket.h>
#include <sys/ucred.h>],
[struct sockcred sockcred;],
[pgac_cv_struct_sockcred=yes],
[pgac_cv_struct_sockcred=no])])
if test x"$pgac_cv_struct_sockcred" = xyes ; then
AC_DEFINE(HAVE_STRUCT_SOCKCRED, 1, [Set to 1 if you have `struct sockcred'])
fi])# PGAC_STRUCT_SOCKCRED
# PGAC_HEADER_STRING # PGAC_HEADER_STRING
# ------------------ # ------------------
# Tests whether <string.h> and <strings.h> can both be included # Tests whether <string.h> and <strings.h> can both be included
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -828,6 +828,9 @@ PGAC_C_SIGNED ...@@ -828,6 +828,9 @@ PGAC_C_SIGNED
PGAC_C_VOLATILE PGAC_C_VOLATILE
AC_STRUCT_TIMEZONE AC_STRUCT_TIMEZONE
PGAC_UNION_SEMUN PGAC_UNION_SEMUN
PGAC_STRUCT_CMSGCRED
PGAC_STRUCT_FCRED
PGAC_STRUCT_SOCKCRED
PGAC_STRUCT_SOCKADDR_UN PGAC_STRUCT_SOCKADDR_UN
## ##
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.65 2001/09/06 03:23:38 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.66 2001/09/07 19:52:53 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/socket.h> /* for SCM_CREDS */ #include <sys/socket.h>
#ifdef SCM_CREDS #if defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || defined(HAVE_STRUCT_SOCKCRED)
#include <sys/uio.h> /* for struct iovec */ #include <sys/uio.h>
#include <sys/ucred.h> #include <sys/ucred.h>
#include <errno.h> #include <errno.h>
#endif #endif
...@@ -520,13 +520,16 @@ ClientAuthentication(Port *port) ...@@ -520,13 +520,16 @@ ClientAuthentication(Port *port)
break; break;
case uaIdent: case uaIdent:
#if !defined(SO_PEERCRED) && defined(SCM_CREDS) #if !defined(SO_PEERCRED) && (defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || defined(HAVE_STRUCT_SOCKCRED))
/* /*
* If we are doing ident on unix-domain sockets, * If we are doing ident on unix-domain sockets,
* use SCM_CREDS only if it is defined and SO_PEERCRED isn't. * use SCM_CREDS only if it is defined and SO_PEERCRED isn't.
*/ */
#ifdef fc_uid #if defined(HAVE_STRUCT_FCRED) || defined(HAVE_STRUCT_SOCKCRED)
/* Receive credentials on next message receipt, BSD/OS */ /*
* Receive credentials on next message receipt, BSD/OS, NetBSD.
* We need to set this before the client sends the next packet.
*/
{ {
int on = 1; int on = 1;
if (setsockopt(port->sock, 0, LOCAL_CREDS, &on, sizeof(on)) < 0) if (setsockopt(port->sock, 0, LOCAL_CREDS, &on, sizeof(on)) < 0)
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.69 2001/09/06 03:23:38 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.70 2001/09/07 19:52:54 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/socket.h> /* for SCM_CREDS */ #include <sys/socket.h>
#ifdef SCM_CREDS #if defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || defined(HAVE_STRUCT_SOCKCRED)
#include <sys/uio.h> /* for struct iovec */ #include <sys/uio.h>
#include <sys/ucred.h> #include <sys/ucred.h>
#endif #endif
#include <netinet/in.h> #include <netinet/in.h>
...@@ -872,7 +872,7 @@ ident_inet(const struct in_addr remote_ip_addr, ...@@ -872,7 +872,7 @@ ident_inet(const struct in_addr remote_ip_addr,
static bool static bool
ident_unix(int sock, char *ident_user) ident_unix(int sock, char *ident_user)
{ {
#ifdef SO_PEERCRED #if defined(SO_PEERCRED)
/* Linux style: use getsockopt(SO_PEERCRED) */ /* Linux style: use getsockopt(SO_PEERCRED) */
struct ucred peercred; struct ucred peercred;
ACCEPT_TYPE_ARG3 so_len = sizeof(peercred); ACCEPT_TYPE_ARG3 so_len = sizeof(peercred);
...@@ -906,16 +906,19 @@ ident_unix(int sock, char *ident_user) ...@@ -906,16 +906,19 @@ ident_unix(int sock, char *ident_user)
return true; return true;
#elif defined(SCM_CREDS) #elif defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || defined(HAVE_STRUCT_SOCKCRED)
struct msghdr msg; struct msghdr msg;
/* Credentials structure */ /* Credentials structure */
#ifndef fc_uid #ifdef HAVE_STRUCT_CMSGCRED
typedef struct cmsgcred Cred; typedef struct cmsgcred Cred;
#define cruid cmcred_uid #define cruid cmcred_uid
#else #elif HAVE_STRUCT_FCRED
typedef struct fcred Cred; typedef struct fcred Cred;
#define cruid fc_uid #define cruid fc_uid
#elif HAVE_STRUCT_SOCKCRED
typedef struct sockcred Cred;
#define cruid sc_uid
#endif #endif
Cred *cred; Cred *cred;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* or in pg_config.h afterwards. Of course, if you edit pg_config.h, then your * or in pg_config.h afterwards. Of course, if you edit pg_config.h, then your
* changes will be overwritten the next time you run configure. * changes will be overwritten the next time you run configure.
* *
* $Id: pg_config.h.in,v 1.4 2001/09/07 00:27:29 tgl Exp $ * $Id: pg_config.h.in,v 1.5 2001/09/07 19:52:54 momjian Exp $
*/ */
#ifndef PG_CONFIG_H #ifndef PG_CONFIG_H
...@@ -607,6 +607,15 @@ extern int fdatasync(int fildes); ...@@ -607,6 +607,15 @@ extern int fdatasync(int fildes);
/* Set to 1 if you have union semun */ /* Set to 1 if you have union semun */
#undef HAVE_UNION_SEMUN #undef HAVE_UNION_SEMUN
/* Set to 1 if you have struct cmsgcred */
#undef HAVE_STRUCT_CMSGCRED
/* Set to 1 if you have struct fcred */
#undef HAVE_STRUCT_FCRED
/* Set to 1 if you have struct sockcred */
#undef HAVE_STRUCT_SOCKCRED
/* Set to 1 if you have struct sockaddr_un */ /* Set to 1 if you have struct sockaddr_un */
#undef HAVE_STRUCT_SOCKADDR_UN #undef HAVE_STRUCT_SOCKADDR_UN
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes). * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.58 2001/08/21 15:49:17 momjian Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.59 2001/09/07 19:52:54 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -44,9 +44,9 @@ ...@@ -44,9 +44,9 @@
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> /* for MAXHOSTNAMELEN on most */ #include <sys/param.h> /* for MAXHOSTNAMELEN on most */
#include <sys/socket.h> /* for SCM_CREDS */ #include <sys/socket.h>
#ifdef SCM_CREDS #if defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || defined(HAVE_STRUCT_SOCKCRED)
#include <sys/uio.h> /* for struct iovec */ #include <sys/uio.h>
#include <sys/ucred.h> #include <sys/ucred.h>
#endif #endif
#ifndef MAXHOSTNAMELEN #ifndef MAXHOSTNAMELEN
...@@ -436,19 +436,25 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, ...@@ -436,19 +436,25 @@ pg_krb5_sendauth(char *PQerrormsg, int sock,
#endif /* KRB5 */ #endif /* KRB5 */
#ifdef SCM_CREDS #if defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || defined(HAVE_STRUCT_SOCKCRED)
static int static int
pg_local_sendauth(char *PQerrormsg, PGconn *conn) pg_local_sendauth(char *PQerrormsg, PGconn *conn)
{ {
char buf; char buf;
struct iovec iov; struct iovec iov;
struct msghdr msg; struct msghdr msg;
#ifndef fc_uid #ifdef HAVE_STRUCT_CMSGCRED
/* Prevent padding */ /* Prevent padding */
char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct cmsgcred)]; char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct cmsgcred)];
/* Point to start of first structure */ /* Point to start of first structure */
struct cmsghdr *cmsg = (struct cmsghdr *)cmsgmem; struct cmsghdr *cmsg = (struct cmsghdr *)cmsgmem;
#endif #endif
#ifdef HAVE_STRUCT_SOCKCRED
/* Prevent padding */
char cmsgmem[sizeof(struct cmsghdr) + sizeof(struct sockcred)];
/* Point to start of first structure */
struct cmsghdr *cmsg = (struct cmsghdr *)cmsgmem;
#endif
/* /*
* The backend doesn't care what we send here, but it wants * The backend doesn't care what we send here, but it wants
...@@ -463,7 +469,7 @@ pg_local_sendauth(char *PQerrormsg, PGconn *conn) ...@@ -463,7 +469,7 @@ pg_local_sendauth(char *PQerrormsg, PGconn *conn)
msg.msg_iov = &iov; msg.msg_iov = &iov;
msg.msg_iovlen = 1; msg.msg_iovlen = 1;
#ifndef fc_uid #ifdef HAVE_STRUCT_CMSGCRED
/* Create control header, FreeBSD */ /* Create control header, FreeBSD */
msg.msg_control = cmsg; msg.msg_control = cmsg;
msg.msg_controllen = sizeof(cmsgmem); msg.msg_controllen = sizeof(cmsgmem);
...@@ -609,7 +615,7 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname, ...@@ -609,7 +615,7 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
break; break;
case AUTH_REQ_SCM_CREDS: case AUTH_REQ_SCM_CREDS:
#ifdef SCM_CREDS #if defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || defined(HAVE_STRUCT_SOCKCRED)
if (pg_local_sendauth(PQerrormsg, conn) != STATUS_OK) if (pg_local_sendauth(PQerrormsg, conn) != STATUS_OK)
return STATUS_ERROR; return STATUS_ERROR;
#else #else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment