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
David Barchiesi
OpenLDAP
Commits
14b2b4de
Commit
14b2b4de
authored
19 years ago
by
Pierangelo Masarati
Browse files
Options
Downloads
Patches
Plain Diff
cleanup
parent
09e4da6b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
servers/slapd/back-passwd/init.c
+30
-1
30 additions, 1 deletion
servers/slapd/back-passwd/init.c
servers/slapd/back-passwd/proto-passwd.h
+3
-3
3 additions, 3 deletions
servers/slapd/back-passwd/proto-passwd.h
servers/slapd/back-passwd/search.c
+55
-78
55 additions, 78 deletions
servers/slapd/back-passwd/search.c
with
88 additions
and
82 deletions
servers/slapd/back-passwd/init.c
+
30
−
1
View file @
14b2b4de
...
...
@@ -25,6 +25,9 @@
ldap_pvt_thread_mutex_t
passwd_mutex
;
AttributeDescription
*
ad_sn
;
AttributeDescription
*
ad_desc
;
int
passwd_back_initialize
(
BackendInfo
*
bi
...
...
@@ -32,7 +35,7 @@ passwd_back_initialize(
{
ldap_pvt_thread_mutex_init
(
&
passwd_mutex
);
bi
->
bi_open
=
0
;
bi
->
bi_open
=
passwd_back_open
;
bi
->
bi_config
=
0
;
bi
->
bi_close
=
0
;
bi
->
bi_destroy
=
passwd_back_destroy
;
...
...
@@ -63,6 +66,32 @@ passwd_back_initialize(
return
0
;
}
int
passwd_back_open
(
BackendInfo
*
bi
)
{
const
char
*
text
;
int
rc
;
rc
=
slap_str2ad
(
"sn"
,
&
ad_sn
,
&
text
);
if
(
rc
!=
LDAP_SUCCESS
)
{
Debug
(
LDAP_DEBUG_ANY
,
"passwd_back_open: "
"slap_str2ad(
\"
%s
\"
) returned %d: %s
\n
"
,
"sn"
,
rc
,
text
);
return
-
1
;
}
rc
=
slap_str2ad
(
"description"
,
&
ad_desc
,
&
text
);
if
(
rc
!=
LDAP_SUCCESS
)
{
Debug
(
LDAP_DEBUG_ANY
,
"passwd_back_open: "
"slap_str2ad(
\"
%s
\"
) returned %d: %s
\n
"
,
"description"
,
rc
,
text
);
return
-
1
;
}
return
0
;
}
int
passwd_back_destroy
(
BackendInfo
*
bi
...
...
This diff is collapsed.
Click to expand it.
servers/slapd/back-passwd/proto-passwd.h
+
3
−
3
View file @
14b2b4de
...
...
@@ -19,13 +19,13 @@
LDAP_BEGIN_DECL
extern
BI_init
passwd_back_initialize
;
extern
BI_open
passwd_back_open
;
extern
BI_destroy
passwd_back_destroy
;
extern
BI_db_config
passwd_back_db_config
;
extern
BI_op_search
passwd_back_search
;
extern
AttributeDescription
*
ad_sn
;
extern
AttributeDescription
*
ad_desc
;
LDAP_END_DECL
#endif
/* PROTO_PASSWD_H */
This diff is collapsed.
Click to expand it.
servers/slapd/back-passwd/search.c
+
55
−
78
View file @
14b2b4de
...
...
@@ -50,8 +50,7 @@ static void pw_start( Backend *be );
static
Entry
*
pw2entry
(
Backend
*
be
,
struct
passwd
*
pw
,
const
char
**
text
);
struct
passwd
*
pw
);
int
passwd_back_search
(
...
...
@@ -60,7 +59,6 @@ passwd_back_search(
{
struct
passwd
*
pw
;
Entry
*
e
;
char
*
s
;
time_t
stoptime
;
LDAPRDN
rdn
=
NULL
;
...
...
@@ -74,14 +72,13 @@ passwd_back_search(
/* Handle a query for the base of this backend */
if
(
be_issuffix
(
op
->
o_bd
,
&
op
->
o_req_ndn
)
)
{
struct
berval
vals
[
2
];
vals
[
1
].
bv_val
=
NULL
;
struct
berval
val
;
rs
->
sr_matched
=
op
->
o_req_dn
.
bv_val
;
if
(
op
->
ors_scope
!=
LDAP_SCOPE_ONELEVEL
)
{
AttributeDescription
*
desc
=
NULL
;
AttributeDescription
*
desc
=
NULL
;
char
*
next
;
/* Create an entry corresponding to the base DN */
e
=
(
Entry
*
)
ch_calloc
(
1
,
sizeof
(
Entry
));
...
...
@@ -95,7 +92,7 @@ passwd_back_search(
/* Use the first attribute of the DN
* as an attribute within the entry itself.
*/
if
(
ldap_bv2rdn
(
&
op
->
o_req_dn
,
&
rdn
,
(
char
**
)
&
rs
->
sr_t
ext
,
if
(
ldap_bv2rdn
(
&
op
->
o_req_dn
,
&
rdn
,
&
n
ext
,
LDAP_DN_FORMAT_LDAP
)
)
{
rs
->
sr_err
=
LDAP_INVALID_DN_SYNTAX
;
...
...
@@ -108,8 +105,7 @@ passwd_back_search(
goto
done
;
}
vals
[
0
]
=
rdn
[
0
]
->
la_value
;
attr_mergeit
(
e
,
desc
,
vals
);
attr_mergeit_one
(
e
,
desc
,
&
rdn
[
0
]
->
la_value
);
ldap_rdnfree
(
rdn
);
rdn
=
NULL
;
...
...
@@ -121,9 +117,8 @@ passwd_back_search(
*
* should be a configuratable item
*/
vals
[
0
].
bv_val
=
"organizationalUnit"
;
vals
[
0
].
bv_len
=
sizeof
(
"organizationalUnit"
)
-
1
;
attr_mergeit
(
e
,
ad_objectClass
,
vals
);
BER_BVSTR
(
&
val
,
"organizationalUnit"
);
attr_mergeit_one
(
e
,
ad_objectClass
,
&
val
);
if
(
test_filter
(
op
,
e
,
op
->
ors_filter
)
==
LDAP_COMPARE_TRUE
)
{
rs
->
sr_entry
=
e
;
...
...
@@ -156,7 +151,7 @@ passwd_back_search(
return
(
0
);
}
if
(
!
(
e
=
pw2entry
(
op
->
o_bd
,
pw
,
&
rs
->
sr_text
))
)
{
if
(
!
(
e
=
pw2entry
(
op
->
o_bd
,
pw
)
)
)
{
rs
->
sr_err
=
LDAP_OTHER
;
endpwent
();
ldap_pvt_thread_mutex_unlock
(
&
passwd_mutex
);
...
...
@@ -185,6 +180,7 @@ passwd_back_search(
}
}
else
{
char
*
next
;
if
(
!
be_issuffix
(
op
->
o_bd
,
&
op
->
o_req_ndn
)
)
{
dnParent
(
&
op
->
o_req_ndn
,
&
parent
);
}
...
...
@@ -208,7 +204,7 @@ passwd_back_search(
goto
done
;
}
if
(
ldap_bv2rdn
(
&
op
->
o_req_dn
,
&
rdn
,
(
char
**
)
&
rs
->
sr_t
ext
,
if
(
ldap_bv2rdn
(
&
op
->
o_req_dn
,
&
rdn
,
&
n
ext
,
LDAP_DN_FORMAT_LDAP
))
{
rs
->
sr_err
=
LDAP_OTHER
;
...
...
@@ -224,7 +220,7 @@ passwd_back_search(
goto
done
;
}
e
=
pw2entry
(
op
->
o_bd
,
pw
,
&
rs
->
sr_text
);
e
=
pw2entry
(
op
->
o_bd
,
pw
);
ldap_pvt_thread_mutex_unlock
(
&
passwd_mutex
);
if
(
!
e
)
{
rs
->
sr_err
=
LDAP_OTHER
;
...
...
@@ -265,29 +261,14 @@ pw_start(
}
static
Entry
*
pw2entry
(
Backend
*
be
,
struct
passwd
*
pw
,
const
char
**
text
)
pw2entry
(
Backend
*
be
,
struct
passwd
*
pw
)
{
size_t
pwlen
;
size_t
pwlen
;
Entry
*
e
;
struct
berval
val
s
[
2
]
;
struct
berval
val
;
struct
berval
bv
;
int
rc
;
AttributeDescription
*
ad_objectClass
=
slap_schema
.
si_ad_objectClass
;
AttributeDescription
*
ad_cn
=
NULL
;
AttributeDescription
*
ad_sn
=
NULL
;
AttributeDescription
*
ad_uid
=
NULL
;
AttributeDescription
*
ad_description
=
NULL
;
rc
=
slap_str2ad
(
"cn"
,
&
ad_cn
,
text
);
if
(
rc
!=
LDAP_SUCCESS
)
return
NULL
;
rc
=
slap_str2ad
(
"sn"
,
&
ad_sn
,
text
);
if
(
rc
!=
LDAP_SUCCESS
)
return
NULL
;
rc
=
slap_str2ad
(
"uid"
,
&
ad_uid
,
text
);
if
(
rc
!=
LDAP_SUCCESS
)
return
NULL
;
rc
=
slap_str2ad
(
"description"
,
&
ad_description
,
text
);
if
(
rc
!=
LDAP_SUCCESS
)
return
NULL
;
int
rc
;
/*
* from pw we get pw_name and make it cn
...
...
@@ -295,45 +276,43 @@ pw2entry( Backend *be, struct passwd *pw, const char **text )
*/
pwlen
=
strlen
(
pw
->
pw_name
);
val
s
[
0
]
.
bv_len
=
(
sizeof
(
"uid=,"
)
-
1
)
+
(
pwlen
+
be
->
be_suffix
[
0
].
bv_len
);
val
s
[
0
]
.
bv_val
=
ch_malloc
(
val
s
[
0
]
.
bv_len
+
1
);
val
.
bv_len
=
STRLENOF
(
"uid=,"
)
+
(
pwlen
+
be
->
be_suffix
[
0
].
bv_len
);
val
.
bv_val
=
ch_malloc
(
val
.
bv_len
+
1
);
/* rdn attribute type should be a configuratable item */
sprintf
(
val
s
[
0
]
.
bv_val
,
"uid=%s,%s"
,
sprintf
(
val
.
bv_val
,
"uid=%s,%s"
,
pw
->
pw_name
,
be
->
be_suffix
[
0
].
bv_val
);
rc
=
dnNormalize
(
0
,
NULL
,
NULL
,
val
s
,
&
bv
,
NULL
);
rc
=
dnNormalize
(
0
,
NULL
,
NULL
,
&
val
,
&
bv
,
NULL
);
if
(
rc
!=
LDAP_SUCCESS
)
{
free
(
val
s
[
0
]
.
bv_val
);
free
(
val
.
bv_val
);
return
NULL
;
}
e
=
(
Entry
*
)
ch_calloc
(
1
,
sizeof
(
Entry
)
);
e
->
e_name
=
val
s
[
0
]
;
e
->
e_name
=
val
;
e
->
e_nname
=
bv
;
e
->
e_attrs
=
NULL
;
vals
[
1
].
bv_val
=
NULL
;
/* objectclasses should be configurable items */
vals
[
0
].
bv_val
=
"top"
;
vals
[
0
].
bv_len
=
sizeof
(
"top"
)
-
1
;
attr_mergeit
(
e
,
ad_objectClass
,
vals
);
#if 0
/* "top" is redundant */
BER_BVSTR( &val, "top" );
attr_mergeit_one( e, ad_objectClass, &val );
#endif
vals
[
0
].
bv_val
=
"person"
;
vals
[
0
].
bv_len
=
sizeof
(
"person"
)
-
1
;
attr_mergeit
(
e
,
ad_objectClass
,
vals
);
BER_BVSTR
(
&
val
,
"person"
);
attr_mergeit_one
(
e
,
slap_schema
.
si_ad_objectClass
,
&
val
);
vals
[
0
].
bv_val
=
"uidObject"
;
vals
[
0
].
bv_len
=
sizeof
(
"uidObject"
)
-
1
;
attr_mergeit
(
e
,
ad_objectClass
,
vals
);
BER_BVSTR
(
&
val
,
"uidObject"
);
attr_mergeit_one
(
e
,
slap_schema
.
si_ad_objectClass
,
&
val
);
val
s
[
0
]
.
bv_val
=
pw
->
pw_name
;
val
s
[
0
]
.
bv_len
=
pwlen
;
attr_mergeit
(
e
,
ad_uid
,
val
s
);
/* required by uidObject */
attr_mergeit
(
e
,
ad_cn
,
val
s
);
/* required by person */
attr_mergeit
(
e
,
ad_sn
,
val
s
);
/* required by person */
val
.
bv_val
=
pw
->
pw_name
;
val
.
bv_len
=
pwlen
;
attr_mergeit
_one
(
e
,
slap_schema
.
si_
ad_uid
,
&
val
);
/* required by uidObject */
attr_mergeit
_one
(
e
,
slap_schema
.
si_
ad_cn
,
&
val
);
/* required by person */
attr_mergeit
_one
(
e
,
ad_sn
,
&
val
);
/* required by person */
#ifdef HAVE_PW_GECOS
/*
...
...
@@ -344,37 +323,35 @@ pw2entry( Backend *be, struct passwd *pw, const char **text )
if
(
pw
->
pw_gecos
[
0
])
{
char
*
s
;
vals
[
0
].
bv_val
=
pw
->
pw_gecos
;
vals
[
0
].
bv_len
=
strlen
(
vals
[
0
].
bv_val
);
attr_mergeit
(
e
,
ad_description
,
vals
);
ber_str2bv
(
pw
->
pw_gecos
,
0
,
0
,
&
val
);
attr_mergeit_one
(
e
,
ad_desc
,
&
val
);
s
=
strchr
(
val
s
[
0
]
.
bv_val
,
','
);
if
(
s
)
*
s
=
'\0'
;
s
=
strchr
(
val
.
bv_val
,
','
);
if
(
s
)
*
s
=
'\0'
;
s
=
strchr
(
val
s
[
0
]
.
bv_val
,
'&'
);
if
(
s
)
{
s
=
strchr
(
val
.
bv_val
,
'&'
);
if
(
s
)
{
char
buf
[
1024
];
if
(
val
s
[
0
]
.
bv_len
+
pwlen
<
sizeof
(
buf
)
)
{
int
i
=
s
-
val
s
[
0
]
.
bv_val
;
strncpy
(
buf
,
val
s
[
0
]
.
bv_val
,
i
);
s
=
buf
+
i
;
strcpy
(
s
,
pw
->
pw_name
);
if
(
val
.
bv_len
+
pwlen
<
sizeof
(
buf
)
)
{
int
i
=
s
-
val
.
bv_val
;
strncpy
(
buf
,
val
.
bv_val
,
i
);
s
=
buf
+
i
;
strcpy
(
s
,
pw
->
pw_name
);
*
s
=
TOUPPER
((
unsigned
char
)
*
s
);
strcat
(
s
,
val
s
[
0
]
.
bv_val
+
i
+
1
);
val
s
[
0
]
.
bv_val
=
buf
;
strcat
(
s
,
val
.
bv_val
+
i
+
1
);
val
.
bv_val
=
buf
;
}
}
val
s
[
0
]
.
bv_len
=
strlen
(
val
s
[
0
]
.
bv_val
);
val
.
bv_len
=
strlen
(
val
.
bv_val
);
if
(
val
s
[
0
]
.
bv_len
&&
strcasecmp
(
val
s
[
0
]
.
bv_val
,
pw
->
pw_name
))
{
attr_mergeit
(
e
,
ad_cn
,
val
s
);
if
(
val
.
bv_len
&&
strcasecmp
(
val
.
bv_val
,
pw
->
pw_name
)
)
{
attr_mergeit
_one
(
e
,
slap_schema
.
si_
ad_cn
,
&
val
);
}
if
(
(
s
=
strrchr
(
vals
[
0
].
bv_val
,
' '
)))
{
vals
[
0
].
bv_val
=
s
+
1
;
vals
[
0
].
bv_len
=
strlen
(
vals
[
0
].
bv_val
);
attr_mergeit
(
e
,
ad_sn
,
vals
);
if
(
(
s
=
strrchr
(
val
.
bv_val
,
' '
)
)
)
{
ber_str2bv
(
s
+
1
,
0
,
0
,
&
val
);
attr_mergeit_one
(
e
,
ad_sn
,
&
val
);
}
}
#endif
...
...
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