Commit Graph

107 Commits

Author SHA1 Message Date
Michael Kerrisk 6fdbc7794f access.2, prctl.2, recv.2, send.2, euidaccess.3, mbstowcs.3, mcheck.3: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2012-06-08 03:10:26 +12:00
Stefan Puiu 4c49bf908c send.2: Document EACCES error case for UDP
It seems sendto() can return EACCES for UDP as well; the current
man page in git only says it can return EACCES for Unix sockets.

I was able to make sendto() return EACCES if I try to send from
192.168.1.1/24 to 192.168.1.0. I think the relevant code (in
kernel 2.6.38, but also present in 2.6.7 and 2.6.32, the 2 kernels
we use) is this (net/ipv4/udp.c, udp_sendmsg()):

 910                err = -EACCES;
 911                if ((rt->rt_flags & RTCF_BROADCAST) &&
 912                    !sock_flag(sk, SOCK_BROADCAST))
 913                        goto out;

So I guess if the kernel finds a route to the destination and
it's a broadcast route (and the socket doesn't have the broadcast
flag), then it returns EACCES.

I can verify the behavior with a very simple program (attached).
I've run it on my Ubuntu 10.10 (2.6.35 kernel) and got this:

stefan@spuiu-vml2:~/src/test/broadcast$ ./broadcast_test 10.205.20.94
10.205.20.1
sendto() returned 4
stefan@spuiu-vml2:~/src/test/broadcast$ ./broadcast_test 10.205.20.94
10.205.20.0
sendto() returned negative, errno: 13/Permission denied

(10.205.20.94 is my local IP, of course).

=====
    #include <stdio.h>

    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    #include <errno.h>
    #include <stdlib.h>

    int main(int argc, char **argv)
    {
        int sock;

        if (argc < 2) {
            printf("Usage: %s local_address destination_address\n", argv[0]);
            exit(1);
        }

        sock = socket(AF_INET, SOCK_DGRAM, 0);
        if (sock < 0) {
            perror("socket");
            return -1;
        }

        struct sockaddr_in local_addr;
        local_addr.sin_family = AF_INET;
        local_addr.sin_port = htons(1234);
        local_addr.sin_addr.s_addr = inet_addr(argv[1]);
        int ret = bind(sock, (struct sockaddr *) &local_addr, sizeof(local_addr));
        if (ret < 0) {
            perror("bind");
            return -1;
        }

        struct sockaddr_in remote_addr;
        remote_addr.sin_family = AF_INET;
        remote_addr.sin_port = htons(1234);
        remote_addr.sin_addr.s_addr = inet_addr(argv[2]);
        ret = sendto(sock, "blah", 4, 0, (struct sockaddr *)&remote_addr, sizeof(remote_addr));
        if (ret < 0) {
            printf("sendto() returned negative, errno: %d/%m\n", errno);
        }
        else {
            printf("sendto() returned %d\n", ret);
        }

        return 0;
    }
=====

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2012-04-23 08:15:01 +12:00
Michael Kerrisk 1901002c4a fallocate.2, fork.2, open.2, send.2: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2012-02-27 14:12:16 +13:00
Michael Kerrisk 53aeb9c2da send.2: Add mention of sendmmsg(2)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2012-02-27 11:10:11 +13:00
Michael Kerrisk e5ded49fc8 send.2: CONFORMING TO: POSIX.1-2008 adds MSG_NOSIGNAL
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2011-10-01 07:16:10 +02:00
Michael Kerrisk 008f1ecc43 intro.1, time.1, accept.2, bind.2, connect.2, execve.2, flock.2, getdents.2, getpriority.2, getuid.2, intro.2, ioctl.2, mincore.2, mknod.2, personality.2, ptrace.2, read.2, recv.2, select_tut.2, send.2, sendfile.2, shmctl.2, sigaction.2, signal.2, stat.2, times.2, truncate.2, umask.2, wait.2, MB_CUR_MAX.3, MB_LEN_MAX.3, argz_add.3, btowc.3, clearenv.3, clock.3, cmsg.3, end.3, endian.3, errno.3, exit.3, fgetwc.3, fgetws.3, fopen.3, fputwc.3, fputws.3, fseek.3, fwide.3, getfsent.3, getgrnam.3, gethostid.3, getipnodebyname.3, getmntent.3, getpwnam.3, getwchar.3, grantpt.3, iconv.3, iconv_close.3, iconv_open.3, insque.3, intro.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, malloc.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mkstemp.3, mktemp.3, nl_langinfo.3, openpty.3, posix_openpt.3, printf.3, ptsname.3, putwchar.3, qecvt.3, rcmd.3, readdir.3, rexec.3, rpc.3, setnetgrent.3, shm_open.3, sigpause.3, stdin.3, stpcpy.3, strftime.3, strptime.3, syslog.3, towctrans.3, towlower.3, towupper.3, ttyslot.3, ungetwc.3, unlocked_stdio.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wprintf.3, console_ioctl.4, pts.4, elf.5, filesystems.5, hosts.5, proc.5, ttytype.5, boot.7, capabilities.7, credentials.7, epoll.7, glob.7, koi8-r.7, path_resolution.7, pty.7, signal.7, suffixes.7, time.7, unicode.7, unix.7, uri.7, utf-8.7: global fix: s/Unix/UNIX/
The man pages were rather inconsistent in the use of "Unix"
versus "UNIX". Let's go with the trademark usage.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-12 06:49:17 +02:00
Michael Kerrisk 3701130ad7 send.2: wfix
Signed-off-by: Michael Kerrisk <mtk@konstanz.(none)>
2010-08-29 08:33:07 +02:00
Michael Kerrisk b637ad73b1 recv.2, send.2: Remove obsolete reference to glibc version in NOTES
Signed-off-by: Michael Kerrisk <mtk@konstanz.(none)>
2010-08-29 08:32:22 +02:00
Nicholas Hunt f07435fbcc recv.2, send.2: Adjust type shown for msg_controllen to glibc reality
This patch fixes the type of msg_controllen in the struct msghdr
definition given in send.2 and recv.2 to match the definition in
glibc and the kernel.

