Chapter Contents |
Previous |
Next |
getlogin |
Portability: | POSIX.1 conforming, UNIX compatible |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
EXAMPLE | |
RELATED FUNCTIONS | |
SEE ALSO |
SYNOPSIS |
#include <unistd.h> char *getlogin(void);
DESCRIPTION |
getlogin
returns the login name for the current process. Under USS OS/390, this is
the same as the userid defined for the batch job or TSO session that generated
the process. The name string is stored in a static area and may be overwritten
by subsequent calls to
getlogin
. The
getlogin
function fails if USS is not active
or installed.
RETURN VALUE |
getlogin
returns a pointer to the name string if successful, and a NULL pointer if
unsuccessful.
EXAMPLE |
This example tests to see if the effective user ID is the ID belonging to the login name.
#include <sys/types.h> #include <unistd.h> #include <pwd.h> #include <stdio.h> #include <stdlib.h> main() { char *name; struct passwd *unifo; name = getlogin(); if (!name) { perror("getlogin failure"); exit(EXIT_FAILURE); } unifo = getpwnam(name); if (!unifo) { perror("getpwnam failure"); exit(EXIT_FAILURE); } if (unifo->pw_uid == geteuid()) puts("Your user ID number matches the effective user ID."); else puts("Your user ID does not match the effective user ID."); exit(EXIT_SUCCESS); }
RELATED FUNCTIONS |
SEE ALSO |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.