This service will be undergoing maintenance at 00:00 UTC, 2016-09-28. It is expected to last about 1 hours
Bug 231093 - db2bak: crash bug
db2bak: crash bug
Status: CLOSED CURRENTRELEASE
Product: 389
Classification: Community
Component: Database - General (Show other bugs)
1.0.4
All Linux
high Severity high
: ---
: ---
Assigned To: Noriko Hosoi
Viktor Ashirov
:
Depends On:
Blocks: 152373 240316 FDS1.1.0
  Show dependency treegraph
 
Reported: 2007-03-05 21:25 EST by Noriko Hosoi
Modified: 2015-12-07 11:37 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-12-07 11:37:43 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
cvs diff dblayer.c (12.18 KB, patch)
2007-03-05 21:45 EST, Noriko Hosoi
no flags Details | Diff
cvs diffs (10.05 KB, patch)
2007-12-03 18:21 EST, Noriko Hosoi
no flags Details | Diff
test cases and results (2.56 KB, text/plain)
2007-12-03 18:48 EST, Noriko Hosoi
no flags Details
revised ldbm_config.c (6.48 KB, patch)
2007-12-03 19:49 EST, Noriko Hosoi
no flags Details | Diff
cvs commit message (1.64 KB, text/plain)
2007-12-03 19:51 EST, Noriko Hosoi
no flags Details

  None (edit)
Description Noriko Hosoi 2007-03-05 21:25:09 EST
Description of problem:
Occurred in the falied test cases.  Caused by the initial configuration error:
    errors:[...] - Db home directory is not set. Possibly nsslapd-directory
(optinally nsslapd-db-home-directory) is missing in the config file.

Still, the server should not crash.

[stacktrace]
#0  0xb6edd2c7 in dblayer_get_full_inst_dir (li=0x8127350, inst=0x8187f00,
    buf=0xbfffc480 "", buflen=4096)
    at ldap/servers/slapd/back-ldbm/dblayer.c:1209
#1  0xb6ee4d42 in dblayer_in_import (inst=0x8187f00)
    at ldap/servers/slapd/back-ldbm/dblayer.c:5623
#2  0xb6ed8bd0 in ldbm_back_ldbm2archive (pb=0xbfffd570)
    at ldap/servers/slapd/back-ldbm/archive.c:353
#3  0x0805d59e in slapd_exemode_db2archive () at ldap/servers/slapd/main.c:2457
#4  0x0805e5e7 in main (argc=6, argv=0xbfffdca4)
    at ldap/servers/slapd/main.c:947
Comment 1 Noriko Hosoi 2007-03-05 21:45:16 EST
Created attachment 149315 [details]
cvs diff dblayer.c

File: ldap/servers/slapd/back-ldbm/dblayer.c

Problem description: 
The server instance home directory in the dblayer private structure
(li->li_dblayer_private) is empty.  Either of these fields is supposed to be
set:
  dblayer_home_directory = 0x0
  dblayer_dbhome_directory = 0x8125ba0 ""

Fix descrption: if the fields are not set, issues an error message and returns.
Comment 2 Rich Megginson 2007-03-06 10:56:03 EST
In this code:
https://bugzilla.redhat.com/bugzilla/attachment.cgi?id=149315&action=diff#dblayer.c_sec3

Do you need to initialize inst->inst_parent_dir_name, or is it already
initialized to NULL?

In this code:
https://bugzilla.redhat.com/bugzilla/attachment.cgi?id=149315&action=diff#dblayer.c_sec5

Do you need to initialize priv->dblayer_home_directory to NULL?

In this code:
https://bugzilla.redhat.com/bugzilla/attachment.cgi?id=149315&action=diff#dblayer.c_sec6

Do you need to initialize envdir to NULL?

In this code:
https://bugzilla.redhat.com/bugzilla/attachment.cgi?id=149315&action=diff#dblayer.c_sec12

Do you need to initialize dirhandle to NULL?
Comment 3 Noriko Hosoi 2007-03-06 13:23:17 EST
Thanks for the comments, Rich.

