configdse.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. #ifdef HAVE_CONFIG_H
  39. # include <config.h>
  40. #endif
  41. /* configdse.c - routines to manage the config DSE */
  42. #include <stdio.h>
  43. #include <string.h>
  44. #include <sys/types.h>
  45. #include <errno.h>
  46. #ifndef _WIN32
  47. #include <sys/socket.h>
  48. #include <sys/param.h>
  49. #endif
  50. #include "log.h"
  51. #include "slap.h"
  52. #include "pw.h"
  53. static int check_all_maxdiskspace_and_mlogsize(Slapi_PBlock *pb, LDAPMod **mod, char *returntext);
  54. static void get_log_max_size( LDAPMod *mod,
  55. char *maxdiskspace_str,
  56. char *mlogsize_str,
  57. int *maxdiskspace,
  58. int *mlogsize);
  59. /* List of attributes which require server restart to take effect */
  60. static const char *requires_restart[] = {
  61. "cn=config:nsslapd-port",
  62. "cn=config:nsslapd-secureport",
  63. "cn=config:" CONFIG_LDAPI_FILENAME_ATTRIBUTE,
  64. "cn=config:" CONFIG_LDAPI_SWITCH_ATTRIBUTE,
  65. "cn=config:nsslapd-workingdir",
  66. "cn=config:nsslapd-plugin",
  67. "cn=config:nsslapd-sslclientauth",
  68. "cn=config:nsslapd-changelogdir",
  69. "cn=config:nsslapd-changelogsuffix",
  70. "cn=config:nsslapd-changelogmaxentries",
  71. "cn=config:nsslapd-changelogmaxage",
  72. "cn=config:nsslapd-db-locks",
  73. #if !defined(_WIN32) && !defined(AIX)
  74. "cn=config:nsslapd-maxdescriptors",
  75. #endif
  76. "cn=config:" CONFIG_RETURN_EXACT_CASE_ATTRIBUTE,
  77. "cn=config:" CONFIG_SCHEMA_IGNORE_TRAILING_SPACES,
  78. "cn=config,cn=ldbm:nsslapd-idlistscanlimit",
  79. "cn=config,cn=ldbm:nsslapd-parentcheck",
  80. "cn=config,cn=ldbm:nsslapd-dbcachesize",
  81. "cn=config,cn=ldbm:nsslapd-dbncache",
  82. "cn=config,cn=ldbm:nsslapd-cachesize",
  83. "cn=config,cn=ldbm:nsslapd-plugin",
  84. "cn=encryption,cn=config:nssslsessiontimeout",
  85. "cn=encryption,cn=config:nssslclientauth",
  86. "cn=encryption,cn=config:nsssl2",
  87. "cn=encryption,cn=config:nsssl3" };
  88. static int
  89. isASyntaxOrMrPluginOrPss(Slapi_Entry *e)
  90. {
  91. char *ptype = slapi_entry_attr_get_charptr(e, ATTR_PLUGIN_TYPE);
  92. int retval = (ptype && !strcasecmp(ptype, "syntax"));
  93. if (!retval)
  94. retval = (ptype && !strcasecmp(ptype, "matchingrule"));
  95. if (!retval)
  96. retval = (ptype && !strcasecmp(ptype, "pwdstoragescheme"));
  97. if (!retval)
  98. retval = (ptype && !strcasecmp(ptype, "reverpwdstoragescheme"));
  99. slapi_ch_free_string(&ptype);
  100. return retval;
  101. }
  102. /* these attr types are ignored for the purposes of configuration search/modify */
  103. static int
  104. ignore_attr_type(const char *attr_type)
  105. {
  106. if ( !attr_type ||
  107. (strcasecmp (attr_type, "cn") == 0) ||
  108. (strcasecmp (attr_type, "aci") == 0) ||
  109. (strcasecmp (attr_type, "objectclass") == 0) ||
  110. (strcasecmp (attr_type, "numsubordinates") == 0) ||
  111. (strcasecmp (attr_type, "internalModifiersname") == 0) ||
  112. (strcasecmp (attr_type, "modifytimestamp") == 0) ||
  113. (strcasecmp (attr_type, "modifiersname") == 0)) {
  114. return 1;
  115. }
  116. return 0;
  117. }
  118. int
  119. read_config_dse (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg)
  120. {
  121. struct berval *vals[2];
  122. struct berval val;
  123. Slapi_Backend *be;
  124. slapdFrontendConfig_t *slapdFrontendConfig;
  125. struct slapdplugin *pPlugin;
  126. char *cookie;
  127. int i;
  128. slapdFrontendConfig = getFrontendConfig();
  129. vals[0] = &val;
  130. vals[1] = NULL;
  131. /*
  132. * We can skip using the config accessor functions here because we're holding
  133. * the read lock explicitly
  134. */
  135. CFG_LOCK_READ(slapdFrontendConfig);
  136. /* show backend config */
  137. attrlist_delete ( &e->e_attrs, "nsslapd-backendconfig");
  138. for ( i = 0;
  139. slapdFrontendConfig->backendconfig &&
  140. slapdFrontendConfig->backendconfig[i];
  141. i++) {
  142. val.bv_val = slapdFrontendConfig->backendconfig[i];
  143. val.bv_len = strlen ( val.bv_val );
  144. attrlist_merge ( &e->e_attrs, "nsslapd-backendconfig", vals);
  145. }
  146. CFG_UNLOCK_READ(slapdFrontendConfig);
  147. /* show other config entries */
  148. attrlist_delete ( &e->e_attrs, "nsslapd-backendconfig");
  149. cookie = NULL;
  150. be = slapi_get_first_backend (&cookie);
  151. while ( be )
  152. {
  153. if(!be->be_private)
  154. {
  155. Slapi_DN dn;
  156. slapi_sdn_init(&dn);
  157. be_getconfigdn(be,&dn);
  158. val.bv_val = (char*)slapi_sdn_get_ndn(&dn);
  159. val.bv_len = strlen (val.bv_val);
  160. attrlist_merge ( &e->e_attrs, "nsslapd-backendconfig", vals);
  161. slapi_sdn_done(&dn);
  162. }
  163. be = slapi_get_next_backend (cookie);
  164. }
  165. slapi_ch_free_string (&cookie);
  166. /* show be_type */
  167. attrlist_delete( &e->e_attrs, "nsslapd-betype");
  168. cookie = NULL;
  169. be = slapi_get_first_backend(&cookie);
  170. while ( be ) {
  171. if( !be->be_private )
  172. {
  173. val.bv_val = be->be_type;
  174. val.bv_len = strlen (be->be_type);
  175. attrlist_replace( &e->e_attrs, "nsslapd-betype", vals );
  176. }
  177. be = slapi_get_next_backend(cookie);
  178. }
  179. slapi_ch_free_string (&cookie);
  180. /* show private suffixes */
  181. attrlist_delete ( &e->e_attrs, "nsslapd-privatenamespaces");
  182. cookie = NULL;
  183. be = slapi_get_first_backend(&cookie);
  184. while ( be )
  185. {
  186. if(be->be_private)
  187. {
  188. int n= 0;
  189. const Slapi_DN *base= NULL;
  190. do {
  191. base= slapi_be_getsuffix(be,n);
  192. if(base!=NULL)
  193. {
  194. val.bv_val = (void*)slapi_sdn_get_dn(base); /* jcm: had to cast away const */
  195. val.bv_len = strlen (val.bv_val);
  196. attrlist_merge ( &e->e_attrs, "nsslapd-privatenamespaces", vals);
  197. }
  198. n++;
  199. } while (base!=NULL);
  200. }
  201. be = slapi_get_next_backend(cookie);
  202. }
  203. slapi_ch_free_string (&cookie);
  204. /* show syntax plugins */
  205. attrlist_delete ( &e->e_attrs, CONFIG_PLUGIN_ATTRIBUTE );
  206. for ( pPlugin = slapi_get_global_syntax_plugins(); pPlugin != NULL;
  207. pPlugin = pPlugin->plg_next ) {
  208. val.bv_val = pPlugin->plg_dn;
  209. val.bv_len = strlen ( val.bv_val );
  210. attrlist_merge ( &e->e_attrs, CONFIG_PLUGIN_ATTRIBUTE, vals );
  211. }
  212. /* show matching rule plugins */
  213. for ( pPlugin = slapi_get_global_mr_plugins(); pPlugin != NULL;
  214. pPlugin = pPlugin->plg_next ) {
  215. val.bv_val = pPlugin->plg_dn;
  216. val.bv_len = strlen ( val.bv_val );
  217. attrlist_merge ( &e->e_attrs, CONFIG_PLUGIN_ATTRIBUTE, vals );
  218. }
  219. /* show requiresrestart */
  220. attrlist_delete( &e->e_attrs, "nsslapd-requiresrestart");
  221. for ( i = 0; i < sizeof(requires_restart)/sizeof(requires_restart[0]); i++ ) {
  222. val.bv_val = (char *)requires_restart[i];
  223. val.bv_len = strlen (val.bv_val);
  224. attrlist_merge ( &e->e_attrs, "nsslapd-requiresrestart", vals);
  225. }
  226. /* show the rest of the configuration parameters */
  227. *returncode= config_set_entry(e);
  228. return SLAPI_DSE_CALLBACK_OK;
  229. }
  230. int
  231. load_config_dse(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* ignored, int *returncode, char *returntext, void *arg)
  232. {
  233. int retval = LDAP_SUCCESS;
  234. Slapi_Attr *attr = 0;
  235. for (slapi_entry_first_attr(e, &attr); (retval == LDAP_SUCCESS) && attr;
  236. slapi_entry_next_attr(e, attr, &attr))
  237. {
  238. char *attr_name = 0;
  239. struct berval **values = 0;
  240. int nvals = 0;
  241. slapi_attr_get_type(attr, &attr_name);
  242. if (ignore_attr_type(attr_name))
  243. continue;
  244. slapi_attr_get_numvalues(attr, &nvals);
  245. /* convert the values into an array of bervals */
  246. if (nvals)
  247. {
  248. Slapi_Value *v = 0;
  249. int index = 0;
  250. values = (struct berval **)slapi_ch_malloc((nvals+1) *
  251. sizeof(struct berval *));
  252. values[nvals] = 0;
  253. for (index = slapi_attr_first_value(attr, &v);
  254. v && (index != -1);
  255. index = slapi_attr_next_value(attr, index, &v))
  256. {
  257. values[index] = (struct berval *)slapi_value_get_berval(v);
  258. }
  259. }
  260. if (attr_name)
  261. {
  262. retval = config_set(attr_name, values, returntext, 1 /* force apply */);
  263. if ((strcasecmp(attr_name, CONFIG_MAXDESCRIPTORS_ATTRIBUTE) == 0) ||
  264. (strcasecmp(attr_name, CONFIG_RESERVEDESCRIPTORS_ATTRIBUTE) == 0) ||
  265. (strcasecmp(attr_name, CONFIG_CONNTABLESIZE_ATTRIBUTE) == 0)) {
  266. /* We should not treat an LDAP_UNWILLING_TO_PERFORM as fatal for
  267. * the these config attributes. This error is returned when
  268. * the value we are trying to set is higher than the current
  269. * process limit. The set function will auto-adjust the runtime
  270. * value to the current process limit when this happens. We want
  271. * to allow the server to still start in this case. */
  272. if (retval == LDAP_UNWILLING_TO_PERFORM) {
  273. slapi_log_error (SLAPI_LOG_FATAL, NULL, "Config Warning: - %s\n", returntext);
  274. retval = LDAP_SUCCESS;
  275. }
  276. } else {
  277. if (((retval != LDAP_SUCCESS) &&
  278. slapi_attr_flag_is_set(attr, SLAPI_ATTR_FLAG_OPATTR)) ||
  279. (LDAP_NO_SUCH_ATTRIBUTE == retval)) {
  280. /* ignore attempts to modify operational attrs and */
  281. /* ignore attempts to modify unknown attributes for load. */
  282. retval = LDAP_SUCCESS;
  283. }
  284. }
  285. }
  286. if (values)
  287. {
  288. /* slapi_value_get_berval returns the actual memory owned by the
  289. slapi attr, so we cannot free it */
  290. slapi_ch_free((void **)&values);
  291. }
  292. }
  293. *returncode = retval;
  294. return (retval == LDAP_SUCCESS) ? SLAPI_DSE_CALLBACK_OK
  295. : SLAPI_DSE_CALLBACK_ERROR;
  296. }
  297. int
  298. load_plugin_entry(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* ignored, int *returncode, char *returntext, void *arg)
  299. {
  300. int retval = LDAP_SUCCESS;
  301. if (isASyntaxOrMrPluginOrPss(e))
  302. {
  303. /*
  304. * syntax/matching/passwd storage scheme rule plugins are loaded
  305. * at bootstrap time, so no need to load them here. BUT -- the
  306. * descriptive information that is registered by the plugin is
  307. * thrown away during bootstrap time, so we set it here.
  308. */
  309. (void)plugin_add_descriptive_attributes( e, NULL );
  310. } else {
  311. /*
  312. * Process plugins that were not loaded during bootstrap.
  313. */
  314. retval = plugin_setup(e, 0, 0, 1);
  315. /*
  316. * well this damn well sucks, but this function is used as a callback
  317. * and to ensure we do not continue if a plugin fails to load or init
  318. * properly we must exit here.
  319. */
  320. if(retval)
  321. {
  322. char dnbuf[ BUFSIZ ];
  323. slapi_log_error( SLAPI_LOG_FATAL, NULL,
  324. "Unable to load plugin \"%s\"\n",
  325. escape_string( slapi_entry_get_dn_const( e ), dnbuf ));
  326. exit(1);
  327. }
  328. }
  329. *returncode = retval;
  330. return (retval == LDAP_SUCCESS) ? SLAPI_DSE_CALLBACK_OK
  331. : SLAPI_DSE_CALLBACK_ERROR;
  332. }
  333. int
  334. modify_config_dse(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg)
  335. {
  336. char *config_attr;
  337. LDAPMod **mods;
  338. int rc = LDAP_SUCCESS;
  339. int apply_mods = 0;
  340. char *pwd = 0;
  341. int checked_all_maxdiskspace_and_mlogsize = 0;
  342. slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
  343. returntext[0] = '\0';
  344. /*
  345. * First pass: set apply mods to 0 so only input validation will be done;
  346. * 2nd pass: set apply mods to 1 to apply changes to internal storage
  347. */
  348. for ( apply_mods = 0; apply_mods <= 1; apply_mods++ ) {
  349. int i = 0;
  350. for (i = 0; (mods[i] && (LDAP_SUCCESS == rc)); i++) {
  351. /* send all aci modifications to the backend */
  352. config_attr = (char *)mods[i]->mod_type;
  353. if (ignore_attr_type(config_attr))
  354. continue;
  355. if (SLAPI_IS_MOD_ADD(mods[i]->mod_op)) {
  356. if (apply_mods) { /* log warning once */
  357. slapi_log_error (SLAPI_LOG_FATAL, NULL,
  358. "Warning: Adding configuration attribute \"%s\"\n",
  359. config_attr);
  360. }
  361. rc = config_set(config_attr, mods[i]->mod_bvalues,
  362. returntext, apply_mods);
  363. if (LDAP_NO_SUCH_ATTRIBUTE == rc) {
  364. /* config_set returns LDAP_NO_SUCH_ATTRIBUTE if the
  365. * attr is not defined for cn=config.
  366. * map it to LDAP_UNWILLING_TO_PERFORM */
  367. rc = LDAP_UNWILLING_TO_PERFORM;
  368. }
  369. } else if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) {
  370. /* Need to allow deleting some configuration attrs */
  371. if (config_allowed_to_delete_attrs(config_attr)) {
  372. rc = config_set(config_attr, mods[i]->mod_bvalues,
  373. returntext, apply_mods);
  374. if (apply_mods) { /* log warning once */
  375. slapi_log_error (SLAPI_LOG_FATAL, NULL,
  376. "Warning: Deleting configuration attribute \"%s\"\n",
  377. config_attr);
  378. }
  379. } else {
  380. rc= LDAP_UNWILLING_TO_PERFORM;
  381. PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
  382. "Deleting attributes is not allowed");
  383. }
  384. } else if (SLAPI_IS_MOD_REPLACE(mods[i]->mod_op)) {
  385. if (( checked_all_maxdiskspace_and_mlogsize == 0 ) &&
  386. ((strcasecmp( mods[i]->mod_type, CONFIG_ERRORLOG_MAXLOGDISKSPACE_ATTRIBUTE) == 0) ||
  387. (strcasecmp( mods[i]->mod_type, CONFIG_ERRORLOG_MAXLOGSIZE_ATTRIBUTE) == 0) ||
  388. (strcasecmp( mods[i]->mod_type, CONFIG_ACCESSLOG_MAXLOGDISKSPACE_ATTRIBUTE) == 0) ||
  389. (strcasecmp( mods[i]->mod_type, CONFIG_ACCESSLOG_MAXLOGSIZE_ATTRIBUTE) == 0) ||
  390. (strcasecmp( mods[i]->mod_type, CONFIG_AUDITLOG_MAXLOGDISKSPACE_ATTRIBUTE) == 0) ||
  391. (strcasecmp( mods[i]->mod_type, CONFIG_AUDITLOG_MAXLOGSIZE_ATTRIBUTE) == 0)) )
  392. {
  393. checked_all_maxdiskspace_and_mlogsize = 1;
  394. if ( (rc=check_all_maxdiskspace_and_mlogsize(pb, mods, returntext)) != LDAP_SUCCESS )
  395. {
  396. goto finish_and_return;
  397. }
  398. }
  399. rc = config_set(config_attr, mods[i]->mod_bvalues, returntext,
  400. apply_mods);
  401. if (LDAP_NO_SUCH_ATTRIBUTE == rc) {
  402. /* config_set returns LDAP_NO_SUCH_ATTRIBUTE if the
  403. * attr is not defined for cn=config.
  404. * map it to LDAP_UNWILLING_TO_PERFORM */
  405. rc = LDAP_UNWILLING_TO_PERFORM;
  406. }
  407. }
  408. }
  409. }
  410. finish_and_return:
  411. /*
  412. * The DSE code will be writing the resultant entry value to the
  413. * dse.ldif file. We *must*not* write plain passwords into here.
  414. */
  415. slapi_entry_attr_delete( e, CONFIG_ROOTPW_ATTRIBUTE );
  416. /* if the password has been set, it will be hashed */
  417. if ((pwd = config_get_rootpw()) != NULL) {
  418. slapi_entry_attr_set_charptr(e, CONFIG_ROOTPW_ATTRIBUTE, pwd);
  419. slapi_ch_free_string(&pwd);
  420. }
  421. *returncode= rc;
  422. if(LDAP_SUCCESS == rc) {
  423. return(SLAPI_DSE_CALLBACK_OK); /* success -- apply the mods. */
  424. }
  425. else {
  426. return(SLAPI_DSE_CALLBACK_ERROR); /* failure -- reject the mods. */
  427. }
  428. }
  429. int
  430. postop_modify_config_dse(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg)
  431. {
  432. static int num_requires_restart = sizeof(requires_restart)/sizeof(char*);
  433. LDAPMod **mods;
  434. int i, j;
  435. char *p;
  436. slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
  437. returntext[0] = '\0';
  438. for (i = 0; mods[i]; i++) {
  439. if (mods[i]->mod_op & LDAP_MOD_REPLACE ) {
  440. /* Check if the server needs to be restarted */
  441. for (j = 0; j < num_requires_restart; j++)
  442. {
  443. p = strchr (requires_restart[j], ':');
  444. if (p == NULL)
  445. continue;
  446. while ( *(++p) == ' ' || *p == '\t' );
  447. if ( strcasecmp (p, mods[i]->mod_type) == 0 ) {
  448. PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
  449. "The change of %s will not take effect "
  450. "until the server is restarted", mods[i]->mod_type);
  451. slapi_log_error (SLAPI_LOG_FATAL, NULL, "%s\n", returntext);
  452. break;
  453. }
  454. }
  455. if (j < num_requires_restart) {
  456. /* That's enough, don't check remaining mods any more */
  457. break;
  458. }
  459. }
  460. }
  461. *returncode = LDAP_SUCCESS;
  462. return *returncode;
  463. }
  464. static int
  465. check_all_maxdiskspace_and_mlogsize(Slapi_PBlock *pb, LDAPMod **mods, char *returntext)
  466. {
  467. int i = 0;
  468. int rc = LDAP_SUCCESS;
  469. int errormaxdiskspace = -1;
  470. int errormlogsize = -1;
  471. int accessmaxdiskspace = -1;
  472. int accessmlogsize = -1;
  473. int auditmaxdiskspace = -1;
  474. int auditmlogsize = -1;
  475. for (i = 0; mods[i] ; i++)
  476. {
  477. get_log_max_size(mods[i],
  478. CONFIG_ERRORLOG_MAXLOGDISKSPACE_ATTRIBUTE,
  479. CONFIG_ERRORLOG_MAXLOGSIZE_ATTRIBUTE,
  480. &errormaxdiskspace,
  481. &errormlogsize);
  482. get_log_max_size(mods[i],
  483. CONFIG_ACCESSLOG_MAXLOGDISKSPACE_ATTRIBUTE,
  484. CONFIG_ACCESSLOG_MAXLOGSIZE_ATTRIBUTE,
  485. &accessmaxdiskspace,
  486. &accessmlogsize);
  487. get_log_max_size(mods[i],
  488. CONFIG_AUDITLOG_MAXLOGDISKSPACE_ATTRIBUTE,
  489. CONFIG_AUDITLOG_MAXLOGSIZE_ATTRIBUTE,
  490. &auditmaxdiskspace,
  491. &auditmlogsize);
  492. }
  493. if ( (rc=check_log_max_size(
  494. CONFIG_ERRORLOG_MAXLOGDISKSPACE_ATTRIBUTE,
  495. CONFIG_ERRORLOG_MAXLOGSIZE_ATTRIBUTE,
  496. errormaxdiskspace,
  497. errormlogsize,
  498. returntext,
  499. SLAPD_ERROR_LOG)) != LDAP_SUCCESS )
  500. {
  501. return rc;
  502. }
  503. if ( (rc=check_log_max_size(
  504. CONFIG_ACCESSLOG_MAXLOGDISKSPACE_ATTRIBUTE,
  505. CONFIG_ACCESSLOG_MAXLOGSIZE_ATTRIBUTE,
  506. accessmaxdiskspace,
  507. accessmlogsize,
  508. returntext,
  509. SLAPD_ACCESS_LOG)) != LDAP_SUCCESS )
  510. {
  511. return rc;
  512. }
  513. if ( (rc=check_log_max_size(
  514. CONFIG_AUDITLOG_MAXLOGDISKSPACE_ATTRIBUTE,
  515. CONFIG_AUDITLOG_MAXLOGSIZE_ATTRIBUTE,
  516. auditmaxdiskspace,
  517. auditmlogsize,
  518. returntext,
  519. SLAPD_AUDIT_LOG)) != LDAP_SUCCESS )
  520. {
  521. return rc;
  522. }
  523. return rc;
  524. }
  525. static void
  526. get_log_max_size( LDAPMod *mod,
  527. char *maxdiskspace_str,
  528. char *mlogsize_str,
  529. int *maxdiskspace,
  530. int *mlogsize)
  531. {
  532. if ( mod->mod_bvalues != NULL &&
  533. (strcasecmp( mod->mod_type, maxdiskspace_str ) == 0) )
  534. {
  535. *maxdiskspace = atoi((char *) mod->mod_bvalues[0]->bv_val);
  536. }
  537. if ( mod->mod_bvalues != NULL &&
  538. (strcasecmp( mod->mod_type, mlogsize_str ) == 0) )
  539. {
  540. *mlogsize = atoi((char *) mod->mod_bvalues[0]->bv_val);
  541. }
  542. }