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
Dragoș Haiduc
OpenLDAP
Commits
41a97179
Commit
41a97179
authored
22 years ago
by
Kurt Zeilenga
Browse files
Options
Downloads
Patches
Plain Diff
fix time attrs
parent
408fd25e
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
servers/slapd/back-monitor/time.c
+85
-94
85 additions, 94 deletions
servers/slapd/back-monitor/time.c
with
85 additions
and
94 deletions
servers/slapd/back-monitor/time.c
+
85
−
94
View file @
41a97179
...
...
@@ -55,12 +55,9 @@ monitor_subsys_time_init(
Entry
*
e
,
*
e_tmp
,
*
e_time
;
struct
monitorentrypriv
*
mp
;
char
buf
[
1024
],
ztmbuf
[
20
];
struct
tm
*
ztm
;
#ifdef HACK_LOCAL_TIME
struct
tm
*
ltm
;
char
ltmbuf
[
20
];
#endif
char
buf
[
1024
];
struct
tm
*
tms
;
char
tmbuf
[
20
];
/*
* Note: ltmbuf, ltm are used only if HACK_LOCAL_TIME is defined
...
...
@@ -73,10 +70,10 @@ monitor_subsys_time_init(
if
(
monitor_cache_get
(
mi
,
&
monitor_subsys
[
SLAPD_MONITOR_TIME
].
mss_ndn
,
&
e_time
)
)
{
#ifdef NEW_LOGGING
LDAP_LOG
(
(
"operation"
,
LDAP_LEVEL_
CRIT
,
LDAP_LOG
(
OPERATION
,
CRIT
,
"monitor_subsys_time_init: "
"unable to get entry '%s'
\n
"
,
monitor_subsys
[
SLAPD_MONITOR_TIME
].
mss_ndn
.
bv_val
)
);
monitor_subsys
[
SLAPD_MONITOR_TIME
].
mss_ndn
.
bv_val
,
0
,
0
);
#else
Debug
(
LDAP_DEBUG_ANY
,
"monitor_subsys_time_init: "
...
...
@@ -93,35 +90,29 @@ monitor_subsys_time_init(
* Start
*/
ldap_pvt_thread_mutex_lock
(
&
gmtime_mutex
);
ztm
=
gmtime
(
&
starttime
);
strftime
(
ztmbuf
,
sizeof
(
ztmbuf
),
"%Y%m%d%H%M%SZ"
,
ztm
);
#ifdef HACK_LOCAL_TIME
ltm
=
localtime
(
&
starttime
);
local_time
(
ltm
,
-
timezone
,
ltmbuf
,
sizeof
(
ltmbuf
)
);
#endif
/* HACK_LOCAL_TIME */
tms
=
localtime
(
&
starttime
);
local_time
(
tms
,
-
timezone
,
tmbuf
,
sizeof
(
tmbuf
)
);
#else
/* !HACK_LOCAL_TIME */
tms
=
gmtime
(
&
starttime
);
lutil_gentime
(
tmbuf
,
sizeof
(
tmbuf
),
tms
);
#endif
/* !HACK_LOCAL_TIME */
ldap_pvt_thread_mutex_unlock
(
&
gmtime_mutex
);
snprintf
(
buf
,
sizeof
(
buf
),
"dn: cn=Start,%s
\n
"
SLAPD_MONITOR_OBJECTCLASSES
"cn: Start
\n
"
"description: %s
\n
"
#ifdef HACK_LOCAL_TIME
"description;lang-x-local: %s"
#endif
/* HACK_LOCAL_TIME */
,
monitor_subsys
[
SLAPD_MONITOR_TIME
].
mss_dn
.
bv_val
,
ztmbuf
#ifdef HACK_LOCAL_TIME
,
ltmbuf
#endif
/* HACK_LOCAL_TIME */
);
"createTimestamp: %s"
,
monitor_subsys
[
SLAPD_MONITOR_TIME
].
mss_dn
.
bv_val
,
tmbuf
);
e
=
str2entry
(
buf
);
if
(
e
==
NULL
)
{
#ifdef NEW_LOGGING
LDAP_LOG
(
(
"operation"
,
LDAP_LEVEL_
CRIT
,
LDAP_LOG
(
OPERATION
,
CRIT
,
"monitor_subsys_time_init: "
"unable to create entry 'cn=Start,%s'
\n
"
,
monitor_subsys
[
SLAPD_MONITOR_TIME
].
mss_ndn
.
bv_val
)
);
monitor_subsys
[
SLAPD_MONITOR_TIME
].
mss_ndn
.
bv_val
,
0
,
0
);
#else
Debug
(
LDAP_DEBUG_ANY
,
"monitor_subsys_time_init: "
...
...
@@ -142,10 +133,10 @@ monitor_subsys_time_init(
if
(
monitor_cache_add
(
mi
,
e
)
)
{
#ifdef NEW_LOGGING
LDAP_LOG
(
(
"operation"
,
LDAP_LEVEL_
CRIT
,
LDAP_LOG
(
OPERATION
,
CRIT
,
"monitor_subsys_time_init: "
"unable to add entry 'cn=Start,%s'
\n
"
,
monitor_subsys
[
SLAPD_MONITOR_TIME
].
mss_ndn
.
bv_val
)
);
monitor_subsys
[
SLAPD_MONITOR_TIME
].
mss_ndn
.
bv_val
,
0
,
0
);
#else
Debug
(
LDAP_DEBUG_ANY
,
"monitor_subsys_time_init: "
...
...
@@ -165,24 +156,18 @@ monitor_subsys_time_init(
"dn: cn=Current,%s
\n
"
SLAPD_MONITOR_OBJECTCLASSES
"cn: Current
\n
"
"description: %s
\n
"
#ifdef HACK_LOCAL_TIME
"description;lang-x-local: %s"
#endif
/* HACK_LOCAL_TIME */
,
monitor_subsys
[
SLAPD_MONITOR_TIME
].
mss_dn
.
bv_val
,
ztmbuf
#ifdef HACK_LOCAL_TIME
,
ltmbuf
#endif
/* HACK_LOCAL_TIME */
);
"createTimestamp: %s
\n
"
"modifyTimestamp: %s"
,
monitor_subsys
[
SLAPD_MONITOR_TIME
].
mss_dn
.
bv_val
,
tmbuf
,
tmbuf
);
e
=
str2entry
(
buf
);
if
(
e
==
NULL
)
{
#ifdef NEW_LOGGING
LDAP_LOG
(
(
"operation"
,
LDAP_LEVEL_
CRIT
,
LDAP_LOG
(
OPERATION
,
CRIT
,
"monitor_subsys_time_init: "
"unable to create entry 'cn=Current,%s'
\n
"
,
monitor_subsys
[
SLAPD_MONITOR_TIME
].
mss_ndn
.
bv_val
)
);
monitor_subsys
[
SLAPD_MONITOR_TIME
].
mss_ndn
.
bv_val
,
0
,
0
);
#else
Debug
(
LDAP_DEBUG_ANY
,
"monitor_subsys_time_init: "
...
...
@@ -203,10 +188,10 @@ monitor_subsys_time_init(
if
(
monitor_cache_add
(
mi
,
e
)
)
{
#ifdef NEW_LOGGING
LDAP_LOG
(
(
"operation"
,
LDAP_LEVEL_
CRIT
,
LDAP_LOG
(
OPERATION
,
CRIT
,
"monitor_subsys_time_init: "
"unable to add entry 'cn=Current,%s'
\n
"
,
monitor_subsys
[
SLAPD_MONITOR_TIME
].
mss_ndn
.
bv_val
)
);
monitor_subsys
[
SLAPD_MONITOR_TIME
].
mss_ndn
.
bv_val
,
0
,
0
);
#else
Debug
(
LDAP_DEBUG_ANY
,
"monitor_subsys_time_init: "
...
...
@@ -233,77 +218,83 @@ monitor_subsys_time_update(
Entry
*
e
)
{
char
ztmbuf
[
20
];
struct
tm
*
ztm
;
#ifdef HACK_LOCAL_TIME
char
ltmbuf
[
20
];
struct
tm
*
#endif
/* HACK_LOCAL_TIME */
time_t
currenttime
;
char
stmbuf
[
20
],
ctmbuf
[
20
];
struct
tm
*
stm
,
*
ctm
;
Attribute
*
a
;
#ifdef HACK_LOCAL_TIME
static
AttributeDescription
*
ad_local
=
NULL
;
const
char
*
text
=
NULL
;
#endif
/* HACK_LOCAL_TIME */
ber_len_t
len
;
static
int
init_start
=
0
;
/*
* Note: ltmbuf, ltm, ad_local, text are used only if HACK_LOCAL_TIME
* is defined
*/
static
int
init_start
=
0
,
init_current
=
0
;
#define ENTRY_TIME 0
#define ENTRY_START 1
#define ENTRY_CURRENT 2
int
entry
=
ENTRY_TIME
;
assert
(
mi
);
assert
(
e
);
if
(
init_start
==
0
&&
strncmp
(
e
->
e_nname
.
bv_val
,
"cn=START"
,
sizeof
(
"cn=START"
)
-
1
)
==
0
)
{
currenttime
=
starttime
;
init_start
=
1
;
}
else
if
(
strncmp
(
e
->
e_nname
.
bv_val
,
"cn=CURRENT"
,
sizeof
(
"cn=CURRENT"
)
-
1
)
==
0
)
{
currenttime
=
slap_get_time
();
if
(
strncmp
(
e
->
e_nname
.
bv_val
,
"cn=start"
,
sizeof
(
"cn=start"
)
-
1
)
==
0
)
{
entry
=
ENTRY_START
;
if
(
init_start
==
1
)
{
return
(
0
);
}
}
else
{
return
(
0
);
}
else
if
(
strncmp
(
e
->
e_nname
.
bv_val
,
"cn=current"
,
sizeof
(
"cn=current"
)
-
1
)
==
0
)
{
entry
=
ENTRY_CURRENT
;
}
ldap_pvt_thread_mutex_lock
(
&
gmtime_mutex
);
ztm
=
gmtime
(
&
currenttime
);
strftime
(
ztmbuf
,
sizeof
(
ztmbuf
),
"%Y%m%d%H%M%SZ"
,
ztm
);
if
(
init_start
==
0
)
{
#ifdef HACK_LOCAL_TIME
ltm
=
localtime
(
&
currenttime
);
local_time
(
ltm
,
-
timezone
,
ltmbuf
,
sizeof
(
ltmbuf
)
);
#endif
/* HACK_LOCAL_TIME */
ldap_pvt_thread_mutex_unlock
(
&
gmtime_mutex
);
a
=
attr_find
(
e
->
e_attrs
,
monitor_ad_desc
);
if
(
a
==
NULL
)
{
return
(
-
1
);
stm
=
localtime
(
&
starttime
);
local_time
(
stm
,
-
timezone
,
stmbuf
,
sizeof
(
stmbuf
)
);
#else
/* !HACK_LOCAL_TIME */
stm
=
gmtime
(
&
starttime
);
lutil_gentime
(
stmbuf
,
sizeof
(
stmbuf
),
stm
);
#endif
/* !HACK_LOCAL_TIME */
}
len
=
strlen
(
ztmbuf
);
assert
(
len
==
a
->
a_vals
[
0
].
bv_len
);
AC_MEMCPY
(
a
->
a_vals
[
0
].
bv_val
,
ztmbuf
,
len
);
if
(
entry
==
ENTRY_CURRENT
)
{
time_t
currentTime
=
slap_get_time
();
#ifdef HACK_LOCAL_TIME
if
(
ad_local
==
NULL
)
{
if
(
slap_str2ad
(
"description;lang-x-local"
,
&
ad_local
,
&
text
)
!=
LDAP_SUCCESS
)
{
ctm
=
localtime
(
&
currentTime
);
local_time
(
ctm
,
-
timezone
,
ctmbuf
,
sizeof
(
ctmbuf
)
);
#else
/* !HACK_LOCAL_TIME */
ctm
=
gmtime
(
&
currentTime
);
lutil_gentime
(
ctmbuf
,
sizeof
(
ctmbuf
),
ctm
);
#endif
/* !HACK_LOCAL_TIME */
}
ldap_pvt_thread_mutex_unlock
(
&
gmtime_mutex
);
if
(
(
entry
==
ENTRY_START
&&
init_start
==
0
)
||
(
entry
==
ENTRY_CURRENT
&&
init_current
==
0
)
)
{
a
=
attr_find
(
e
->
e_attrs
,
slap_schema
.
si_ad_createTimestamp
);
if
(
a
==
NULL
)
{
return
(
-
1
);
}
}
a
=
attr_find
(
e
->
e_attrs
,
ad_local
);
if
(
a
==
NULL
)
{
return
(
-
1
);
len
=
strlen
(
stmbuf
);
assert
(
len
==
a
->
a_vals
[
0
].
bv_len
);
AC_MEMCPY
(
a
->
a_vals
[
0
].
bv_val
,
stmbuf
,
len
);
if
(
entry
==
ENTRY_START
)
{
init_start
=
1
;
}
else
if
(
entry
==
ENTRY_CURRENT
)
{
init_current
=
1
;
}
}
len
=
strlen
(
ltmbuf
);
assert
(
len
==
a
->
a_vals
[
0
].
bv_len
);
AC_MEMCPY
(
a
->
a_vals
[
0
].
bv_val
,
ltmbuf
,
len
);
#endif
/* HACK_LOCAL_TIME */
if
(
entry
==
ENTRY_CURRENT
)
{
a
=
attr_find
(
e
->
e_attrs
,
slap_schema
.
si_ad_modifyTimestamp
);
if
(
a
==
NULL
)
{
return
(
-
1
);
}
len
=
strlen
(
ctmbuf
);
assert
(
len
==
a
->
a_vals
[
0
].
bv_len
);
AC_MEMCPY
(
a
->
a_vals
[
0
].
bv_val
,
ctmbuf
,
len
);
}
return
(
0
);
}
...
...
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