Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the last access time of a directory results in ERROR_SHARING_VIOLATION #218

Closed
nedsociety opened this issue Dec 10, 2020 · 1 comment
Labels
fixed in next build Fixed in the next Sandboxie version Known issue Old known Sandboxie issues

Comments

@nedsociety
Copy link

nedsociety commented Dec 10, 2020

Driver 5.45.0

Problem

On Python (3.9) I tried to run pip install comtypes within the sandbox which failed with:

    Complete output (4 lines):
    running egg_info
    C:\Users\ned\AppData\Local\Temp\pip-pip-egg-info-ey1uqbv6\comtypes.egg-info
    creating C:\Users\ned\AppData\Local\Temp\pip-pip-egg-info-ey1uqbv6\comtypes.egg-info
    error: [WinError 32] The process cannot access the file because it is being used by another process

Tracking the problem so far, I've narrowed the culprit down to:

  • Trying to change the last access time of a directory inside a sandbox results in ERROR_SHARING_VIOLATION (32).
  • It also happens when trying to change the directory access time for host directory for the second time. (as the first change will import the directory into the sandbox)

Minimal reproducing app

#include <Windows.h>
#include <stdexcept>
#include <string>
#include <iostream>

int main(int argc, char** argv) {
    try {
        if (argc < 2) {
            throw std::runtime_error("need argument");
        }

        HANDLE hFile = CreateFileA(argv[1], FILE_WRITE_ATTRIBUTES, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
        if (hFile == INVALID_HANDLE_VALUE) {
            throw std::runtime_error("failed to open");
        }

        FILETIME time;
        GetSystemTimeAsFileTime(&time);

        // Change the access time
        if (!SetFileTime(hFile, NULL, NULL, &time))
            throw std::runtime_error(std::to_string(GetLastError()));
        CloseHandle(hFile);
    }
    catch (std::runtime_error e) {
        std::cout << e.what() << "\n";
    }
    
    return 0;
}

Built as testapp.exe, then ran this app in Sandboxie:

C:\> mkdir testdir
C:\> testapp testdir
32
C:\> testapp hostdir
C:\> testapp hostdir
32

(ERROR_SHARING_VIOLATION is 32)

@nedsociety nedsociety changed the title Changing directory access time results in ERROR_SHARING_VIOLATION Changing the last access time of a directory results in ERROR_SHARING_VIOLATION Dec 10, 2020
@DavidXanatos DavidXanatos added under investigation fixed in next build Fixed in the next Sandboxie version Known issue Old known Sandboxie issues and removed under investigation labels Dec 20, 2020
@DavidXanatos
Copy link
Member

I have found the issue and fixed it for the next build, thank you for the great bug report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in next build Fixed in the next Sandboxie version Known issue Old known Sandboxie issues
Projects
None yet
Development

No branches or pull requests

2 participants