Skip to content
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

Create button and functions for decreasing NI #18

Merged
merged 3 commits into from
Apr 1, 2018

Conversation

LauraAubin
Copy link
Owner

@LauraAubin LauraAubin commented Mar 31, 2018

What does this do?

Part of #13

This creates a button that will decrease the selected process' NI value.

What I learned:

Through this, I discovered that I could not lower the priority without having root privileges.

From the man page for setpriority:

EACCES
The caller attempted to lower a process priority, but did not have the required privilege.

And from the man page for renice:

Bugs
Non super-users can not increase scheduling priorities of their own processes, even if they were the ones that decreased the priorities in the first place.

What we learn here is that no non-privileged users can lower the niceness value, which in turn would increase it's priority. This is a security measure to protect vulnerability from applications taking up too much of the computer's CPU.

How to overcome this?

First I compiled the app in Xcode with created a .app file. When I tried to use sudo to run the app with root privileges:

sudo ./Xcode.app/Contents/MacOS/Xcode

It returned an error: Illegal instruction: 4. This error means that the OS did not understand the compiled application.

As a result, I had to take the app out of sandbox mode. Basically, sandboxing is a feature in Xcode that protects your system by limiting the app's privileges. In our case, we do not want this. These settings were found in the entitlements:

I removed both the security and the sandbox settings. The entitlements section is now empty.

After doing this, I recompiled a new .app file, and ran this command again:

sudo ./Xcode.app/Contents/MacOS/Xcode

Decreasing the NI value now works because sudo gives us the proper permissions and removing the sandbox allows the app to be understood by the OS.

@LauraAubin LauraAubin mentioned this pull request Apr 1, 2018
2 tasks
@@ -1,10 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
Copy link
Owner Author

Choose a reason for hiding this comment

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

Removed sandbox entitlement

<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
Copy link
Owner Author

Choose a reason for hiding this comment

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

Removed security entitlement

@LauraAubin LauraAubin merged commit 03c9aa4 into master Apr 1, 2018
@LauraAubin LauraAubin deleted the decrease-NI-with-button branch April 1, 2018 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant