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