How to check if my app is being launched by Sudo?

Linux specific forum
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Code: Select all

If getuid_() = 0
  ; mighty root
Else
  ; somebody else
EndIf
quidquid Latine dictum sit altum videtur
thamarok
Enthusiast
Enthusiast
Posts: 282
Joined: Wed Sep 06, 2006 1:37 pm

Post by thamarok »

That's good code freak! Compliment, with this I can do programs that are limited for normal users but fully functional for superusers :)

By the way, when I did a search for getuid_ on Google, I found this page on IBM which is the command reference for Fortran for Linux:
http://publib.boulder.ibm.com/infocente ... getuid.htm

That's a good reference for API calls for Linux :D
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

I suggest to use the glibc documentation, as that is what PB links to.
It is a very complete and well written manual:
http://www.gnu.org/software/libc/manual ... index.html
(downloadable versions here)

It even is a funny read at times... :D
At this point in time this mystery should not be revealed, unless you have the relevant spell-casting materials: ashes from an original DOS 6.2 boot disk burnt in effigy, a crucifix blessed by St. Emacs, assorted herbal roots from Central America, sand from Cebu, etc. Sorry! The part of the implementation where this is used is not yet finished. For now please simply follow the existing examples. It'll become clearer once it is. –drepper
Oh btw, do not seach for "getuid_". The real function name is "getuid". PB just has
the convention of the _ at the end for external commands.
Last edited by freak on Tue Oct 03, 2006 1:09 pm, edited 1 time in total.
quidquid Latine dictum sit altum videtur
DarkDragon
Addict
Addict
Posts: 2347
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

I like this Linux-API reference more than any other: http://www.mkssoftware.com/docs/api_index.asp
bye,
Daniel
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

> I like this Linux-API reference more than any other: http://www.mkssoftware.com/docs/api_index.asp

There is no such thing as a "linux api" in general. There are several standards, but the
actual implementations may vary. Thats why i suggest to use the documentation
of the library that is actually used, which is the glibc.
quidquid Latine dictum sit altum videtur
Straker
Enthusiast
Enthusiast
Posts: 701
Joined: Wed Apr 13, 2005 10:45 pm
Location: Idaho, USA

Post by Straker »

Thanks for all the info. Exactly what I was looking for.
Image Image
Post Reply