![]() |
|
|
|||||||
| Home | Forums | Register | Rules & FAQ | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
Other UNIX.COM Threads You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's | manas6 | UNIX for Dummies Questions & Answers | 0 | 4 Weeks Ago 03:44 AM |
| asking about return code | naamas03 | Shell Programming and Scripting | 3 | 08-28-2007 01:53 AM |
| return value of a function | prez | Shell Programming and Scripting | 3 | 08-22-2007 02:08 PM |
| What is wrapper script and how to write | chiru | UNIX for Dummies Questions & Answers | 1 | 06-12-2006 02:23 AM |
| Return Code of tar in AIX | dupeng | AIX | 3 | 02-22-2004 08:05 PM |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
how to write a wrapper c code to return uid using getuid() function
And how to use setuid() ?
thanks |
| Forum Sponsor | ||
|
|
|
|||
|
Code:
#include <unistd.h>
uid_t myuid(void)
{
return getuid();
}
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 |
|
|||
|
setuid() is pretty integral to a safe unix process.
One basic mode is for a root privileged parent to acquire resources only it can handle (ports < 1024) and then delegate service to setuid(> 0) children/threads, ala OpenSSH and many other pieces of software via IPC. Given it's not easy to do securely and does pose a considerable security issue: mostly races and various abuses of unsafe programing practices in the privileged process. |
|
|||
|
one way:
Code:
id >> logfile Code:
/* myid.c */
#include <unistd.h>
uid_t myuid(void)
{
return getuid();
}
int main()
{
printf("%d\n", myuid() );
return 0;
}
in your script Code:
myid >> logfile |
|||
| Google UNIX.COM |