Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
1b51018a
Commit
1b51018a
authored
14 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Fix up poor handling of unsupported-platform case in requirepeer patch.
parent
25241aee
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/interfaces/libpq/fe-connect.c
+20
-21
20 additions, 21 deletions
src/interfaces/libpq/fe-connect.c
with
20 additions
and
21 deletions
src/interfaces/libpq/fe-connect.c
+
20
−
21
View file @
1b51018a
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.40
1
2010/07/18 1
6:42:20
tgl Exp $
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.40
2
2010/07/18 1
7:08:11
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1751,15 +1751,15 @@ keep_going: /* We will come back to here until there is
char
*
startpacket
;
int
packetlen
;
#ifdef HAVE_UNIX_SOCKETS
if
(
conn
->
requirepeer
)
if
(
conn
->
requirepeer
&&
conn
->
requirepeer
[
0
])
{
#if defined(HAVE_GETPEEREID) || defined(SO_PEERCRED) || defined(HAVE_GETPEERUCRED)
char
pwdbuf
[
BUFSIZ
];
struct
passwd
pass_buf
;
struct
passwd
*
pass
;
uid_t
uid
;
#
if defined(HAVE_GETPEEREID)
#if defined(HAVE_GETPEEREID)
gid_t
gid
;
errno
=
0
;
...
...
@@ -1770,12 +1770,13 @@ keep_going: /* We will come back to here until there is
pqStrerror
(
errno
,
sebuf
,
sizeof
(
sebuf
)));
goto
error_return
;
}
#
elif defined(SO_PEERCRED)
#elif defined(SO_PEERCRED)
struct
ucred
peercred
;
ACCEPT_TYPE_ARG3
so_len
=
sizeof
(
peercred
);
errno
=
0
;
if
(
getsockopt
(
conn
->
sock
,
SOL_SOCKET
,
SO_PEERCRED
,
&
peercred
,
&
so_len
)
!=
0
||
if
(
getsockopt
(
conn
->
sock
,
SOL_SOCKET
,
SO_PEERCRED
,
&
peercred
,
&
so_len
)
!=
0
||
so_len
!=
sizeof
(
peercred
))
{
appendPQExpBuffer
(
&
conn
->
errorMessage
,
...
...
@@ -1784,10 +1785,10 @@ keep_going: /* We will come back to here until there is
goto
error_return
;
}
uid
=
peercred
.
uid
;
#
elif defined(HAVE_GETPEERUCRED)
#elif defined(HAVE_GETPEERUCRED)
ucred_t
*
ucred
;
ucred
=
NULL
;
/* must be initialized to NULL */
ucred
=
NULL
;
/* must be initialized to NULL */
if
(
getpeerucred
(
sock
,
&
ucred
)
==
-
1
)
{
appendPQExpBuffer
(
&
conn
->
errorMessage
,
...
...
@@ -1805,35 +1806,33 @@ keep_going: /* We will come back to here until there is
goto
error_return
;
}
ucred_free
(
ucred
);
# else
appendPQExpBuffer
(
&
conn
->
errorMessage
,
libpq_gettext
(
"requirepeer parameter is not supported on this platform
\n
"
));
goto
error_return
;
# endif
#else
#error missing implementation method for requirepeer
#endif
pqGetpwuid
(
uid
,
&
pass_buf
,
pwdbuf
,
sizeof
(
pwdbuf
),
&
pass
);
if
(
pass
==
NULL
)
{
appendPQExpBuffer
(
&
conn
->
errorMessage
,
# if defined(SO_PEERCRED)
libpq_gettext
(
"local user with ID %d does not exist
\n
"
),
(
int
)
peercred
.
uid
);
#else
libpq_gettext
(
"matching local user does not exist
\n
"
));
#endif
(
int
)
uid
);
goto
error_return
;
}
if
(
strcmp
(
pass
->
pw_name
,
conn
->
requirepeer
)
!=
0
)
{
appendPQExpBuffer
(
&
conn
->
errorMessage
,
libpq_gettext
(
"requirepeer
failed (actual: %s != required: %s)
\n
"
),
pass
->
pw_name
,
conn
->
requirepeer
);
libpq_gettext
(
"requirepeer
specifies
\"
%s
\"
, but actual peer user name is
\"
%s
\"
\n
"
),
conn
->
requirepeer
,
pass
->
pw_name
);
goto
error_return
;
}
#else
/* can't support requirepeer */
appendPQExpBuffer
(
&
conn
->
errorMessage
,
libpq_gettext
(
"requirepeer parameter is not supported on this platform
\n
"
));
goto
error_return
;
#endif
}
#endif
/* HAVE_UNIX_SOCKETS */
#ifdef USE_SSL
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment