[SCM] Samba Shared Repository - branch v3-devel updated -
release-3-2-0pre2-3827-g737f664
Michael Adam
obnox at samba.org
Tue Aug 26 13:06:01 GMT 2008
The branch, v3-devel has been updated
via 737f664604b28f230be63bfc2f3d516fd9eb1c63 (commit)
via c548e5c69f9d8bc85a654f4d29d64c735a5e780b (commit)
via 56c5a6f024875bb79b0104beb36f6b0ec1e1e9f9 (commit)
via 5ccdc58ce91ee40ca7171dd040191291aeb7fe02 (commit)
via 794e48b809036871287df8416a2c669b7e26f216 (commit)
from d31683cdc877b468e7443216ab9e6edff844c131 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-devel
- Log -----------------------------------------------------------------
commit 737f664604b28f230be63bfc2f3d516fd9eb1c63
Author: Andrew Tridgell <tridge at samba.org>
Date: Tue Aug 26 14:06:42 2008 +1000
EINVAL is also a valid error return, meaning "this filesystem
cannot do sendfile for this file"
commit c548e5c69f9d8bc85a654f4d29d64c735a5e780b
Author: Andrew Tridgell <tridge at samba.org>
Date: Sun Aug 24 13:58:05 2008 +1000
become root for AIO operations
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
commit 56c5a6f024875bb79b0104beb36f6b0ec1e1e9f9
Author: Andrew Tridgell <tridge at samba.org>
Date: Sun Aug 24 13:56:59 2008 +1000
Avoid a race condition in glibc between AIO and setresuid().
See this test: http://samba.org/~tridge/junkcode/aio_uid.c
The problem is that setresuid() tries to be clever about threads, and
tries to change the euid of any threads that are running. If a AIO read
or write completes while this is going on then the signal from the thread
where the IO completed is lost, as it gets -1/EPERM from rt_sigqueueinfo()
The simplest fix is to try to use setreuid() instead of setresuid(),
as setreuid() doesn't try to be clever. Unfortunately this also means
we must use become_root()/unbecome_root() in the aio code.
commit 5ccdc58ce91ee40ca7171dd040191291aeb7fe02
Author: Andrew Tridgell <tridge at samba.org>
Date: Sun Aug 24 13:53:19 2008 +1000
fixed an errno handling bug that could lead to an infinite loop
commit 794e48b809036871287df8416a2c669b7e26f216
Author: Andrew Tridgell <tridge at samba.org>
Date: Sat Aug 23 11:36:27 2008 +1000
fixed tsmsm_sendfile(). The logic was totally broken.
-----------------------------------------------------------------------
Summary of changes:
source/configure.in | 24 +++++++++++++-----------
source/modules/vfs_tsmsm.c | 15 +++++++++------
source/smbd/aio.c | 8 +++++++-
source/smbd/reply.c | 5 +++--
4 files changed, 32 insertions(+), 20 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/configure.in b/source/configure.in
index 5508d9b..9436fed 100644
--- a/source/configure.in
+++ b/source/configure.in
@@ -2627,30 +2627,32 @@ AC_CHECK_FUNCS(getpagesize)
################################################
# look for a method of setting the effective uid
seteuid=no;
+
if test $seteuid = no; then
-AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
+AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
AC_TRY_RUN([
#define AUTOCONF_TEST 1
-#define USE_SETRESUID 1
+#define USE_SETREUID 1
#include "confdefs.h"
#include "${srcdir-.}/lib/util_sec.c"],
- samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
-if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
- seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
+ samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
+if test x"$samba_cv_USE_SETREUID" = x"yes"; then
+ seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
fi
fi
-
+# we check for setresuid second as it conflicts with AIO on Linux.
+# see http://samba.org/~tridge/junkcode/aio_uid.c
if test $seteuid = no; then
-AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
+AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
AC_TRY_RUN([
#define AUTOCONF_TEST 1
-#define USE_SETREUID 1
+#define USE_SETRESUID 1
#include "confdefs.h"
#include "${srcdir-.}/lib/util_sec.c"],
- samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
-if test x"$samba_cv_USE_SETREUID" = x"yes"; then
- seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
+ samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
+if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
+ seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
fi
fi
diff --git a/source/modules/vfs_tsmsm.c b/source/modules/vfs_tsmsm.c
index 4a732bc..ee958b1 100644
--- a/source/modules/vfs_tsmsm.c
+++ b/source/modules/vfs_tsmsm.c
@@ -200,9 +200,9 @@ static bool tsmsm_is_offline(struct vfs_handle_struct *handle,
goto done;
}
- lerrno = 0;
-
do {
+ lerrno = 0;
+
ret = dm_get_dmattr(*dmsession_id, dmhandle, dmhandle_len,
DM_NO_TOKEN, &dmname, buflen, buf, &rlen);
if (ret == -1 && errno == EINVAL) {
@@ -279,10 +279,13 @@ static ssize_t tsmsm_aio_return(struct vfs_handle_struct *handle, struct files_s
static ssize_t tsmsm_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fsp, const DATA_BLOB *hdr,
SMB_OFF_T offset, size_t n)
{
- bool file_online = tsmsm_aio_force(handle, fsp);
+ bool file_offline = tsmsm_aio_force(handle, fsp);
- if(!file_online)
- return ENOSYS;
+ if (file_offline) {
+ DEBUG(10,("tsmsm_sendfile on offline file - rejecting\n"));
+ errno = ENOSYS;
+ return -1;
+ }
return SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, hdr, offset, n);
}
@@ -333,7 +336,7 @@ static int tsmsm_set_offline(struct vfs_handle_struct *handle,
if (tsmd->hsmscript == NULL) {
/* no script enabled */
- DEBUG(1, ("tsmsm_set_offline: No tsmsm:hsmscript configured\n"));
+ DEBUG(1, ("tsmsm_set_offline: No 'tsmsm:hsm script' configured\n"));
return 0;
}
diff --git a/source/smbd/aio.c b/source/smbd/aio.c
index 2889e3c..7427536 100644
--- a/source/smbd/aio.c
+++ b/source/smbd/aio.c
@@ -268,12 +268,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",
@@ -366,13 +369,16 @@ 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();
+
release_level_2_oplocks_on_change(fsp);
if (!write_through && !lp_syncalways(SNUM(fsp->conn))
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index b3d691f..06aa835 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -3198,8 +3198,9 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
setup_readX_header((char *)headerbuf, smb_maxcnt);
if ((nread = SMB_VFS_SENDFILE(smbd_server_fd(), fsp, &header, startpos, smb_maxcnt)) == -1) {
- /* Returning ENOSYS means no data at all was sent. Do this as a normal read. */
- if (errno == ENOSYS) {
+ /* Returning ENOSYS or EINVAL means no data at all was sent.
+ Do this as a normal read. */
+ if (errno == ENOSYS || errno == EINVAL) {
goto normal_read;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list