Signed-off-by: Michael Kerrisk <mtk@konstanz.(none)>
2010-08-29 08:29:04 +02:00
Michael Kerrisk ff40dbb354 accept.2, connect.2, eventfd.2, flock.2, open.2, posix_fadvise.2, read.2, recv.2, sched_setscheduler.2, select_tut.2, send.2, signalfd.2, splice.2, timerfd_create.2, write.2, flockfile.3, mkfifo.3, mq_notify.3, mq_open.3, pthread_tryjoin_np.3, scanf.3, random.4, ddp.7, epoll.7, fifo.7, ip.7, pipe.7, socket.7, spufs.7: Global fix: s/non-blocking/nonblocking/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 17:43:10 +01:00
Michael Kerrisk 86426e0be4 accept.2, read.2, recv.2, send.2, write.2: Fix discussion of EAGAIN/EWOULDBLOCK errors
For a non-blocking socket, POSIX.1-2001/2008 allow either
EAGAIN or EWOULDBLOCK to be returned in cases where a call
would have blocked.  Although these constants are defined
with the same value on most Linux architectures (PA-RISC
is the exception), POSIX.1 does not require them to have
the same value.  Therefore, a portable application using
the sockets API should test for both errors when checking
this case.

(NB POSIX.1 only mentions EWOULDBLOCK in the context of
the sockets interfaces.)

Change made after a note cross-posted on linux-arch@vger,
http://thread.gmane.org/gmane.linux.debian.ports.hppa/5615
and a suggestion for write(2) from Carlos O'Donell

Reported-by: Carlos O'Donell <carlos@systemhalted.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2009-02-23 20:31:52 +13:00
Michael Kerrisk 3e4088f4a4 getpeername.2, getsockname.2, getsockopt.2, recv.2, send.2, shutdown.2: minor s/s/sockfd/ for cases not caught in previous changes
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2008-12-05 22:28:59 -05:00
Michael Kerrisk b56905c62b send.2: wfix (s/s/sockfd/ for a case missed earlier) 2008-12-05 22:28:59 -05:00
Michael Kerrisk 167441ee0b send.2: Minor layout fix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2008-12-05 22:28:59 -05:00
Michael Kerrisk 6926dbf541 recv.2, send.2: Make names of "address" and "address length" args more consistent
Make the names of these arguments more consistent with other
sockets man pages.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2008-12-05 22:28:58 -05:00
Michael Kerrisk c4e7b71426 getpeername.2, getsockname.2, getsockopt.2, recv.2, send.2, shutdown.2, sockatmark.3, socket.7, udplite.7: SYNOPSIS: Rename socket file descriptor argument to 'sockfd'
Many sockets man pages use the name 'sockfd' already.
For consistency, changes the others to do so as well.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2008-12-05 22:28:56 -05:00
Michael Kerrisk 5a2ff571fb connect.2, listen.2, send.2, uname.2, cmsg.3, proc.5, arp.7, ddp.7, icmp.7, ip.7, raw.7, socket.7, tcp.7, udp.7: Global fix: eliminate mention of the obsolete sysctl(2) interface
Many pages still mention use of the obsolete sysctl(2) system
call, or used the term "sysctls"; rewrite these mentions to
instead be in terms of /proc interfaces.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2008-11-25 20:54:11 -05:00
Michael Kerrisk 7f546896f5 tstamp 2008-10-06 16:26:23 +02:00
Michael Kerrisk 2dd5352dae send.2: make kernel version for MSG_CONFIRM more precise
s/2.3+ only/Since Linux 2.3.15/

