configdse.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  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, "modifytimestamp") == 0) ||
  112. (strcasecmp (attr_type, "modifiersname") == 0)) {
  113. return 1;
  114. }
  115. return 0;
  116. }
  117. int
  118. read_config_dse (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg)
  119. {
  120. struct berval *vals[2];
  121. struct berval val;
  122. Slapi_Backend *be;
  123. slapdFrontendConfig_t *slapdFrontendConfig;
  124. struct slapdplugin *pPlugin;
  125. char *cookie;
  126. int i;
  127. slapdFrontendConfig = getFrontendConfig();
  128. vals[0] = &val;
  129. vals[1] = NULL;
  130. /*
  131. * We can skip using the config accessor functions here because we're holding
  132. * the read lock explicitly
  133. */
  134. CFG_LOCK_READ(slapdFrontendConfig);
  135. /* show backend config */
  136. attrlist_delete ( &e->e_attrs, "nsslapd-backendconfig");
  137. for ( i = 0;
  138. slapdFrontendConfig->backendconfig &&
  139. slapdFrontendConfig->backendconfig[i];
  140. i++) {
  141. val.bv_val = slapdFrontendConfig->backendconfig[i];
  142. val.bv_len = strlen ( val.bv_val );
  143. attrlist_merge ( &e->e_attrs, "nsslapd-backendconfig", vals);
  144. }
  145. CFG_UNLOCK_READ(slapdFrontendConfig);
  146. /* show other config entries */
  147. attrlist_delete ( &e->e_attrs, "nsslapd-backendconfig");
  148. cookie = NULL;
  149. be = slapi_get_first_backend (&cookie);
  150. while ( be )
  151. {
  152. if(!be->be_private)
  153. {
  154. Slapi_DN dn;
  155. slapi_sdn_init(&dn);
  156. be_getconfigdn(be,&dn);
  157. val.bv_val = (char*)slapi_sdn_get_ndn(&dn);
  158. val.bv_len = strlen (val.bv_val);
  159. attrlist_merge ( &e->e_attrs, "nsslapd-backendconfig", vals);
  160. slapi_sdn_done(&dn);
  161. }
  162. be = slapi_get_next_backend (cookie);
  163. }
  164. slapi_ch_free_string (&cookie);
  165. /* show be_type */
  166. attrlist_delete( &e->e_attrs, "nsslapd-betype");
  167. cookie = NULL;
  168. be = slapi_get_first_backend(&cookie);
  169. while ( be ) {
  170. if( !be->be_private )
  171. {
  172. val.bv_val = be->be_type;
  173. val.bv_len = strlen (be->be_type);
  174. attrlist_replace( &e->e_attrs, "nsslapd-betype", vals );
  175. }
  176. be = slapi_get_next_backend(cookie);
  177. }
  178. slapi_ch_free_string (&cookie);
  179. /* show private suffixes */
  180. attrlist_delete ( &e->e_attrs, "nsslapd-privatenamespaces");
  181. cookie = NULL;
  182. be = slapi_get_first_backend(&cookie);
  183. while ( be )
  184. {
  185. if(be->be_private)
  186. {
  187. int n= 0;
  188. const Slapi_DN *base= NULL;
  189. do {
  190. base= slapi_be_getsuffix(be,n);
  191. if(base!=NULL)
  192. {
  193. val.bv_val = (void*)slapi_sdn_get_dn(base); /* jcm: had to cast away const */
  194. val.bv_len = strlen (val.bv_val);
  195. attrlist_merge ( &e->e_attrs, "nsslapd-privatenamespaces", vals);
  196. }
  197. n++;
  198. } while (base!=NULL);
  199. }
  200. be = slapi_get_next_backend(cookie);
  201. }
  202. slapi_ch_free_string (&cookie);
  203. /* show syntax plugins */
  204. attrlist_delete ( &e->e_attrs, CONFIG_PLUGIN_ATTRIBUTE );
  205. for ( pPlugin = slapi_get_global_syntax_plugins(); pPlugin != NULL;
  206. pPlugin = pPlugin->plg_next ) {
  207. val.bv_val = pPlugin->plg_dn;
  208. val.bv_len = strlen ( val.bv_val );
  209. attrlist_merge ( &e->e_attrs, CONFIG_PLUGIN_ATTRIBUTE, vals );
  210. }
  211. /* show matching rule plugins */
  212. for ( pPlugin = slapi_get_global_mr_plugins(); pPlugin != NULL;
  213. pPlugin = pPlugin->plg_next ) {
  214. val.bv_val = pPlugin->plg_dn;
  215. val.bv_len = strlen ( val.bv_val );
  216. attrlist_merge ( &e->e_attrs, CONFIG_PLUGIN_ATTRIBUTE, vals );
  217. }
  218. /* show requiresrestart */
  219. attrlist_delete( &e->e_attrs, "nsslapd-requiresrestart");
  220. for ( i = 0; i < sizeof(requires_restart)/sizeof(requires_restart[0]); i++ ) {
  221. val.bv_val = (char *)requires_restart[i];
  222. val.bv_len = strlen (val.bv_val);
  223. attrlist_merge ( &e->e_attrs, "nsslapd-requiresrestart", vals);
  224. }
  225. /* show the rest of the configuration parameters */
  226. *returncode= config_set_entry(e);
  227. return SLAPI_DSE_CALLBACK_OK;
  228. }
  229. int
  230. load_config_dse(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* ignored, int *returncode, char *returntext, void *arg)
  231. {
  232. int retval = LDAP_SUCCESS;
  233. Slapi_Attr *attr = 0;
  234. for (slapi_entry_first_attr(e, &attr); (retval == LDAP_SUCCESS) && attr;
  235. slapi_entry_next_attr(e, attr, &attr))
  236. {
  237. char *attr_name = 0;
  238. struct berval **values = 0;
  239. int nvals = 0;
  240. slapi_attr_get_type(attr, &attr_name);
  241. if (ignore_attr_type(attr_name))
  242. continue;
  243. slapi_attr_get_numvalues(attr, &nvals);
  244. /* convert the values into an array of bervals */
  245. if (nvals)
  246. {
  247. Slapi_Value *v = 0;
  248. int index = 0;
  249. values = (struct berval **)slapi_ch_malloc((nvals+1) *
  250. sizeof(struct berval *));
  251. values[nvals] = 0;
  252. for (index = slapi_attr_first_value(attr, &v);
  253. v && (index != -1);
  254. index = slapi_attr_next_value(attr, index, &v))
  255. {
  256. values[index] = (struct berval *)slapi_value_get_berval(v);
  257. }
  258. }
  259. if (attr_name)
  260. {
  261. retval = config_set(attr_name, values, returntext, 1 /* force apply */);
  262. if ((strcasecmp(attr_name, CONFIG_MAXDESCRIPTORS_ATTRIBUTE) == 0) ||
  263. (strcasecmp(attr_name, CONFIG_RESERVEDESCRIPTORS_ATTRIBUTE) == 0) ||
  264. (strcasecmp(attr_name, CONFIG_CONNTABLESIZE_ATTRIBUTE) == 0)) {
  265. /* We should not treat an LDAP_UNWILLING_TO_PERFORM as fatal for
  266. * the these config attributes. This error is returned when
  267. * the value we are trying to set is higher than the current
  268. * process limit. The set function will auto-adjust the runtime
  269. * value to the current process limit when this happens. We want
  270. * to allow the server to still start in this case. */
  271. if (retval == LDAP_UNWILLING_TO_PERFORM) {
  272. slapi_log_error (SLAPI_LOG_FATAL, NULL, "Config Warning: - %s\n", returntext);
  273. retval = LDAP_SUCCESS;
  274. }
  275. } else {
  276. if ((retval != LDAP_SUCCESS) &&
  277. slapi_attr_flag_is_set(attr, SLAPI_ATTR_FLAG_OPATTR)) {
  278. retval = LDAP_SUCCESS; /* ignore attempts to modify operational attrs */
  279. }
  280. }
  281. }
  282. if (values)
  283. {
  284. /* slapi_value_get_berval returns the actual memory owned by the
  285. slapi attr, so we cannot free it */
  286. slapi_ch_free((void **)&values);
  287. }
  288. }
  289. *returncode = retval;
  290. return (retval == LDAP_SUCCESS) ? SLAPI_DSE_CALLBACK_OK
  291. : SLAPI_DSE_CALLBACK_ERROR;
  292. }
  293. int
  294. load_plugin_entry(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* ignored, int *returncode, char *returntext, void *arg)
  295. {
  296. int retval = LDAP_SUCCESS;
  297. if (isASyntaxOrMrPluginOrPss(e))
  298. {
  299. /*
  300. * syntax/matching/passwd storage scheme rule plugins are loaded
  301. * at bootstrap time, so no need to load them here. BUT -- the
  302. * descriptive information that is registered by the plugin is
  303. * thrown away during bootstrap time, so we set it here.
  304. */
  305. (void)plugin_add_descriptive_attributes( e, NULL );
  306. } else {
  307. /*
  308. * Process plugins that were not loaded during bootstrap.
  309. */
  310. retval = plugin_setup(e, 0, 0, 1);
  311. /*
  312. * well this damn well sucks, but this function is used as a callback
  313. * and to ensure we do not continue if a plugin fails to load or init
  314. * properly we must exit here.
  315. */
  316. if(retval)
  317. {
  318. char dnbuf[ BUFSIZ ];
  319. slapi_log_error( SLAPI_LOG_FATAL, NULL,
  320. "Unable to load plugin \"%s\"\n",
  321. escape_string( slapi_entry_get_dn_const( e ), dnbuf ));
  322. exit(1);
  323. }
  324. }
  325. *returncode = retval;
  326. return (retval == LDAP_SUCCESS) ? SLAPI_DSE_CALLBACK_OK
  327. : SLAPI_DSE_CALLBACK_ERROR;
  328. }
  329. int
  330. modify_config_dse(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg)
  331. {
  332. char *config_attr;
  333. LDAPMod **mods;
  334. int rc = LDAP_SUCCESS;
  335. int apply_mods = 0;
  336. char *pwd = 0;
  337. int checked_all_maxdiskspace_and_mlogsize = 0;
  338. slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
  339. returntext[0] = '\0';
  340. /*
  341. * First pass: set apply mods to 0 so only input validation will be done;
  342. * 2nd pass: set apply mods to 1 to apply changes to internal storage
  343. */
  344. for ( apply_mods = 0; apply_mods <= 1; apply_mods++ ) {
  345. int i = 0;
  346. for (i = 0; (mods[i] && (LDAP_SUCCESS == rc)); i++) {
  347. if ((mods[i]->mod_op & LDAP_MOD_DELETE) ||
  348. (mods[i]->mod_op & LDAP_MOD_ADD)) {
  349. rc= LDAP_UNWILLING_TO_PERFORM;
  350. PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "%s attributes is not allowed",
  351. (mods[i]->mod_op & LDAP_MOD_DELETE) ? "Deleting" : "Adding");
  352. } else if (mods[i]->mod_op & LDAP_MOD_REPLACE) {
  353. /* send all aci modifications to the backend */
  354. config_attr = (char *)mods[i]->mod_type;
  355. if (ignore_attr_type(config_attr))
  356. continue;
  357. if ( (checked_all_maxdiskspace_and_mlogsize == 0 ) &&
  358. ((strcasecmp( mods[i]->mod_type, CONFIG_ERRORLOG_MAXLOGDISKSPACE_ATTRIBUTE) == 0) ||
  359. (strcasecmp( mods[i]->mod_type, CONFIG_ERRORLOG_MAXLOGSIZE_ATTRIBUTE) == 0) ||
  360. (strcasecmp( mods[i]->mod_type, CONFIG_ACCESSLOG_MAXLOGDISKSPACE_ATTRIBUTE) == 0) ||
  361. (strcasecmp( mods[i]->mod_type, CONFIG_ACCESSLOG_MAXLOGSIZE_ATTRIBUTE) == 0) ||
  362. (strcasecmp( mods[i]->mod_type, CONFIG_AUDITLOG_MAXLOGDISKSPACE_ATTRIBUTE) == 0) ||
  363. (strcasecmp( mods[i]->mod_type, CONFIG_AUDITLOG_MAXLOGSIZE_ATTRIBUTE) == 0)) )
  364. {
  365. checked_all_maxdiskspace_and_mlogsize = 1;
  366. if ( (rc=check_all_maxdiskspace_and_mlogsize(pb, mods, returntext)) != LDAP_SUCCESS )
  367. {
  368. goto finish_and_return;
  369. }
  370. }
  371. rc = config_set(config_attr, mods[i]->mod_bvalues, returntext,
  372. apply_mods);
  373. }
  374. }
  375. }
  376. finish_and_return:
  377. /*
  378. * The DSE code will be writing the resultant entry value to the
  379. * dse.ldif file. We *must*not* write plain passwords into here.
  380. */
  381. slapi_entry_attr_delete( e, CONFIG_ROOTPW_ATTRIBUTE );
  382. /* if the password has been set, it will be hashed */
  383. if ((pwd = config_get_rootpw()) != NULL) {
  384. slapi_entry_attr_set_charptr(e, CONFIG_ROOTPW_ATTRIBUTE, pwd);
  385. slapi_ch_free_string(&pwd);
  386. }
  387. *returncode= rc;
  388. if(LDAP_SUCCESS == rc) {
  389. return(SLAPI_DSE_CALLBACK_OK); /* success -- apply the mods. */
  390. }
  391. else {
  392. return(SLAPI_DSE_CALLBACK_ERROR); /* failure -- reject the mods. */
  393. }
  394. }
  395. int
  396. postop_modify_config_dse(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg)
  397. {
  398. static int num_requires_restart = sizeof(requires_restart)/sizeof(char*);
  399. LDAPMod **mods;
  400. int i, j;
  401. char *p;
  402. slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
  403. returntext[0] = '\0';
  404. for (i = 0; mods[i]; i++) {
  405. if (mods[i]->mod_op & LDAP_MOD_REPLACE ) {
  406. /* Check if the server needs to be restarted */
  407. for (j = 0; j < num_requires_restart; j++)
  408. {
  409. p = strchr (requires_restart[j], ':');
  410. if (p == NULL)
  411. continue;
  412. while ( *(++p) == ' ' || *p == '\t' );
  413. if ( strcasecmp (p, mods[i]->mod_type) == 0 ) {
  414. PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
  415. "The change of %s will not take effect "
  416. "until the server is restarted", mods[i]->mod_type);
  417. slapi_log_error (SLAPI_LOG_FATAL, NULL, "%s\n", returntext);
  418. break;
  419. }
  420. }
  421. if (j < num_requires_restart) {
  422. /* That's enough, don't check remaining mods any more */
  423. break;
  424. }
  425. }
  426. }
  427. *returncode = LDAP_SUCCESS;
  428. return *returncode;
  429. }
  430. static int
  431. check_all_maxdiskspace_and_mlogsize(Slapi_PBlock *pb, LDAPMod **mods, char *returntext)
  432. {
  433. int i = 0;
  434. int rc = LDAP_SUCCESS;
  435. int errormaxdiskspace = -1;
  436. int errormlogsize = -1;
  437. int accessmaxdiskspace = -1;
  438. int accessmlogsize = -1;
  439. int auditmaxdiskspace = -1;
  440. int auditmlogsize = -1;
  441. for (i = 0; mods[i] ; i++)
  442. {
  443. get_log_max_size(mods[i],
  444. CONFIG_ERRORLOG_MAXLOGDISKSPACE_ATTRIBUTE,
  445. CONFIG_ERRORLOG_MAXLOGSIZE_ATTRIBUTE,
  446. &errormaxdiskspace,
  447. &errormlogsize);
  448. get_log_max_size(mods[i],
  449. CONFIG_ACCESSLOG_MAXLOGDISKSPACE_ATTRIBUTE,
  450. CONFIG_ACCESSLOG_MAXLOGSIZE_ATTRIBUTE,
  451. &accessmaxdiskspace,
  452. &accessmlogsize);
  453. get_log_max_size(mods[i],
  454. CONFIG_AUDITLOG_MAXLOGDISKSPACE_ATTRIBUTE,
  455. CONFIG_AUDITLOG_MAXLOGSIZE_ATTRIBUTE,
  456. &auditmaxdiskspace,
  457. &auditmlogsize);
  458. }
  459. if ( (rc=check_log_max_size(
  460. CONFIG_ERRORLOG_MAXLOGDISKSPACE_ATTRIBUTE,
  461. CONFIG_ERRORLOG_MAXLOGSIZE_ATTRIBUTE,
  462. errormaxdiskspace,
  463. errormlogsize,
  464. returntext,
  465. SLAPD_ERROR_LOG)) != LDAP_SUCCESS )
  466. {
  467. return rc;
  468. }
  469. if ( (rc=check_log_max_size(
  470. CONFIG_ACCESSLOG_MAXLOGDISKSPACE_ATTRIBUTE,
  471. CONFIG_ACCESSLOG_MAXLOGSIZE_ATTRIBUTE,
  472. accessmaxdiskspace,
  473. accessmlogsize,
  474. returntext,
  475. SLAPD_ACCESS_LOG)) != LDAP_SUCCESS )
  476. {
  477. return rc;
  478. }
  479. if ( (rc=check_log_max_size(
  480. CONFIG_AUDITLOG_MAXLOGDISKSPACE_ATTRIBUTE,
  481. CONFIG_AUDITLOG_MAXLOGSIZE_ATTRIBUTE,
  482. auditmaxdiskspace,
  483. auditmlogsize,
  484. returntext,
  485. SLAPD_AUDIT_LOG)) != LDAP_SUCCESS )
  486. {
  487. return rc;
  488. }
  489. return rc;
  490. }
  491. static void
  492. get_log_max_size( LDAPMod *mod,
  493. char *maxdiskspace_str,
  494. char *mlogsize_str,
  495. int *maxdiskspace,
  496. int *mlogsize)
  497. {
  498. if ( mod->mod_bvalues != NULL &&
  499. (strcasecmp( mod->mod_type, maxdiskspace_str ) == 0) )
  500. {
  501. *maxdiskspace = atoi((char *) mod->mod_bvalues[0]->bv_val);
  502. }
  503. if ( mod->mod_bvalues != NULL &&
  504. (strcasecmp( mod->mod_type, mlogsize_str ) == 0) )
  505. {
  506. *mlogsize = atoi((char *) mod->mod_bvalues[0]->bv_val);
  507. }
  508. }