(In reply to comment #2)
> In this code:
>
https://bugzilla.redhat.com/bugzilla/attachment.cgi?id=149315&action=diff#dblayer.c_sec3
>
> Do you need to initialize inst->inst_parent_dir_name, or is it already
> initialized to NULL?

The structure ldbm_instance (inst) is allocated in ldbm_instance_create, where
the field is initialized to NULL.

> In this code:
>
https://bugzilla.redhat.com/bugzilla/attachment.cgi?id=149315&action=diff#dblayer.c_sec5
>
> Do you need to initialize priv->dblayer_home_directory to NULL?

The structure "dblayer_private" is allocated in dblayer_init, where the field is
initialized to NULL.  And the attribute value of nsslapd-directory is set in
dblayer_start.

> In this code:
>
https://bugzilla.redhat.com/bugzilla/attachment.cgi?id=149315&action=diff#dblayer.c_sec6
>
> Do you need to initialize envdir to NULL?

I think it is.
   2269 int dblayer_release_aux_id2entry(backend *be, DB *pDB, DB_ENV *pEnv)
   2270 {
   2271     ldbm_instance *inst;
   2272     char *envdir = NULL;
    [...]
   2284     inst_dirp = dblayer_get_full_inst_dir(inst->inst_li, inst,
   2285                                           inst_dir, MAXPATHLEN);
   2286     if (inst_dirp && *inst_dirp)
   2287     {
   2288         envdir = slapi_ch_smprintf("%s/dbenv", inst_dirp);
   2289     }

> In this code:
>
https://bugzilla.redhat.com/bugzilla/attachment.cgi?id=149315&action=diff#dblayer.c_sec12
>
> Do you need to initialize dirhandle to NULL?

I think it is.
   4111 static int _dblayer_delete_instance_dir(ldbm_instance *inst, int startdb
       )
   4112 {
   4113     PRDir *dirhandle = NULL;
    [...]
   4146     inst_dirp = dblayer_get_full_inst_dir(li, inst, inst_dir, MAXPATHLEN
       );
   4147     if (inst_dirp && *inst_dirp) {
   4148         dirhandle = PR_OpenDir(inst_dirp);
   4149     }
Comment 4 Noriko Hosoi 2007-03-15 17:37:01 EDT
Checked in with 232050: Change format of DBVERSION and guardian files
Checking in dblayer.c;
/cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/dblayer.c,v  <--  dblayer.c
new revision: 1.18; previous revision: 1.17
done
Comment 5 Noriko Hosoi 2007-11-28 20:16:17 EST
Steps to reproduce:
1. stop the server
2. edit dse.ldif to remove nsslapd-directory and nsslapd-db-home-directory.
3. run db2bak

Note: the server's owner should be non root (e.g., nobody)

If the command line fails with errors as follows instead of crashes, it's okay.
[...]
[...] - WARNING---no write permission to file /usr/sbin//vgexport
[...] - libdb: /usr/sbin/__db.001: Permission denied
[...] - Opening database environment (/usr/sbin/) failed. err=13: Permission denied
[...] - db2archive: Failed to init database
Comment 6 Chandrasekar Kannan 2007-11-29 17:16:43 EST
Tried the above steps. when I run db2bak, I get these messages.

[root@colossus slapd-colossus]# ./db2bak
Back up directory: /var/lib/dirsrv/slapd-colossus/bak/colossus-2007_11_29_14_03_58
[29/Nov/2007:14:03:58 -0800] - WARNING---no write permission to file
/usr/sbin//amreport
[29/Nov/2007:14:03:58 -0800] - WARNING---no write permission to file
/usr/sbin//tcpslice
[29/Nov/2007:14:03:59 -0800] - WARNING---no write permission to file
/usr/sbin//semodule
[29/Nov/2007:14:03:59 -0800] - WARNING---no write permission to file
/usr/sbin//named-checkconf
[29/Nov/2007:14:03:59 -0800] - WARNING---no write permission to file
/usr/sbin//genhomedircon
[29/Nov/2007:14:03:59 -0800] - WARNING---no write permission to file /usr/sbin//ripd
[29/Nov/2007:14:03:59 -0800] - WARNING---no write permission to file
/usr/sbin//lockdev
[29/Nov/2007:14:03:59 -0800] - WARNING---no write permission to file
/usr/sbin//postqueue
[29/Nov/2007:14:03:59 -0800] - WARNING---no write permission to file
/usr/sbin//foomatic-ppdload
[29/Nov/2007:14:03:59 -0800] - WARNING---no write permission to file
/usr/sbin//setup-ds-admin.pl

...
...

[29/Nov/2007:14:04:00 -0800] - libdb: /usr/sbin/__db.001: Permission denied
[29/Nov/2007:14:04:00 -0800] - Opening database environment (/usr/sbin/) failed.
err=13: Permission denied
[29/Nov/2007:14:04:00 -0800] - db2archive: Failed to init database

######################################################################
db2bak is attempting to write to each file in /usr/sbin/. that seems
wrong to me. 

if the variable nsslapd-directory is not set in dse.ldif, db2bak 
should print out a message saying, this variable is not set (OR)
dont have permission to write to value defined in nsslapd-directory
and quit.
Comment 7 Noriko Hosoi 2007-12-03 18:21:18 EST
Created attachment 276401 [details]
cvs diffs

Files:
 ldbm_config.h
 ldbm_instance_config.c
 ldbm_config.c
 dblayer.c
 start.c

Description:
Set the strong requirement: nsslapd-directory must have some value.
to guarantee it:
1) checking errors from ldbm_config_directory_set. If the check fails, don't
start the server.
2) if nsslapd-directory does not exist or the value is empty in dse.ldif,
issuing an error message and returning the error code.
3) since it was difficult to distinguish the nsslapd-directory empty value from
the initial default value, introduced CONFIG_FLAG_SKIP_DEFAULT_SETTING flag to
tell the backend config code to skip setting the default value.
Comment 8 Noriko Hosoi 2007-12-03 18:48:21 EST
Created attachment 276431 [details]
test cases and results
Comment 9 Rich Megginson 2007-12-03 19:01:07 EST
If there is a problem with the entry, does it print the DN of the entry?
Comment 10 Noriko Hosoi 2007-12-03 19:47:06 EST
Good idea!  I've added the backend config entry to the error message:
[..] - ERROR: db directory is not set; check nsslapd-directory in the db config:
cn=config,cn=ldbm database,cn=plugins,cn=config
Comment 11 Noriko Hosoi 2007-12-03 19:49:23 EST
Created attachment 276451 [details]
revised ldbm_config.c

This diff includes the suggestion from Rich and PL_strcmp fix.
Comment 12 Noriko Hosoi 2007-12-03 19:51:31 EST
Created attachment 276461 [details]
cvs commit message

Thank you to Rich for the reviews and comments.

Checked in into CVS HEAD.

Note You need to log in before you can comment on or make changes to this bug.