summaryrefslogtreecommitdiffstats
path: root/ldap/servers/slapd/protect_db.c
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2007-08-17 02:12:37 +0000
committerNoriko Hosoi <nhosoi@redhat.com>2007-08-17 02:12:37 +0000
commit7afaf4974625c0d80d81cfbedbfe9635f21d5a57 (patch)
tree511777a52148580fd1f2100f4725cf7ced32dd53 /ldap/servers/slapd/protect_db.c
parent750fa2c4c2b3a570ffbbdb5b3e8aabf95a28c597 (diff)
downloadds-7afaf4974625c0d80d81cfbedbfe9635f21d5a57.tar.gz
ds-7afaf4974625c0d80d81cfbedbfe9635f21d5a57.tar.xz
ds-7afaf4974625c0d80d81cfbedbfe9635f21d5a57.zip
Resolves: #253069
Summary: cyclic dependency from getpwnam() in log rotation code Description: Moved getpwnam call to the startup time, store the info in slapdFrontendConfig to reuse.
Diffstat (limited to 'ldap/servers/slapd/protect_db.c')
-rw-r--r--ldap/servers/slapd/protect_db.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/ldap/servers/slapd/protect_db.c b/ldap/servers/slapd/protect_db.c
index e234450a..ccef1bb3 100644
--- a/ldap/servers/slapd/protect_db.c
+++ b/ldap/servers/slapd/protect_db.c
@@ -201,17 +201,16 @@ make_sure_dir_exists(char *dir)
}
/* Make sure it's owned by the correct user */
- if (slapdFrontendConfig->localuser != NULL) {
- if ( (pw = getpwnam(slapdFrontendConfig->localuser)) == NULL ) {
- LDAPDebug(LDAP_DEBUG_ANY, GETPWNAM_WARNING, slapdFrontendConfig->localuser, errno, strerror(errno));
- } else {
+ if (slapdFrontendConfig->localuser != NULL &&
+ slapdFrontendConfig->localuserinfo != NULL) {
+ pw = slapdFrontendConfig->localuserinfo;
if (chown(dir, pw->pw_uid, -1) == -1) {
stat(dir, &stat_buffer);
if (stat_buffer.st_uid != pw->pw_uid) {
LDAPDebug(LDAP_DEBUG_ANY, CHOWN_WARNING, dir, 0, 0);
+ return 1;
}
}
- } /* else */
}
return 0;
@@ -233,24 +232,23 @@ add_this_process_to(char *dir_name)
file_name[sizeof(file_name)-1] = (char)0;
if ((prfd = PR_Open(file_name, PR_RDWR | PR_CREATE_FILE, 0666)) == NULL) {
- LDAPDebug(LDAP_DEBUG_ANY, FILE_CREATE_WARNING, file_name, 0, 0);
- return;
+ LDAPDebug(LDAP_DEBUG_ANY, FILE_CREATE_WARNING, file_name, 0, 0);
+ return;
}
/* Make sure the owner is of the file is the user the server
* runs as. */
- if (slapdFrontendConfig->localuser != NULL) {
- if ( (pw = getpwnam(slapdFrontendConfig->localuser)) == NULL ) {
- LDAPDebug(LDAP_DEBUG_ANY, GETPWNAM_WARNING, slapdFrontendConfig->localuser, errno, strerror(errno));
- } else {
+ if (slapdFrontendConfig->localuser != NULL &&
+ slapdFrontendConfig->localuserinfo != NULL) {
+ pw = slapdFrontendConfig->localuserinfo;
if (chown(file_name, pw->pw_uid, -1) == -1) {
stat(file_name, &stat_buffer);
if (stat_buffer.st_uid != pw->pw_uid) {
LDAPDebug(LDAP_DEBUG_ANY, CHOWN_WARNING, file_name, 0, 0);
}
}
- } /* else */
}
+bail:
PR_Close(prfd);
}