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

Commit cb23f15

Browse files
authored
Merge pull request #28 from github/exclusive-access
Only allow one running instance of app
2 parents 5cd865a + 9a1bd5d commit cb23f15

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

SoftU2FDriver/SoftU2FDriver.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,15 @@ void SoftU2FDriver::free() {
3535
IOWorkLoop* SoftU2FDriver::getWorkLoop() const {
3636
return _workLoop;
3737
}
38+
39+
IOReturn SoftU2FDriver::newUserClient(task_t owningTask, void *securityID, UInt32 type, OSDictionary *properties, IOUserClient **handler) {
40+
IOLog("%s[%p]::%s()\n", getName(), this, __FUNCTION__);
41+
42+
// Check that another client isn't already connected.
43+
if (getClient()) {
44+
IOLog("%s[%p]::%s() -> kIOReturnExclusiveAccess\n", getName(), this, __FUNCTION__);
45+
return kIOReturnExclusiveAccess;
46+
}
47+
48+
return super::newUserClient(owningTask, securityID, type, properties, handler);
49+
}

SoftU2FDriver/SoftU2FDriver.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public :
2020
virtual bool start(IOService *provider) override;
2121
void free() override;
2222
IOWorkLoop* getWorkLoop() const override;
23+
24+
virtual IOReturn newUserClient(task_t owningTask, void *securityID, UInt32 type, OSDictionary *properties, IOUserClient **handler) override;
2325
};
2426

2527
#endif /* SoftU2F_hpp */

0 commit comments

Comments
 (0)