version 1.39, 2003/07/18 20:46:42 |
version 1.40, 2003/07/25 20:10:53 |
|
|
} |
} |
|
|
if (!nosave) { |
if (!nosave) { |
sb->st_mtimespec.tv_sec = info.mtime; |
if (info.mtime != 0) { |
sb->st_mtimespec.tv_nsec = 0; |
sb->st_mtimespec.tv_sec = |
|
sb->st_atimespec.tv_sec = info.mtime; |
|
sb->st_mtimespec.tv_nsec = |
|
sb->st_atimespec.tv_nsec = 0; |
|
} else |
|
nosave = 1; /* no timestamp to restore */ |
|
|
|
if (cat && strcmp(out, "/dev/stdout") != 0) |
|
cat = 0; /* have a real output name */ |
} |
} |
|
|
if (ofd != -1 && close(ofd)) { |
if (ofd != -1 && close(ofd)) { |
|
|
{ |
{ |
struct timeval tv[2]; |
struct timeval tv[2]; |
|
|
fs->st_mode &= S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO; |
if (!pipin || !nosave) { |
|
TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atimespec); |
|
TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtimespec); |
|
if (utimes(name, tv)) |
|
warn("utimes: %s", name); |
|
} |
|
|
TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atimespec); |
/* |
TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtimespec); |
* If input was a pipe we don't have any info to restore but we |
if (utimes(name, tv)) |
* must set the mode since the current mode on the file is 0200. |
warn("utimes: %s", name); |
*/ |
|
if (pipin) { |
|
mode_t mask = umask(022); |
|
chmod(name, DEFFILEMODE & ~mask); |
|
umask(mask); |
|
return; |
|
} |
|
|
/* |
/* |
* Changing the ownership probably won't succeed, unless we're root |
* Changing the ownership probably won't succeed, unless we're root |
|
|
* the mode; current BSD behavior is to remove all setuid bits on |
* the mode; current BSD behavior is to remove all setuid bits on |
* chown. If chown fails, lose setuid/setgid bits. |
* chown. If chown fails, lose setuid/setgid bits. |
*/ |
*/ |
|
fs->st_mode &= S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO; |
if (chown(name, fs->st_uid, fs->st_gid)) { |
if (chown(name, fs->st_uid, fs->st_gid)) { |
if (errno != EPERM) |
if (errno != EPERM) |
warn("chown: %s", name); |
warn("chown: %s", name); |