rpms/shadow-utils/devel shadow-4.0.18.1-mtime.patch, NONE, 1.1 shadow-utils.spec, 1.105, 1.106

Peter Vrabec (pvrabec) fedora-extras-commits at redhat.com
Thu Oct 18 10:39:09 UTC 2007


Author: pvrabec

Update of /cvs/extras/rpms/shadow-utils/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv25616

Modified Files:
	shadow-utils.spec 
Added Files:
	shadow-4.0.18.1-mtime.patch 
Log Message:
fix timestamps when moving home dirs to another file system (#278571)


shadow-4.0.18.1-mtime.patch:

--- NEW FILE shadow-4.0.18.1-mtime.patch ---
diff -up shadow-4.0.18.1/libmisc/copydir.c.utime shadow-4.0.18.1/libmisc/copydir.c
--- shadow-4.0.18.1/libmisc/copydir.c.utime	2007-10-16 11:36:54.000000000 +0200
+++ shadow-4.0.18.1/libmisc/copydir.c	2007-10-18 11:59:22.000000000 +0200
@@ -33,6 +33,7 @@
 
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/time.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include "prototypes.h"
@@ -154,6 +155,7 @@ int copy_tree (const char *src_root, con
 	struct DIRECT *ent;
 	struct stat sb;
 	struct link_name *lp;
+	struct timeval mt[2];
 	DIR *dir;
 
 	/*
@@ -215,6 +217,18 @@ int copy_tree (const char *src_root, con
 		if (LSTAT (src_name, &sb) == -1)
 			continue;
 
+#if  defined(_BSD_SOURCE) || defined(_SVID_SOURCE)
+		mt[0].tv_sec  = sb.st_atim.tv_sec;
+		mt[0].tv_usec = sb.st_atim.tv_nsec / 1000;
+		mt[1].tv_sec  = sb.st_mtim.tv_sec;
+		mt[1].tv_usec = sb.st_mtim.tv_nsec / 1000;
+#else
+                mt[0].tv_sec  = sb.st_atime;
+                mt[0].tv_usec = sb.st_atimensec / 1000;
+                mt[1].tv_sec  = sb.st_mtime;
+                mt[1].tv_usec = sb.st_mtimensec / 1000;
+#endif
+		
 		if (S_ISDIR (sb.st_mode)) {
 
 			/*
@@ -230,10 +244,12 @@ int copy_tree (const char *src_root, con
 				      uid == (uid_t) - 1 ? sb.st_uid : uid,
 				      gid == (gid_t) - 1 ? sb.st_gid : gid)
 			    || chmod (dst_name, sb.st_mode)
-			    || copy_tree (src_name, dst_name, uid, gid)) {
+			    || copy_tree (src_name, dst_name, uid, gid)
+			    || utimes (dst_name, mt)) {
 				err++;
 				break;
 			}
+
 			continue;
 		}
 #ifdef	S_IFLNK
@@ -270,13 +286,21 @@ int copy_tree (const char *src_root, con
 #ifdef WITH_SELINUX
 			selinux_file_context (dst_name);
 #endif
-			if (symlink (oldlink, dst_name) ||
-			    lchown (dst_name,
+			if (symlink (oldlink, dst_name)
+			    || lchown (dst_name,
 				    uid == (uid_t) - 1 ? sb.st_uid : uid,
 				    gid == (gid_t) - 1 ? sb.st_gid : gid)) {
 				err++;
 				break;
 			}
+
+			/* 2007-10-18: We don't care about 
+			 *  exit status of lutimes because
+			 *  it returns ENOSYS on many system
+			 *  - not implemented
+			 */
+			lutimes (dst_name, mt);
+
 			continue;
 		}
 #endif
@@ -314,10 +338,12 @@ int copy_tree (const char *src_root, con
 			    || chown (dst_name,
 				      uid == (uid_t) - 1 ? sb.st_uid : uid,
 				      gid == (gid_t) - 1 ? sb.st_gid : gid)
-			    || chmod (dst_name, sb.st_mode & 07777)) {
+			    || chmod (dst_name, sb.st_mode & 07777)
+			    || utimes (dst_name, mt)) {
 				err++;
 				break;
 			}
+			
 			continue;
 		}
 
@@ -343,14 +369,25 @@ int copy_tree (const char *src_root, con
 			err++;
 			break;
 		}
+
 		while ((cnt = read (ifd, buf, sizeof buf)) > 0) {
 			if (write (ofd, buf, cnt) != cnt) {
 				cnt = -1;
 				break;
 			}
 		}
+
 		close (ifd);
-		close (ofd);
+		
+		if (futimes (ofd, mt) != 0) {
+		  err++;
+		  break;
+		}
+		
+		if (close (ofd) != 0) {
+		  err++;
+		  break;
+		}
 
 		if (cnt == -1) {
 			err++;


Index: shadow-utils.spec
===================================================================
RCS file: /cvs/extras/rpms/shadow-utils/devel/shadow-utils.spec,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -r1.105 -r1.106
--- shadow-utils.spec	8 Oct 2007 17:46:20 -0000	1.105
+++ shadow-utils.spec	18 Oct 2007 10:38:36 -0000	1.106
@@ -5,7 +5,7 @@
 Summary: Utilities for managing accounts and shadow password files
 Name: shadow-utils
 Version: 4.0.18.1
-Release: 18%{?dist}
+Release: 19%{?dist}
 Epoch: 2
 URL: http://shadow.pld.org.pl/
 Source0: ftp://ftp.pld.org.pl/software/shadow/shadow-%{version}.tar.bz2
@@ -28,6 +28,7 @@
 Patch13: shadow-4.0.18.1-sysAccount.patch
 Patch14: shadow-4.0.18.1-findNewUidOnce.patch
 Patch15: shadow-4.0.18.1-groupLoop.patch
+Patch16: shadow-4.0.18.1-mtime.patch
 
 License: BSD
 Group: System Environment/Base
@@ -72,6 +73,7 @@
 %patch13 -p1 -b .sysAccount
 %patch14 -p1 -b .findNewUidOnce
 %patch15 -p1 -b .groupLoop
+%patch16 -p1 -b .mtime
 
 rm po/*.gmo
 rm po/stamp-po
@@ -213,6 +215,9 @@
 %{_mandir}/man8/faillog.8*
 
 %changelog
+* Thu Oct 18 2007 Peter Vrabec <pvrabec at redhat.com> 2:4.0.18.1-19
+- fix timestamps when moving home dirs to another file system (#278571)
+
 * Mon Oct 08 2007 Peter Vrabec <pvrabec at redhat.com> 2:4.0.18.1-18
 - mark localized man pages with %%lang
 




More information about the fedora-extras-commits mailing list