strange behaviour geteuid()

F

fabio

hi everybody

i have a weird problem with my project, look at this:
****************************************************
Debian:/progetto/PROGETTO$ ls -al server
-rwsr-xr-x 1 root faz 372731 2006-09-27 15:49 server

debian:/progetto/PROGETTO$ gdb ./server
GNU gdb 6.3-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-linux"...Using host libthread_db library "/lib/tls/libthread_db.so.1".

(gdb) b server.c:411
Breakpoint 1 at 0x804abbc: file server.c, line 411.
(gdb) r
Starting program: /progetto/PROGETTO/server
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 8496)]
[Switching to Thread 16384 (LWP 8496)]

Breakpoint 1, main () at server.c:411
411 if (geteuid() != 0 || getegid() != 0)
(gdb) p geteuid()
$1 = 1000
--------------------------------------------------------------

why geteuid() returns 1000?? shouldn't it return 0??
it doesn't work without gdb neither:

debian:/progetto/PROGETTO$ ls -al faz_server
-rwsr-xr-x 1 root faz 366585 2006-10-06 19:49 faz_server
debian:/progetto/PROGETTO$ ./faz_server

Server has to run with superuser privileges to make authentication!
Quit.
debian:/progetto/PROGETTO$
-------------------------------------------------------------

and the related code is:
-------------------------------------------------------------
int main()
{
int i,j,s,rc, sizeof_csa, optval=1;

struct sockaddr_in sa;
struct sockaddr_in csa;

struct sockaddr_in sa_f;
struct sockaddr_in sa_fc;
int s_f=-1, sizeof_sa_fc;
int idTh = 0;

#ifdef _DEMON
rc = demonize();
if (rc == -1) { err_log("Error process can't be demonized\n"); exit(0); }
else if (rc == -2) { exit(0); }
#endif

//first of all, check if server has euid=0 when auth with pam or shadow are enabled, if not abort
#if defined(_S_AUTH) && (defined(___USE_PAM) || defined(_USE_SHADOW))

//not necessary to have real user id to root , i can use effective to make auth
if (geteuid() != 0 || getegid() != 0)
{
err_log("\nServer has to run with superuser privileges to make authentication!\nQuit.\n");
exit(0);
}

#endif

[...]

so i wonder... where is the bug?? it's the real beginning of program! it's
not a matter of memory corruption, i don't know how to solve it..

thanks for any help
 
C

Coos Haak

Op Fri, 06 Oct 2006 19:57:01 +0200 schreef fabio:

int main()
{
int i,j,s,rc, sizeof_csa, optval=1;

struct sockaddr_in sa;
Standard C does not know sockets
Try another newsgroup, e.g. comp.unix.programmer
 
A

Artie Gold

fabio said:
hi everybody

i have a weird problem with my project, look at this:
****************************************************
Debian:/progetto/PROGETTO$ ls -al server
-rwsr-xr-x 1 root faz 372731 2006-09-27 15:49 server

debian:/progetto/PROGETTO$ gdb ./server
GNU gdb 6.3-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-linux"...Using host libthread_db library "/lib/tls/libthread_db.so.1".

(gdb) b server.c:411
Breakpoint 1 at 0x804abbc: file server.c, line 411.
(gdb) r
Starting program: /progetto/PROGETTO/server
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 8496)]
[Switching to Thread 16384 (LWP 8496)]

Breakpoint 1, main () at server.c:411
411 if (geteuid() != 0 || getegid() != 0)
(gdb) p geteuid()
$1 = 1000

