Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Oren Tirosh
OpenLDAP
Commits
70f7e553
Commit
70f7e553
authored
23 years ago
by
Stig Venaas
Browse files
Options
Downloads
Patches
Plain Diff
Changed get_listener_addresses() to not use getaddrinfo() for PF_LOCAL
parent
511e8b60
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
servers/slapd/daemon.c
+77
-102
77 additions, 102 deletions
servers/slapd/daemon.c
with
77 additions
and
102 deletions
servers/slapd/daemon.c
+
77
−
102
View file @
70f7e553
...
...
@@ -337,35 +337,51 @@ static int slap_get_listener_addresses(
struct
sockaddr
***
sal
)
{
struct
sockaddr
**
sap
;
#ifdef HAVE_GETADDRINFO
struct
addrinfo
hints
,
*
res
,
*
sai
;
int
n
,
err
;
memset
(
&
hints
,
'\0'
,
sizeof
(
hints
)
);
hints
.
ai_flags
=
AI_PASSIVE
;
hints
.
ai_socktype
=
SOCK_STREAM
;
# ifdef LDAP_PF_LOCAL
#ifdef LDAP_PF_LOCAL
if
(
port
==
0
)
{
hints
.
ai_family
=
AF_LOCAL
;
/* host specifies a service in this case */
if
(
err
=
getaddrinfo
(
NULL
,
host
,
&
hints
,
&
res
))
{
*
sal
=
ch_malloc
(
2
*
sizeof
(
void
*
));
if
(
*
sal
==
NULL
)
{
return
-
1
;
}
sap
=
*
sal
;
*
sap
=
ch_malloc
(
sizeof
(
struct
sockaddr_un
));
if
(
*
sap
==
NULL
)
goto
errexit
;
sap
[
1
]
=
NULL
;
if
(
strlen
(
host
)
>
(
sizeof
(((
struct
sockaddr_un
*
)
*
sap
)
->
sun_path
)
-
1
)
)
{
#ifdef NEW_LOGGING
LDAP_LOG
((
"connection"
,
LDAP_LEVEL_INFO
,
"slap_get_listener_addresses:
getaddrinfo failed: %s
\n
"
,
AC_GAI_STRERROR
(
err
)
));
"slap_get_listener_addresses:
domain socket path (%s) too long in URL
\n
"
,
host
));
#else
Debug
(
LDAP_DEBUG_ANY
,
"daemon: getaddrinfo failed: %s
\n
"
,
AC_GAI_STRERROR
(
err
),
0
,
0
);
Debug
(
LDAP_DEBUG_ANY
,
"daemon: domain socket path (%s) too long in URL"
,
host
,
0
,
0
);
#endif
return
-
1
;
goto
errexit
;
}
(
void
)
memset
(
(
void
*
)
*
sap
,
'\0'
,
sizeof
(
struct
sockaddr_un
)
);
(
*
sap
)
->
sa_family
=
AF_LOCAL
;
strcpy
(
((
struct
sockaddr_un
*
)
*
sap
)
->
sun_path
,
host
);
}
else
#
endif
#endif
{
#ifdef HAVE_GETADDRINFO
struct
addrinfo
hints
,
*
res
,
*
sai
;
int
n
,
err
;
char
serv
[
7
];
snprintf
(
serv
,
sizeof
serv
,
"%d"
,
port
);
memset
(
&
hints
,
'\0'
,
sizeof
(
hints
)
);
hints
.
ai_flags
=
AI_PASSIVE
;
hints
.
ai_socktype
=
SOCK_STREAM
;
hints
.
ai_family
=
AF_UNSPEC
;
snprintf
(
serv
,
sizeof
serv
,
"%d"
,
port
);
if
(
err
=
getaddrinfo
(
host
,
serv
,
&
hints
,
&
res
))
{
#ifdef NEW_LOGGING
LDAP_LOG
((
"connection"
,
LDAP_LEVEL_INFO
,
...
...
@@ -377,94 +393,54 @@ static int slap_get_listener_addresses(
#endif
return
-
1
;
}
}
sai
=
res
;
for
(
n
=
2
;
(
sai
=
sai
->
ai_next
)
!=
NULL
;
n
++
)
{
/* EMPTY */
;
}
*
sal
=
ch_malloc
(
n
*
sizeof
(
*
sal
));
if
(
*
sal
==
NULL
)
{
return
-
1
;
}
sai
=
res
;
sap
=
*
sal
;
do
{
switch
(
sai
->
ai_family
)
{
# ifdef LDAP_PF_LOCAL
case
AF_LOCAL
:
{
*
sap
=
ch_malloc
(
sizeof
(
struct
sockaddr_un
));
if
(
*
sap
==
NULL
)
{
freeaddrinfo
(
res
);
goto
errexit
;
}
*
(
struct
sockaddr_un
*
)
*
sap
=
*
((
struct
sockaddr_un
*
)
sai
->
ai_addr
);
}
break
;
# endif
# ifdef LDAP_PF_INET6
case
AF_INET6
:
{
*
sap
=
ch_malloc
(
sizeof
(
struct
sockaddr_in6
));
if
(
*
sap
==
NULL
)
{
freeaddrinfo
(
res
);
goto
errexit
;
}
*
(
struct
sockaddr_in6
*
)
*
sap
=
*
((
struct
sockaddr_in6
*
)
sai
->
ai_addr
);
}
break
;
# endif
case
AF_INET
:
{
*
sap
=
ch_malloc
(
sizeof
(
struct
sockaddr_in
));
if
(
*
sap
==
NULL
)
{
freeaddrinfo
(
res
);
goto
errexit
;
}
*
(
struct
sockaddr_in
*
)
*
sap
=
*
((
struct
sockaddr_in
*
)
sai
->
ai_addr
);
}
break
;
default:
*
sap
=
NULL
;
break
;
}
if
(
*
sap
!=
NULL
)
{
(
*
sap
)
->
sa_family
=
sai
->
ai_family
;
sap
++
;
sai
=
res
;
for
(
n
=
2
;
(
sai
=
sai
->
ai_next
)
!=
NULL
;
n
++
)
{
/* EMPTY */
;
}
}
while
((
sai
=
sai
->
ai_next
)
!=
NULL
);
freeaddrinfo
(
res
);
#else
# ifdef LDAP_PF_LOCAL
if
(
port
==
0
)
{
*
sal
=
ch_malloc
(
2
*
sizeof
(
*
sal
));
*
sal
=
ch_malloc
(
n
*
sizeof
(
void
*
));
if
(
*
sal
==
NULL
)
{
return
-
1
;
}
sai
=
res
;
sap
=
*
sal
;
*
sap
=
ch_malloc
(
sizeof
(
struct
sockaddr_un
));
if
(
*
sap
==
NULL
)
goto
errexit
;
(
void
)
memset
(
(
void
*
)
*
sap
,
'\0'
,
sizeof
(
struct
sockaddr_un
)
);
(
*
sap
)
->
sa_family
=
AF_LOCAL
;
if
(
strlen
(
host
)
>
(
sizeof
(((
struct
sockaddr_un
*
)
*
sal
)
->
sun_path
)
-
1
)
)
{
#ifdef NEW_LOGGING
LDAP_LOG
((
"connection"
,
LDAP_LEVEL_INFO
,
"slap_get_listener_addresses: domain socket path (%s) too long in URL
\n
"
,
host
));
#else
Debug
(
LDAP_DEBUG_ANY
,
"daemon: domain socket path (%s) too long in URL"
,
host
,
0
,
0
);
#endif
goto
errexit
;
}
strcpy
(
((
struct
sockaddr_un
*
)
*
sap
)
->
sun_path
,
host
);
}
else
do
{
switch
(
sai
->
ai_family
)
{
# ifdef LDAP_PF_INET6
case
AF_INET6
:
*
sap
=
ch_malloc
(
sizeof
(
struct
sockaddr_in6
));
if
(
*
sap
==
NULL
)
{
freeaddrinfo
(
res
);
goto
errexit
;
}
*
(
struct
sockaddr_in6
*
)
*
sap
=
*
((
struct
sockaddr_in6
*
)
sai
->
ai_addr
);
break
;
# endif
{
case
AF_INET
:
*
sap
=
ch_malloc
(
sizeof
(
struct
sockaddr_in
));
if
(
*
sap
==
NULL
)
{
freeaddrinfo
(
res
);
goto
errexit
;
}
*
(
struct
sockaddr_in
*
)
*
sap
=
*
((
struct
sockaddr_in
*
)
sai
->
ai_addr
);
break
;
default:
*
sap
=
NULL
;
break
;
}
if
(
*
sap
!=
NULL
)
{
(
*
sap
)
->
sa_family
=
sai
->
ai_family
;
sap
++
;
}
}
while
((
sai
=
sai
->
ai_next
)
!=
NULL
);
*
sap
=
NULL
;
freeaddrinfo
(
res
);
#else
struct
in_addr
in
;
if
(
host
==
NULL
)
{
...
...
@@ -486,7 +462,7 @@ static int slap_get_listener_addresses(
AC_MEMCPY
(
&
in
,
he
->
h_addr
,
sizeof
(
in
)
);
}
*
sal
=
ch_malloc
(
2
*
sizeof
(
*
sal
));
*
sal
=
ch_malloc
(
2
*
sizeof
(
void
*
));
if
(
*
sal
==
NULL
)
{
return
-
1
;
}
...
...
@@ -496,16 +472,15 @@ static int slap_get_listener_addresses(
if
(
*
sap
==
NULL
)
{
goto
errexit
;
}
sap
[
1
]
=
NULL
;
(
void
)
memset
(
(
void
*
)
*
sap
,
'\0'
,
sizeof
(
struct
sockaddr_in
)
);
(
*
sap
)
->
sa_family
=
AF_INET
;
((
struct
sockaddr_in
*
)
*
sap
)
->
sin_port
=
htons
(
port
);
((
struct
sockaddr_in
*
)
*
sap
)
->
sin_addr
=
in
;
}
sap
++
;
#endif
}
*
sap
=
NULL
;
return
0
;
errexit:
...
...
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