Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Setting unix socket options.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas George <nicolas.george@e...>
Subject: Re: [Caml-list] Setting unix socket options.
Le quartidi 24 nivôse, an CCXI, tom hawkins a écrit :
> I just started playing with sockets through Ocaml, but I'm 
> having difficultly setting options on a socket.
> I can get the options just fine (getsockopt), but
> when I try to set an option I get "permission denied".
> 
> What am I doing wrong?

You are doing wrong that you are trying to set an option that obviously
requires superuser privileges. If you are using Linux, by exemple, you
can see in the source code:

                case SO_DEBUG:  
                        if(val && !capable(CAP_NET_ADMIN))
                        {
                                ret = -EACCES;
                        }
                        else
                                sk->debug=valbool;
                        break;

and the manpage says:

       SO_DEBUG
              Enable  socket  debugging.  Only  allowed for processes with the
              CAP_NET_ADMIN capability or an effective user id of 0.

In fact, _you_ are not doing anything wrong: the Linux kernel is wrong,
because the Single Unix Specification does not mention EACCES as a
permitted exit value for setsockopt, nor the fact that SO_DEBUG should
be restricted.