Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Joe Martin
OpenLDAP
Commits
2396cf7d
Commit
2396cf7d
authored
Apr 16, 2010
by
Quanah Gibson-Mount
Browse files
move getpassphrase inside tool_bind; make sure password is always malloc'd and freed
parent
744f6acf
Changes
9
Hide whitespace changes
Inline
Side-by-side
clients/tools/common.c
View file @
2396cf7d
...
...
@@ -260,11 +260,13 @@ tool_destroy( void )
ber_memfree
(
binddn
);
}
#if 0 /* not yet */
if
(
passwd
.
bv_val
!=
NULL
)
{
ber_memfree
(
passwd
.
bv_val
);
}
#endif
if
(
infile
!=
NULL
)
{
ber_memfree
(
infile
);
}
}
void
...
...
@@ -1357,6 +1359,23 @@ tool_bind( LDAP *ld )
assert
(
nsctrls
<
(
int
)
(
sizeof
(
sctrls
)
/
sizeof
(
sctrls
[
0
]))
);
if
(
pw_file
||
want_bindpw
)
{
assert
(
passwd
.
bv_val
==
NULL
&&
passwd
.
bv_len
==
0
);
if
(
pw_file
)
{
if
(
lutil_get_filed_password
(
pw_file
,
&
passwd
)
)
{
exit
(
EXIT_FAILURE
);
}
}
else
{
char
*
pw
=
getpassphrase
(
_
(
"Enter LDAP Password: "
)
);
if
(
pw
)
{
passwd
.
bv_val
=
ber_strdup
(
pw
);
passwd
.
bv_len
=
strlen
(
passwd
.
bv_val
);
}
}
}
if
(
authmethod
==
LDAP_AUTH_SASL
)
{
#ifdef HAVE_CYRUS_SASL
void
*
defaults
;
...
...
clients/tools/ldapcompare.c
View file @
2396cf7d
...
...
@@ -230,16 +230,6 @@ main( int argc, char **argv )
ld
=
tool_conn_setup
(
0
,
0
);
if
(
pw_file
||
want_bindpw
)
{
if
(
pw_file
)
{
rc
=
lutil_get_filed_password
(
pw_file
,
&
passwd
);
if
(
rc
)
return
EXIT_FAILURE
;
}
else
{
passwd
.
bv_val
=
getpassphrase
(
_
(
"Enter LDAP Password: "
)
);
passwd
.
bv_len
=
passwd
.
bv_val
?
strlen
(
passwd
.
bv_val
)
:
0
;
}
}
tool_bind
(
ld
);
if
(
0
...
...
clients/tools/ldapdelete.c
View file @
2396cf7d
...
...
@@ -184,24 +184,10 @@ main( int argc, char **argv )
if
(
optind
>=
argc
)
{
fp
=
stdin
;
}
}
}
ld
=
tool_conn_setup
(
0
,
&
private_conn_setup
);
if
(
pw_file
||
want_bindpw
)
{
if
(
pw_file
)
{
rc
=
lutil_get_filed_password
(
pw_file
,
&
passwd
);
if
(
rc
)
{
if
(
fp
&&
fp
!=
stdin
)
fclose
(
fp
);
return
EXIT_FAILURE
;
}
}
else
{
passwd
.
bv_val
=
getpassphrase
(
_
(
"Enter LDAP Password: "
)
);
passwd
.
bv_len
=
passwd
.
bv_val
?
strlen
(
passwd
.
bv_val
)
:
0
;
}
}
tool_bind
(
ld
);
tool_server_controls
(
ld
,
NULL
,
0
);
...
...
clients/tools/ldapexop.c
View file @
2396cf7d
...
...
@@ -89,16 +89,6 @@ main( int argc, char *argv[] )
usage
();
}
if
(
pw_file
||
want_bindpw
)
{
if
(
pw_file
)
{
rc
=
lutil_get_filed_password
(
pw_file
,
&
passwd
);
if
(
rc
)
return
EXIT_FAILURE
;
}
else
{
passwd
.
bv_val
=
getpassphrase
(
_
(
"Enter LDAP Password: "
)
);
passwd
.
bv_len
=
passwd
.
bv_val
?
strlen
(
passwd
.
bv_val
)
:
0
;
}
}
ld
=
tool_conn_setup
(
0
,
0
);
tool_bind
(
ld
);
...
...
clients/tools/ldapmodify.c
View file @
2396cf7d
...
...
@@ -285,15 +285,6 @@ main( int argc, char **argv )
ld
=
tool_conn_setup
(
dont
,
0
);
if
(
!
dont
)
{
if
(
pw_file
||
want_bindpw
)
{
if
(
pw_file
)
{
rc
=
lutil_get_filed_password
(
pw_file
,
&
passwd
);
if
(
rc
)
return
EXIT_FAILURE
;
}
else
{
passwd
.
bv_val
=
getpassphrase
(
_
(
"Enter LDAP Password: "
)
);
passwd
.
bv_len
=
passwd
.
bv_val
?
strlen
(
passwd
.
bv_val
)
:
0
;
}
}
tool_bind
(
ld
);
}
...
...
clients/tools/ldapmodrdn.c
View file @
2396cf7d
...
...
@@ -194,19 +194,6 @@ main(int argc, char **argv)
ld
=
tool_conn_setup
(
0
,
0
);
if
(
pw_file
||
want_bindpw
)
{
if
(
pw_file
)
{
rc
=
lutil_get_filed_password
(
pw_file
,
&
passwd
);
if
(
rc
)
{
retval
=
EXIT_FAILURE
;
goto
fail
;
}
}
else
{
passwd
.
bv_val
=
getpassphrase
(
_
(
"Enter LDAP Password: "
)
);
passwd
.
bv_len
=
passwd
.
bv_val
?
strlen
(
passwd
.
bv_val
)
:
0
;
}
}
tool_bind
(
ld
);
tool_server_controls
(
ld
,
NULL
,
0
);
...
...
clients/tools/ldappasswd.c
View file @
2396cf7d
...
...
@@ -245,18 +245,6 @@ main( int argc, char *argv[] )
newpw
.
bv_len
=
strlen
(
newpw
.
bv_val
);
}
if
(
pw_file
)
{
rc
=
lutil_get_filed_password
(
pw_file
,
&
passwd
);
if
(
rc
)
{
rc
=
EXIT_FAILURE
;
goto
done
;
}
}
else
if
(
want_bindpw
)
{
passwd
.
bv_val
=
getpassphrase
(
_
(
"Enter LDAP Password: "
)
);
passwd
.
bv_len
=
passwd
.
bv_val
?
strlen
(
passwd
.
bv_val
)
:
0
;
}
ld
=
tool_conn_setup
(
0
,
0
);
tool_bind
(
ld
);
...
...
clients/tools/ldapsearch.c
View file @
2396cf7d
...
...
@@ -899,16 +899,6 @@ main( int argc, char **argv )
ld
=
tool_conn_setup
(
0
,
&
private_conn_setup
);
if
(
pw_file
||
want_bindpw
)
{
if
(
pw_file
)
{
rc
=
lutil_get_filed_password
(
pw_file
,
&
passwd
);
if
(
rc
)
return
EXIT_FAILURE
;
}
else
{
passwd
.
bv_val
=
getpassphrase
(
_
(
"Enter LDAP Password: "
)
);
passwd
.
bv_len
=
passwd
.
bv_val
?
strlen
(
passwd
.
bv_val
)
:
0
;
}
}
tool_bind
(
ld
);
getNextPage:
...
...
clients/tools/ldapwhoami.c
View file @
2396cf7d
...
...
@@ -129,16 +129,6 @@ main( int argc, char *argv[] )
usage
();
}
if
(
pw_file
||
want_bindpw
)
{
if
(
pw_file
)
{
rc
=
lutil_get_filed_password
(
pw_file
,
&
passwd
);
if
(
rc
)
return
EXIT_FAILURE
;
}
else
{
passwd
.
bv_val
=
getpassphrase
(
_
(
"Enter LDAP Password: "
)
);
passwd
.
bv_len
=
passwd
.
bv_val
?
strlen
(
passwd
.
bv_val
)
:
0
;
}
}
ld
=
tool_conn_setup
(
0
,
0
);
tool_bind
(
ld
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment