-
Notifications
You must be signed in to change notification settings - Fork 272
Fix detection of plugdev group for Linux users #1214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() { | ||
boolean result = true; | ||
if (isLinux()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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())) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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."); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename isInElevatedGroupLinux()