caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Setting unix socket options.
@ 2003-01-13 22:51 tom hawkins
  2003-01-13 23:12 ` Nicolas George
  0 siblings, 1 reply; 2+ messages in thread
From: tom hawkins @ 2003-01-13 22:51 UTC (permalink / raw)
  To: caml-list

Hello all,

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".
Here's my test code:

open Unix;;

let s = socket PF_INET SOCK_STREAM 0;;

let f () =
  setsockopt s SO_DEBUG true;;

let main () =
  if not (getsockopt s SO_DEBUG) then begin print_string "DebugOff"; print_newline () end;
  handle_unix_error f ();;

main ();;

Compiles fine.  Running produces this:

DebugOff
./server: "setsockopt" failed: Permission denied

What am I doing wrong?

Thanks,
Tom


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Setting unix socket options.
  2003-01-13 22:51 [Caml-list] Setting unix socket options tom hawkins
@ 2003-01-13 23:12 ` Nicolas George
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas George @ 2003-01-13 23:12 UTC (permalink / raw)
  To: caml-list; +Cc: tom hawkins

[-- Attachment #1: Type: text/plain, Size: 1223 bytes --]

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.

[-- Attachment #2: Type: application/pgp-signature, Size: 185 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-01-13 23:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-13 22:51 [Caml-list] Setting unix socket options tom hawkins
2003-01-13 23:12 ` Nicolas George

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).