[ILUG] finding user name from inside a C program

Colm MacCarthaigh colm at stdlib.net
Tue Sep 20 13:53:25 IST 2005


On Tue, Sep 20, 2005 at 01:23:21PM +0100, Joseph Manning wrote:
>    Does anyone know how to safely and easily determine the user name
>    of someone running a C program?

	getlogin()

That determines the username you are currently logged in as.

	getpwuid(getuid())

Gets the username of your current uid.

	getpwuid(geteuid())

Gets the username of your current effective uid.

Hope that helps :)

-- 
Colm MacCárthaigh                        Public Key: colm+pgp at stdlib.net



More information about the ILUG mailing list