Skip to content

Commit 650ddb2

Browse files
committed
OSX app dir defauts updates
1 parent b339448 commit 650ddb2

16 files changed

Lines changed: 109 additions & 69 deletions

‎osx/Extensions/Action/Action.entitlements‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
<true/>
77
<key>com.apple.security.application-groups</key>
88
<array>
9-
<string>keybase</string>
9+
<string>$(TeamIdentifierPrefix)keybase</string>
1010
</array>
1111
<key>com.apple.security.files.user-selected.read-only</key>
1212
<true/>
13+
<key>keychain-access-groups</key>
14+
<array>
15+
<string>$(AppIdentifierPrefix)keybase</string>
16+
</array>
1317
</dict>
1418
</plist>

‎osx/Extensions/FinderSync/FinderSync.entitlements‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
<true/>
77
<key>com.apple.security.application-groups</key>
88
<array>
9-
<string>keybase</string>
9+
<string>$(TeamIdentifierPrefix)keybase</string>
1010
</array>
1111
<key>com.apple.security.files.user-selected.read-only</key>
1212
<true/>
13+
<key>keychain-access-groups</key>
14+
<array>
15+
<string>$(AppIdentifierPrefix)keybase</string>
16+
</array>
1317
</dict>
1418
</plist>

‎osx/Extensions/Share/Share.entitlements‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
<true/>
77
<key>com.apple.security.application-groups</key>
88
<array>
9-
<string>keybase</string>
9+
<string>$(TeamIdentifierPrefix)keybase</string>
1010
</array>
1111
<key>com.apple.security.files.user-selected.read-only</key>
1212
<true/>
13+
<key>keychain-access-groups</key>
14+
<array>
15+
<string>$(AppIdentifierPrefix)keybase</string>
16+
</array>
1317
</dict>
1418
</plist>

‎osx/KBKit/App/KBApp.m‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,12 @@ - (void)open {
7777
}];
7878
[AFNetworkReachabilityManager.sharedManager startMonitoring];
7979

80-
// Cleanup old stuff
81-
if (![userDefaults objectForKey:@"InstallVersion"]) {
82-
DDLogInfo(@"Removing old services and files");
83-
[KBUninstaller uninstall:@"keybase" completion:^(NSError *error) {}];
84-
}
80+
// // Cleanup old stuff
81+
// if (![userDefaults objectForKey:@"InstallVersion"]) {
82+
// DDLogInfo(@"Removing old services and files");
83+
// [KBUninstaller uninstall:@"keybase" completion:^(NSError *error) {}];
84+
// }
85+
8586
// Save installed version in case a later upgrade needs this info
8687
NSString *version = NSBundle.mainBundle.infoDictionary[@"CFBundleShortVersionString"];
8788
[userDefaults setObject:version forKey:@"InstallVersion"];

‎osx/KBKit/System/KBEnvConfig.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
#import <Foundation/Foundation.h>
1010

1111
typedef NS_ENUM (NSInteger, KBEnv) {
12-
KBEnvKeybaseIO,
13-
KBEnvLocalhost,
14-
KBEnvLocalhost2
12+
KBEnvProd,
13+
KBEnvDevel,
1514
};
1615

1716
@interface KBEnvConfig : NSObject

