Merge pull request #23723 from drodriguez/fix-network-service-handling
[windows] Fix handling of Network Service username.
diff --git a/test/ParseableInterface/Inputs/make-unreadable.py b/test/ParseableInterface/Inputs/make-unreadable.py
index 9610518..e8991b0 100644
--- a/test/ParseableInterface/Inputs/make-unreadable.py
+++ b/test/ParseableInterface/Inputs/make-unreadable.py
@@ -21,10 +21,16 @@
buffer = ctypes.create_unicode_buffer(UNLEN + 1)
size = ctypes.c_uint(len(buffer))
GetUserNameW(buffer, ctypes.byref(size))
+ # For NetworkService, Host$ is returned, so we choose have to turn it back
+ # into something that icacls understands.
+ if not buffer.value.endswith('$'):
+ user_name = buffer.value
+ else:
+ user_name = 'NT AUTHORITY\\NetworkService'
for path in sys.argv[1:]:
subprocess.call(['icacls', path, '/deny',
- '{}:(R)'.format(buffer.value)])
+ '{}:(R)'.format(user_name)])
else:
for path in sys.argv[1:]:
subprocess.call(['chmod', 'a-r', path])