Since the facilities of which you speak are not part of standard C (the
topic of /this/ newsgroup, I have redirected this to

In the future, please be aware of the fact that platform specific
queries should be directed to platform specific forums.

[followups set].

HTH,
--ag
--------------------------------------------------------------

why geteuid() returns 1000?? shouldn't it return 0??
it doesn't work without gdb neither:

debian:/progetto/PROGETTO$ ls -al faz_server
-rwsr-xr-x 1 root faz 366585 2006-10-06 19:49 faz_server
debian:/progetto/PROGETTO$ ./faz_server

Server has to run with superuser privileges to make authentication!
Quit.
debian:/progetto/PROGETTO$
-------------------------------------------------------------

and the related code is:
-------------------------------------------------------------
int main()
{
int i,j,s,rc, sizeof_csa, optval=1;

struct sockaddr_in sa;
struct sockaddr_in csa;

struct sockaddr_in sa_f;
struct sockaddr_in sa_fc;
int s_f=-1, sizeof_sa_fc;
int idTh = 0;

#ifdef _DEMON
rc = demonize();
if (rc == -1) { err_log("Error process can't be demonized\n"); exit(0); }
else if (rc == -2) { exit(0); }
#endif

//first of all, check if server has euid=0 when auth with pam or shadow are enabled, if not abort
#if defined(_S_AUTH) && (defined(___USE_PAM) || defined(_USE_SHADOW))

//not necessary to have real user id to root , i can use effective to make auth
if (geteuid() != 0 || getegid() != 0)
{
err_log("\nServer has to run with superuser privileges to make authentication!\nQuit.\n");
exit(0);
}

#endif

[...]

so i wonder... where is the bug?? it's the real beginning of program! it's
not a matter of memory corruption, i don't know how to solve it..

thanks for any help
 
Y

Yevgen Muntyan

Artie said:
fabio said:
hi everybody

i have a weird problem with my project, look at this:
****************************************************
Debian:/progetto/PROGETTO$ ls -al server
-rwsr-xr-x 1 root faz 372731 2006-09-27 15:49 server

debian:/progetto/PROGETTO$ gdb ./server
GNU gdb 6.3-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "i386-linux"...Using host libthread_db
library "/lib/tls/libthread_db.so.1".

(gdb) b server.c:411
Breakpoint 1 at 0x804abbc: file server.c, line 411.
(gdb) r
Starting program: /progetto/PROGETTO/server
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 8496)]
[Switching to Thread 16384 (LWP 8496)]

Breakpoint 1, main () at server.c:411
411 if (geteuid() != 0 || getegid() != 0)
(gdb) p geteuid()
$1 = 1000


Since the facilities of which you speak are not part of standard C (the
topic of /this/ newsgroup, I have redirected this to

In the future, please be aware of the fact that platform specific
queries should be directed to platform specific forums.

I wonder about the following: if a person made a mistake, and made
an offtopic post by mistake, why the hell tell about this to whole
zillion of people? Another question is: why the hell people like
to "correct" follow-up? Do you think folks in some.some.some
share your opinion about topicality?

There is a specific deserving special attention case. When people
post to twenty newgroups about some bullshit. That needs to be
*ingored*, then trolls don't get what they want, non-trolls might
start thinking "why my very intersting post got no replies while
that trivial ***-specific stuff invoked huge discussion?".

Does someone not agree to the above *trivial* program about
not feeding trolls?

One might say "so it's here in public, others won't make this
mistake" or "many others might become aware that they shouldn't
post what they are gonna post". Well, absolutely not. Just look
at all those off-topic posts. There are about zillion and ten,
and still new appear. You know why? Because those new folks do not
read those *replies* to *irrelevant* off-topic posts, naturally.

One thing is that a person actually answers a question and then says
"you're in a wrong place, go to ...". This actually does good for
people, like useful information and stuff; later someone actually
can use this answer, think people searching net!!!
But what *good* does a reply saying "wrong group"? Please don't say "it
informs OP that this is a wrong group" - you don't need to inform
thousands about that to inform one OP about that. Private mail
or ignoring would do.

Artie Gold, please don't take it like I think you're the evil of
internet. You do contribute, but it's not your fault perhaps. Dark
side...

Also, some might say "off topic". Oh yeah it shizzing is :)

Regards,
Yevgen
 
C

