Merge RedHat's patch shadow-4.0.18.1-mtime.patch:
* NEWS: Document that usermod will now preserve user's file modification and access time. * libmisc/copydir.c: Preserve the access and modification time of copied files. This is important for usermod. This will also impact useradd, for the skeleton files, but this is not important. * libmisc/copydir.c: Stop and return an error if a file could not be closed after during a copy.
This commit is contained in:
parent
3935d32676
commit
65d0682647
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
2007-12-26 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
Merge RedHat's patch shadow-4.0.18.1-mtime.patch:
|
||||||
|
* NEWS: Document that usermod will now preserve user's file modification
|
||||||
|
and access time.
|
||||||
|
* libmisc/copydir.c: Preserve the access and modification time of copied
|
||||||
|
files. This is important for usermod. This will also impact useradd, for
|
||||||
|
the skeleton files, but this is not important.
|
||||||
|
* libmisc/copydir.c: Stop and return an error if a file could not be
|
||||||
|
closed after during a copy.
|
||||||
|
|
||||||
2007-12-26 Nicolas François <nicolas.francois@centraliens.net>
|
2007-12-26 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
Cleanups:
|
Cleanups:
|
||||||
|
3
NEWS
3
NEWS
@ -7,6 +7,9 @@ shadow-4.1.0 -> shadow-4.1.1 UNRELEASED
|
|||||||
* Do not install the shadow library per default.
|
* Do not install the shadow library per default.
|
||||||
- useradd
|
- useradd
|
||||||
* New option -l to avoid adding the user to the lastlog and faillog databases.
|
* New option -l to avoid adding the user to the lastlog and faillog databases.
|
||||||
|
- usermod
|
||||||
|
* Keep the access and modification time of files when moving an user's home
|
||||||
|
directory.
|
||||||
|
|
||||||
shadow-4.0.18.2 -> shadow-4.1.0 09-12-2008
|
shadow-4.0.18.2 -> shadow-4.1.0 09-12-2008
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/time.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
@ -154,6 +155,7 @@ int copy_tree (const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
|||||||
struct DIRECT *ent;
|
struct DIRECT *ent;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
struct link_name *lp;
|
struct link_name *lp;
|
||||||
|
struct timeval mt[2];
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -215,6 +217,18 @@ int copy_tree (const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
|||||||
if (LSTAT (src_name, &sb) == -1)
|
if (LSTAT (src_name, &sb) == -1)
|
||||||
continue;
|
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)) {
|
if (S_ISDIR (sb.st_mode)) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -230,10 +244,12 @@ int copy_tree (const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
|||||||
uid == (uid_t) - 1 ? sb.st_uid : uid,
|
uid == (uid_t) - 1 ? sb.st_uid : uid,
|
||||||
gid == (gid_t) - 1 ? sb.st_gid : gid)
|
gid == (gid_t) - 1 ? sb.st_gid : gid)
|
||||||
|| chmod (dst_name, sb.st_mode)
|
|| 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++;
|
err++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#ifdef S_IFLNK
|
#ifdef S_IFLNK
|
||||||
@ -270,13 +286,21 @@ int copy_tree (const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
|||||||
#ifdef WITH_SELINUX
|
#ifdef WITH_SELINUX
|
||||||
selinux_file_context (dst_name);
|
selinux_file_context (dst_name);
|
||||||
#endif
|
#endif
|
||||||
if (symlink (oldlink, dst_name) ||
|
if (symlink (oldlink, dst_name)
|
||||||
lchown (dst_name,
|
|| lchown (dst_name,
|
||||||
uid == (uid_t) - 1 ? sb.st_uid : uid,
|
uid == (uid_t) - 1 ? sb.st_uid : uid,
|
||||||
gid == (gid_t) - 1 ? sb.st_gid : gid)) {
|
gid == (gid_t) - 1 ? sb.st_gid : gid)) {
|
||||||
err++;
|
err++;
|
||||||
break;
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -314,10 +338,12 @@ int copy_tree (const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
|||||||
|| chown (dst_name,
|
|| chown (dst_name,
|
||||||
uid == (uid_t) - 1 ? sb.st_uid : uid,
|
uid == (uid_t) - 1 ? sb.st_uid : uid,
|
||||||
gid == (gid_t) - 1 ? sb.st_gid : gid)
|
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++;
|
err++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,14 +369,25 @@ int copy_tree (const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
|||||||
err++;
|
err++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((cnt = read (ifd, buf, sizeof buf)) > 0) {
|
while ((cnt = read (ifd, buf, sizeof buf)) > 0) {
|
||||||
if (write (ofd, buf, cnt) != cnt) {
|
if (write (ofd, buf, cnt) != cnt) {
|
||||||
cnt = -1;
|
cnt = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close (ifd);
|
close (ifd);
|
||||||
close (ofd);
|
|
||||||
|
if (futimes (ofd, mt) != 0) {
|
||||||
|
err++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (close (ofd) != 0) {
|
||||||
|
err++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (cnt == -1) {
|
if (cnt == -1) {
|
||||||
err++;
|
err++;
|
||||||
|
Loading…
Reference in New Issue
Block a user