Skip to content

Commit

Permalink
Fix non-root usage
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamgilbert committed Feb 22, 2024
1 parent 5ce9177 commit 5a7dae0
Show file tree
Hide file tree
Showing 3 changed files with 256 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ test:
coverage:
rm -rf coverage
mkdir -p coverage
bazel coverage --combined_report=lcov //...
mv $(BAZEL_OUTPUT_PATH)/_coverage/_coverage_report.dat coverage/lcov.info
# bazel coverage --combined_report=lcov //...
# mv $(BAZEL_OUTPUT_PATH)/_coverage/_coverage_report.dat coverage/lcov.info
go test -coverprofile=coverage/lcov.info ./...

build: check_variables clean-crypt build_binary
xcodebuild -project Crypt.xcodeproj -configuration Release
Expand Down
228 changes: 228 additions & 0 deletions coverage/lcov.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
mode: set
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:29.60,31.16 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:31.16,33.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:35.2,36.16 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:36.16,38.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:40.2,41.16 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:41.16,43.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:45.2,46.16 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:46.16,48.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:50.2,50.50 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:50.50,52.17 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:52.17,54.4 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:59.2,60.24 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:60.24,62.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:62.8,62.23 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:62.23,64.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:66.2,67.16 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:67.16,69.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:71.2,71.33 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:71.33,73.17 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:73.17,75.4 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:78.2,78.79 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:78.79,80.17 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:80.17,82.4 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:85.2,86.16 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:86.16,88.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:90.2,90.21 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:90.21,93.3 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:95.2,96.16 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:96.16,98.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:100.2,104.16 4 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:104.16,106.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:108.2,108.17 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:108.17,110.17 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:110.17,112.4 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:115.2,115.12 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:118.78,119.32 1 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:119.32,121.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:123.2,124.16 2 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:124.16,126.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:128.2,131.47 3 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:131.47,134.3 2 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:136.2,136.18 1 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:139.44,142.2 2 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:144.54,147.16 3 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:147.16,149.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:151.2,152.16 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:152.16,154.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:156.2,156.23 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:159.62,161.16 2 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:161.16,163.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:165.2,166.16 2 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:166.16,168.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:170.2,170.12 1 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:177.63,179.16 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:179.16,182.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:184.2,185.16 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:185.16,187.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:189.2,190.16 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:190.16,192.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:194.2,194.78 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:194.78,196.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:198.2,199.24 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:199.24,201.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:203.2,204.16 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:204.16,206.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:208.2,209.16 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:209.16,211.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:213.2,213.15 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:213.15,215.17 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:215.17,217.4 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:220.2,220.12 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:223.76,229.16 4 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:229.16,231.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:233.2,239.16 2 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:239.16,240.55 1 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:240.55,242.4 1 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:243.3,243.20 1 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:246.2,246.53 1 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:246.53,248.3 1 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:248.8,252.3 3 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:255.75,257.16 2 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:257.16,259.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:260.2,261.16 2 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:261.16,263.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:265.2,266.37 2 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:266.37,269.44 2 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:269.44,271.4 1 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:274.2,274.16 1 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:277.74,279.16 2 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:279.16,281.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:283.2,288.27 6 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:291.60,293.16 2 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:293.16,295.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:296.2,296.40 1 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:296.40,298.3 1 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:299.2,299.36 1 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:302.87,316.16 4 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:316.16,318.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:319.2,319.31 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:319.31,321.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:322.2,324.16 3 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:324.16,327.3 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:328.2,328.25 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:331.77,338.16 3 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:338.16,340.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:341.2,342.16 2 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:342.16,344.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:345.2,347.16 3 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:347.16,349.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:350.2,353.16 3 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:353.16,355.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:356.2,356.12 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:359.73,364.16 3 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:364.16,366.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:367.2,368.16 2 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:368.16,370.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:372.2,373.16 2 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:373.16,375.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:376.2,376.35 1 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:376.35,378.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:380.2,381.16 2 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:381.16,383.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:384.2,385.24 2 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:385.24,387.3 1 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:389.2,389.31 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:389.31,392.17 3 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:392.17,394.4 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:397.2,397.12 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:426.57,433.16 3 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:433.16,435.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:438.2,440.16 3 1
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:440.16,442.3 1 0
github.com/grahamgilbert/crypt/pkg/checkin/escrow.go:444.2,444.29 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:51.58,69.38 6 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:69.38,71.10 2 0
github.com/grahamgilbert/crypt/pkg/pref/pref.go:71.10,73.4 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref.go:74.3,75.17 2 0
github.com/grahamgilbert/crypt/pkg/pref/pref.go:75.17,77.4 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref.go:78.3,78.27 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref.go:82.2,82.34 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:83.29,91.25 3 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:91.25,93.4 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref.go:94.3,94.37 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:95.30,96.66 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:97.29,100.18 3 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:101.28,104.36 3 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:104.36,106.66 2 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:106.66,108.5 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref.go:109.4,116.25 3 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:116.25,118.5 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref.go:119.4,119.37 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:121.3,121.20 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:122.10,123.73 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref.go:127.29,129.16 2 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:129.16,131.3 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref.go:133.2,133.28 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:133.28,135.3 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref.go:136.2,136.19 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:141.66,143.16 2 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:143.16,145.3 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref.go:146.2,148.12 3 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:148.12,150.3 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref.go:150.8,152.3 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:154.2,155.31 2 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:156.14,157.42 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:158.12,159.8 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:159.8,161.4 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:161.9,163.4 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref.go:164.11,165.60 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:166.16,168.42 2 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:168.42,170.4 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:171.10,172.68 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref.go:175.2,176.16 2 1
github.com/grahamgilbert/crypt/pkg/pref/pref.go:176.16,178.3 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref.go:180.2,180.12 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:27.26,31.2 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:34.46,36.16 2 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:36.16,38.3 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:39.2,39.12 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:43.59,45.16 2 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:45.16,47.3 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:48.2,48.28 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:52.55,54.16 2 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:54.16,56.3 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:57.2,57.18 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:57.18,59.3 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:60.2,60.26 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:64.53,66.16 2 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:66.16,68.3 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:69.2,69.18 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:69.18,71.3 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:72.2,72.25 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:76.60,78.16 2 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:78.16,80.3 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:81.2,81.18 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:81.18,83.3 1 0
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:84.2,84.30 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:88.63,90.2 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:93.59,95.2 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:98.57,100.2 1 1
github.com/grahamgilbert/crypt/pkg/pref/pref_helpers.go:103.68,105.2 1 1
github.com/grahamgilbert/crypt/pkg/utils/console_user_darwin.go:33.39,35.17 2 1
github.com/grahamgilbert/crypt/pkg/utils/console_user_darwin.go:35.17,37.3 1 0
github.com/grahamgilbert/crypt/pkg/utils/console_user_darwin.go:39.2,42.17 3 1
github.com/grahamgilbert/crypt/pkg/utils/curl.go:5.34,7.2 1 1
github.com/grahamgilbert/crypt/pkg/utils/curl.go:9.54,11.22 2 1
github.com/grahamgilbert/crypt/pkg/utils/curl.go:11.22,13.3 1 1
github.com/grahamgilbert/crypt/pkg/utils/curl.go:14.2,14.34 1 1
github.com/grahamgilbert/crypt/pkg/utils/exec.go:21.25,25.2 1 0
github.com/grahamgilbert/crypt/pkg/utils/exec.go:27.75,32.16 5 0
github.com/grahamgilbert/crypt/pkg/utils/exec.go:32.16,34.3 1 0
github.com/grahamgilbert/crypt/pkg/utils/exec.go:35.2,35.20 1 0
github.com/grahamgilbert/crypt/pkg/utils/exec.go:38.99,45.16 6 0
github.com/grahamgilbert/crypt/pkg/utils/exec.go:45.16,47.3 1 0
github.com/grahamgilbert/crypt/pkg/utils/exec.go:48.2,48.20 1 0
github.com/grahamgilbert/crypt/pkg/utils/exec_mocks.go:8.75,10.2 1 1
github.com/grahamgilbert/crypt/pkg/utils/exec_mocks.go:12.98,14.2 1 1
github.com/grahamgilbert/crypt/pkg/utils/get_computer_name.go:4.53,6.16 2 1
github.com/grahamgilbert/crypt/pkg/utils/get_computer_name.go:6.16,8.3 1 1
github.com/grahamgilbert/crypt/pkg/utils/get_computer_name.go:9.2,9.25 1 1
github.com/grahamgilbert/crypt/pkg/utils/os_version.go:7.53,9.16 2 1
github.com/grahamgilbert/crypt/pkg/utils/os_version.go:9.16,11.3 1 1
github.com/grahamgilbert/crypt/pkg/utils/os_version.go:13.2,13.44 1 1
github.com/grahamgilbert/crypt/pkg/utils/string_in_slice.go:3.52,4.25 1 1
github.com/grahamgilbert/crypt/pkg/utils/string_in_slice.go:4.25,5.15 1 1
github.com/grahamgilbert/crypt/pkg/utils/string_in_slice.go:5.15,7.4 1 1
github.com/grahamgilbert/crypt/pkg/utils/string_in_slice.go:9.2,9.14 1 1
27 changes: 25 additions & 2 deletions pkg/pref/pref.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Boolean Go_CFStringGetCString(CFStringRef str, char *buffer, CFIndex bufferSize,
import "C"
import (
"fmt"
"os/user"
"unsafe"

"github.com/pkg/errors"
Expand Down Expand Up @@ -123,11 +124,33 @@ func (p *Pref) Get(prefName string) (interface{}, error) {
}
}

func isRoot() (bool, error) {
currentUser, err := user.Current()
if err != nil {
return false, err
}

if currentUser.Uid == "0" {
return true, nil
}
return false, nil
}

// Set sets the value of a preference
// Why use defaults over cgo? It's simpler, and more reliable.
func (p *Pref) Set(prefName string, prefValue interface{}) error {
isRoot, err := isRoot()
if err != nil {
return errors.Wrap(err, "failed to determine if running as root")
}
cmd := "/usr/bin/defaults"
path := fmt.Sprintf("/Library/Preferences/%s", BundleID)
var path string
if isRoot {
path = fmt.Sprintf("/Library/Preferences/%s", BundleID)
} else {
path = BundleID
}

args := []string{"write", path, prefName}
switch v := prefValue.(type) {
case string:
Expand All @@ -149,7 +172,7 @@ func (p *Pref) Set(prefName string, prefValue interface{}) error {
return fmt.Errorf("unsupported preference type for %s", prefName)
}

_, err := p.Runner.RunCmd(cmd, args...)
_, err = p.Runner.RunCmd(cmd, args...)
if err != nil {
return errors.Wrap(err, "failed to set preference")
}
Expand Down

0 comments on commit 5a7dae0

Please sign in to comment.