Reported-by: Nicolas Franois <nicolas.francois@centraliens.net>
2008-09-29 12:35:13 +02:00
Michael Kerrisk 6eb4bccc16 Noted which flags appered in Linux 2.2. 2008-07-14 05:26:06 +00:00
Michael Kerrisk c4bb193f3c s/parameter/argument/ when talking about the things given
to a function call, for consistency with majority usage.
2008-07-10 20:53:08 +00:00
Michael Kerrisk 01538d0d51 ERRORS: Added reference to signal(7) in dicussion of EINTR. 2008-07-04 15:50:36 +00:00
Michael Kerrisk ca92ce95a3 Remove/replace extraneous .sp macros. 2008-01-01 14:13:55 +00:00
Michael Kerrisk 5895e7eb8d wspace in SYNOPSIS 2007-12-23 13:45:24 +00:00
Michael Kerrisk a08ea57c20 Make the standard indent for code samples, shell session
logs, etc. to be ".in +4n".
2007-12-19 05:53:30 +00:00
Michael Kerrisk 66ee0c7e89 ffix 2007-06-23 07:19:07 +00:00
Michael Kerrisk 097585edcb ffix 2007-06-22 20:40:07 +00:00
Michael Kerrisk 2f0af33ba6 ffix 2007-06-22 19:42:52 +00:00
Michael Kerrisk 1274071a69 ffix 2007-06-22 18:25:23 +00:00
Michael Kerrisk 0e1ad98ccf Updated FIXMEs 2007-06-13 21:48:16 +00:00
Michael Kerrisk 2b0fa18232 replace form `....' with \fI...\fP where the enclosed string is a pathname,
type name, or argument name.
2007-06-12 21:19:16 +00:00
Michael Kerrisk 75b94dc35c Change "e.g. " to "e.g., ", or in some cases, "for example, ".
Change "i.e. " to i.e.., ", or in some cases, "that is, ".
2007-06-08 11:56:22 +00:00
Michael Kerrisk d9bfdb9c21 Convert to American spelling conventions 2007-06-08 09:56:56 +00:00
Michael Kerrisk d9343c5c13 Removed version number from .TH line 2007-05-30 05:36:26 +00:00
Michael Kerrisk 1c27853f55 Added new EXAMPLE section referring to example in getaddrinfo.3 2007-05-28 10:53:03 +00:00
Michael Kerrisk ad7cc990f2 Change reference to path_resolution.2 to path_resolutiion.7 2007-05-26 12:41:39 +00:00
Michael Kerrisk 0bfa087b03 Add section numbers to references to other pages 2007-05-11 23:07:02 +00:00
Michael Kerrisk c13182efa3 Wrapped long lines, wrapped at sentence boundaries; stripped trailing
white space.
2007-04-12 22:42:49 +00:00
Michael Kerrisk 521bf58405 ffix 2007-04-03 14:04:54 +00:00
Michael Kerrisk 97c1eac86f Updated CONFORMING TO section 2006-08-03 13:57:17 +00:00
Michael Kerrisk 211ec15cf1 Fix missing arguments in statement about equivalent send() and sendto() calls. 2006-06-05 04:51:40 +00:00
Michael Kerrisk 7145b9a93c spfix 2006-06-03 01:26:30 +00:00
Michael Kerrisk 1c511da218 Updated FIXME. 2006-04-03 01:35:31 +00:00
Michael Kerrisk ea4adf4ba9 Added text to note that although POSIX says msg_controllen
should be socklen_t, glibc actually uses size_t.
Various formatting fixes.
2006-03-12 19:09:15 +00:00
Michael Kerrisk 92057f4dbc Updated FIXMEs 2006-02-08 09:44:13 +00:00
Michael Kerrisk 1df419f2b7 Add cmsg.3 to SEE ALSO. 2005-12-19 09:16:57 +00:00
Michael Kerrisk 69c4c18902 updated FIXME 2005-12-14 16:46:05 +00:00
Michael Kerrisk a28ed21cec Put flags list in alphabetcal order 2005-12-14 16:41:14 +00:00
Michael Kerrisk 145ff0249e Added cross-reference from discussion of MSG_MORE to UDP_CORK in udp(7). 2005-12-14 16:30:49 +00:00
Michael Kerrisk a749f870a8 s/XXX/FIXME/ 2005-10-26 11:27:52 +00:00
Michael Kerrisk e1d6264d9f Manual fixes for parentheses formatting 2005-10-19 07:29:28 +00:00
Michael Kerrisk e511ffb6bc Automated addition of parentheses by add_parens_for_own_funcs.sh 2005-10-19 06:54:38 +00:00
Michael Kerrisk b14d4aa5b8 Classical BSD versions are now always named x.yBSD (formerly
there was a mix of x.yBSD and BSD x.y).
2005-07-18 15:05:56 +00:00
Michael Kerrisk 85a3dc20db Added SEE ALSO for shutdown(2) 2005-06-30 09:40:35 +00:00
Michael Kerrisk cca657e227 triggered by http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=283179
The wording describing how errno is set was tidied up in a number of
pages.
2004-12-20 12:24:06 +00:00
Michael Kerrisk d3018c3c5e "from a socket" --> "on a socket" 2004-12-20 10:53:41 +00:00
Michael Kerrisk fea681dafb Import of man-pages 1.70 2004-11-03 13:51:07 +00:00