mirror of
https://github.com/samsonjs/arq_restore.git
synced 2026-03-25 09:25:53 +00:00
read AWS secret key from stdin instead of command line
This commit is contained in:
parent
bda692313f
commit
3bd7f247c9
2 changed files with 12 additions and 9 deletions
|
|
@ -139,7 +139,7 @@
|
|||
NSString *oAuth2RedirectURI = nil;
|
||||
|
||||
if ([targetType isEqualToString:@"aws"]) {
|
||||
if ([args count] != 6) {
|
||||
if ([args count] != 5) {
|
||||
SETNSERROR([self errorDomain], ERROR_USAGE, @"invalid arguments");
|
||||
return NO;
|
||||
}
|
||||
|
|
@ -149,7 +149,10 @@
|
|||
NSString *urlString = [NSString stringWithFormat:@"https://%@@%@/any_bucket", accessKeyId, [[usEast1 s3EndpointWithSSL:NO] host]];
|
||||
|
||||
endpoint = [NSURL URLWithString:urlString];
|
||||
secret = [args objectAtIndex:5];
|
||||
secret = [self readPasswordWithPrompt:@"enter AWS secret key:" error:error];
|
||||
if (secret == nil) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
} else if ([targetType isEqualToString:@"local"]) {
|
||||
if ([args count] != 5) {
|
||||
|
|
@ -259,7 +262,7 @@
|
|||
}
|
||||
|
||||
NSString *theComputerUUID = [args objectAtIndex:3];
|
||||
NSString *theEncryptionPassword = [self readEncryptionPassword:error];
|
||||
NSString *theEncryptionPassword = [self readPasswordWithPrompt:@"enter encryption password:" error:error];
|
||||
if (theEncryptionPassword == nil) {
|
||||
return NO;
|
||||
}
|
||||
|
|
@ -301,7 +304,7 @@
|
|||
NSString *theComputerUUID = [args objectAtIndex:3];
|
||||
NSString *theBucketUUID = [args objectAtIndex:4];
|
||||
|
||||
NSString *theEncryptionPassword = [self readEncryptionPassword:error];
|
||||
NSString *theEncryptionPassword = [self readPasswordWithPrompt:@"enter encryption password:" error:error];
|
||||
if (theEncryptionPassword == nil) {
|
||||
return NO;
|
||||
}
|
||||
|
|
@ -353,7 +356,7 @@
|
|||
NSString *theComputerUUID = [args objectAtIndex:3];
|
||||
NSString *theBucketUUID = [args objectAtIndex:4];
|
||||
|
||||
NSString *theEncryptionPassword = [self readEncryptionPassword:error];
|
||||
NSString *theEncryptionPassword = [self readPasswordWithPrompt:@"enter encryption password:" error:error];
|
||||
if (theEncryptionPassword == nil) {
|
||||
return NO;
|
||||
}
|
||||
|
|
@ -441,7 +444,7 @@
|
|||
NSString *theComputerUUID = [args objectAtIndex:3];
|
||||
NSString *theBucketUUID = [args objectAtIndex:4];
|
||||
|
||||
NSString *theEncryptionPassword = [self readEncryptionPassword:error];
|
||||
NSString *theEncryptionPassword = [self readPasswordWithPrompt:@"enter encryption password:" error:error];
|
||||
if (theEncryptionPassword == nil) {
|
||||
return NO;
|
||||
}
|
||||
|
|
@ -773,8 +776,8 @@
|
|||
|
||||
|
||||
#pragma mark internal
|
||||
- (NSString *)readEncryptionPassword:(NSError **)error {
|
||||
printf("enter encryption password: ");
|
||||
- (NSString *)readPasswordWithPrompt:(NSString *)thePrompt error:(NSError **)error {
|
||||
printf("%s ", [thePrompt UTF8String]);
|
||||
fflush(stdout);
|
||||
|
||||
struct termios oldTermios;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
static void printUsage(const char *exeName) {
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr, "\t%s [-l loglevel] listtargets\n", exeName);
|
||||
fprintf(stderr, "\t%s [-l loglevel] addtarget <nickname> aws <access_key> <secret_key> \n", exeName);
|
||||
fprintf(stderr, "\t%s [-l loglevel] addtarget <nickname> aws <access_key>\n", exeName);
|
||||
fprintf(stderr, "\t%s [-l loglevel] addtarget <nickname> local <path>\n", exeName);
|
||||
fprintf(stderr, "\t%s [-l loglevel] deletetarget <nickname>\n", exeName);
|
||||
fprintf(stderr, "\n");
|
||||
|
|
|
|||
Loading…
Reference in a new issue