Skip to content

Commit

Permalink
Merge pull request #84 from doronz88/bugfix/location
Browse files Browse the repository at this point in the history
Bugfix/location
  • Loading branch information
doronz88 authored Feb 21, 2022
2 parents e510329 + e08135d commit 82590c1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 29 deletions.
33 changes: 10 additions & 23 deletions src/ents.plist
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,23 @@
<true/>
<key>com.apple.wifi.manager-access</key>
<true/>
<key>task_for_pid-allow</key>
<true/>
<key>com.apple.private.tcc.allow</key>
<array>
<string>kTCCServiceMicrophone</string>
<string>kTCCServiceCamera</string>
</array>
<key>com.apple.security.device.audio-input</key>
<key>com.apple.locationd.preauthorized</key>
<true/>
<key>com.apple.security.device.microphone</key>
<key>com.apple.locationd.authorizeapplications</key>
<true/>
<key>com.apple.security.device.camera</key>
<key>com.apple.locationd.defaults_access</key>
<true/>
<key>com.apple.security.personal-information.location</key>
<key>com.apple.locationd.effective_bundle</key>
<true/>
<key>com.apple.security.personal-information.addressbook</key>
<key>com.apple.locationd.status</key>
<true/>
<key>com.apple.security.personal-information.calendars</key>
<true/>
<key>com.apple.security.personal-information.photos-library</key>
<true/>
<key>com.apple.security.automation.apple-events</key>
<true/>
<key>com.apple.SystemConfiguration.SCDynamicStore-write-access</key>
<key>task_for_pid-allow</key>
<true/>
<key>com.apple.SystemConfiguration.SCPreferences-write-access</key>
<key>com.apple.private.tcc.allow</key>
<array>
<string>com.apple.AutoWake.xml</string>
<string>preferences.plist</string>
<string>com.apple.radios.plist</string>
<string>kTCCServiceMicrophone</string>
<string>kTCCServiceCamera</string>
<string>kTCCServiceLocation</string>
</array>
</dict>
</plist>
30 changes: 25 additions & 5 deletions src/rpcclient/rpcclient/darwin/location.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from enum import Enum
from typing import Mapping
from typing import Mapping, Optional

from rpcclient.exceptions import MissingLibraryError, PermissionDeniedError
from rpcclient.structs.consts import RTLD_NOW


class CLAuthorizationStatus(Enum):
Expand All @@ -28,17 +29,36 @@ class Location:
def __init__(self, client):
self._client = client

if not self._client.dlopen('/System/Library/Frameworks/CoreLocation.framework/Versions/A/CoreLocation', 2):
raise MissingLibraryError('failed to load CoreLocation')
self._load_location_library()
self._CLLocationManager = self._client.symbols.objc_getClass('CLLocationManager')
self._location_manager = self._CLLocationManager.objc_call('sharedManager')

self._location_manager = self._client.symbols.objc_getClass('CLLocationManager').objc_call('sharedManager')
def _load_location_library(self):
options = [
# macOS
'/System/Library/Frameworks/CoreLocation.framework/Versions/A/CoreLocation',
# iOS
'/System/Library/Frameworks/CoreLocation.framework/CoreLocation'
]
for option in options:
if self._client.dlopen(option, RTLD_NOW):
return
raise MissingLibraryError('CoreLocation library isn\'t available')

@property
def location_services_enabled(self) -> bool:
return bool(self._location_manager.objc_call('locationServicesEnabled'))

@location_services_enabled.setter
def location_services_enabled(self, value: bool):
self._CLLocationManager.objc_call('setLocationServicesEnabled:', value)

@property
def authorization_status(self) -> CLAuthorizationStatus:
return CLAuthorizationStatus.from_value(self._location_manager.objc_call('authorizationStatus'))

@property
def last_sample(self) -> Mapping:
def last_sample(self) -> Optional[Mapping]:
return self._location_manager.objc_call('location').objc_call('jsonObject').py

def start_updating_location(self):
Expand Down
2 changes: 1 addition & 1 deletion src/rpcclient/tests/test_spawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_spawn_sanity(client, argv, expected_stdout, errorcode):


def test_spawn_bad_value_stress(client):
for i in range(1000):
for i in range(100):
stdout = StringIO()
assert 256 == client.spawn(['/bin/ls', 'INVALID_PATH'], stdout=stdout, stdin=b'').error

Expand Down

0 comments on commit 82590c1

Please sign in to comment.