‎osx/KBKit/System/KBEnvConfig.m‎

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ @interface KBEnvConfig ()
1919
@property NSString *homeDir;
2020
@property NSString *host;
2121
@property (getter=isDebugEnabled) BOOL debugEnabled;
22+
@property (getter=isDebugEnabled) BOOL develMode;
2223
@property NSString *mountDir;
2324
@property NSString *sockFile;
2425
@property NSString *identifier;
@@ -37,10 +38,10 @@ @implementation KBEnvConfig
3738
- (instancetype)initWithEnv:(KBEnv)env {
3839
if ((self = [super init])) {
3940
switch (env) {
40-
case KBEnvKeybaseIO: {
41+
case KBEnvProd: {
4142
self.title = @"Keybase.io";
4243
self.identifier = @"kb";
43-
self.homeDir = [KBEnvConfig groupContainer:self.identifier];
44+
self.homeDir = KBPath(@"~", NO, NO); // [KBEnvConfig groupContainer:self.identifier];
4445
self.host = @"https://api.keybase.io:443";
4546
self.mountDir = KBPath(@"~/Keybase", NO, NO);
4647
self.debugEnabled = YES;
@@ -50,25 +51,13 @@ - (instancetype)initWithEnv:(KBEnv)env {
5051
self.installEnabled = YES;
5152
break;
5253
}
53-
case KBEnvLocalhost: {
54+
case KBEnvDevel: {
5455
self.title = @"Local";
5556
self.identifier = @"localhost";
56-
self.homeDir = [KBEnvConfig groupContainer:self.identifier];
57+
self.homeDir = KBPath(@"~", NO, NO); //[KBEnvConfig groupContainer:self.identifier];
5758
self.host = @"http://localhost:3000";
58-
self.mountDir = KBPath(@"~/Keybase.localhost", NO, NO);
59-
self.debugEnabled = YES;
60-
self.info = @"Uses the localhost web server";
61-
self.image = [NSImage imageNamed:NSImageNameComputer];
62-
self.launchdEnabled = YES;
63-
self.installEnabled = YES;
64-
break;
65-
}
66-
case KBEnvLocalhost2: {
67-
self.title = @"Local #2";
68-
self.identifier = @"localhost2";
69-
self.homeDir = [KBEnvConfig groupContainer:self.identifier];
70-
self.host = @"http://localhost:3000";
71-
self.mountDir = KBPath(@"~/Keybase.localhost2", NO, NO);
59+
self.develMode = YES;
60+
self.mountDir = KBPath(@"~/Keybase.local", NO, NO);
7261
self.debugEnabled = YES;
7362
self.info = @"Uses the localhost web server";
7463
self.image = [NSImage imageNamed:NSImageNameComputer];
@@ -95,7 +84,7 @@ + (instancetype)loadFromUserDefaults:(NSUserDefaults *)userDefaults {
9584
NSString *homeDir = [userDefaults stringForKey:@"HomeDir"];
9685
NSString *mountDir = [userDefaults stringForKey:@"MountDir"];
9786

98-
if (!homeDir) homeDir = [KBEnvConfig groupContainer:@"dev"];
87+
//if (!homeDir) homeDir = [KBEnvConfig groupContainer:@"dev"];
9988
if (!mountDir) mountDir = KBPath(@"~/Keybase.dev", NO, NO);
10089

10190
return [[KBEnvConfig alloc] initWithHomeDir:homeDir sockFile:nil mountDir:mountDir];
@@ -112,20 +101,26 @@ - (NSString *)sockFile:(BOOL)useDefault {
112101
if (_sockFile) {
113102
sockFile = _sockFile;
114103
} else {
115-
sockFile = KBPathInDir(_homeDir, @".config/keybase/keybased.sock", NO, NO);
104+
sockFile = KBPathInDir([self configDir], @"keybased.sock", NO, NO);
116105
}
117106
if ([sockFile length] > 103) {
118107
[NSException raise:NSInvalidArgumentException format:@"Sock path too long. It should be < 104 characters. %@", sockFile];
119108
}
120109
return sockFile;
121110
}
122111

112+
- (NSString *)configDir {
113+
NSString *appName = @"Keybase";
114+
if (self.develMode) appName = @"KeybaseDev";
115+
return KBPathInDir(_homeDir, NSStringWithFormat(@"Library/Application Support/%@", appName), NO, NO);
116+
}
117+
123118
- (NSString *)configFile:(BOOL)useDefault {
124119
NSString *configFile;
125120
if (_configFile) {
126121
configFile = _configFile;
127122
} else {
128-
configFile = KBPathInDir(_homeDir, @".config/keybase/config.json", NO, NO);
123+
configFile = KBPathInDir([self configDir], @"config.json", NO, NO);
129124
}
130125
return configFile;
131126
}
@@ -198,6 +193,7 @@ - (NSDictionary *)launchdPlistDictionaryForService {
198193
return @{
199194
@"Label": self.launchdLabelService,
200195
@"ProgramArguments": args,
196+
@"RunAtLoad": @YES,
201197
@"KeepAlive": @YES,
202198
@"StandardOutPath": NSStringWithFormat(@"%@/%@.log", logDir, self.launchdLabelService),
203199
@"StandardErrorPath": NSStringWithFormat(@"%@/%@.err", logDir, self.launchdLabelService),
@@ -254,6 +250,7 @@ - (NSDictionary *)launchdPlistDictionaryForKBFS {
254250
@"Label": self.launchdLabelKBFS,
255251
@"EnvironmentVariables": envs,
256252
@"ProgramArguments": args,
253+
@"RunAtLoad": @YES,
257254
@"KeepAlive": @YES,
258255
@"StandardOutPath": NSStringWithFormat(@"%@/%@.log", logDir, self.launchdLabelKBFS),
259256
@"StandardErrorPath": NSStringWithFormat(@"%@/%@.err", logDir, self.launchdLabelKBFS),
@@ -267,6 +264,10 @@ - (NSString *)commandLineForKBFS:(BOOL)useBundle escape:(BOOL)escape tilde:(BOOL
267264
}
268265

269266
- (BOOL)validate:(NSError **)error {
267+
if (!_homeDir) {
268+
if (error) *error = KBMakeError(-1, @"You need to specify a home directory");
269+
return NO;
270+
}
270271
if (![NSFileManager.defaultManager fileExistsAtPath:KBPath(_homeDir, NO, NO) isDirectory:nil]) {
271272
if (error) *error = KBMakeError(-1, @"%@ doesn't exist", _homeDir);
272273
return NO;

‎osx/KBKit/UI/Debug/KBEnvSelectView.m‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ - (void)viewInit {
6363
_customView = [[KBCustomEnvView alloc] init];
6464

6565
NSArray *envs = @[
66-
[[KBEnvironment alloc] initWithConfig:[KBEnvConfig env:KBEnvKeybaseIO]],
67-
[[KBEnvironment alloc] initWithConfig:[KBEnvConfig env:KBEnvLocalhost]],
68-
[[KBEnvironment alloc] initWithConfig:[KBEnvConfig env:KBEnvLocalhost2]],
66+
[[KBEnvironment alloc] initWithConfig:[KBEnvConfig env:KBEnvProd]],
67+
[[KBEnvironment alloc] initWithConfig:[KBEnvConfig env:KBEnvDevel]],
6968
[[KBEnvironment alloc] initWithConfig:[KBEnvConfig loadFromUserDefaults:[KBWorkspace userDefaults]]],
7069
];
7170
[_listView setObjects:envs animated:NO];

‎osx/KBKit/UI/Keys/KBKeyView.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616

1717
@property KBButton *cancelButton;
1818

19-
- (void)setKeyId:(KBRFOKID *)keyId editable:(BOOL)editable;
19+
- (void)setKey:(KBRIdentifyKey *)key editable:(BOOL)editable;
2020

2121
@end

‎osx/KBKit/UI/Keys/KBKeyView.m‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ @interface KBKeyView ()
1717
@property YOVBox *labels;
1818
@property KBPGPTextView *textView;
1919

20-
@property KBRFOKID *keyId;
20+
@property KBRIdentifyKey *key;
2121
@end
2222

2323
@implementation KBKeyView
@@ -77,11 +77,10 @@ - (void)viewInit {
7777
self.viewLayout = [YOBorderLayout layoutWithCenter:_textView top:@[_labels] bottom:@[buttons]];
7878
}
7979

80-
- (void)setKeyId:(KBRFOKID *)keyId editable:(BOOL)editable {
80+
- (void)setKey:(KBRIdentifyKey *)key editable:(BOOL)editable {
8181
NSAssert(self.window, @"Not in a window");
82-
NSAssert(keyId.kid, @"No kid");
8382

84-
_keyId = keyId;
83+
_key = key;
8584

8685
[_labels kb_removeAllSubviews];
8786

@@ -93,11 +92,11 @@ - (void)setKeyId:(KBRFOKID *)keyId editable:(BOOL)editable {
9392
[_labels addSubview:keyLabel];
9493
*/
9594

96-
if (_keyId.pgpFingerprint) {
95+
if (_key.pgpFingerprint) {
9796
KBHeaderLabelView *pgpLabel = [[KBHeaderLabelView alloc] init];
9897
pgpLabel.columnWidth = 140;
9998
[pgpLabel setHeader:@"PGP Fingerprint"];
100-
if (_keyId.pgpFingerprint) [pgpLabel addText:[KBHexString(_keyId.pgpFingerprint, @"") uppercaseString] style:KBTextStyleDefault options:KBTextOptionsMonospace lineBreakMode:NSLineBreakByCharWrapping targetBlock:nil];
99+
if (_key.pgpFingerprint) [pgpLabel addText:[KBHexString(_key.pgpFingerprint, @"") uppercaseString] style:KBTextStyleDefault options:KBTextOptionsMonospace lineBreakMode:NSLineBreakByCharWrapping targetBlock:nil];
101100
[_labels addSubview:pgpLabel];
102101
}
103102

@@ -120,7 +119,7 @@ - (void)addDescription:(NSString *)desc {
120119
KBHeaderLabelView *label = [[KBHeaderLabelView alloc] init];
121120
label.columnWidth = 140;
122121
[label setHeader:@"Description"];
123-
if (_keyId.pgpFingerprint) [label addText:desc style:KBTextStyleDefault options:KBTextOptionsMonospace lineBreakMode:NSLineBreakByWordWrapping targetBlock:nil];
122+
if (_key.pgpFingerprint) [label addText:desc style:KBTextStyleDefault options:KBTextOptionsMonospace lineBreakMode:NSLineBreakByWordWrapping targetBlock:nil];
124123
[_labels addSubview:label];
125124
[self setNeedsLayout];
126125
}
@@ -129,7 +128,7 @@ - (void)showPublic:(void (^)(NSError *error, KBRKeyInfo *keyInfo))completion {
129128
GHWeakSelf gself = self;
130129
KBRPgpRequest *request = [[KBRPgpRequest alloc] initWithClient:self.client];
131130
KBRPGPQuery *options = [[KBRPGPQuery alloc] init];
132-
options.query = KBHexString(_keyId.kid, nil);
131+
options.query = KBHexString(_key.KID, nil);
133132
options.exactMatch = YES;
134133
[request pgpExportWithSessionID:request.sessionId options:options completion:^(NSError *error, NSArray *keys) {
135134
// TODO This only works when we are the user being key exported
@@ -142,7 +141,7 @@ - (void)showPublic:(void (^)(NSError *error, KBRKeyInfo *keyInfo))completion {
142141
- (void)showSecret:(void (^)(NSError *error, KBRKeyInfo *keyInfo))completion {
143142
KBRPgpRequest *request = [[KBRPgpRequest alloc] initWithClient:self.client];
144143
KBRPGPQuery *options = [[KBRPGPQuery alloc] init];
145-
options.query = KBHexString(_keyId.kid, nil);
144+
options.query = KBHexString(_key.KID, nil);
146145
options.exactMatch = YES;
147146
options.secret = YES;
148147
GHWeakSelf gself = self;
@@ -156,8 +155,7 @@ - (void)showSecret:(void (^)(NSError *error, KBRKeyInfo *keyInfo))completion {
156155
}
157156

158157
- (void)removePGPKey:(dispatch_block_t)completion {
159-
NSAssert(_keyId.kid, @"No kid");
160-
NSData *kid = _keyId.kid;
158+
NSData *kid = _key.KID;
161159
[KBAlert yesNoWithTitle:@"Delete PGP Key" description:@"Are you sure you want to remove this PGP Key?" yes:@"Delete" view:self completion:^(BOOL yes) {
162160
if (yes) {
163161
KBRRevokeRequest *request = [[KBRRevokeRequest alloc] initWithClient:self.client];

‎osx/KBKit/UI/User/KBUserInfoLabels.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
- (void)addProofResults:(NSArray *)proofResults serviceName:(NSString *)serviceName editable:(BOOL)editable targetBlock:(void (^)(KBProofLabel *proofLabel))targetBlock;
2121

22-
- (void)addKey:(KBRFOKID *)key targetBlock:(void (^)(id sender, id object))targetBlock;
22+
- (void)addKey:(KBRIdentifyKey *)key targetBlock:(void (^)(id sender, KBRIdentifyKey *key))targetBlock;
2323

2424
- (void)addCryptocurrency:(KBRCryptocurrency *)cryptocurrency targetBlock:(void (^)(id sender, id object))targetBlock;
2525

0 commit comments

Comments
 (0)