00001 /* 00002 Unix SMB/CIFS implementation. 00003 Authenticate against a remote domain 00004 Copyright (C) Andrew Tridgell 1992-2002 00005 Copyright (C) Andrew Bartlett 2002 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00020 */ 00021 00022 #include "includes.h" 00023 00024 /* For reasons known only to MS, many of their NT/Win2k versions 00025 need serialised access only. Two connections at the same time 00026 may (in certain situations) cause connections to be reset, 00027 or access to be denied. 00028 00029 This locking allows smbd's mutlithread architecture to look 00030 like the single-connection that NT makes. */ 00031 00032 static char *mutex_server_name; 00033 00034 BOOL grab_server_mutex(const char *name) 00035 { 00036 mutex_server_name = SMB_STRDUP(name); 00037 if (!mutex_server_name) { 00038 DEBUG(0,("grab_server_mutex: malloc failed for %s\n", name)); 00039 return False; 00040 } 00041 if (!secrets_named_mutex(mutex_server_name, 10)) { 00042 DEBUG(10,("grab_server_mutex: failed for %s\n", name)); 00043 SAFE_FREE(mutex_server_name); 00044 return False; 00045 } 00046 00047 return True; 00048 } 00049 00050 void release_server_mutex(void) 00051 { 00052 if (mutex_server_name) { 00053 secrets_named_mutex_release(mutex_server_name); 00054 SAFE_FREE(mutex_server_name); 00055 } 00056 }