Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions OpenBCI_GUI/Extras.pde
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,34 @@ public boolean isElevationNeeded(String path) {
}
return result;
}
/**
* Determines if user is in elevated group (plugdev).
*
* @return <code>true</code> if user is in group plugdev, <code>false</code> otherwise.
*/
public boolean isInElevatedGroup() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename isInElevatedGroupLinux()

boolean result = true;
if (isLinux()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverse if and do if(!isLinux) return at the beginning of this method.

try {
String command = "groups";
Process p = Runtime.getRuntime().exec(command);
p.waitFor();
InputStream stdIn = p.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(stdIn));
String[] values = bufferedReader.readLine().split(" ");
for (int idx=0; idx<values.length; idx++) {
result = values[idx].equals("plugdev");
if (result) {
break;
}
}
} catch (Exception e) {
return false;
}
}
return result;
}

/**
* Determine if user has administrative privileges.
*
Expand Down
4 changes: 2 additions & 2 deletions OpenBCI_GUI/OpenBCI_GUI.pde
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,8 @@ void delayedSetup() {
//Apply GUI-wide settings to front end at the end of setup
guiSettings.applySettings();

if (!isAdminUser() || isElevationNeeded()) {
outputError("OpenBCI_GUI: This application is not being run with Administrator access. This could limit the ability to connect to devices or read/write files.");
if (!isInElevatedGroup() && (!isAdminUser() || isElevationNeeded())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please separate this out to new if statement and say if (isLinux() && !isInElevatedGroupLinux()) since this only applies to one OS.

outputError("OpenBCI_GUI: This application is not being run with Administrator access or user is not member of plugdev group. This could limit the ability to connect to devices or read/write files.");
}
}

Expand Down