Bug 207427 - parameterizing the hardcoded paths (phase 1. config, schema, ldif dir)
parameterizing the hardcoded paths (phase 1. config, schema, ldif dir)
Status: CLOSED CURRENTRELEASE
Product: 389
Classification: Community
Component: Directory Server (Show other bugs)
1.0.2
All All
medium Severity medium
: ---
: ---
Assigned To: Noriko Hosoi
Viktor Ashirov
:
Depends On:
Blocks: 152373 240316
  Show dependency treegraph
 
Reported: 2006-09-20 21:04 EDT by Noriko Hosoi
Modified: 2015-12-07 11:31 EST (History)
2 users (show)

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


Attachments (Terms of Use)
cvs diffs (96.74 KB, text/plain)
2006-09-20 21:09 EDT, Noriko Hosoi
no flags Details
revised cvs diffs (94.79 KB, patch)
2006-09-21 14:52 EDT, Noriko Hosoi
no flags Details | Diff
cvs diffs (revised) (107.07 KB, patch)
2006-09-26 21:30 EDT, Noriko Hosoi
no flags Details | Diff
cvs diffs (ldapserver -- revised) (107.21 KB, patch)
2006-09-27 19:31 EDT, Noriko Hosoi
no flags Details | Diff
cvs commit message (ldapserver) (4.49 KB, text/plain)
2006-09-27 19:46 EDT, Noriko Hosoi
no flags Details

  None (edit)
Description Noriko Hosoi 2006-09-20 21:04:04 EDT
Description of problem:
to prepare for FHS packaging.
Comment 1 Noriko Hosoi 2006-09-20 21:09:46 EDT
Created attachment 136799 [details]
cvs diffs
Comment 2 Noriko Hosoi 2006-09-20 21:23:53 EDT
Files:
 ldap/admin/include/dsalib.h  ldap/admin/lib/dsalib_conf.c
 ldap/admin/lib/dsalib_location.c
 ldap/admin/lib/dsalib_updown.c
 ldap/admin/src/cfg_sspt.c
 ldap/admin/src/create_instance.c
 ldap/admin/src/create_instance.h
 ldap/admin/src/ds_newinst.c
 ldap/admin/src/ds_newinst.pl
 ldap/admin/src/makemccvlvindexes
 ldap/servers/slapd/auth.c
 ldap/servers/slapd/config.c

 ldap/servers/slapd/dse.c
 ldap/servers/slapd/fedse.c
 ldap/servers/slapd/libglobs.c
 ldap/servers/slapd/main.c
 ldap/servers/slapd/proto-slap.h
 ldap/servers/slapd/schema.c
 ldap/servers/slapd/slap.h
 ldap/servers/slapd/test-plugins/testbind.c
 ldap/servers/slapd/tools/pwenc.c

Changes:
0. this is just the first phase... :)
1. changed the option "-D <instancedir>" for ns-slapd to "-D <configdir>"
2. introduced FHS fields to the admin config structure and modified
create_instance using them.  (the job is not completed yet since the location
should be synchronized with the server side.  Such codes are found with the
comment "/* will go away */") 
+ * FHS description
+ * cf->prefix: %{_prefix}
+ * cf->sroot: %{_libdir}/BRAND_DS
+ * cf->localstatedir: %{_localstatedir}
+ * cf->sysconfdir: %{_sysconfdir}
+ * cf->bindir: %{_bindir}
+ * cf->datadir: %{_datadir}
+ * cf->docdir: %{_docdir}
+ * cf->inst_dir: <sroot>/slapd-<servid>
+ * cf->config_dir: <localstatedir>/lib/slapd-<servid>
+ * cf->schema_dir: <localstatedir>/lib/slapd-<servid>/schema
+ * cf->lock_dir: <localstatedir>/lock/slapd-<servid>
+ * cf->log_dir: <localstatedir>/log/slapd-<servid>
+ * cf->run_dir: <localstatedir>/run/slapd-<servid>
3. introduced "prefix".  this is the code in ds_newinst.pl.
+if ($table{General}->{prefix}) {
+        $cgiargs{prefix} = $table{General}->{prefix};
+}
And having this line in [General] section of the install info file
prefix=  /export/servers/ds72_core
the above FHS directories starts from the prefix directory.
4. I also cleaned up some dead looking codes especially in create_instance.c.

Installation:
$ cd <serverroot>
$ tar -xzvf <path_to_slapd.tar.gz>
$ perl ./bin/slapd/admin/bin/ds_newinst.pl <path_to_your_install_inf_file>
Success!  Your new directory server instance was created
Comment 3 Rich Megginson 2006-09-21 13:41:32 EDT
Probably a copy/paste error on access and audit logs:
+#if 0
+    fprintf(f, "nsslapd-errorlog: %s/access\n", cf->log_dir);
+#else /* will go away */
and
+#if 0
+    fprintf(f, "nsslapd-errorlog: %s/audit\n", cf->log_dir);
+#else /* will go away */

Do we really want to get rid of the chown code during instance creation?

We still need that code that reads from ssusers.conf.  It is not used when doing
instance creation with ds_newinst, but it is used with ds_create.  So it's ok to
remove it, we just need to use it elsewhere.

Is it important to have instancedir still?  What uses it?

Comment 4 Noriko Hosoi 2006-09-21 14:25:33 EDT
Thanks, Rich, for finding them out!  I replaced nsslapd-errorlog with the
correct directives...

#if 0
    fprintf(f, "nsslapd-accesslog: %s/access\n", cf->log_dir);
#else /* will go away */

#if 0
    fprintf(f, "nsslapd-auditlog: %s/audit\n", cf->log_dir);
#else /* will go away */

> Do we really want to get rid of the chown code during instance creation?
Could you tell me which code you are mentioning here?  Actually, I moved chown
dir code into create_instance_mkdir_p to apply recursively.  In my test, I
installed the DS as root with the server user "nhosoi".  I had to change not
just the bottom dir of the path, but in the middle as well, if the created
directory is not one level.

> We still need that code that reads from ssusers.conf.
I resurrected getSuiteSpotUserGroup and the calling points in create_server and
update_server.

> Is it important to have instancedir still?  What uses it?
Actually, unknown... :)  I was just thinking someone who opens the config file
and wants to find out where the instance is really located.  Maybe, no use. :)

Thanks!  (I'm attaching the revised diff...)
Comment 5 Noriko Hosoi 2006-09-21 14:52:48 EDT
Created attachment 136899 [details]
revised cvs diffs
Comment 6 Noriko Hosoi 2006-09-26 21:30:38 EDT
Created attachment 137191 [details]
cvs diffs (revised)

Files:
 ldap/admin/include/dsalib.h
 ldap/admin/lib/dsalib_conf.c
 ldap/admin/lib/dsalib_location.c
 ldap/admin/lib/dsalib_updown.c
 ldap/admin/src/cfg_sspt.c
 ldap/admin/src/create_instance.c
 ldap/admin/src/create_instance.h
 ldap/admin/src/ds_newinst.c
 ldap/admin/src/ds_newinst.pl
 ldap/admin/src/makemccvlvindexes
 ldap/cm/Makefile
 ldap/servers/slapd/auth.c
 ldap/servers/slapd/config.c
 ldap/servers/slapd/dse.c
 ldap/servers/slapd/fedse.c
 ldap/servers/slapd/libglobs.c
 ldap/servers/slapd/main.c
 ldap/servers/slapd/proto-slap.h
 ldap/servers/slapd/schema.c
 ldap/servers/slapd/slap.h
 ldap/servers/slapd/test-plugins/testbind.c
 ldap/servers/slapd/tools/pwenc.c

Changes:
In addition to Comment#1 and #5, fixed bugs found in the acceptance tests.
Now, it passes 89% (about the same as the nightly test)
Comment 8 Rich Megginson 2006-09-26 23:44:09 EDT
The setenv() function is not supported on solaris.  Use putenv() instead for
maximal portability.

It seems as though CROOT is set in many places.  Is there a place we can just
set it once?

Otherwise, looks good.
Comment 10 Rich Megginson 2006-09-27 10:21:49 EDT
I don't think that putenv will work either.  I believe putenv requires either
static (e.g. a static array) or global (a global variable or malloc) memory. 
That is, it requires the storage to persist after the call, and a stack variable
won't work.
Comment 11 Noriko Hosoi 2006-09-27 13:01:59 EDT
(In reply to comment #10)
> I don't think that putenv will work either.  I believe putenv requires either
> static (e.g. a static array) or global (a global variable or malloc) memory. 
> That is, it requires the storage to persist after the call, and a stack variable
> won't work.

Oops...  I've added "static"...  Thanks!

DS_EXPORT_SYMBOL void
ds_set_config_dir(char *config_dir)
{
    static char env[PATH_MAX];
    PR_snprintf(env, sizeof(env), "DS_CONFIG_DIR=%s", config_dir);
    putenv(env);
}

Comment 12 Rich Megginson 2006-09-27 13:04:35 EDT
Ok.
Comment 13 Nathan Kinder 2006-09-27 14:38:47 EDT
You should be declaring the ds_get_run_dir() function in dsalib.h.  Other than
that, the diffs in comment#6 look good.
Comment 15 Noriko Hosoi 2006-09-27 19:31:55 EDT
Created attachment 137266 [details]
cvs diffs (ldapserver -- revised)

Final diffs including the fixes Rich and Nathan suggested.  (Thanks!)
Comment 17 Noriko Hosoi 2006-09-27 19:46:01 EDT
Created attachment 137272 [details]
cvs commit message (ldapserver)

Thank you, reviewers!  Checked in into HEAD.

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