config.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. /* config.c - configuration file handling routines */
  13. #include <stdio.h>
  14. #include <string.h>
  15. #include <sys/types.h>
  16. #include <errno.h>
  17. #include <stdlib.h>
  18. #include <sys/socket.h>
  19. #include <sys/param.h>
  20. #include <unistd.h>
  21. #include <pwd.h>
  22. #include "slap.h"
  23. #include "pw.h"
  24. #include <sys/stat.h>
  25. #include <prio.h>
  26. #define MAXARGS 1000
  27. extern int should_detach;
  28. extern Slapi_PBlock *repl_pb;
  29. extern char* slapd_SSL3ciphers;
  30. extern char *localuser;
  31. char* rel2abspath( char * );
  32. /*
  33. See if the given entry has an attribute with the given name and the
  34. given value; if value is NULL, just test for the presence of the given
  35. attribute; if value is an empty string (i.e. value[0] == 0),
  36. the first value in the attribute will be copied into the given buffer
  37. and returned
  38. */
  39. static int
  40. entry_has_attr_and_value(Slapi_Entry *e, const char *attrname,
  41. char *value, size_t valuebufsize )
  42. {
  43. int retval = 0;
  44. Slapi_Attr *attr = 0;
  45. if (!e || !attrname)
  46. return retval;
  47. /* see if the entry has the specified attribute name */
  48. if (!slapi_entry_attr_find(e, attrname, &attr) && attr)
  49. {
  50. /* if value is not null, see if the attribute has that
  51. value */
  52. if (!value)
  53. {
  54. retval = 1;
  55. }
  56. else
  57. {
  58. Slapi_Value *v = 0;
  59. int index = 0;
  60. for (index = slapi_attr_first_value(attr, &v);
  61. v && (index != -1);
  62. index = slapi_attr_next_value(attr, index, &v))
  63. {
  64. const char *s = slapi_value_get_string(v);
  65. if (!s)
  66. continue;
  67. if (!*value)
  68. {
  69. size_t len = strlen(s);
  70. if ( len < valuebufsize )
  71. {
  72. strcpy(value, s);
  73. retval = 1;
  74. }
  75. else
  76. {
  77. slapi_log_error( SLAPI_LOG_FATAL, "bootstrap config",
  78. "Ignoring extremely large value for"
  79. " configuration attribute %s"
  80. " (length=%ld, value=%40.40s...)\n",
  81. attrname, (long int)len, s );
  82. retval = 0; /* value is too large: ignore it */
  83. }
  84. break;
  85. }
  86. else if (!strcasecmp(s, value))
  87. {
  88. retval = 1;
  89. break;
  90. }
  91. }
  92. }
  93. }
  94. return retval;
  95. }
  96. /*
  97. Extract just the configuration information we need for bootstrapping
  98. purposes
  99. 1) set up error logging
  100. 2) disable syntax checking
  101. 3) load the syntax plugins
  102. etc.
  103. */
  104. int
  105. slapd_bootstrap_config(const char *configdir)
  106. {
  107. char configfile[MAXPATHLEN+1];
  108. PRFileInfo64 prfinfo;
  109. int rc = 0; /* Fail */
  110. int done = 0;
  111. PRInt32 nr = 0;
  112. PRFileDesc *prfd = 0;
  113. char returntext[SLAPI_DSE_RETURNTEXT_SIZE] = "";
  114. char *buf = 0;
  115. char *lastp = 0;
  116. char *entrystr = 0;
  117. char tmpfile[MAXPATHLEN+1];
  118. if (NULL == configdir) {
  119. slapi_log_error(SLAPI_LOG_FATAL,
  120. "startup", "Passed null config directory\n");
  121. return rc; /* Fail */
  122. }
  123. PR_snprintf(configfile, sizeof(configfile), "%s/%s", configdir,
  124. CONFIG_FILENAME);
  125. PR_snprintf(tmpfile, sizeof(tmpfile), "%s/%s.tmp", configdir,
  126. CONFIG_FILENAME);
  127. if ( (rc = dse_check_file(configfile, tmpfile)) == 0 ) {
  128. PR_snprintf(tmpfile, sizeof(tmpfile), "%s/%s.bak", configdir,
  129. CONFIG_FILENAME);
  130. rc = dse_check_file(configfile, tmpfile);
  131. }
  132. if ( (rc = PR_GetFileInfo64( configfile, &prfinfo )) != PR_SUCCESS )
  133. {
  134. PRErrorCode prerr = PR_GetError();
  135. slapi_log_error(SLAPI_LOG_FATAL, "config", "The given config file %s could not be accessed, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n",
  136. configfile, prerr, slapd_pr_strerror(prerr));
  137. return rc;
  138. }
  139. else if (( prfd = PR_Open( configfile, PR_RDONLY,
  140. SLAPD_DEFAULT_FILE_MODE )) == NULL )
  141. {
  142. PRErrorCode prerr = PR_GetError();
  143. slapi_log_error(SLAPI_LOG_FATAL, "config", "The given config file %s could not be opened for reading, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n",
  144. configfile, prerr, slapd_pr_strerror(prerr));
  145. return rc; /* Fail */
  146. }
  147. else
  148. {
  149. /* read the entire file into core */
  150. buf = slapi_ch_malloc( prfinfo.size + 1 );
  151. if (( nr = slapi_read_buffer( prfd, buf, prfinfo.size )) < 0 )
  152. {
  153. slapi_log_error(SLAPI_LOG_FATAL, "config", "Could only read %d of %ld bytes from config file %s\n",
  154. nr, (long int)prfinfo.size, configfile);
  155. rc = 0; /* Fail */
  156. done= 1;
  157. }
  158. (void)PR_Close(prfd);
  159. buf[ nr ] = '\0';
  160. if(!done)
  161. {
  162. char workpath[MAXPATHLEN+1];
  163. char loglevel[BUFSIZ];
  164. char maxdescriptors[BUFSIZ];
  165. char val[BUFSIZ];
  166. char _localuser[BUFSIZ];
  167. char logenabled[BUFSIZ];
  168. char schemacheck[BUFSIZ];
  169. char syntaxcheck[BUFSIZ];
  170. char syntaxlogging[BUFSIZ];
  171. char plugintracking[BUFSIZ];
  172. char dn_validate_strict[BUFSIZ];
  173. char moddn_aci[BUFSIZ];
  174. Slapi_DN plug_dn;
  175. workpath[0] = loglevel[0] = maxdescriptors[0] = '\0';
  176. val[0] = logenabled[0] = schemacheck[0] = syntaxcheck[0] = '\0';
  177. syntaxlogging[0] = _localuser[0] = '\0';
  178. plugintracking [0] = dn_validate_strict[0] = moddn_aci[0] ='\0';
  179. /* Convert LDIF to entry structures */
  180. slapi_sdn_init_ndn_byref(&plug_dn, PLUGIN_BASE_DN);
  181. while ((entrystr = dse_read_next_entry(buf, &lastp)) != NULL)
  182. {
  183. char errorbuf[BUFSIZ];
  184. /*
  185. * XXXmcs: it would be better to also pass
  186. * SLAPI_STR2ENTRY_REMOVEDUPVALS in the flags, but
  187. * duplicate value checking requires that the syntax
  188. * and schema subsystems be initialized... and they
  189. * are not yet.
  190. */
  191. Slapi_Entry *e = slapi_str2entry(entrystr,
  192. SLAPI_STR2ENTRY_NOT_WELL_FORMED_LDIF);
  193. if (e == NULL)
  194. {
  195. LDAPDebug(LDAP_DEBUG_ANY, "The entry [%s] in the configfile %s was empty or could not be parsed\n",
  196. entrystr, configfile, 0);
  197. continue;
  198. }
  199. /* increase file descriptors */
  200. if (!maxdescriptors[0] &&
  201. entry_has_attr_and_value(e, CONFIG_MAXDESCRIPTORS_ATTRIBUTE,
  202. maxdescriptors, sizeof(maxdescriptors)))
  203. {
  204. if (config_set_maxdescriptors(
  205. CONFIG_MAXDESCRIPTORS_ATTRIBUTE,
  206. maxdescriptors, errorbuf, CONFIG_APPLY)
  207. != LDAP_SUCCESS)
  208. {
  209. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s\n", configfile,
  210. CONFIG_MAXDESCRIPTORS_ATTRIBUTE, errorbuf);
  211. }
  212. }
  213. /* see if we need to enable error logging */
  214. if (!logenabled[0] &&
  215. entry_has_attr_and_value(e,
  216. CONFIG_ERRORLOG_LOGGING_ENABLED_ATTRIBUTE,
  217. logenabled, sizeof(logenabled)))
  218. {
  219. if (log_set_logging(
  220. CONFIG_ERRORLOG_LOGGING_ENABLED_ATTRIBUTE,
  221. logenabled, SLAPD_ERROR_LOG, errorbuf, CONFIG_APPLY)
  222. != LDAP_SUCCESS)
  223. {
  224. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s\n", configfile,
  225. CONFIG_ERRORLOG_LOGGING_ENABLED_ATTRIBUTE, errorbuf);
  226. }
  227. }
  228. /* set the local user name; needed to set up error log */
  229. if (!_localuser[0] &&
  230. entry_has_attr_and_value(e, CONFIG_LOCALUSER_ATTRIBUTE,
  231. _localuser, sizeof(_localuser)))
  232. {
  233. if (config_set_localuser(CONFIG_LOCALUSER_ATTRIBUTE,
  234. _localuser, errorbuf, CONFIG_APPLY) != LDAP_SUCCESS)
  235. {
  236. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s. \n", configfile,
  237. CONFIG_LOCALUSER_ATTRIBUTE, errorbuf);
  238. }
  239. }
  240. /* set the log file name */
  241. workpath[0] = '\0';
  242. if (!workpath[0] &&
  243. entry_has_attr_and_value(e, CONFIG_ERRORLOG_ATTRIBUTE,
  244. workpath, sizeof(workpath)))
  245. {
  246. if (config_set_errorlog(CONFIG_ERRORLOG_ATTRIBUTE,
  247. workpath, errorbuf, CONFIG_APPLY) != LDAP_SUCCESS)
  248. {
  249. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s. \n", configfile,
  250. CONFIG_ERRORLOG_ATTRIBUTE, errorbuf);
  251. }
  252. }
  253. /* set the error log level */
  254. if (!loglevel[0] &&
  255. entry_has_attr_and_value(e, CONFIG_LOGLEVEL_ATTRIBUTE,
  256. loglevel, sizeof(loglevel)))
  257. {
  258. if (should_detach || !config_get_errorlog_level())
  259. { /* -d wasn't on command line */
  260. if (config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE,
  261. loglevel, errorbuf, CONFIG_APPLY) != LDAP_SUCCESS)
  262. {
  263. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s. \n", configfile,
  264. CONFIG_LOGLEVEL_ATTRIBUTE, errorbuf);
  265. }
  266. }
  267. else
  268. {
  269. LDAPDebug(LDAP_DEBUG_ANY,
  270. "%s: ignoring %s (since -d %d was given on "
  271. "the command line)\n",
  272. CONFIG_LOGLEVEL_ATTRIBUTE, loglevel,
  273. config_get_errorlog_level());
  274. }
  275. }
  276. /* set the cert dir; needed in slapd_nss_init */
  277. workpath[0] = '\0';
  278. if (entry_has_attr_and_value(e, CONFIG_CERTDIR_ATTRIBUTE,
  279. workpath, sizeof(workpath)))
  280. {
  281. if (config_set_certdir(CONFIG_CERTDIR_ATTRIBUTE,
  282. workpath, errorbuf, CONFIG_APPLY) != LDAP_SUCCESS)
  283. {
  284. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s. \n", configfile,
  285. CONFIG_CERTDIR_ATTRIBUTE, errorbuf);
  286. }
  287. }
  288. /* set the sasl path; needed in main */
  289. workpath[0] = '\0';
  290. if (entry_has_attr_and_value(e, CONFIG_SASLPATH_ATTRIBUTE,
  291. workpath, sizeof(workpath)))
  292. {
  293. if (config_set_saslpath(CONFIG_SASLPATH_ATTRIBUTE,
  294. workpath, errorbuf, CONFIG_APPLY) != LDAP_SUCCESS)
  295. {
  296. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s. \n", configfile,
  297. CONFIG_SASLPATH_ATTRIBUTE, errorbuf);
  298. }
  299. }
  300. #if defined(ENABLE_LDAPI)
  301. /* set the ldapi file path; needed in main */
  302. workpath[0] = '\0';
  303. if (entry_has_attr_and_value(e, CONFIG_LDAPI_FILENAME_ATTRIBUTE,
  304. workpath, sizeof(workpath)))
  305. {
  306. if (config_set_ldapi_filename(CONFIG_LDAPI_FILENAME_ATTRIBUTE,
  307. workpath, errorbuf, CONFIG_APPLY) != LDAP_SUCCESS)
  308. {
  309. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s. \n", configfile,
  310. CONFIG_LDAPI_FILENAME_ATTRIBUTE, errorbuf);
  311. }
  312. }
  313. /* set the ldapi switch; needed in main */
  314. workpath[0] = '\0';
  315. if (entry_has_attr_and_value(e, CONFIG_LDAPI_SWITCH_ATTRIBUTE,
  316. workpath, sizeof(workpath)))
  317. {
  318. if (config_set_ldapi_switch(CONFIG_LDAPI_SWITCH_ATTRIBUTE,
  319. workpath, errorbuf, CONFIG_APPLY) != LDAP_SUCCESS)
  320. {
  321. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s. \n", configfile,
  322. CONFIG_LDAPI_SWITCH_ATTRIBUTE, errorbuf);
  323. }
  324. }
  325. #endif
  326. /* see if the entry is a child of the plugin base dn */
  327. if (slapi_sdn_isparent(&plug_dn,
  328. slapi_entry_get_sdn_const(e)))
  329. {
  330. if (entry_has_attr_and_value(e, "objectclass",
  331. "nsSlapdPlugin", 0) &&
  332. (entry_has_attr_and_value(e, ATTR_PLUGIN_TYPE,
  333. "syntax", 0) ||
  334. entry_has_attr_and_value(e, ATTR_PLUGIN_TYPE,
  335. "matchingrule", 0)))
  336. {
  337. /* add the syntax/matching scheme rule plugin */
  338. if (plugin_setup(e, 0, 0, 1, returntext))
  339. {
  340. LDAPDebug(LDAP_DEBUG_ANY, "The plugin entry [%s] in the configfile %s was invalid. %s\n",
  341. slapi_entry_get_dn(e), configfile, returntext);
  342. rc = 0;
  343. slapi_sdn_done(&plug_dn);
  344. goto bail;
  345. }
  346. }
  347. }
  348. /* see if the entry is a grand child of the plugin base dn */
  349. if (slapi_sdn_isgrandparent(&plug_dn,
  350. slapi_entry_get_sdn_const(e)))
  351. {
  352. if (entry_has_attr_and_value(e, "objectclass",
  353. "nsSlapdPlugin", 0) &&
  354. ( entry_has_attr_and_value(e, ATTR_PLUGIN_TYPE,
  355. "pwdstoragescheme", 0) ||
  356. entry_has_attr_and_value(e, ATTR_PLUGIN_TYPE,
  357. "reverpwdstoragescheme", 0) ) )
  358. {
  359. /* add the pwd storage scheme rule plugin */
  360. if (plugin_setup(e, 0, 0, 1, returntext))
  361. {
  362. LDAPDebug(LDAP_DEBUG_ANY, "The plugin entry [%s] in the configfile %s was invalid. %s\n",
  363. slapi_entry_get_dn(e), configfile, returntext);
  364. rc = 0;
  365. slapi_sdn_done(&plug_dn);
  366. goto bail;
  367. }
  368. }
  369. }
  370. /* see if we need to disable schema checking */
  371. if (!schemacheck[0] &&
  372. entry_has_attr_and_value(e, CONFIG_SCHEMACHECK_ATTRIBUTE,
  373. schemacheck, sizeof(schemacheck)))
  374. {
  375. if (config_set_schemacheck(CONFIG_SCHEMACHECK_ATTRIBUTE,
  376. schemacheck, errorbuf, CONFIG_APPLY)
  377. != LDAP_SUCCESS)
  378. {
  379. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s\n", configfile,
  380. CONFIG_SCHEMACHECK_ATTRIBUTE, errorbuf);
  381. }
  382. }
  383. /* see if we need to enable plugin binddn tracking */
  384. if (!plugintracking[0] &&
  385. entry_has_attr_and_value(e, CONFIG_PLUGIN_BINDDN_TRACKING_ATTRIBUTE,
  386. plugintracking, sizeof(plugintracking)))
  387. {
  388. if (config_set_plugin_tracking(CONFIG_PLUGIN_BINDDN_TRACKING_ATTRIBUTE,
  389. plugintracking, errorbuf, CONFIG_APPLY)
  390. != LDAP_SUCCESS)
  391. {
  392. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s\n", configfile,
  393. CONFIG_PLUGIN_BINDDN_TRACKING_ATTRIBUTE, errorbuf);
  394. }
  395. }
  396. /* see if we allow moddn aci */
  397. if (!moddn_aci[0] &&
  398. entry_has_attr_and_value(e, CONFIG_MODDN_ACI_ATTRIBUTE,
  399. moddn_aci, sizeof(moddn_aci)))
  400. {
  401. if (config_set_moddn_aci(CONFIG_MODDN_ACI_ATTRIBUTE,
  402. moddn_aci, errorbuf, CONFIG_APPLY)
  403. != LDAP_SUCCESS)
  404. {
  405. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s\n", configfile,
  406. CONFIG_MODDN_ACI_ATTRIBUTE, errorbuf);
  407. }
  408. }
  409. /* see if we need to enable syntax checking */
  410. if (!syntaxcheck[0] &&
  411. entry_has_attr_and_value(e, CONFIG_SYNTAXCHECK_ATTRIBUTE,
  412. syntaxcheck, sizeof(syntaxcheck)))
  413. {
  414. if (config_set_syntaxcheck(CONFIG_SYNTAXCHECK_ATTRIBUTE,
  415. syntaxcheck, errorbuf, CONFIG_APPLY)
  416. != LDAP_SUCCESS)
  417. {
  418. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s\n", configfile,
  419. CONFIG_SYNTAXCHECK_ATTRIBUTE, errorbuf);
  420. }
  421. }
  422. /* see if we need to enable syntax warnings */
  423. if (!syntaxlogging[0] &&
  424. entry_has_attr_and_value(e, CONFIG_SYNTAXLOGGING_ATTRIBUTE,
  425. syntaxlogging, sizeof(syntaxlogging)))
  426. {
  427. if (config_set_syntaxlogging(CONFIG_SYNTAXLOGGING_ATTRIBUTE,
  428. syntaxlogging, errorbuf, CONFIG_APPLY)
  429. != LDAP_SUCCESS)
  430. {
  431. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s\n", configfile,
  432. CONFIG_SYNTAXLOGGING_ATTRIBUTE, errorbuf);
  433. }
  434. }
  435. /* see if we need to enable strict dn validation */
  436. if (!dn_validate_strict[0] &&
  437. entry_has_attr_and_value(e, CONFIG_DN_VALIDATE_STRICT_ATTRIBUTE,
  438. dn_validate_strict, sizeof(dn_validate_strict)))
  439. {
  440. if (config_set_dn_validate_strict(CONFIG_DN_VALIDATE_STRICT_ATTRIBUTE,
  441. dn_validate_strict, errorbuf, CONFIG_APPLY)
  442. != LDAP_SUCCESS)
  443. {
  444. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s\n", configfile,
  445. CONFIG_DN_VALIDATE_STRICT_ATTRIBUTE, errorbuf);
  446. }
  447. }
  448. /* see if we need to expect quoted schema values */
  449. if (entry_has_attr_and_value(e, CONFIG_ENQUOTE_SUP_OC_ATTRIBUTE,
  450. val, sizeof(val)))
  451. {
  452. if (config_set_enquote_sup_oc(
  453. CONFIG_ENQUOTE_SUP_OC_ATTRIBUTE, val, errorbuf,
  454. CONFIG_APPLY) != LDAP_SUCCESS)
  455. {
  456. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s\n", configfile,
  457. CONFIG_ENQUOTE_SUP_OC_ATTRIBUTE, errorbuf);
  458. }
  459. val[0] = 0;
  460. }
  461. /* see if we need to maintain case in AT and OC names */
  462. if (entry_has_attr_and_value(e,
  463. CONFIG_RETURN_EXACT_CASE_ATTRIBUTE, val, sizeof(val)))
  464. {
  465. if (config_set_return_exact_case(
  466. CONFIG_RETURN_EXACT_CASE_ATTRIBUTE, val,
  467. errorbuf, CONFIG_APPLY) != LDAP_SUCCESS)
  468. {
  469. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s\n", configfile,
  470. CONFIG_RETURN_EXACT_CASE_ATTRIBUTE, errorbuf);
  471. }
  472. val[0] = 0;
  473. }
  474. /* see if we should allow attr. name exceptions, e.g. '_'s */
  475. if (entry_has_attr_and_value(e,
  476. CONFIG_ATTRIBUTE_NAME_EXCEPTION_ATTRIBUTE,
  477. val, sizeof(val)))
  478. {
  479. if (config_set_attrname_exceptions(
  480. CONFIG_ATTRIBUTE_NAME_EXCEPTION_ATTRIBUTE, val,
  481. errorbuf, CONFIG_APPLY) != LDAP_SUCCESS)
  482. {
  483. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s\n", configfile,
  484. CONFIG_ATTRIBUTE_NAME_EXCEPTION_ATTRIBUTE,
  485. errorbuf);
  486. }
  487. val[0] = 0;
  488. }
  489. /* see if we need to maintain schema compatibility with 4.x */
  490. if (entry_has_attr_and_value(e,
  491. CONFIG_DS4_COMPATIBLE_SCHEMA_ATTRIBUTE, val, sizeof(val)))
  492. {
  493. if (config_set_ds4_compatible_schema(
  494. CONFIG_DS4_COMPATIBLE_SCHEMA_ATTRIBUTE, val,
  495. errorbuf, CONFIG_APPLY) != LDAP_SUCCESS)
  496. {
  497. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s\n", configfile,
  498. CONFIG_DS4_COMPATIBLE_SCHEMA_ATTRIBUTE,
  499. errorbuf);
  500. }
  501. val[0] = 0;
  502. }
  503. /* see if we need to allow trailing spaces in OC and AT names */
  504. if (entry_has_attr_and_value(e,
  505. CONFIG_SCHEMA_IGNORE_TRAILING_SPACES, val, sizeof(val)))
  506. {
  507. if (config_set_schema_ignore_trailing_spaces(
  508. CONFIG_SCHEMA_IGNORE_TRAILING_SPACES, val,
  509. errorbuf, CONFIG_APPLY) != LDAP_SUCCESS)
  510. {
  511. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s\n", configfile,
  512. CONFIG_SCHEMA_IGNORE_TRAILING_SPACES,
  513. errorbuf);
  514. }
  515. val[0] = 0;
  516. }
  517. /* rfc1274-rewrite */
  518. if (entry_has_attr_and_value(e,
  519. CONFIG_REWRITE_RFC1274_ATTRIBUTE,
  520. val, sizeof(val))) {
  521. if (config_set_rewrite_rfc1274(
  522. CONFIG_REWRITE_RFC1274_ATTRIBUTE, val,
  523. errorbuf, CONFIG_APPLY) != LDAP_SUCCESS) {
  524. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s\n",
  525. configfile,
  526. CONFIG_REWRITE_RFC1274_ATTRIBUTE,
  527. errorbuf);
  528. }
  529. val[0] = 0;
  530. }
  531. /* what is our localhost name */
  532. if (entry_has_attr_and_value(e, CONFIG_LOCALHOST_ATTRIBUTE,
  533. val, sizeof(val)))
  534. {
  535. if (config_set_localhost(
  536. CONFIG_LOCALHOST_ATTRIBUTE, val, errorbuf,
  537. CONFIG_APPLY) != LDAP_SUCCESS)
  538. {
  539. LDAPDebug(LDAP_DEBUG_ANY, "%s: %s: %s\n", configfile,
  540. CONFIG_LOCALHOST_ATTRIBUTE, errorbuf);
  541. }
  542. val[0] = 0;
  543. }
  544. if (e)
  545. slapi_entry_free(e);
  546. }
  547. /* kexcoff: initialize rootpwstoragescheme and pw_storagescheme
  548. * if not explicilty set in the config file
  549. */
  550. if ( config_set_storagescheme() ) { /* default scheme plugin not loaded */
  551. slapi_log_error(SLAPI_LOG_FATAL, "startup",
  552. "The default password storage scheme SSHA could not be read or was not found in the file %s. It is mandatory.\n",
  553. configfile);
  554. exit (1);
  555. }
  556. else {
  557. slapi_sdn_done(&plug_dn);
  558. rc= 1; /* OK */
  559. }
  560. }
  561. slapi_ch_free_string(&buf);
  562. }
  563. bail:
  564. slapi_ch_free_string(&buf);
  565. return rc;
  566. }