Репозитории ALT
S: | 3.20.1-alt2 |
5.1: | 3.7.9-alt0.M51.1 |
4.1: | 3.6.2-alt4 |
4.0: | 3.6.2-alt4 |
3.0: | 3.6.2-alt3 |
Группа :: Работа с файлами
Пакет: logrotate
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: logrotate-3.6.2-alt-owl-fchmod-fchown-race.patch
Скачать
Скачать
diff -ur logrotate-3.6.2~/logrotate.c logrotate-3.6.2/logrotate.c
--- logrotate-3.6.2~/logrotate.c Sat Mar 23 23:22:17 2002
+++ logrotate-3.6.2/logrotate.c Sat Mar 23 23:24:24 2002
@@ -139,13 +139,13 @@
return 1;
}
if ((fdsave = open(saveLog, O_WRONLY | O_CREAT | O_TRUNC,
- sb->st_mode)) < 0) {
+ (S_IRUSR | S_IWUSR) & sb->st_mode)) < 0) {
message(MESS_ERROR, "error creating %s: %s\n", saveLog,
strerror(errno));
close(fdcurr);
return 1;
}
- if (fchmod(fdsave, sb->st_mode)) {
+ if (fchmod(fdsave, (S_IRUSR | S_IWUSR) & sb->st_mode)) {
message(MESS_ERROR, "error setting mode of %s: %s\n",
saveLog, strerror(errno));
close(fdcurr);
@@ -159,6 +159,13 @@
close(fdsave);
return 1;
}
+ if (fchmod(fdsave, sb->st_mode)) {
+ message(MESS_ERROR, "error setting mode of %s: %s\n",
+ saveLog, strerror(errno));
+ close(fdcurr);
+ close(fdsave);
+ return 1;
+ }
while ((cnt = read(fdcurr, buf, sizeof(buf))) > 0) {
if (write(fdsave, buf, cnt) != cnt) {
message(MESS_ERROR, "error writing to %s: %s\n",
@@ -459,13 +466,13 @@
"gid = %d\n", createMode, createUid, createGid);
if (!debug) {
- fd = open(log->files[logNum], O_CREAT | O_RDWR, createMode);
+ fd = open(log->files[logNum], O_CREAT | O_RDWR, (S_IRUSR | S_IWUSR) & createMode);
if (fd < 0) {
message(MESS_ERROR, "error creating %s: %s\n",
log->files[logNum], strerror(errno));
hasErrors = 1;
} else {
- if (fchmod(fd, createMode)) {
+ if (fchmod(fd, (S_IRUSR | S_IWUSR) & createMode)) {
message(MESS_ERROR, "error setting mode of "
"%s: %s\n", log->files[logNum],
strerror(errno));
@@ -477,6 +484,12 @@
strerror(errno));
hasErrors = 1;
}
+ if (fchmod(fd, createMode)) {
+ message(MESS_ERROR, "error setting mode of "
+ "%s: %s\n", log->files[logNum],
+ strerror(errno));
+ hasErrors = 1;
+ }
close(fd);
}