WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: running a binary as root  (Read 2592 times)

Offline robc

  • Sr. Member
  • ****
  • Posts: 447
running a binary as root
« on: December 03, 2009, 01:34:55 PM »
I just built bleachbit (http://bleachbit.sourceforge.net/) into an extension, but in order for it to run properly (ie use swapoff, remove some files) it will need to be ran as root. Setting the permissions to 4755 does not seem to help. The only ways that seem to work are using sudo and as the root user.

I would like to make it easy for the end user so they will only need to select it from the menu or click on it in wbar. Is it appropriate to use the sudo command in cases like this? Some users may have there sudo locked down so it would not work properly on their system. Or should I just run the binary as the normal user and leave it up to the user to explicitly call the binary as root if/when needed?
"Never give up! Never surrender!" - Commander Peter Quincy Taggart

"Make it so." - Captain Picard

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: running a binary as root
« Reply #1 on: December 03, 2009, 01:52:50 PM »
Is it beacuse it is linked in from loop? Perhaps a startup script to force copy into filesystem with desired permissions?
10+ Years Contributing to Linux Open Source Projects.

Offline robc

  • Sr. Member
  • ****
  • Posts: 447
Re: running a binary as root
« Reply #2 on: December 03, 2009, 02:14:07 PM »
well, the binary is actually a python script. I have manually changed the permissions to 4755 after I loaded the extension, this does not work. I think it is a problem because it is a python script.
"Never give up! Never surrender!" - Commander Peter Quincy Taggart

"Make it so." - Captain Picard

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: running a binary as root
« Reply #3 on: December 03, 2009, 02:16:26 PM »
Scripts cannot run setuid, only binaries.
This is a security issue.

Offline robc

  • Sr. Member
  • ****
  • Posts: 447
Re: running a binary as root
« Reply #4 on: December 03, 2009, 02:22:56 PM »
Scripts cannot run setuid, only binaries.
This is a security issue.
Yes I just read this, I would have to create a C wrapper for this to work.
"Never give up! Never surrender!" - Commander Peter Quincy Taggart

"Make it so." - Captain Picard

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: running a binary as root
« Reply #5 on: December 03, 2009, 02:24:06 PM »
Just curious, how does that project suggest it be run?
10+ Years Contributing to Linux Open Source Projects.

Offline robc

  • Sr. Member
  • ****
  • Posts: 447
Re: running a binary as root
« Reply #6 on: December 03, 2009, 02:57:26 PM »
Just curious, how does that project suggest it be run?
They use the sudo command to run the application as root from a menu...here is a bug report about it: https://bugs.launchpad.net/bleachbit/+bug/480488
"Never give up! Never surrender!" - Commander Peter Quincy Taggart

"Make it so." - Captain Picard

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: running a binary as root
« Reply #7 on: December 03, 2009, 03:26:01 PM »
What advantage would a C wrapper have over sudo?
Sudo is a C wrapper with configurable security features.

Offline robc

  • Sr. Member
  • ****
  • Posts: 447
Re: running a binary as root
« Reply #8 on: December 03, 2009, 04:00:34 PM »
What advantage would a C wrapper have over sudo?
Sudo is a C wrapper with configurable security features.
I was thinking the same thing. I'll just use sudo and comment in the info file that sudo needs to be properly configured for running scripts.
Or would it be better to offer both a non-root and root option in the menu? what about for wbar then?
"Never give up! Never surrender!" - Commander Peter Quincy Taggart

"Make it so." - Captain Picard