Merge "Set permissions on adb key file after write." into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1761566315
@@ -661,12 +661,6 @@ public class AdbDebuggingManager {
|
|||||||
return mTestUserKeyFile == null ? getAdbFile(ADB_KEYS_FILE) : mTestUserKeyFile;
|
return mTestUserKeyFile == null ? getAdbFile(ADB_KEYS_FILE) : mTestUserKeyFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createKeyFile(File keyFile) throws IOException {
|
|
||||||
keyFile.createNewFile();
|
|
||||||
FileUtils.setPermissions(keyFile.toString(),
|
|
||||||
FileUtils.S_IRUSR | FileUtils.S_IWUSR | FileUtils.S_IRGRP, -1, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeKey(String key) {
|
private void writeKey(String key) {
|
||||||
try {
|
try {
|
||||||
File keyFile = getUserKeyFile();
|
File keyFile = getUserKeyFile();
|
||||||
@@ -675,14 +669,13 @@ public class AdbDebuggingManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!keyFile.exists()) {
|
|
||||||
createKeyFile(keyFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
FileOutputStream fo = new FileOutputStream(keyFile, true);
|
FileOutputStream fo = new FileOutputStream(keyFile, true);
|
||||||
fo.write(key.getBytes());
|
fo.write(key.getBytes());
|
||||||
fo.write('\n');
|
fo.write('\n');
|
||||||
fo.close();
|
fo.close();
|
||||||
|
|
||||||
|
FileUtils.setPermissions(keyFile.toString(),
|
||||||
|
FileUtils.S_IRUSR | FileUtils.S_IWUSR | FileUtils.S_IRGRP, -1, -1);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Slog.e(TAG, "Error writing key:" + ex);
|
Slog.e(TAG, "Error writing key:" + ex);
|
||||||
}
|
}
|
||||||
@@ -698,10 +691,6 @@ public class AdbDebuggingManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!keyFile.exists()) {
|
|
||||||
createKeyFile(keyFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
atomicKeyFile = new AtomicFile(keyFile);
|
atomicKeyFile = new AtomicFile(keyFile);
|
||||||
fo = atomicKeyFile.startWrite();
|
fo = atomicKeyFile.startWrite();
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
@@ -709,6 +698,9 @@ public class AdbDebuggingManager {
|
|||||||
fo.write('\n');
|
fo.write('\n');
|
||||||
}
|
}
|
||||||
atomicKeyFile.finishWrite(fo);
|
atomicKeyFile.finishWrite(fo);
|
||||||
|
|
||||||
|
FileUtils.setPermissions(keyFile.toString(),
|
||||||
|
FileUtils.S_IRUSR | FileUtils.S_IWUSR | FileUtils.S_IRGRP, -1, -1);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Slog.e(TAG, "Error writing keys: " + ex);
|
Slog.e(TAG, "Error writing keys: " + ex);
|
||||||
if (atomicKeyFile != null) {
|
if (atomicKeyFile != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user