From dc36d8768aa13000c48b520f09f6678ea9ffbf28 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 24 Sep 1998 22:33:13 +0000 Subject: Integration of Anders Blomdell 's smbpasswd changes. Not exactly the same as his code - several changes. Jeremy. (This used to be commit e96747a8e3b9ea5a79c4258e55d7e8f3bf0bf193) --- source3/smbd/oplock.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'source3/smbd') diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index d73fcda117..b418e7cd54 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -240,16 +240,47 @@ BOOL set_file_oplock(files_struct *fsp) { #if defined(HAVE_KERNEL_OPLOCKS) if(lp_kernel_oplocks()) { - if(fcntl(fsp->fd_ptr->fd, F_OPLKREG, oplock_pipe_write) < 0) { - if(errno != EAGAIN) { +#if 0 /* for now. */ + extern struct current_user current_user; +#endif + int saved_errno; + int fcntl_ret; + +#if 0 /* for now. */ + /* + * Go back to being root. + */ + + unbecome_user(); +#endif + + fcntl_ret = fcntl(fsp->fd_ptr->fd, F_OPLKREG, oplock_pipe_write); + saved_errno = errno; + +#if 0 /* for now. */ + /* + * Go back to being the correct user. + */ + if(!become_user(fsp->conn, current_user.vuid)) + { + DEBUG( 0, ( "set_file_oplock: unable to re-become user!" ) ); + DEBUGADD( 0, ( "Shutting down server\n" ) ); + close_sockets(); + close(oplock_sock); + exit_server("unable to re-become user"); + } +#endif + + if(fcntl_ret < 0) { + if(saved_errno != EAGAIN) { DEBUG(0,("set_file_oplock: Unable to get kernel oplock on file %s, dev = %x, \ inode = %.0f. Error was %s\n", fsp->fsp_name, (unsigned int)fsp->fd_ptr->dev, (double)fsp->fd_ptr->inode, strerror(errno) )); } else { - DEBUG(5,("set_file_oplock: Refused oplock on file %s, dev = %x, \ + DEBUG(5,("set_file_oplock: Refused oplock on file %s, fd = %d, dev = %x, \ inode = %.0f. Another process had the file open.\n", - fsp->fsp_name, (unsigned int)fsp->fd_ptr->dev, (double)fsp->fd_ptr->inode )); + fsp->fsp_name, fsp->fd_ptr->fd, (unsigned int)fsp->fd_ptr->dev, (double)fsp->fd_ptr->inode )); } return False; } -- cgit