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

Remove VPN metadata admin check #2127

Merged
merged 2 commits into from
Jan 29, 2024

Conversation

samsymons
Copy link
Collaborator

Query creation is having serious problems when combined with takeRetainedValue. Using takeUnretainedValue fixes this issue, but leaks the query instances.

We don’t desperately need to know this value, so we’ll go without it and let the system extension API tell us when it doesn’t have admin privileges.

Task/Issue URL: https://app.asana.com/0/1199230911884351/1206456172266325/f
Tech Design URL:
CC:

Description:

This PR removes the admin user check from the metadata collector.

The query functions used to do these checks have issues when used from Swift, crashing after a few invocations unless you use takeUnretainedValue, which we don't want to do as that then leaks the query.

We could do this call once and cache the result, but instead I think we should just rely on system extension APIs etc telling us when they fail due to lack of privileges (error cases do exist for this situation, so we'll still know when it happens).

Steps to test this PR:

  1. Open Debug -> Network Protection
  2. Click the Log Metadata function a few times
  3. Make sure nothing crashes, and that there is no admin check in the JSON output

Internal references:

Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation

Query creation is having serious problems when combined with `takeRetainedValue`. Using `takeUnretainedValue` fixes this issue, but leaks the query instances.

We don’t desperately need to know this value, so we’ll go without it and let the system extension API tell us when it doesn’t have admin privileges.
@samsymons samsymons requested a review from quanganhdo January 27, 2024 04:18
extension VPNMetadataCollector {

private func getUser() throws -> CSIdentity? {
let query = CSIdentityQueryCreateForCurrentUser(kCFAllocatorDefault).takeRetainedValue()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is being a real pain. Changing it to takeUnretainedValue solves the problem, but leaks the query instances. Since we get error information about lack of privileges elsewhere, I think this one is a little redundant anyway, so let's just remove it and keep things simple.

@samsymons samsymons merged commit 2255ac9 into release/1.72.0 Jan 29, 2024
14 checks passed
@samsymons samsymons deleted the sam/remove-admin-check-due-to-crash branch January 29, 2024 05:29
samsymons added a commit that referenced this pull request Jan 29, 2024
Task/Issue URL: https://app.asana.com/0/1199230911884351/1206456172266325/f
Tech Design URL:
CC:

Description:

This PR removes the admin user check from the metadata collector.

The query functions used to do these checks have issues when used from Swift, crashing after a few invocations unless you use takeUnretainedValue, which we don't want to do as that then leaks the query.

We could do this call once and cache the result, but instead I think we should just rely on system extension APIs etc telling us when they fail due to lack of privileges (error cases do exist for this situation, so we'll still know when it happens).
samsymons added a commit that referenced this pull request Jan 29, 2024
samsymons added a commit that referenced this pull request Jan 30, 2024
# By Brian Hall (2) and others
# Via GitHub
* main:
  Bump BSK to 103.0.2 (#2126)
  Fix `site:` queries escaping with iOS 17 SDK (#640) (#2130)
  Add January 2024 brokers (part 2) (#2125)
  lastSentDate + web breakage report improvements (#2041)
  Remove VPN metadata admin check (#2127)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
samsymons added a commit that referenced this pull request Jan 30, 2024
* main:
  Restore VPN pixels in main browser (#2129)
  Bump BSK to 103.0.2 (#2126)
  Fix `site:` queries escaping with iOS 17 SDK (#640) (#2130)
  Add January 2024 brokers (part 2) (#2125)
  lastSentDate + web breakage report improvements (#2041)
  Remove VPN metadata admin check (#2127)
  Add Spokeo mirror sites (#2086)
  appcastManager: Retain release notes for all versions (#2123)
  Don't report CancellationError from BookmarksFaviconsFetcher (#2120)
  Sabrina/revert cards experiment (#2119)
  Bump version to 1.72.0 (113)
  Update embedded files
  Release Branch: VPN fixes (#2113)
  Adds info about whether the login items are actually running (#2122)
  Remove connection status awaiter. (#2121)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants