[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.2

Changing a NTFS volume between writable and read-only in a Windows C/C++ program

Asked by jmgallag in Miscellaneous Programming

Tags: buildexplicitaccesswithname

Hi,

I have a NTFS volume with ~300,000 folders and files on it. Using C/C++, I need to change the effective permission from read-only to writable QUICKLY. I have written some code using SetNamedSecurityInfo() against the root directory, which worked, however, I was dismayed to find that using the ACE flags CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE caused the new ACE to be propagated immediately, instead of calculated when the subobjects were accessed. It took about 15 minutes for SetSecurityInfo() to return.  Here is my test code:

int main(int argc, char* argv[])
{
#define THE_PATH "g:\\"
      
      PSECURITY_DESCRIPTOR SecurityDescriptor = NULL;
      PACL pDacl;
      DWORD status;
      PSID psidOwner;
      PACL NewAcl = NULL;
      time_t seconds;
      
      DWORD InheritFlag = CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE;
      ACCESS_MODE option = GRANT_ACCESS;
      EXPLICIT_ACCESS explicitaccess;
      
      seconds = time(NULL);      
      
      status = GetNamedSecurityInfo(
            THE_PATH,
            SE_FILE_OBJECT,
            DACL_SECURITY_INFORMATION|OWNER_SECURITY_INFORMATION,
            &psidOwner,
            NULL,
            &pDacl,
            NULL,
            &SecurityDescriptor
            );

      BuildExplicitAccessWithName(
            &explicitaccess,
            "Users",
            FILE_ALL_ACCESS,
            // FILE_GENERIC_READ,
            SET_ACCESS,
            InheritFlag
            );
      
      status = SetEntriesInAcl(
            1,
            &explicitaccess,
            NULL,
            &NewAcl
            );
      
      status = SetNamedSecurityInfo(
            THE_PATH,
            SE_FILE_OBJECT,
            DACL_SECURITY_INFORMATION ,
            NULL,
            NULL,
            NewAcl,
            NULL);
      
      seconds = time(NULL) - seconds;
      
      printf("It took %d seconds.\n", seconds);
      
      if (ERROR_SUCCESS != status)  {
            printf( "SetNamedSecurityInfo Error %u\n", status );
      }  
      
      if(SecurityDescriptor) LocalFree(SecurityDescriptor);
      return 0;
}


Some background on my situation: The volume in question is essentially a database extract, which is distributed on a hard drive to my customers. The customers are frequently in situations where a network connection is unavailable, so the hard drive provides them the data they need without requiring a network connection. Also provided is a util for synchronizing their copy with a master copy, which is used when a network connection is available.  We have run into problems where a user accidentally drags one of the folders into another folder, which disturbs the structure expected by the update util. Hence the desire for this data to be read-only, except when the util is running. The owner of all the files/dirs is the group Users, so the customers will not have problems running a program that changes permissions on objects on this volume. What this boils down to is that we are not concerned with setting protections that can't be changed with the Explorer Security dialog, merely preventing accidental moves/deletes.

I have thoughts on how I might solve this:

- Are inherited ACEs always propagated immediately? If not, what code is required for this behavior?

- I have seen hints that XP supports mounting NTFS volumes read-only, but no code samples on how this is accomplised. Is this a flag that can easily be set without unmounting the volume? My volume is actually encrypted using PGPdisk, so if I can't set a flag on an already mounted volume, I doubt I could get this approach to work.

Other suggestions?

Thanks


[+][-]03/08/06 07:27 AM, ID: 16134583Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/08/06 09:41 AM, ID: 16136234Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/08/06 09:48 AM, ID: 16136302Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/08/06 09:51 AM, ID: 16136338Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/08/06 09:54 AM, ID: 16136373Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/08/06 10:40 AM, ID: 16136814Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/08/06 10:47 AM, ID: 16136899Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/08/06 11:21 AM, ID: 16137292Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/08/06 11:53 AM, ID: 16137629Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/08/06 11:58 AM, ID: 16137685Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/08/06 12:02 PM, ID: 16137726Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/08/06 12:25 PM, ID: 16137962Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/08/06 01:18 PM, ID: 16138549Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/08/06 03:00 PM, ID: 16139720Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/08/06 05:07 PM, ID: 16140548Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/08/06 10:04 PM, ID: 16141776Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/09/06 06:32 AM, ID: 16144837Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/09/06 06:47 AM, ID: 16144970Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/09/06 08:42 AM, ID: 16146258Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/09/06 12:23 PM, ID: 16148369Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/09/06 12:44 PM, ID: 16148636Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/09/06 03:12 PM, ID: 16150325Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/09/06 06:56 PM, ID: 16151420Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/10/06 04:53 PM, ID: 16160519Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/14/06 08:03 AM, ID: 16184676Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Miscellaneous Programming
Tags: buildexplicitaccesswithname
Sign Up Now!
Solution Provided By: Kavar
Participating Experts: 2
Solution Grade: B
 
 
Loading Advertisement...
20091111-EE-VQP-89