Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 May 2002 22:56:54 +0200
From:      "Daniel Blankensteiner" <db@traceroute.dk>
To:        <freebsd-questions@freebsd.org>
Subject:   I386<<FreeBSD 4.5<<getlogin()
Message-ID:  <005401c2068a$35c1ebf0$6800a8c0@rafter>

next in thread | raw e-mail | index | archive | help
 Hi all
I have found a weird problem using getlogin() or maybe it is just me that
is weird ;-)
Here is the program:
#include <iostream.h>
#include <unistd.h>
#include <sys/types.h>
main() {
char *name[20];
*name = getlogin();
cout<<You are logged in as: "<<name<<endl;
int group;
group = getgid();
cout<<"Your group number is: "<<group<<endl;
int uid;
uid = getuid();
cout<<"Your uid is: "<<uid<<endl;
}
db# whoami
root
db# ./test
You are logged in as: root
Your group number is: 0
Your uid is: 0
db# su testuser
~% whoami
testuser
~% ./test
You are logged in as: root
Your group number is: 1000
Your uid is: 1000
What is going on? If I ssh to the computer and log in as testuser, the
program
works fine. Programs(proccess) that change user and use getlogin() may have
a security problem or am I just missing som "su" info?
btw what is the difference between a real and effective user?
br
db



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?005401c2068a$35c1ebf0$6800a8c0>