Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review 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
Christopher Ng
OpenLDAP
Commits
57316ae1
Commit
57316ae1
authored
17 years ago
by
Pierangelo Masarati
Browse files
Options
Downloads
Patches
Plain Diff
move session tracking control creation to helper
parent
a9b4c04f
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
clients/tools/common.c
+52
-84
52 additions, 84 deletions
clients/tools/common.c
with
52 additions
and
84 deletions
clients/tools/common.c
+
52
−
84
View file @
57316ae1
...
@@ -152,6 +152,53 @@ static struct tool_ctrls_t {
...
@@ -152,6 +152,53 @@ static struct tool_ctrls_t {
static
int
gotintr
;
static
int
gotintr
;
static
int
abcan
;
static
int
abcan
;
#ifdef LDAP_CONTROL_X_SESSION_TRACKING
static
int
st_value
(
LDAP
*
ld
,
struct
berval
*
value
)
{
char
*
ip
=
NULL
,
*
name
=
NULL
;
struct
berval
id
=
{
0
};
char
namebuf
[
MAXHOSTNAMELEN
];
if
(
gethostname
(
namebuf
,
sizeof
(
namebuf
)
)
==
0
)
{
struct
hostent
*
h
;
struct
in_addr
addr
;
name
=
namebuf
;
h
=
gethostbyname
(
name
);
if
(
h
!=
NULL
)
{
AC_MEMCPY
(
&
addr
,
h
->
h_addr
,
sizeof
(
addr
)
);
ip
=
inet_ntoa
(
addr
);
}
}
#ifdef HAVE_CYRUS_SASL
if
(
sasl_authz_id
!=
NULL
)
{
ber_str2bv
(
sasl_authz_id
,
0
,
0
,
&
id
);
}
else
if
(
sasl_authc_id
!=
NULL
)
{
ber_str2bv
(
sasl_authc_id
,
0
,
0
,
&
id
);
}
else
#endif
/* HAVE_CYRUS_SASL */
if
(
binddn
!=
NULL
)
{
ber_str2bv
(
binddn
,
0
,
0
,
&
id
);
}
if
(
ldap_create_session_tracking_value
(
ld
,
ip
,
name
,
LDAP_CONTROL_X_SESSION_TRACKING_USERNAME
,
&
id
,
&
stValue
)
)
{
fprintf
(
stderr
,
_
(
"Session tracking control encoding error!
\n
"
)
);
return
-
1
;
}
return
0
;
}
#endif
/* LDAP_CONTROL_X_SESSION_TRACKING */
RETSIGTYPE
RETSIGTYPE
do_sig
(
int
sig
)
do_sig
(
int
sig
)
{
{
...
@@ -1232,55 +1279,14 @@ tool_bind( LDAP *ld )
...
@@ -1232,55 +1279,14 @@ tool_bind( LDAP *ld )
#ifdef LDAP_CONTROL_X_SESSION_TRACKING
#ifdef LDAP_CONTROL_X_SESSION_TRACKING
if
(
sessionTracking
)
{
if
(
sessionTracking
)
{
LDAPControl
c
;
LDAPControl
c
;
char
*
ip
=
NULL
,
*
name
=
NULL
;
struct
berval
id
=
{
0
},
prefix_id
;
char
namebuf
[
MAXHOSTNAMELEN
];
char
*
ptr
;
if
(
gethostname
(
namebuf
,
sizeof
(
namebuf
)
)
==
0
)
{
struct
hostent
*
h
;
struct
in_addr
addr
;
name
=
namebuf
;
h
=
gethostbyname
(
name
);
if
(
h
!=
NULL
)
{
AC_MEMCPY
(
&
addr
,
h
->
h_addr
,
sizeof
(
addr
)
);
ip
=
inet_ntoa
(
addr
);
}
}
#ifdef HAVE_CYRUS_SASL
if
(
stValue
.
bv_val
==
NULL
&&
st_value
(
ld
,
&
stValue
)
)
{
if
(
sasl_authz_id
!=
NULL
)
{
ber_str2bv
(
sasl_authz_id
,
0
,
0
,
&
id
);
}
else
if
(
sasl_authc_id
!=
NULL
)
{
ber_str2bv
(
sasl_authc_id
,
0
,
0
,
&
id
);
}
else
#endif
/* HAVE_CYRUS_SASL */
if
(
binddn
!=
NULL
)
{
ber_str2bv
(
binddn
,
0
,
0
,
&
id
);
}
else
{
ber_str2bv
(
"anonymous"
,
0
,
0
,
&
id
);
}
prefix_id
.
bv_len
=
STRLENOF
(
"binding:"
)
+
id
.
bv_len
;
ptr
=
prefix_id
.
bv_val
=
malloc
(
prefix_id
.
bv_len
+
1
);
ptr
=
lutil_strcopy
(
ptr
,
"binding:"
);
ptr
=
lutil_strcopy
(
ptr
,
id
.
bv_val
);
if
(
ldap_create_session_tracking_value
(
ld
,
ip
,
name
,
LDAP_CONTROL_X_SESSION_TRACKING_USERNAME
,
&
prefix_id
,
&
c
.
ldctl_value
)
)
{
fprintf
(
stderr
,
_
(
"Session tracking control encoding error!
\n
"
)
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
c
.
ldctl_oid
=
LDAP_CONTROL_X_SESSION_TRACKING
;
c
.
ldctl_oid
=
LDAP_CONTROL_X_SESSION_TRACKING
;
c
.
ldctl_iscritical
=
0
;
c
.
ldctl_iscritical
=
0
;
ber_dupbv
(
&
c
.
ldctl_value
,
&
stValue
);
sctrl
[
nsctrls
]
=
c
;
sctrl
[
nsctrls
]
=
c
;
sctrls
[
nsctrls
]
=
&
sctrl
[
nsctrls
];
sctrls
[
nsctrls
]
=
&
sctrl
[
nsctrls
];
...
@@ -1673,52 +1679,14 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
...
@@ -1673,52 +1679,14 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
#ifdef LDAP_CONTROL_X_SESSION_TRACKING
#ifdef LDAP_CONTROL_X_SESSION_TRACKING
if
(
sessionTracking
)
{
if
(
sessionTracking
)
{
if
(
stValue
.
bv_val
==
NULL
)
{
if
(
stValue
.
bv_val
==
NULL
&&
st_value
(
ld
,
&
stValue
)
)
{
char
*
ip
=
NULL
,
*
name
=
NULL
;
exit
(
EXIT_FAILURE
);
struct
berval
id
=
{
0
};
char
namebuf
[
MAXHOSTNAMELEN
];
if
(
gethostname
(
namebuf
,
sizeof
(
namebuf
)
)
==
0
)
{
struct
hostent
*
h
;
struct
in_addr
addr
;
name
=
namebuf
;
h
=
gethostbyname
(
name
);
if
(
h
!=
NULL
)
{
AC_MEMCPY
(
&
addr
,
h
->
h_addr
,
sizeof
(
addr
)
);
ip
=
inet_ntoa
(
addr
);
}
}
#ifdef HAVE_CYRUS_SASL
if
(
sasl_authz_id
!=
NULL
)
{
ber_str2bv
(
sasl_authz_id
,
0
,
0
,
&
id
);
}
else
if
(
sasl_authc_id
!=
NULL
)
{
ber_str2bv
(
sasl_authc_id
,
0
,
0
,
&
id
);
}
else
#endif
/* HAVE_CYRUS_SASL */
if
(
binddn
!=
NULL
)
{
ber_str2bv
(
binddn
,
0
,
0
,
&
id
);
}
else
{
ber_str2bv
(
"anonymous"
,
0
,
0
,
&
id
);
}
if
(
ldap_create_session_tracking_value
(
ld
,
ip
,
name
,
LDAP_CONTROL_X_SESSION_TRACKING_USERNAME
,
&
id
,
&
stValue
)
)
{
fprintf
(
stderr
,
_
(
"Session tracking control encoding error!
\n
"
)
);
exit
(
EXIT_FAILURE
);
}
}
}
c
[
i
].
ldctl_oid
=
LDAP_CONTROL_X_SESSION_TRACKING
;
c
[
i
].
ldctl_oid
=
LDAP_CONTROL_X_SESSION_TRACKING
;
c
[
i
].
ldctl_iscritical
=
0
;
c
[
i
].
ldctl_iscritical
=
0
;
ber_dupbv
(
&
c
[
i
].
ldctl_value
,
&
stValue
);
ber_dupbv
(
&
c
[
i
].
ldctl_value
,
&
stValue
);
ctrls
[
i
]
=
&
c
[
i
];
ctrls
[
i
]
=
&
c
[
i
];
i
++
;
i
++
;
}
}
...
...
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