473,395 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

strange behaviour geteuid()

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
8 2567
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
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
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
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


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

"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Constantine | last post by:
Hello, What is the best way to copy a file? I need to copy a file that belongs to the user who ran my programme to my own directory. suid is set on the binary file that is to perform the job....
2
by: Paul Drummond | last post by:
Hi all, I am developing software for Linux Redhat9 and I have noticed some very strange behaviour when throwing exceptions within a shared library. All our exceptions are derived from...
3
by: Bruno van Dooren | last post by:
Hi All, i have some (3) different weird pointer problems that have me stumped. i suspect that the compiler behavior is correct because gcc shows the same results. ...
3
by: Sebastian C. | last post by:
Hello everybody Since I upgraded my Office XP Professional to SP3 I got strange behaviour. Pieces of code which works for 3 years now are suddenly stop to work properly. I have Office XP...
6
by: Edd Dawson | last post by:
Hi. I have a strange problem involving the passing of command line arguments to a C program I'm writing. I tried posting this in comp.programming yesterday but someone kindly suggested that I'd...
31
by: DeltaOne | last post by:
#include<stdio.h> typedef struct test{ int i; int j; }test; main(){ test var; var.i=10; var.j=20;
4
by: Gotch | last post by:
Hi, I'm getting a very strange behaviour while running a project I've done.... Let's expose it: I've two projects. Both of them use a Form to do some Gui stuff. Other threads pack up messages...
8
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples....
20
by: Pilcrow | last post by:
This behavior seems very strange to me, but I imagine that someone will be able to 'explain' it in terms of the famous C standard. -------------------- code -----------------------------------...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.