Nmap Development mailing list archives
Re: Locking a mutex by name?
From: "Patrick Donnelly" <batrick.donnelly () gmail com>
Date: Thu, 13 Nov 2008 21:30:18 -0700
Hi Ron, On Thu, Nov 13, 2008 at 8:17 PM, Ron <ron () skullsecurity net> wrote:
Hey, I've been trying to use mutexes to stop SMB from breaking itself, but, after some further research, I don't think I'm doing it right. I suspect I know how to fix it, but I want to make sure I'm fixing it the right way. The issue is that a single Windows server can't handle multiple SMB connections from the same person at the same time. If a second person connects from the same IP, the first gets kicked off. The most logical way to fix that is to use a mutex. What I initially tried to do was lock a mutex based on the name of the server, basically: local mutex = nmap.mutex("SMB" .. server_name) Unfortunately, I don't think that works the way I expected it to, since the nmap.mutex() function expects an object, and multiplexes on that object. I don't think two instances of that string, especially in different scripts being run, will result in the same object, so it falls apart.
This should work. Strings in Lua are immutable and interned. As long as the string is the same in both threads (instances) of the script, then the mutex function should be the same. I suggest you assert this is true by checking the function pointer using a simple print statement.
My thought is to store the mutexable objects in the nmap registry, in a table based on the name. That would give the different scritps access to the same actual object. Is that the best way of handling this situation, or is there a better way I can do it?
What you are doing is the expected use. Storing the mutexes in the registry should not be necessary.
Thanks! Ron
Cheers, -- -Patrick Donnelly "One of the lessons of history is that nothing is often a good thing to do and always a clever thing to say." -Will Durant _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- Locking a mutex by name? Ron (Nov 13)
- Re: Locking a mutex by name? Patrick Donnelly (Nov 13)
- Re: Locking a mutex by name? Ron (Nov 14)
- Re: Locking a mutex by name? Patrick Donnelly (Nov 14)
- Re: Locking a mutex by name? Ron (Nov 14)
- Re: Locking a mutex by name? Patrick Donnelly (Nov 14)
- Re: Locking a mutex by name? Ron (Nov 14)
- Re: Locking a mutex by name? Patrick Donnelly (Nov 14)
- Re: Locking a mutex by name? Ron (Nov 14)
- Re: Locking a mutex by name? Kris Katterjohn (Nov 14)
- Re: Locking a mutex by name? Patrick Donnelly (Nov 14)
- Re: Locking a mutex by name? Ron (Nov 15)
- Re: Locking a mutex by name? Ron (Nov 14)
- Re: Locking a mutex by name? Patrick Donnelly (Nov 13)