FAQ SearchLogin
Tuxera Home
View unanswered posts | View active topics It is currently Thu Jun 24, 2021 14:37



Post new topic Reply to topic  [ 13 posts ] 
NTFS ACLs from a WIM file 
Author Message

Joined: Mon Jun 22, 2009 17:13
Posts: 7
Post NTFS ACLs from a WIM file
I am writing an application to restore a WIM file from Linux (or WinPE if you didn't want to use ImageX). This will be a small part of a suite I am writing for imaging. Currently I am using partimage and partimage-ng for my imaging, but I'd like to support Microsoft's WIM files. I have done all the work to get the data and metadata from the WIM files, and now I am at the point where I need to be able to restore the ACLs. I noticed the secaudit application on the NTFS-3g website here, and thought it would be nice to be able to use secaudit like a library to restore the ACLs. Unfortunately, I am not familiar enough with NTFS to determine if the WIM ACLs are stored in the same format as secaudit uses to restore the ACLs. It was a huge pain to get where I am at now, as the WIM file format Microsoft freely provides is inaccurate, and their LZX compression modifications was a pain to figure out, now I need ACLs, and would love some help from the NTFS-3g community to make this happen.

Thanks,
Suede


Mon Jun 22, 2009 17:32
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: NTFS ACLs from a WIM file
Hi,

Quote:
I have done all the work to get the data and metadata from the WIM files, and now I am at the point where I need to be able to restore the ACLs

Your application decodes WIM files and restores them to NTFS. secaudit will not help you much, it was designed to audit the ACL data in a partition, its ability to restore the ACLs is just a by-product.
If you use ntfs-3g to restore the user data, you might use the extended attribute mappings (available in Advanced ntfs-3g) to restore the metadata unknown to Linux such as the ACLs. See http://pagesperso-orange.fr/b.andre/extend-attr.html
In http://pagesperso-orange.fr/b.andre/tools.zip there is a file copy program which shows how you can use them.
Quote:
I am not familiar enough with NTFS to determine if the WIM ACLs are stored in the same format as secaudit uses to restore the ACLs

You will have to build an ACL structure identical to an ACL record on disk. ACL dumps by secaudit show the exact pattern you have to feed in.

Regards

Jean-Pierre


Mon Jun 22, 2009 18:14
Profile

Joined: Mon Jun 22, 2009 17:13
Posts: 7
Post Re: NTFS ACLs from a WIM file
Thanks for pointing me in the right direction.

I really appreciate the quick response, and I'll check out the tools you suggested.

I have another question as well, in relation to this. Does NTFS-3g handle Alternate Data Streams like Windows does? As in if I have file.txt and an alternate data stream file.txt:ads1.bin, can I just refer to the full path (as in with the colon in the middle) with to get to the ADS, or would it create/read a POSIX-style filename instead?

Thanks Again,
Suede


Mon Jun 22, 2009 18:37
Profile

Joined: Mon Jun 22, 2009 17:13
Posts: 7
Post Re: NTFS ACLs from a WIM file
Ok, I think the last post I requested info about was covered in your previous reply as well.

Thanks,
Suede


Mon Jun 22, 2009 18:40
Profile

Joined: Mon Jun 22, 2009 17:13
Posts: 7
Post Re: NTFS ACLs from a WIM file
Well, Thanks to Jean-Pierre's assistance, I have been able to get WIM Images to restore to NTFS-3G mounted NTFS Volumes, but I still have an issue with: (I found this in the ntfs-3g manual)

Quote:
Windows Filename Compatibility
NTFS supports several filename namespaces: DOS, Win32 and POSIX. While the ntfs-3g driver handles all of them, it always creates new files in the POSIX namespace for maximum portability and interoperability reasons. This means that filenames are case sensitive and all characters are allowed except ’/’ and ’\0’. This is perfectly legal on Windows, though some application may get confused. If you find so then please report it to the developer of the relevant Windows software.


The issue I am having now is (possibly) due to NTFS-3G only using the POSIX namespace when creating new files. I am not 100% sure of this, and currently can't I need to be able to restore the files as if they were a backup (which is pretty-much what a WIM file is). What I mean by this is I need to restore them with their Win32 filename and their DOS filename(if they have one), instead of using the POSIX namespace. Is this possible? If so, how would one go about doing so?

Most of the files will likely have a filename that would exist in DOS and Win32 namespaces. There may be some that don't, so I'd only need the Win32 namespace for that.

I'd appreciate any help.

Thanks,
Suede


Mon Jun 29, 2009 22:00
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: NTFS ACLs from a WIM file
Hi,

Quote:
What I mean by this is I need to restore them with their Win32 filename and their DOS filename(if they have one), instead of using the POSIX namespace. Is this possible? If so, how would one go about doing so?

There is an experimental version which supports querying and setting DOS names in http://pagesperso-orange.fr/b.andre/ntf ... 4AA.13.tgz
The DOS name is mapped to the extended attribute system.ntfs_dos_name and, when setting, the original name is moved to the Win32 name space.
This is not documented yet, but there is some information in a recent thread viewtopic.php?f=2&t=1227

Regards

Jean-Pierre


Tue Jun 30, 2009 08:24
Profile

Joined: Mon Jun 22, 2009 17:13
Posts: 7
Post Re: NTFS ACLs from a WIM file
That's great. I'll check out the experimental version.

I discovered another issue while working on this. If I try to set the reparse data on an exesting Junction, it seems to set the reparse data on the Junction's target rather than the original Junction folder. If the reparse data I am trying to set makes it (the target of the original Junction) point to the target I am trying to change the old Junction to, it sets the target to point to itself, effectively breaking the filesystem.

I will post an example from my linux dev box to make this make sense...

I am thinking a workaround may be to rmdir the Junction, and re-create it instead of trying to change the reparse data, but I'd like to not have to do this if possible. (This is with version ntfs-3g-2009.4.4AR.12). I have not tried the experimental version you linked yet.

Thanks,
Suede


Tue Jun 30, 2009 15:22
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: NTFS ACLs from a WIM file
Hi,

Quote:
If I try to set the reparse data on an exesting Junction, it seems to set the reparse data on the Junction's target rather than the original Junction folder.

This may be the expected behaviour : according to the man, the function setxattr(2) follows the links, and the existing reparse point is probably interpreted as a symbolic link. If you do not want this, use lsetxattr(2).

Regards

Jean-Pierre


Tue Jun 30, 2009 15:35
Profile

Joined: Mon Jun 22, 2009 17:13
Posts: 7
Post Re: NTFS ACLs from a WIM file
Your suggestion worked beautifully.

I'll get to work on the DOS file namespace testing, and let you know how it goes.

Also, is there a way to force the Win32 namespace without setting a DOS name in the experimental version? Maybe a mount option with something like file_namespace=Win32 or file_namespace=POSIX with POSIX the default?

Thanks,
Suede


Tue Jun 30, 2009 15:43
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: NTFS ACLs from a WIM file
Hi again,

Quote:
Also, is there a way to force the Win32 namespace without setting a DOS name in the experimental version?

No. There is only two documented configurations : a single name in the Posix name space, and a couple of names in Win32 + DOS name spaces (if the Win32 and DOS names are identical they can be collapsed - but the experimental version does not support collapsing yet). Other configurations may be interpreted incorrectly and should be rejected.

Regards

Jean-Pierre


Tue Jun 30, 2009 15:57
Profile

Joined: Mon Jun 22, 2009 17:13
Posts: 7
Post Re: NTFS ACLs from a WIM file
Well, I got everything working with the last version you provided, and it seems to be working well. Some of the issues I experienced were due to a couple bugs I found in my decompression code, which I have fixed, and some were due to the DOS Filenames (some applications use them in the registry rather than their LFN counterparts). Other than those cases, the POSIX namespace seems to make no difference (so far).

One last question (which is probably answered elsewhere)... Is there a way I can do all of this with a library rather than mounting the FS in userspace? I know the linux-ntfs project has a library, but NTFS-3G is more complete (and I know it does what I need it to do).

Thanks,
Suede


Tue Jul 07, 2009 17:34
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: NTFS ACLs from a WIM file
Hi,

Quote:
Is there a way I can do all of this with a library rather than mounting the FS in userspace?

Yes... ntfs-3g is a library (apart from the part which handles the interface with fuse), and you can issue direct calls to the library (secaudit does this).

But... you will have to develop some interface between your program and the library and cope with subsequent modifications to the interface (which are common for the special functions you need). You will also need to start your program as root.

Regards

Jean-Pierre


Tue Jul 07, 2009 18:37
Profile

Joined: Wed Mar 21, 2012 22:18
Posts: 1
Post Re: NTFS ACLs from a WIM file
suedeworthey,

it is a old post.
Tried to followe you somewhere through google.
Did you succeed in your quest?

I would like to have your solutions.
Now i try through WineHQ gimage.

If i can deploy without winehq is much more efficient.
I noticed that some calls seem to fail. (in other words, i dont trust it with WineHQ)

Hope to hear from you..

Regards,
PTR


Wed Mar 21, 2012 22:22
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Original forum style by Vjacheslav Trushkin.