Cong Wang

Artie said:
fabio wrote:
hi everybody
i have a weird problem with my project, look at this:
****************************************************
Debian:/progetto/PROGETTO$ ls -al server
-rwsr-xr-x 1 root faz 372731 2006-09-27 15:49 server
debian:/progetto/PROGETTO$ gdb ./server
GNU gdb 6.3-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "i386-linux"...Using host libthread_db
library "/lib/tls/libthread_db.so.1".
(gdb) b server.c:411
Breakpoint 1 at 0x804abbc: file server.c, line 411.
(gdb) r
Starting program: /progetto/PROGETTO/server
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 8496)]
[Switching to Thread 16384 (LWP 8496)]
Breakpoint 1, main () at server.c:411
411 if (geteuid() != 0 || getegid() != 0)
(gdb) p geteuid()
$1 = 1000
Since the facilities of which you speak are not part of standard C (the
topic of /this/ newsgroup, I have redirected this to
news:comp.unix.programmer.
In the future, please be aware of the fact that platform specific
queries should be directed to platform specific forums.I wonder about the following: if a person made a mistake, and made
an offtopic post by mistake, why the hell tell about this to whole
zillion of people? Another question is: why the hell people like
to "correct" follow-up? Do you think folks in some.some.some
share your opinion about topicality?

There is a specific deserving special attention case. When people
post to twenty newgroups about some bullshit. That needs to be
*ingored*, then trolls don't get what they want, non-trolls might
start thinking "why my very intersting post got no replies while
that trivial ***-specific stuff invoked huge discussion?".

Does someone not agree to the above *trivial* program about
not feeding trolls?

One might say "so it's here in public, others won't make this
mistake" or "many others might become aware that they shouldn't
post what they are gonna post". Well, absolutely not. Just look
at all those off-topic posts. There are about zillion and ten,
and still new appear. You know why? Because those new folks do not
read those *replies* to *irrelevant* off-topic posts, naturally.

One thing is that a person actually answers a question and then says
"you're in a wrong place, go to ...". This actually does good for
people, like useful information and stuff; later someone actually
can use this answer, think people searching net!!!
But what *good* does a reply saying "wrong group"? Please don't say "it
informs OP that this is a wrong group" - you don't need to inform
thousands about that to inform one OP about that. Private mail
or ignoring would do.

Artie Gold, please don't take it like I think you're the evil of
internet. You do contribute, but it's not your fault perhaps. Dark
side...

Also, some might say "off topic". Oh yeah it shizzing is :)

Regards,
Yevgen

Hmm, we all should look at the off-topic posts and then do nothing.
Right?
 
F

fiocco

Hmm, we all should look at the off-topic posts and then do nothing.
Right?

ehi man, i was talking about _C_ and unix programming aniway.
i was not talking about some offensive horseshit
so don't take it this way, what should you do, shoot me? :)
 
O

Old Wolf

Yevgen said:
One thing is that a person actually answers a question and then says
"you're in a wrong place, go to ...". This actually does good for
people, like useful information and stuff; later someone actually
can use this answer, think people searching net!!!
But what *good* does a reply saying "wrong group"? Please don't say "it
informs OP that this is a wrong group" - you don't need to inform
thousands about that to inform one OP about that. Private mail
or ignoring would do.

How would you suggest that we send "private mail" to
the original poster? Look at his supplied email address.

If everyone ignores his post, he may think that nobody read it
or there was a technical problem, in either case he will wait
around for a while before he realises that maybe he should
have posted it elsewhere.

If someone tells him what the correct newsgroup is, then he
can post there and get a correct answer quickly.

If you post in the wrong place, would you rather be ignored,
or be directed to the right place?
 
I

Igmar Palsenberg

fabio said:
so i wonder... where is the bug?? it's the real beginning of program! it's
not a matter of memory corruption, i don't know how to solve it..

The filesystem is probably NFS, or something else mounted nosuid.



Igmar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top