/* * $Header: /home/gene/library/website/docsrc/show-uid/RCS/show-uid-c.c,v 395.1 2008/04/20 17:25:50 gene Exp $ */ /* Standard C */ #include #include #include /* Unix */ #include #include static void S_Print (char str[]) { printf ("%s\r\n", str); } static void S_PrintA (char *a[], int length) { int i; for (i = 0; i < length; ++i) { S_Print (a[i]); } } int main () { int rc = 0; struct passwd *pw_real, *pw_eff; { static char *a[] = { "Content-type: text/html", "", "", "", "

", "The Real & Effective User in a", "set-uid", "Program Written in C", "

", "", "" }; static int alen = sizeof a / sizeof a[0]; S_PrintA (a, alen); } pw_real = getpwuid (getuid ()); pw_eff = getpwuid (geteuid ()); printf ("\r\n", pw_real->pw_name, pw_eff->pw_name); { static char *b[] = { "
real user effective user
%s %s
", "

End.

", "", "" }; static int blen = sizeof b / sizeof b[0]; S_PrintA (b, blen); } return rc == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } /* --- end of file --- */