become root for AIO operations
authorAndrew Tridgell <tridge@samba.org>
Tue, 26 Aug 2008 16:59:54 +0000 (09:59 -0700)
committerKarolin Seeger <kseeger@samba.org>
Mon, 12 Jan 2009 09:11:48 +0000 (10:11 +0100)
We need to become root for AIO read and write to allow the AIO thread
to send a completion signal to the parent process when the IO
completes
(cherry picked from commit 91dcce0e4deb87c6d5e491eb9dbb09fd04981d28)

source/smbd/aio.c

index 2559dc950574ee1cfac7f56c4ec8c592fc80c58a..21b6efb19865ffe05d6a90154d583be5d8d4eaf1 100644 (file)
@@ -253,12 +253,15 @@ BOOL schedule_aio_read_and_X(connection_struct *conn,
        a->aio_sigevent.sigev_signo  = RT_SIGNAL_AIO;
        a->aio_sigevent.sigev_value.sival_int = aio_ex->mid;
 
+       become_root();
        if (SMB_VFS_AIO_READ(fsp,a) == -1) {
                DEBUG(0,("schedule_aio_read_and_X: aio_read failed. "
                         "Error %s\n", strerror(errno) ));
                delete_aio_ex(aio_ex);
+               unbecome_root();
                return False;
        }
+       unbecome_root();
 
        DEBUG(10,("schedule_aio_read_and_X: scheduled aio_read for file %s, "
                  "offset %.0f, len = %u (mid = %u)\n",
@@ -343,12 +346,15 @@ BOOL schedule_aio_write_and_X(connection_struct *conn,
        a->aio_sigevent.sigev_signo  = RT_SIGNAL_AIO;
        a->aio_sigevent.sigev_value.sival_int = aio_ex->mid;
 
+       become_root();
        if (SMB_VFS_AIO_WRITE(fsp,a) == -1) {
                DEBUG(3,("schedule_aio_wrote_and_X: aio_write failed. "
                         "Error %s\n", strerror(errno) ));
                delete_aio_ex(aio_ex);
+               unbecome_root();
                return False;
        }
+       unbecome_root();
 
        if (!write_through && !lp_syncalways(SNUM(fsp->conn))
            && fsp->aio_write_behind) {