Post by Davin PearsonPost by PaulPost by Davin PearsonI am trying to get write access to the Emacs file dir under the MS Windows operating system.
c:\Program Files (x86)\emacs-24.5\share\info>chmod 666 dir
chmod: changing permissions of 'dir': Permission denied
What gives? How do I go about getting write access to the file "dir"?
You didn't say what version of MS Windows.
My guess would be something Vista or more recent.
I am running Windows 10...
Post by Paulicacls c:\ /save ntfsCdrive.txt /t /c
Edit the ACL text file. The first line will be blank
signifying the current directory (which in this case happens
to be the root of the drive). Put a single period (.) in this line.
When restoring the ACL file, the restore command will correctly
interpret this to mean the current directory (since a single
period represents the current directory in most command syntaxes).
icacls c:\ /restore ntfsCdrive.txt
Here is a fragment of the file generated by
icacls c:\ /save ntfsCdrive.txt /t /c
Note that I have added a period like you asked me to do.
What gives about the strange format of the file... so many null
characters. Are you sure that I have correctly followed your
instructions?
Here is a fragment of the output of running od -x on ntfsCdrive.txt
C:\Uswers\Davin Pearson>od -x ntfsCdrive.txt | head
0000000 0d2e 0a00 4400 3a00 5000 4100 4900 2800
0000020 4100 3b00 4f00 4900 4300 4900 3b00 4600
0000040 4100 3b00 3b00 3b00 4200 4100 2900 2800
0000060 4100 3b00 4f00 4900 4300 4900 3b00 4600
0000100 4100 3b00 3b00 3b00 5300 5900 2900 2800
0000120 4100 3b00 4f00 4900 4300 4900 3b00 3000
0000140 7800 3100 3200 3000 3000 6100 3900 3b00
0000160 3b00 3b00 4200 5500 2900 2800 4100 3b00
0000200 4f00 4900 4300 4900 4900 4f00 3b00 5300
0000220 4400 4700 5800 4700 5700 4700 5200 3b00
Here is the output of running the second command that you mentioned in
PS C:\Users\Davin Pearson> icacls c:\ /restore ntfsCdrive.txt
Not all privileges or groups referenced are assigned to the caller.
Successfully processed 0 files; Failed processing 0 files
It seems that nothing has been changed. So what am I doing wrong?
To answer the first question, you need a text editor that
can handle wide (16 bit) characters. Notepad can do this.
I'm willing to bet, even the copy of Notepad in WINE
could do this.
After suitable manipulation (byte swap of the above), then
Windows 16 bit character to ASCII or so, gives text as follows.
That's what the above hex looks like, if interpreted as
16 bit character text. This is what I see in Notepad,
using your example. (I wrote a little AWK script to translate.)
.
D:PAI(A;OICI;FA;;;BA)(A;OICI;FA;;;SY)(A;OICI;0x1200a9;;;BU)(A;OICIIO;SDGXGWGR;
Now, if we break that down, each part in brackets is a separate item.
These are in the order of the Properties of the file, as
viewed in File Explorer. (When you view the security properties,
there will be at least four lines, and in the same order as these items.)
Now, using my secret decoder ring
https://msdn.microsoft.com/en-us/library/windows/desktop/aa379602(v=vs.85).aspx
(A;OICI;FA;;;BA) BUILTIN_ADMINISTRATORS
(A;OICI;FA;;;SY) LOCAL_SYSTEM [the SYSTEM account]
(A;OICI;0x1200a9;;;BU) BUILTIN_USERS
(A;OICIIO;SDGXGWGR; <--- missing a bit of the string on the end
The last one probably reads as
(A;OICIIO;SDGXGWGR;;;AU) AUTHENTICATED_USERS
Using the 0x1200a9 part, I can find the article by
Jesper Johansson, which does a better job of explaining
this stuff than I ever could.
https://technet.microsoft.com/en-us/magazine/2007.06.acl.aspx
Remember that the intention of the dump file, whether
applied to the entire C: or to a subsection, is for
restoration after you've "broken" things. You need a
utility that accepts symbolic arguments, if you want
to make small changes here and there. Editing the above file,
except to add the "." in place of the top line, isn't really
the intention.
*******
If you go back and look at the example here...
http://dandar3.blogspot.ca/2013/01/how-to-ntfs-compress-windows-winsxs.html
takeown /f "%WINDIR%\WinSxS" /r
icacls "%WINDIR%\WinSxS" /grant "%USERDOMAIN%\%USERNAME%":(F) /t
that kind of two-command stanza is typically used to
"smash" permissions. If you need to get something
done, and don't want to take "No" for an answer.
In Windows, we can even add those two, into a right-click
context menu item. Or, as a .bat file for script usage.
For example, the following two line script, accepts one parameter,
which is the "thing you want to own". The %1 is the command line parameter
being passed.
https://blogs.msdn.microsoft.com/tims/2006/11/10/windows-vista-secret-11-deleting-the-undeletable/
******* itsmine.cmd *******
takeown /f %1 /r /d y
icacls %1 /grant administrators:F /t
The following article, adds a new right-click context menu item.
These .reg files, if you right click them and select
"Merge", they get added to the Registry. Then, when
you right-click an item in File Explorer, you can add
yourself as an owner. Later, you could restore (remove)
the thing you changed, using your icacls dump.
Note: Do *not* apply this to the top of C:\ . This
is for working on small sections of the disk,
not as a means to turn the partition into your
own version of FAT32 (no permissions at all).
http://www.tenforums.com/tutorials/3841-take-ownership-add-context-menu-windows-10-a.html
If you're in a destructive mood, do a complete backup
of the drive before becoming immersed in this stuff.
It's OK to break things, if you have good backup images.
I expect, for the Takeown right-click menu thing
to work, your account should belong to "Administrators Group".
Which would be the default if you just set up Windows 10
with one account. The main account belongs to the
Administrators group. And that helps a lot with little
permission smashing exercises. Even if being a member
of Administrator group, does not directly allow you
to deal with TrustedInstaller ownership, you can see
that there are "plenty of hammers" for beating the
permissions into shape. A skilled artisan puts
everything back later, the way they found it.
And unlike MacOSX, Windows does not provide any sort
of "permission repair" for users. So after they've
been "TakeOwning" for a few weeks, you can clean it up.
I think MacOSX has something which can do that sort of
cleanup, restoring sane looking permissions. With Windows,
if you didn't use tools like the ICACLS dump/restore,
you'd probably have nothing to use as a substitute.
(In other words, you have to prepare in advance.)
I haven't seen evidence of any Windows "convenience" tool
for such a purpose (to undo the damage a user
belonging to the Administrators Group could do).
Paul