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
Nadezhda Ivanova
OpenLDAP
Commits
b0c3d115
Commit
b0c3d115
authored
Aug 29, 2002
by
Kurt Zeilenga
Browse files
passfile support
parent
30c8aeb9
Changes
2
Hide whitespace changes
Inline
Side-by-side
libraries/liblutil/Makefile.in
View file @
b0c3d115
...
...
@@ -13,11 +13,11 @@ NT_OBJS = ntservice.o slapdmsg.res
UNIX_SRCS
=
detach.c
UNIX_OBJS
=
detach.o
SRCS
=
base64.c csn.c entropy.c sasl.c signal.c hash.c
\
SRCS
=
base64.c csn.c entropy.c sasl.c signal.c hash.c
passfile.c
\
md5.c passwd.c sha1.c getpass.c lockf.c utils.c uuid.c sockpair.c
\
@LIBSRCS@
$
(
@PLAT@_SRCS
)
OBJS
=
base64.o csn.o entropy.o sasl.o signal.o hash.o
\
OBJS
=
base64.o csn.o entropy.o sasl.o signal.o hash.o
passfile.o
\
md5.o passwd.o sha1.o getpass.o lockf.o utils.o uuid.o sockpair.o
\
@LIBOBJS@
$
(
@PLAT@_OBJS
)
...
...
libraries/liblutil/passfile.c
0 → 100644
View file @
b0c3d115
/* $OpenLDAP$ */
/*
* Copyright 2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include
"portable.h"
#include
<stdio.h>
#include
<ac/ctype.h>
#include
<ac/string.h>
#ifdef HAVE_FSTAT
#include
<sys/types.h>
#include
<sys/stat.h>
#endif
/* HAVE_FSTAT */
#include
<lber.h>
#include
<lutil.h>
/* Get a password from a file. */
int
lutil_get_filed_password
(
const
char
*
filename
,
struct
berval
*
passwd
)
{
int
rc
;
size_t
nread
,
nleft
,
nr
;
FILE
*
f
=
fopen
(
filename
,
"r"
);
if
(
f
==
NULL
)
{
perror
(
filename
);
return
-
1
;
}
passwd
->
bv_val
=
NULL
;
passwd
->
bv_len
=
4196
;
#ifdef HAVE_FSTAT
{
struct
stat
sb
;
if
(
fstat
(
fileno
(
f
),
&
sb
)
==
0
)
{
if
(
sb
.
st_mode
&
006
)
{
fprintf
(
stderr
,
"Warning: Password file %s is publicly readable/writeable
\n
"
,
filename
);
}
passwd
->
bv_len
=
sb
.
st_size
;
}
}
#endif
/* HAVE_FSTAT */
passwd
->
bv_val
=
(
char
*
)
malloc
(
passwd
->
bv_len
+
1
);
if
(
passwd
->
bv_val
==
NULL
)
{
perror
(
filename
);
return
-
1
;
}
nread
=
0
;
nleft
=
passwd
->
bv_len
;
do
{
if
(
nleft
==
0
)
{
/* double the buffer size */
char
*
p
=
(
char
*
)
realloc
(
passwd
->
bv_val
,
2
*
passwd
->
bv_len
+
1
);
if
(
p
==
NULL
)
{
free
(
passwd
->
bv_val
);
passwd
->
bv_val
=
NULL
;
passwd
->
bv_len
=
0
;
return
-
1
;
}
nleft
=
passwd
->
bv_len
;
passwd
->
bv_len
*=
2
;
passwd
->
bv_val
=
p
;
}
nr
=
fread
(
&
passwd
->
bv_val
[
nread
],
1
,
nleft
,
f
);
if
(
nr
<
nleft
&&
ferror
(
f
)
)
{
free
(
passwd
->
bv_val
);
passwd
->
bv_val
=
NULL
;
passwd
->
bv_len
=
0
;
return
-
1
;
}
nread
+=
nr
;
nleft
-=
nr
;
}
while
(
!
feof
(
f
)
);
passwd
->
bv_len
=
nread
;
passwd
->
bv_val
[
nread
]
=
'\0'
;
fclose
(
f
);
return
0
;
}
Write
Preview
Supports
Markdown
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