Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Commit

Permalink
Merge pull request #28 from github/exclusive-access
Browse files Browse the repository at this point in the history
Only allow one running instance of app
  • Loading branch information
mastahyeti authored Aug 11, 2017
2 parents 5cd865a + 9a1bd5d commit cb23f15
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions SoftU2FDriver/SoftU2FDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,15 @@ void SoftU2FDriver::free() {
IOWorkLoop* SoftU2FDriver::getWorkLoop() const {
return _workLoop;
}

IOReturn SoftU2FDriver::newUserClient(task_t owningTask, void *securityID, UInt32 type, OSDictionary *properties, IOUserClient **handler) {
IOLog("%s[%p]::%s()\n", getName(), this, __FUNCTION__);

// Check that another client isn't already connected.
if (getClient()) {
IOLog("%s[%p]::%s() -> kIOReturnExclusiveAccess\n", getName(), this, __FUNCTION__);
return kIOReturnExclusiveAccess;
}

return super::newUserClient(owningTask, securityID, type, properties, handler);
}
2 changes: 2 additions & 0 deletions SoftU2FDriver/SoftU2FDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public :
virtual bool start(IOService *provider) override;
void free() override;
IOWorkLoop* getWorkLoop() const override;

virtual IOReturn newUserClient(task_t owningTask, void *securityID, UInt32 type, OSDictionary *properties, IOUserClient **handler) override;
};

#endif /* SoftU2F_hpp */

0 comments on commit cb23f15

Please sign in to comment.