1

I want to copy my home directory to a new install of the same version of windows. On my new install, my user name will correspond to a new UUID, so I want to edit the permissions to add the a copy of the existing permissions with the new UUID (file by file)

I want to do that with a shell script on Linux. How can I get and set those permissions with scriptable commands ?

Camion
  • 274
  • Please, see my answer to similar question: https://unix.stackexchange.com/a/437138/273268 – Yurij Goncharuk Apr 20 '18 at 12:20
  • Thank-you for this hint. It feels that the right command in this case would be setfacl and getfacl instead on setfattr and getfattr, but I need to examine the manpages. – Camion Apr 20 '18 at 12:50
  • after examination, it seems it doesn't work, because it work with unix like permissions. I'm looking for something which would keep the ntfs security structure. – Camion Apr 20 '18 at 13:25
  • Please specify the full path of the old home directory and the target directory. – agc Apr 20 '18 at 15:51
  • @agc: I do not understand what you mean. I do not have an old and a new home directory. I have a file (or a directory), with some permissions given to some SID, and I want to read those permissions, and then add the exact same permissions on the same file, but associated with another SID. – Camion Apr 23 '18 at 16:14
  • Please specify the full path of the source file and the target file. – agc Apr 23 '18 at 19:07
  • @agc: I still do not understand what you want : there is no source versus target file. There is only one file at a time whatever in is. I need to read it's NTFS permission which must have some NTFS (not unix - user should be a SID) form, then text edit it to create the same permission for another SID, and then write the new permissions to the same file. – Camion Apr 24 '18 at 20:21
  • @Camion, Consider a copy command cp ~/foo ~/bar/baz or a move command mv ~/foo ~/bar/baz. In either case ~/foo is the source file, and ~/bar/baz the target file, and if we accept ~ as a given, those are full pathnames as well. In your Q the full pathnames of both source and target may well be relevant; the question is incomplete without them. Granted you wish to do this for a directory and its contents, but the pathnames remain relevant. – agc Apr 25 '18 at 01:07
  • @agc, Copying my home directory from one computer is only the context of my question. It is easy to do and it is not part of the problem and I do not need help for that. What I'm asking is: what scriptable command I can use to edit (read/change) NTFS permissions of a file on an NTFS volume with Linux/NTFS-3G – Camion Apr 25 '18 at 10:52
  • @Camion, If copying is indeed not relevant to the question, it would be better to omit all mention of copying. – agc Apr 25 '18 at 17:31
  • @agc, copying is not irrelevant, it is the context. – Camion Apr 25 '18 at 18:57
  • @Camion, It sounds more like you wish know how to copy or move NTFS metadata, rather than files as such. – agc Apr 25 '18 at 21:53
  • @agc, I believe that the title is perfectly clear : I want to know how I can get/set ntfs permission from command-line (or script) on linux. and then I explain why I do that (the context), in order to prevent irrelevant nitpicking (which failed). – Camion Apr 26 '18 at 09:19

1 Answers1

0

You can't at all, unless you know in advance what SID your user will have on the new Windows install (which is not predictable like UID's are on UNIX systems).

Assuming you have some way of knowing what SID you will have, you can functionally replicate ownership and basic ACE's by using regular UNIX commands and the NTFS-3G username mapping functionality. See the 'User Mapping' section of the NTFS-3G manpage for info on how to set that up. Once that is set up, you can use regular UNIX commands to manipulate ownership and basic permissions of files (IIRC, POSIX read permission translates to 'Read' and 'Read & Execute' Windows permissions, and POSIX write translates to 'Modify', but I don't remember any beyond that).

As far as I know, there is no way from Linux to copy all Windows ACE's.

One slight side note, you probably want to copy NTFS Alternate Data Streams too. You can do this easily with UNIX tools that support Linux xattrs (provided you don't supply a streams-interface option to NTFS-3G, it will default to exposing them as xattrs).

  • knowing the SID is not a problem : I'm doing that AFTER I created the new install – Camion Apr 20 '18 at 20:14
  • If you're right about the fact that there is no way to edit all windows ACE on linux, this means that I will have to do it from windows which might make things uglier. – Camion Apr 26 '18 at 09:30