mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
commit
2e857e1591
3 changed files with 53 additions and 58 deletions
|
@ -179,9 +179,8 @@ public class CommandProcessor {
|
||||||
int permission = parsePermission(args[2]);
|
int permission = parsePermission(args[2]);
|
||||||
String repName = args[3];
|
String repName = args[3];
|
||||||
if (!userMgr.isValidUser(sid)) {
|
if (!userMgr.isValidUser(sid)) {
|
||||||
log.error(
|
log.error("Failed to grant access for '" + sid +
|
||||||
"Failed to grant access for '" + sid +
|
"', user has not been added to server.");
|
||||||
"', user has not been added to server.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (permission < 0) {
|
if (permission < 0) {
|
||||||
|
|
|
@ -169,8 +169,8 @@ public class Repository implements FileSystemListener, RepositoryLogger {
|
||||||
GTimer.scheduleRunnable(RepositoryHandle.CLIENT_CHECK_PERIOD, () -> {
|
GTimer.scheduleRunnable(RepositoryHandle.CLIENT_CHECK_PERIOD, () -> {
|
||||||
synchronized (fileSystem) {
|
synchronized (fileSystem) {
|
||||||
RepositoryHandleImpl[] handles = getHandles();
|
RepositoryHandleImpl[] handles = getHandles();
|
||||||
for (int i = 0; i < handles.length; i++) {
|
for (RepositoryHandleImpl handle : handles) {
|
||||||
handles[i].checkHandle();
|
handle.checkHandle();
|
||||||
}
|
}
|
||||||
scheduleHandleCheck();
|
scheduleHandleCheck();
|
||||||
}
|
}
|
||||||
|
@ -195,8 +195,8 @@ public class Repository implements FileSystemListener, RepositoryLogger {
|
||||||
handles = new RepositoryHandleImpl[handleList.size()];
|
handles = new RepositoryHandleImpl[handleList.size()];
|
||||||
handleList.toArray(handles);
|
handleList.toArray(handles);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < handles.length; i++) {
|
for (RepositoryHandleImpl handle : handles) {
|
||||||
handles[i].dispose();
|
handle.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,8 +239,8 @@ public class Repository implements FileSystemListener, RepositoryLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
RepositoryHandleImpl[] handles = getHandles();
|
RepositoryHandleImpl[] handles = getHandles();
|
||||||
for (int i = 0; i < handles.length; i++) {
|
for (RepositoryHandleImpl handle : handles) {
|
||||||
handles[i].dispatchEvents(events);
|
handle.dispatchEvents(events);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ public class Repository implements FileSystemListener, RepositoryLogger {
|
||||||
* defined to the repository user manager.
|
* defined to the repository user manager.
|
||||||
* @param currentUser user performing request
|
* @param currentUser user performing request
|
||||||
* @return list of user names.
|
* @return list of user names.
|
||||||
* @throws IOException
|
* @throws IOException if an IO error occurs
|
||||||
*/
|
*/
|
||||||
public String[] getServerUserList(String currentUser) throws IOException {
|
public String[] getServerUserList(String currentUser) throws IOException {
|
||||||
if (UserManager.ANONYMOUS_USERNAME.equals(currentUser)) {
|
if (UserManager.ANONYMOUS_USERNAME.equals(currentUser)) {
|
||||||
|
@ -343,7 +343,7 @@ public class Repository implements FileSystemListener, RepositoryLogger {
|
||||||
* @param users user access list
|
* @param users user access list
|
||||||
* @param allowAnonymousAccess true if anonymous access should be permitted (assume allowed by server config).
|
* @param allowAnonymousAccess true if anonymous access should be permitted (assume allowed by server config).
|
||||||
* @throws UserAccessException if currentUser is not a current repository admin
|
* @throws UserAccessException if currentUser is not a current repository admin
|
||||||
* @throws IOException
|
* @throws IOException if an IO error occurs
|
||||||
*/
|
*/
|
||||||
public void setUserList(String currentUser, User[] users, boolean allowAnonymousAccess)
|
public void setUserList(String currentUser, User[] users, boolean allowAnonymousAccess)
|
||||||
throws UserAccessException, IOException {
|
throws UserAccessException, IOException {
|
||||||
|
@ -352,12 +352,12 @@ public class Repository implements FileSystemListener, RepositoryLogger {
|
||||||
validateAdminPrivilege(currentUser);
|
validateAdminPrivilege(currentUser);
|
||||||
|
|
||||||
LinkedHashMap<String, User> newUserMap = new LinkedHashMap<>();
|
LinkedHashMap<String, User> newUserMap = new LinkedHashMap<>();
|
||||||
for (int i = 0; i < users.length; i++) {
|
for (User user : users) {
|
||||||
String userName = users[i].getName();
|
String userName = user.getName();
|
||||||
if (UserManager.ANONYMOUS_USERNAME.equals(userName)) {
|
if (UserManager.ANONYMOUS_USERNAME.equals(userName)) {
|
||||||
continue; // ignore
|
continue; // ignore
|
||||||
}
|
}
|
||||||
newUserMap.put(userName, users[i]);
|
newUserMap.put(userName, user);
|
||||||
}
|
}
|
||||||
User user = newUserMap.get(currentUser);
|
User user = newUserMap.get(currentUser);
|
||||||
if (user == null || !user.isAdmin()) {
|
if (user == null || !user.isAdmin()) {
|
||||||
|
@ -434,8 +434,9 @@ public class Repository implements FileSystemListener, RepositoryLogger {
|
||||||
/**
|
/**
|
||||||
* Get the list of known users for this repository.
|
* Get the list of known users for this repository.
|
||||||
* @param currentUser user that is requesting the user list.
|
* @param currentUser user that is requesting the user list.
|
||||||
|
* @return array of repository users in the ACL
|
||||||
* @throws UserAccessException if currentUser is not a current repository admin
|
* @throws UserAccessException if currentUser is not a current repository admin
|
||||||
* @throws IOException
|
* @throws IOException if an IO error occurs
|
||||||
*/
|
*/
|
||||||
public User[] getUserList(String currentUser) throws UserAccessException, IOException {
|
public User[] getUserList(String currentUser) throws UserAccessException, IOException {
|
||||||
synchronized (fileSystem) {
|
synchronized (fileSystem) {
|
||||||
|
@ -446,9 +447,8 @@ public class Repository implements FileSystemListener, RepositoryLogger {
|
||||||
validateReadPrivilege(currentUser);
|
validateReadPrivilege(currentUser);
|
||||||
User[] users = new User[userMap.size()];
|
User[] users = new User[userMap.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Iterator<User> iter = userMap.values().iterator();
|
for (User element : userMap.values()) {
|
||||||
while (iter.hasNext()) {
|
users[i++] = element;
|
||||||
users[i++] = iter.next();
|
|
||||||
}
|
}
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
@ -488,7 +488,7 @@ public class Repository implements FileSystemListener, RepositoryLogger {
|
||||||
* @param newUserMap user map
|
* @param newUserMap user map
|
||||||
* @param allowAnonymous true if anonymous access is allowed
|
* @param allowAnonymous true if anonymous access is allowed
|
||||||
* @throws UserAccessException if currentUser does not have admin priviledge
|
* @throws UserAccessException if currentUser does not have admin priviledge
|
||||||
* @throws IOException
|
* @throws IOException if an IO error occurs
|
||||||
*/
|
*/
|
||||||
private void writeUserList(String currentUser, LinkedHashMap<String, User> newUserMap,
|
private void writeUserList(String currentUser, LinkedHashMap<String, User> newUserMap,
|
||||||
boolean allowAnonymous) throws UserAccessException, IOException {
|
boolean allowAnonymous) throws UserAccessException, IOException {
|
||||||
|
@ -506,7 +506,7 @@ public class Repository implements FileSystemListener, RepositoryLogger {
|
||||||
* @param newUserMap user map
|
* @param newUserMap user map
|
||||||
* @param allowAnonymous true if anonymous access is allowed
|
* @param allowAnonymous true if anonymous access is allowed
|
||||||
* @throws UserAccessException if currentUser does not have admin priviledge
|
* @throws UserAccessException if currentUser does not have admin priviledge
|
||||||
* @throws IOException
|
* @throws IOException if an IO error occurs
|
||||||
*/
|
*/
|
||||||
private void writeUserList(LinkedHashMap<String, User> newUserMap, boolean allowAnonymous)
|
private void writeUserList(LinkedHashMap<String, User> newUserMap, boolean allowAnonymous)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
@ -524,9 +524,7 @@ public class Repository implements FileSystemListener, RepositoryLogger {
|
||||||
out.println(ANONYMOUS_STR);
|
out.println(ANONYMOUS_STR);
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<User> iter = newUserMap.values().iterator();
|
for (User user : newUserMap.values()) {
|
||||||
while (iter.hasNext()) {
|
|
||||||
User user = iter.next();
|
|
||||||
String line = user.getName() + "=" + TYPE_NAMES[user.getPermissionType()];
|
String line = user.getName() + "=" + TYPE_NAMES[user.getPermissionType()];
|
||||||
out.println(line);
|
out.println(line);
|
||||||
}
|
}
|
||||||
|
@ -546,8 +544,8 @@ public class Repository implements FileSystemListener, RepositoryLogger {
|
||||||
* NOTE: This method is not yet implemented. Server admin should stop server
|
* NOTE: This method is not yet implemented. Server admin should stop server
|
||||||
* and simply delete those repository directories which are unwanted.
|
* and simply delete those repository directories which are unwanted.
|
||||||
* @param currentUser current user
|
* @param currentUser current user
|
||||||
* @throws IOException
|
* @throws IOException if an IO error occurs
|
||||||
* @throws UserAccessException
|
* @throws UserAccessException if currentUser does not have Admin priviledge
|
||||||
*/
|
*/
|
||||||
void delete(String currentUser) throws IOException, UserAccessException {
|
void delete(String currentUser) throws IOException, UserAccessException {
|
||||||
synchronized (fileSystem) {
|
synchronized (fileSystem) {
|
||||||
|
@ -621,7 +619,7 @@ public class Repository implements FileSystemListener, RepositoryLogger {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read user access list from local file.
|
* Read user access list from local file.
|
||||||
* @throws IOException
|
* @throws IOException if an IO error occurs
|
||||||
*/
|
*/
|
||||||
private void readAccessFile() throws IOException {
|
private void readAccessFile() throws IOException {
|
||||||
if (!userAccessFile.exists()) {
|
if (!userAccessFile.exists()) {
|
||||||
|
@ -633,15 +631,14 @@ public class Repository implements FileSystemListener, RepositoryLogger {
|
||||||
readAccessFile(userAccessFile, list) && mgr.anonymousAccessAllowed();
|
readAccessFile(userAccessFile, list) && mgr.anonymousAccessAllowed();
|
||||||
|
|
||||||
LinkedHashMap<String, User> newUserMap = new LinkedHashMap<>();
|
LinkedHashMap<String, User> newUserMap = new LinkedHashMap<>();
|
||||||
Iterator<User> iter = list.iterator();
|
|
||||||
boolean hasAdmin = false;
|
boolean hasAdmin = false;
|
||||||
while (iter.hasNext()) {
|
for (User user : list) {
|
||||||
User user = iter.next();
|
|
||||||
hasAdmin |= user.isAdmin();
|
hasAdmin |= user.isAdmin();
|
||||||
newUserMap.put(user.getName(), user);
|
newUserMap.put(user.getName(), user);
|
||||||
}
|
}
|
||||||
if (!hasAdmin) {
|
if (!hasAdmin) {
|
||||||
throw new IOException("Repository does not have an Admin");
|
RepositoryManager.log
|
||||||
|
.info("WARNING: Repository '" + name + "' does not have an assigned Admin");
|
||||||
}
|
}
|
||||||
userMap = newUserMap;
|
userMap = newUserMap;
|
||||||
}
|
}
|
||||||
|
@ -652,7 +649,7 @@ public class Repository implements FileSystemListener, RepositoryLogger {
|
||||||
* @param userAccessFile repository user access file
|
* @param userAccessFile repository user access file
|
||||||
* @param users list to be populated with user permissions defined by userAccessFile
|
* @param users list to be populated with user permissions defined by userAccessFile
|
||||||
* @return true if anonymous read-only access is permitted, else false
|
* @return true if anonymous read-only access is permitted, else false
|
||||||
* @throws IOException
|
* @throws IOException if an IO error occurs
|
||||||
*/
|
*/
|
||||||
private static boolean readAccessFile(File userAccessFile, List<User> users)
|
private static boolean readAccessFile(File userAccessFile, List<User> users)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
@ -684,7 +681,7 @@ public class Repository implements FileSystemListener, RepositoryLogger {
|
||||||
/**
|
/**
|
||||||
* Parse input line from user access list
|
* Parse input line from user access list
|
||||||
* @param line text line from user access file
|
* @param line text line from user access file
|
||||||
* @return
|
* @return new {@link User} instance parsed from text line of file or null
|
||||||
*/
|
*/
|
||||||
private static User processAccessLine(String line) {
|
private static User processAccessLine(String line) {
|
||||||
|
|
||||||
|
@ -977,8 +974,8 @@ public class Repository implements FileSystemListener, RepositoryLogger {
|
||||||
int indexVersion = IndexedLocalFileSystem.readIndexVersion(rootPath);
|
int indexVersion = IndexedLocalFileSystem.readIndexVersion(rootPath);
|
||||||
if (indexVersion >= IndexedLocalFileSystem.LATEST_INDEX_VERSION) {
|
if (indexVersion >= IndexedLocalFileSystem.LATEST_INDEX_VERSION) {
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
System.err.println(
|
System.err
|
||||||
"Repository '" + repositoryName + "' is already indexed!");
|
.println("Repository '" + repositoryName + "' is already indexed!");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ public class RepositoryAdapter implements RemoteAdapterListener {
|
||||||
* @param name repository name
|
* @param name repository name
|
||||||
*/
|
*/
|
||||||
public RepositoryAdapter(RepositoryServerAdapter serverAdapter, String name) {
|
public RepositoryAdapter(RepositoryServerAdapter serverAdapter, String name) {
|
||||||
|
(new Exception("CONSTRUCTED " + name)).printStackTrace();
|
||||||
this.serverAdapter = serverAdapter;
|
this.serverAdapter = serverAdapter;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
changeDispatcher = new RepositoryChangeDispatcher(this);
|
changeDispatcher = new RepositoryChangeDispatcher(this);
|
||||||
|
@ -178,6 +179,7 @@ public class RepositoryAdapter implements RemoteAdapterListener {
|
||||||
serverAdapter.connect(); // may cause auto-reconnect of repository
|
serverAdapter.connect(); // may cause auto-reconnect of repository
|
||||||
}
|
}
|
||||||
if (repository == null) {
|
if (repository == null) {
|
||||||
|
(new Exception("CONNECTION")).printStackTrace();
|
||||||
repository = serverAdapter.getRepositoryHandle(name);
|
repository = serverAdapter.getRepositoryHandle(name);
|
||||||
unexpectedDisconnect = false;
|
unexpectedDisconnect = false;
|
||||||
if (repository == null) {
|
if (repository == null) {
|
||||||
|
@ -410,8 +412,8 @@ public class RepositoryAdapter implements RemoteAdapterListener {
|
||||||
catch (NotConnectedException | RemoteException e) {
|
catch (NotConnectedException | RemoteException e) {
|
||||||
if (recoverConnection(e)) {
|
if (recoverConnection(e)) {
|
||||||
ManagedBufferFileAdapter bf =
|
ManagedBufferFileAdapter bf =
|
||||||
new ManagedBufferFileAdapter(repository.createDatabase(parentPath,
|
new ManagedBufferFileAdapter(repository.createDatabase(parentPath, itemName,
|
||||||
itemName, fileID, bufferSize, contentType, projectPath));
|
fileID, bufferSize, contentType, projectPath));
|
||||||
fileOpened();
|
fileOpened();
|
||||||
return bf;
|
return bf;
|
||||||
}
|
}
|
||||||
|
@ -428,17 +430,15 @@ public class RepositoryAdapter implements RemoteAdapterListener {
|
||||||
synchronized (serverAdapter) {
|
synchronized (serverAdapter) {
|
||||||
checkRepository();
|
checkRepository();
|
||||||
try {
|
try {
|
||||||
ManagedBufferFileAdapter bf =
|
ManagedBufferFileAdapter bf = new ManagedBufferFileAdapter(
|
||||||
new ManagedBufferFileAdapter(repository.openDatabase(parentPath, itemName,
|
repository.openDatabase(parentPath, itemName, version, minChangeDataVer));
|
||||||
version, minChangeDataVer));
|
|
||||||
fileOpened();
|
fileOpened();
|
||||||
return bf;
|
return bf;
|
||||||
}
|
}
|
||||||
catch (NotConnectedException | RemoteException e) {
|
catch (NotConnectedException | RemoteException e) {
|
||||||
if (recoverConnection(e)) {
|
if (recoverConnection(e)) {
|
||||||
ManagedBufferFileAdapter bf =
|
ManagedBufferFileAdapter bf = new ManagedBufferFileAdapter(
|
||||||
new ManagedBufferFileAdapter(repository.openDatabase(parentPath, itemName,
|
repository.openDatabase(parentPath, itemName, version, minChangeDataVer));
|
||||||
version, minChangeDataVer));
|
|
||||||
fileOpened();
|
fileOpened();
|
||||||
return bf;
|
return bf;
|
||||||
}
|
}
|
||||||
|
@ -450,22 +450,20 @@ public class RepositoryAdapter implements RemoteAdapterListener {
|
||||||
/*
|
/*
|
||||||
* @see ghidra.framework.remote.RepositoryHandle#openDatabase(java.lang.String, java.lang.String, long)
|
* @see ghidra.framework.remote.RepositoryHandle#openDatabase(java.lang.String, java.lang.String, long)
|
||||||
*/
|
*/
|
||||||
public ManagedBufferFileAdapter openDatabase(String parentPath, String itemName, long checkoutId)
|
public ManagedBufferFileAdapter openDatabase(String parentPath, String itemName,
|
||||||
throws IOException {
|
long checkoutId) throws IOException {
|
||||||
synchronized (serverAdapter) {
|
synchronized (serverAdapter) {
|
||||||
checkRepository();
|
checkRepository();
|
||||||
try {
|
try {
|
||||||
ManagedBufferFileAdapter bf =
|
ManagedBufferFileAdapter bf = new ManagedBufferFileAdapter(
|
||||||
new ManagedBufferFileAdapter(repository.openDatabase(parentPath, itemName,
|
repository.openDatabase(parentPath, itemName, checkoutId));
|
||||||
checkoutId));
|
|
||||||
fileOpened();
|
fileOpened();
|
||||||
return bf;
|
return bf;
|
||||||
}
|
}
|
||||||
catch (NotConnectedException | RemoteException e) {
|
catch (NotConnectedException | RemoteException e) {
|
||||||
if (recoverConnection(e)) {
|
if (recoverConnection(e)) {
|
||||||
ManagedBufferFileAdapter bf =
|
ManagedBufferFileAdapter bf = new ManagedBufferFileAdapter(
|
||||||
new ManagedBufferFileAdapter(repository.openDatabase(parentPath, itemName,
|
repository.openDatabase(parentPath, itemName, checkoutId));
|
||||||
checkoutId));
|
|
||||||
fileOpened();
|
fileOpened();
|
||||||
return bf;
|
return bf;
|
||||||
}
|
}
|
||||||
|
@ -745,7 +743,8 @@ public class RepositoryAdapter implements RemoteAdapterListener {
|
||||||
/*
|
/*
|
||||||
* @see ghidra.framework.remote.RepositoryHandle#getCheckout(java.lang.String, java.lang.String)
|
* @see ghidra.framework.remote.RepositoryHandle#getCheckout(java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public ItemCheckoutStatus[] getCheckouts(String parentPath, String itemName) throws IOException {
|
public ItemCheckoutStatus[] getCheckouts(String parentPath, String itemName)
|
||||||
|
throws IOException {
|
||||||
synchronized (serverAdapter) {
|
synchronized (serverAdapter) {
|
||||||
checkRepository();
|
checkRepository();
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue