I've had a client ask if it's possible to rename his server log file whilst the server is running but not allow deletion. This is harder than you'd expect to achieve. The established view of "the internet" is that NTFS doesn't support permissions to allow file renaming and still prevent file deletion. This is true. If you want to allow renaming you need to create or open the file with FILE_SHARE_DELETE
access and this allows rename AND delete. The reason for this is that a rename is actually a process of creating a copy of the file with a new name and then deleting the old file. I pointed this out to my client and he immediately responded with "I can rename a running exe but am prevented from deleting it.". This, of course, is true. Executable files can be renamed and not deleted if they are currently running.
The fact that executables can work this way gave me the hint I needed. I figured it's likely the fact that the file is mapped into memory that prevents the deletion...
Adding some code that uses CreateFileMapping()
to create a file mapping object from the log file's file handle, and then holding the file mapping open whilst we're using the log, gives the results that my client wants. A log file that can be renamed but not deleted. Note that you don't actually have to map the file mapping into memory, just hold the handle open.
Note that the file in question needs to contain at least one byte to be able to create the file mapping but that's easy to work around for us.
As of the latest Chrome, Edge, Opera, and FireFox updates all of my 'obsolete' hardware (routers, NAS drives, network switches, etc) are inaccessible as they don't use TLS 1.2. I'm unlikely to be alone in this. I can understand the technical decision but IMHO it's wrong and, actually pretty stupid. To make it more than a click through warning to access these obsolete devices on my local subnet. Sure ban connections to other subnets (that would cause me pain too as I manage some stuff via a VPN) but 90% of users would be fine.
So now we'll see a lot of "The client and server don't support a common SSL protocol version or cipher suite." or "This site can't provide a secure connection" errors when trying to access older hardware.
I now have an old version of FireFox installed with updates disabled and I know to only use it for my local stuff that doesn't work with updated browsers. It's a bit clunky, even with shortcuts which run the browser with the correct URL, but it works. I'm not sure that everyone will end up with this kind of set up; they may just have someone suggest that they downgrade their main browser and turn off updates...
Allowing access to the local subnet with a click through scary warning would probably be 'safer' than forcing people to find out how to work around the problem or preventing them from ever adjusting their routers, or whatever, again...
I'm sure there are lots and lots of valid reasons for the decision; they're just all wrong when the end result will be non-technical users downgrading their browsers and turning off updates.
Recent Comments