restorecond: avoid busy-loop when watch list is empty
Stephen Smalley
maintainerPATCH 1/1 restorecond: avoid busy-loop when watch list is empty
If nothing in the original config exists or every inotify_add_watch() fails for some other reason, firstDir will be NULL, watch() will return 0, and main() will busy-loop. Just fall through to blocking on the read() on the inotify fd, which correctly will wait until the config or utmp is updated and further watches are added.
--- restorecond/watch.c | 2 -- 1 file changed, 2 deletions(-)
restorecond/watch.c +0 -2
@@ -313,8 +313,6 @@ int watch(int fd, const char *watch_file) {char buf[BUF_LEN ];int len, i =0 ; -if (firstDir ==NULL ) -return 0 ; len =read (fd, buf,BUF_LEN );if (len <0 ) {
Signature · 1 line
2.54.0
Quoted 8 lines · Stephen Smalley
If nothing in the original config exists or every
inotify_add_watch()fails for some other reason, firstDir will be NULL,watch()will return 0, andmain()will busy-loop. Just fall through to blocking on theread()on the inotify fd, which correctly will wait until the config or utmp is updated and further watches are added.Signed-off-by Stephen Smalley <[email protected]>
Quoted 20 lines
--- restorecond/watch.c | 2 -- 1 file changed, 2 deletions(-)restorecond/watch.c +0
-3@@ -313,8 +313,6 @@ int watch(int fd, const char *watch_file) {char buf[BUF_LEN ];int len, i =0 ; -if (firstDir ==NULL ) -return 0 ; len =read (fd, buf,BUF_LEN );if (len <0 ) { --2.54.0
Stephen Smalley
maintainerQuoted 10 lines · James Carter
Quoted 7 lines · Stephen Smalley
If nothing in the original config exists or every
inotify_add_watch()fails for some other reason, firstDir will be NULL,watch()will return 0, andmain()will busy-loop. Just fall through to blocking on theread()on the inotify fd, which correctly will wait until the config or utmp is updated and further watches are added.
Quoted 3 lines
Quoted 1 line
Signed-off-by Stephen Smalley <[email protected]>Acked-by James Carter <[email protected]>
Merged.
Quoted 21 lines
Quoted 21 lines
--- restorecond/watch.c | 2 -- 1 file changed, 2 deletions(-)restorecond/watch.c +0
-3@@ -313,8 +313,6 @@ int watch(int fd, const char *watch_file) {char buf[BUF_LEN ];int len, i =0 ; -if (firstDir ==NULL ) -return 0 ; len =read (fd, buf,BUF_LEN );if (len <0 ) { --2.54.0