The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 05-12-2008
jim mcnamara jim mcnamara is offline
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,464
Code:
#include <unistd.h>
uid_t myuid(void)
{
    return getuid();
}
No offense meant, but setuid is a major security risk. Don't go implementing your code on your system unless it is a home desktop that can be trashed.

setuid requires either root or the so-called sticky bit set to allow the program to change it's username.

It may seem simple but there is a lot to writing a setuid program:

http://nob.cs.ucdavis.edu/bishop/sec...sproglogin.pdf
Reply With Quote