[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm import-threads.c, 1.18, 1.19

Noriko Hosoi nhosoi at fedoraproject.org
Tue Nov 4 23:12:42 UTC 2008


Author: nhosoi

Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv28179

Modified Files:
	import-threads.c 
Log Message:
Resolves: #462922
Summary: Import of data does not record timestamps
Description: Added a static function import_add_created_attrs to add 
ModifiersName, CreateTimestamp, ModifyTimestamp to each imported entry.  I 
also added a check if nsslapd-lastmod is on or off.  It adds the created info 
only if the lastmod is on.



Index: import-threads.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/import-threads.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- import-threads.c	17 Oct 2008 16:54:47 -0000	1.18
+++ import-threads.c	4 Nov 2008 23:12:39 -0000	1.19
@@ -301,6 +301,47 @@
     return my_version;
 }
 
+/*
+ * add CreatorsName, ModifiersName, CreateTimestamp, ModifyTimestamp to entry
+ */
+static void
+import_add_created_attrs(Slapi_Entry *e)
+{
+    char          buf[20];
+    struct berval bv;
+    struct berval *bvals[2];
+    time_t        curtime;
+    struct tm     ltm;
+
+    bvals[0] = &bv;
+    bvals[1] = NULL;
+    
+    bv.bv_val = "";
+    bv.bv_len = 0;
+    slapi_entry_attr_replace(e, "creatorsname", bvals);
+    slapi_entry_attr_replace(e, "modifiersname", bvals);
+
+    curtime = current_time();
+#ifdef _WIN32
+{
+    struct tm *pt;
+    pt = gmtime(&curtime);
+    memcpy(&ltm, pt, sizeof(struct tm));
+}
+#else
+    gmtime_r(&curtime, &ltm);
+#endif
+    strftime(buf, sizeof(buf), "%Y%m%d%H%M%SZ", &ltm);
+
+    bv.bv_val = buf;
+    bv.bv_len = strlen(bv.bv_val);
+    slapi_entry_attr_replace(e, "createtimestamp", bvals);
+
+    bv.bv_val = buf;
+    bv.bv_len = strlen(bv.bv_val);
+    slapi_entry_attr_replace(e, "modifytimestamp", bvals);
+}
+
 /* producer thread:
  * read through the given file list, parsing entries (str2entry), assigning
  * them IDs and queueing them on the entry FIFO.  other threads will do
@@ -501,6 +542,9 @@
 
         /* generate uniqueid if necessary */
         import_generate_uniqueid(job, e);
+        if (g_get_global_lastmod()) {
+            import_add_created_attrs(e);
+        }
 
         ep = import_make_backentry(e, id);
         if (!ep)




More information about the Fedora-directory-commits mailing list