By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,106 Members | 1,080 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,106 IT Pros & Developers. It's quick & easy.

strange behaviour geteuid()

P: n/a
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

Oct 6 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Op Fri, 06 Oct 2006 19:57:01 +0200 schreef fabio:

<snip>
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
--
Coos
Oct 6 '06 #2

P: n/a
Il Fri, 06 Oct 2006 20:09:29 +0200, Coos Haak ha scritto:

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

Oct 6 '06 #3

P: n/a
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.

[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

--
Artie Gold -- Austin, Texas
http://goldsays.blogspot.com
"You can't KISS* unless you MISS**"
[*-Keep it simple, stupid. **-Make it simple, stupid.]
Oct 6 '06 #4

P: n/a
Artie Gold wrote:
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
Oct 7 '06 #5

P: n/a


On Oct 7, 12:58 pm, Yevgen Muntyan <muntyan.removet...@tamu.edu>
wrote:
Artie Gold wrote:
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?

Oct 7 '06 #6

P: n/a

"Cong Wang" <xi************@gmail.comha scritto nel messaggio
news:11**********************@k70g2000cwa.googlegr oups.com...
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? :)
Oct 7 '06 #7

P: n/a
Yevgen Muntyan wrote:
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?

Oct 9 '06 #8

P: n/a
fabio wrote:
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
Oct 9 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.