configdse.c 18 KB

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