Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 546319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:51:17+00:00 2026-05-13T10:51:17+00:00

Is it possible to use a sudo frontend (like gksudo) to elevate the privileges

  • 0

Is it possible to use a sudo frontend (like gksudo) to elevate the privileges of the current process? I know I can do the following:

sudo cat /etc/passwd-

But I’m interested in doing this:

sudo-become-root # magic function/command
cat /etc/passwd-

I’m writing in Python. My usecase is that I have a program that runs as the user, but may encounter files to read/write that are root-owned. I’d like to prompt for password, gain root privileges, do what I need, and then optionally drop privileges again.

I know I could separate admin logic and non-admin logic into separate processes, and then just run the admin process as root (with some communication — policykit/dbus would be a good fit here). But I was hoping for a much simpler (though admittedly more risky) solution.

I’m thinking something like running Solaris’s ppriv through sudo to then modify the current process’s privileges. Which seems like a hacky-but-workable roundtrip. But as far as I know, linux doesn’t offer ppriv.

(I’m surprised this isn’t obvious already; it seems like a not-uncommon thing to want and doesn’t seem to be a security hole to allow escalation in-process over escalation of a new process.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:51:17+00:00Added an answer on May 13, 2026 at 10:51 am

    Unfortunately, I’m not aware of a way to do what you want to do cleanly. I think your best bet is to make the program setuid (or run it under sudo) and then either do your dirty work and drop permissions, or fork() and drop permissions from one process and keep the other one around to do your root work.

    What you’re looking for are the setuid(2) / setreuid(2) / setregid(2) / setgroups(2) calls, but they are all hard wired to not allow you to gain privileges mid-invocation. You can only use them to “give away” privileges, as far as I know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Do I need to create all objects which i will possible use with itemRenderer
Possible Duplicate: Use of 'prototype' vs. 'this' in Javascript? I went to various websites
Is it possible to use a .netrc file on Windows when I'm using Git
is it possible to use captureScreenShotOnFailure for IE? maybe some kind of hacking that
Is it possible to use a Model inside the layout page? For instance, we
is it possible to use ffmpeg to convert a movie with variable framerate to
is it possible to use .hgignore in mercurial to ignore header files generated from
is it possible to use Java Reflection to print out the attributes of a
Is it possible to use jQuery in win32 application? I have seen interesting stuff
SOLVED so i forgot to sudo apt-get php5-sqlite also. downvoters gonna downvote :D (fyi,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.