Skip to content

Commit

Permalink
* partly revert ccca64e
Browse files Browse the repository at this point in the history
* revert 45b834f
* revert e4c6ec9

The real fixes for the crash on log rotate were commited later on and this brought pretty bad behavior.
  • Loading branch information
HeisSpiter committed Dec 10, 2014
1 parent fac6acc commit 0ad9d24
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2014-12-10 Pierre Schweitzer <pierre@reactos.org>

* ForbidHosts.cpp: partly revert ccca64eee3c457ce91db2327df04d8e92a6824ee
* ForbidHosts.cpp: revert 45b834fbddcbf55e7e6bf874929e56ee36d6e122
* ForbidHosts.cpp: revert e4c6ec9de00c3fbf07ed3058410ed35b7f17b470

2014-12-05 Pierre Schweitzer <pierre@reactos.org>

* ForbidHosts.cpp: Always zero inotify_event len field to prevent attempts to read random len of data from inotify.
Expand Down
28 changes: 8 additions & 20 deletions ForbidHosts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,21 +462,13 @@ int main(int argc, char ** argv) {
exit(EXIT_FAILURE);
}

int iAuth = inotify_add_watch(iNotify, AuthLogFile, IN_MODIFY);
int iAuth = inotify_add_watch(iNotify, AuthLogFile,
IN_MODIFY | IN_MOVE_SELF | IN_DELETE_SELF);
if (iAuth < 0) {
close(iNotify);
close(AuthLog);
exit(EXIT_FAILURE);
}

// Also watch log dir to spot new auth.log
int iDir = inotify_add_watch(iNotify, AuthLogDir, IN_CREATE);
if (iDir < 0) {
inotify_rm_watch(iNotify, iAuth);
close(iNotify);
close(AuthLog);
exit(EXIT_FAILURE);
}
#endif

for (;;) {
Expand Down Expand Up @@ -514,14 +506,10 @@ int main(int argc, char ** argv) {
}

// Check the event
if (iEvent.Event.mask & IN_CREATE) {
// This happened in log dir
soft_assert(iEvent.Event.wd == iDir);

// Check we're dealing with our file
if (strncmp(iEvent.Event.name, AuthFileName, iEvent.Event.len - 1) != 0) {
continue;
}
if (iEvent.Event.mask & IN_MOVE_SELF ||
iEvent.Event.mask & IN_DELETE_SELF) {
// We got moved/deleted (likely log rotate)
soft_assert((iEvent.Event.mask & IN_MODIFY) != IN_MODIFY);

// Remove the file from watch list
inotify_rm_watch(iNotify, iAuth);
Expand All @@ -540,7 +528,8 @@ int main(int argc, char ** argv) {
lseek(AuthLog, 0, SEEK_END);

// Reinit watching
iAuth = inotify_add_watch(iNotify, AuthLogFile, IN_MODIFY);
iAuth = inotify_add_watch(iNotify, AuthLogFile,
IN_MODIFY | IN_MOVE_SELF | IN_DELETE_SELF);
if (iAuth < 0) {
syslog(LOG_ERR, "Failed to rewatch auth.log. Quitting.");
break;
Expand Down Expand Up @@ -571,7 +560,6 @@ int main(int argc, char ** argv) {
}

#ifndef WITHOUT_INOTIFY
inotify_rm_watch(iNotify, iDir);
inotify_rm_watch(iNotify, iAuth);
close(iNotify);
#endif
Expand Down

0 comments on commit 0ad9d24

Please sign in to comment.