rebus / rpms / samba

Forked from rpms/samba 3 years ago
Clone
ssorce af8bfa3
=== modified file 'source/smbd/notify_inotify.c'
9276a57
--- source3/smbd/notify_inotify.c	2007-03-09 12:07:58 +0000
9276a57
+++ source3/smbd/notify_inotify.c	2007-04-10 16:27:47 +0000
ssorce af8bfa3
@@ -66,6 +66,7 @@
ssorce af8bfa3
 	struct sys_notify_context *ctx;
ssorce af8bfa3
 	int fd;
ssorce af8bfa3
 	struct inotify_watch_context *watches;
59e2830
+	bool broken_inotify;	/* Late stop for broken system */
ssorce af8bfa3
 };
ssorce af8bfa3
 
ssorce af8bfa3
 struct inotify_watch_context {
ssorce af8bfa3
@@ -229,8 +230,16 @@
ssorce af8bfa3
 	  filenames, and thus can't know how much to allocate
ssorce af8bfa3
 	  otherwise
ssorce af8bfa3
 	*/
ssorce af8bfa3
-	if (ioctl(in->fd, FIONREAD, &bufsize) != 0 || 
ssorce af8bfa3
-	    bufsize == 0) {
ssorce af8bfa3
+
ssorce af8bfa3
+	if ((ioctl(in->fd, FIONREAD, &bufsize) != 0) && (errno == EACCES)) {
ssorce af8bfa3
+		/*
59e2830
+		 * Workaround for broken system (SELinux policy bug fixed since long but it is always better not to loop on EACCES)
ssorce af8bfa3
+		 */
ssorce af8bfa3
+		TALLOC_FREE(fde);
ssorce af8bfa3
+		in->broken_inotify = True;
ssorce af8bfa3
+		return;
ssorce af8bfa3
+	}
ssorce af8bfa3
+	if (bufsize == 0) {
ssorce af8bfa3
 		DEBUG(0,("No data on inotify fd?!\n"));
ssorce af8bfa3
 		return;
ssorce af8bfa3
 	}
ssorce af8bfa3
@@ -281,6 +290,7 @@
ssorce af8bfa3
 	}
ssorce af8bfa3
 	in->ctx = ctx;
ssorce af8bfa3
 	in->watches = NULL;
ssorce af8bfa3
+	in->broken_inotify = False;
ssorce af8bfa3
 
ssorce af8bfa3
 	ctx->private_data = in;
ssorce af8bfa3
 	talloc_set_destructor(in, inotify_destructor);
ssorce af8bfa3
@@ -375,6 +385,10 @@
ssorce af8bfa3
 
ssorce af8bfa3
 	in = talloc_get_type(ctx->private_data, struct inotify_private);
ssorce af8bfa3
 
ssorce af8bfa3
+	if (in->broken_inotify) {
ssorce af8bfa3
+		return NT_STATUS_OK;
ssorce af8bfa3
+	}
ssorce af8bfa3
+
ssorce af8bfa3
 	mask = inotify_map(e);
ssorce af8bfa3
 	if (mask == 0) {
ssorce af8bfa3
 		/* this filter can't be handled by inotify */
ssorce af8bfa3