Skip to content

Commit f988edb

Browse files
committed
Add OpenBSD local indent credentials, from William Ahern.
1 parent 31504cc commit f988edb

File tree

4 files changed

+36
-7
lines changed

4 files changed

+36
-7
lines changed

configure

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9819,7 +9819,8 @@ test $ac_cv_func_memcmp_working = no && LIBOBJS="$LIBOBJS memcmp.$ac_objext"
98199819
98209820
98219821
9822-
for ac_func in cbrt fcvt getopt_long memmove pstat setproctitle setsid sigprocmask sysconf waitpid dlopen fdatasync
9822+
9823+
for ac_func in cbrt fcvt getopt_long getpeereid memmove pstat setproctitle setsid sigprocmask sysconf waitpid dlopen fdatasync
98239824
do
98249825
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
98259826
echo "$as_me:$LINENO: checking for $ac_func" >&5

configure.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $Header: /cvsroot/pgsql/configure.in,v 1.218 2002/11/04 21:36:13 tgl Exp $
2+
dnl $Header: /cvsroot/pgsql/configure.in,v 1.219 2002/12/03 21:50:43 momjian Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -782,7 +782,7 @@ PGAC_FUNC_GETTIMEOFDAY_1ARG
782782
# SunOS doesn't handle negative byte comparisons properly with +/- return
783783
AC_FUNC_MEMCMP
784784

785-
AC_CHECK_FUNCS([cbrt fcvt getopt_long memmove pstat setproctitle setsid sigprocmask sysconf waitpid dlopen fdatasync])
785+
AC_CHECK_FUNCS([cbrt fcvt getopt_long getpeereid memmove pstat setproctitle setsid sigprocmask sysconf waitpid dlopen fdatasync])
786786

787787
AC_CHECK_DECLS(fdatasync, [], [], [#include <unistd.h>])
788788

doc/src/sgml/client-auth.sgml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/client-auth.sgml,v 1.41 2002/11/15 03:11:15 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/client-auth.sgml,v 1.42 2002/12/03 21:50:44 momjian Exp $
33
-->
44

55
<chapter id="client-authentication">
@@ -318,7 +318,8 @@ hostssl <replaceable>database</replaceable> <replaceable>user</replaceable> <
318318
support Unix-domain socket credentials (currently
319319
<systemitem class=osname>Linux</>, <systemitem
320320
class=osname>FreeBSD</>, <systemitem class=osname>NetBSD</>,
321-
and <systemitem class=osname>BSD/OS</>).
321+
<systemitem class=osname>OpenBSD</>, and
322+
<systemitem class=osname>BSD/OS</>).
322323
</para>
323324

324325
<para>

src/backend/libpq/hba.c

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.87 2002/09/04 20:31:19 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.88 2002/12/03 21:50:44 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -1216,7 +1216,34 @@ ident_inet(const struct in_addr remote_ip_addr,
12161216
static bool
12171217
ident_unix(int sock, char *ident_user)
12181218
{
1219-
#if defined(SO_PEERCRED)
1219+
#if defined(HAVE_GETPEEREID)
1220+
/* OpenBSD style: */
1221+
uid_t uid;
1222+
gid_t gid;
1223+
struct passwd *pass;
1224+
1225+
errno = 0;
1226+
if (getpeereid(sock,&uid,&gid) != 0)
1227+
{
1228+
/* We didn't get a valid credentials struct. */
1229+
elog(LOG, "ident_unix: error receiving credentials: %m");
1230+
return false;
1231+
}
1232+
1233+
pass = getpwuid(uid);
1234+
1235+
if (pass == NULL)
1236+
{
1237+
elog(LOG, "ident_unix: unknown local user with uid %d",
1238+
(int) uid);
1239+
return false;
1240+
}
1241+
1242+
StrNCpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1);
1243+
1244+
return true;
1245+
1246+
#elsif defined(SO_PEERCRED)
12201247
/* Linux style: use getsockopt(SO_PEERCRED) */
12211248
struct ucred peercred;
12221249
ACCEPT_TYPE_ARG3 so_len = sizeof(peercred);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy