Hello All,
Here I have a small program which tries to register a port. If I run
this program as super user then the port is registered at a number
less than 1024. If I run the program as any other user then the port
is registed at a number more than 1024.
I want the super user also to use the ports above 1024. How do I force
the port number to be registered at a number > 1024, even when super
user is running the program.
I am using SunOS 5.7 Generic_106541-32 sun4u sparc SUNW,Ultra-5_10
Program:
#define PORTMAP
#include <rpc/rpc.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
unsigned long registryProg = 33333333;
unsigned long registryVers = 2;
bool_t pmap_unset(u_long prognum, u_long versnum);
void (*signal(int sig, void (*func)(int)))(int);
static void
regdaemonprog_2( struct svc_req *rqstp, register SVCXPRT *transp)
{
}
int main(int argc, char **argv)
{
register SVCXPRT *transp;
registryProg += getuid();
setpgrp();
pmap_unset(registryProg, registryVers);
pmap_unset(registryProg, 1);
transp = svctcp_create(RPC_ANYSOCK, 0, 0);
if (transp == NULL) {
fprintf(stderr, "cannot create tcp service.");
exit(1);
}
if (!svc_register(transp, registryProg, registryVers,
regdaemonprog_2, IPPROTO_TCP)) {
fprintf(stderr, "unable to register (registryProg,
registryVers, tcp)\n");
exit(1);
}
svc_run();
fprintf(stderr, "svc_run returned");
exit(1);
return(1);
}
Any help is greatly appreciated.
Thanks
-Vittal
|
|
0
|
|
|
|
Reply
|
vsnadagouda
|
8/18/2004 2:54:31 PM |
|
vsnadagouda@yahoo.com (Vittal) writes:
>Here I have a small program which tries to register a port. If I run
>this program as super user then the port is registered at a number
>less than 1024. If I run the program as any other user then the port
>is registed at a number more than 1024.
>I want the super user also to use the ports above 1024. How do I force
>the port number to be registered at a number > 1024, even when super
>user is running the program.
>I am using SunOS 5.7 Generic_106541-32 sun4u sparc SUNW,Ultra-5_10
Either create a socket and don't bind it to a specific part and
pass that to the svc create function or use TI-RPC (the native
Solaris RPC) which will not use reserved ports for services started
by the super user.
Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
|
|
0
|
|
|
|
Reply
|
Casper
|
8/18/2004 5:31:40 PM
|
|
Hello Casper,
Where can I find this TI-RPC library?
Thanks
-Vittal
Casper H.S. Dik <Casper.Dik@Sun.COM> wrote in message news:<4123927c$0$48933$e4fe514c@news.xs4all.nl>...
> vsnadagouda@yahoo.com (Vittal) writes:
>
> >Here I have a small program which tries to register a port. If I run
> >this program as super user then the port is registered at a number
> >less than 1024. If I run the program as any other user then the port
> >is registed at a number more than 1024.
>
> >I want the super user also to use the ports above 1024. How do I force
> >the port number to be registered at a number > 1024, even when super
> >user is running the program.
>
> >I am using SunOS 5.7 Generic_106541-32 sun4u sparc SUNW,Ultra-5_10
>
>
> Either create a socket and don't bind it to a specific part and
> pass that to the svc create function or use TI-RPC (the native
> Solaris RPC) which will not use reserved ports for services started
> by the super user.
>
> Casper
|
|
0
|
|
|
|
Reply
|
vsnadagouda
|
8/19/2004 11:36:09 AM
|
|
vsnadagouda@yahoo.com (Vittal) writes:
>Hello Casper,
>Where can I find this TI-RPC library?
it's part of linsl; just use the standard (non-socket) RPC interfaces.
Casper
|
|
0
|
|
|
|
Reply
|
Casper
|
8/19/2004 10:18:24 PM
|
|
I am using TI-PRC libs but still ports are alloted with numbers less than 1024.
$>cc -g registry.c -lnsl
stopped in main at line 62 in file "registry.c"
62 transp = svctcp_create(RPC_ANYSOCK, 0, 0);
(dbx) n
stopped in main at line 63 in file "registry.c"
63 if (transp == NULL) {
(dbx) p *transp
*transp = {
xp_fd = 3
xp_port = 684U
xp_ops = 0xff328ec0
xp_addrlen = 0
xp_tp = 0x21788 "/dev/tcp"
xp_netid = 0x21320 "tcp"
Am I doing anything wrong here???
Thanks
-Vittal
Casper H.S. Dik <Casper.Dik@Sun.COM> wrote in message news:<41252730$0$65124$e4fe514c@news.xs4all.nl>...
> vsnadagouda@yahoo.com (Vittal) writes:
>
> >Hello Casper,
>
> >Where can I find this TI-RPC library?
>
>
>
> it's part of linsl; just use the standard (non-socket) RPC interfaces.
>
>
> Casper
|
|
0
|
|
|
|
Reply
|
vsnadagouda
|
8/26/2004 1:51:56 PM
|
|
vsnadagouda@yahoo.com (Vittal) writes:
>I am using TI-PRC libs but still ports are alloted with numbers less than 1024.
>$>cc -g registry.c -lnsl
>stopped in main at line 62 in file "registry.c"
> 62 transp = svctcp_create(RPC_ANYSOCK, 0, 0);
That's still the "socket" interface, even though it's part of a single
library (anything with "tcp" in the name is socket based)
Look at the svc_create and related manual pages.,
Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
|
|
0
|
|
|
|
Reply
|
Casper
|
8/26/2004 3:00:40 PM
|
|
|
5 Replies
213 Views
(page loaded in 0.103 seconds)
|