diff options
Diffstat (limited to 'inet/rcmd.c')
-rw-r--r-- | inet/rcmd.c | 100 |
1 files changed, 25 insertions, 75 deletions
diff --git a/inet/rcmd.c b/inet/rcmd.c index 0bcb731a16..341304acd5 100644 --- a/inet/rcmd.c +++ b/inet/rcmd.c @@ -137,21 +137,13 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) (void)__snprintf(num, sizeof(num), "%d", ntohs(rport)); error = getaddrinfo(*ahost, num, &hints, &res); if (error) { - if (error == EAI_NONAME && *ahost != NULL) { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf(stderr, L"%s: Unknown host\n", - *ahost); - else - fprintf(stderr, "%s: Unknown host\n", *ahost); - } else { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf(stderr, L"rcmd: getaddrinfo: %s\n", - gai_strerror(error)); - else - fprintf(stderr, "rcmd: getaddrinfo: %s\n", - gai_strerror(error)); - } - return (-1); + if (error == EAI_NONAME && *ahost != NULL) + __fxprintf(NULL, "%s: Unknown host\n", *ahost); + else + __fxprintf(NULL, "rcmd: getaddrinfo: %s\n", + gai_strerror(error)); + + return -1; } pfd[0].events = POLLIN; @@ -161,13 +153,9 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) free (ahostbuf); ahostbuf = strdup (res->ai_canonname); if (ahostbuf == NULL) { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf(stderr, L"%s", - _("rcmd: Cannot allocate memory\n")); - else - fputs(_("rcmd: Cannot allocate memory\n"), - stderr); - return (-1); + __fxprintf(NULL, "%s", + _("rcmd: Cannot allocate memory\n")); + return -1; } *ahost = ahostbuf; } else @@ -180,20 +168,12 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) s = rresvport_af(&lport, ai->ai_family); if (s < 0) { - if (errno == EAGAIN) { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf(stderr, L"%s", - _("rcmd: socket: All ports in use\n")); - else - fputs(_("rcmd: socket: All ports in use\n"), - stderr); - } else { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf(stderr, - L"rcmd: socket: %m\n"); - else - fprintf(stderr, "rcmd: socket: %m\n"); - } + if (errno == EAGAIN) + __fxprintf(NULL, "%s", _("\ +rcmd: socket: All ports in use\n")); + else + __fxprintf(NULL, "rcmd: socket: %m\n"); + __sigsetmask(oldmask); freeaddrinfo(res); return -1; @@ -220,10 +200,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) if (__asprintf (&buf, _("connect to address %s: "), paddr) >= 0) { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf(stderr, L"%s", buf); - else - fputs (buf, stderr); + __fxprintf(NULL, "%s", buf); free (buf); } __set_errno (oerrno); @@ -235,10 +212,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) NI_NUMERICHOST); if (__asprintf (&buf, _("Trying %s...\n"), paddr) >= 0) { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); + __fxprintf (NULL, "%s", buf); free (buf); } continue; @@ -251,14 +225,8 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) continue; } freeaddrinfo(res); - if (_IO_fwide (stderr, 0) > 0) - (void)__fwprintf(stderr, L"%s: %s\n", *ahost, - __strerror_r(errno, - errbuf, sizeof (errbuf))); - else - (void)fprintf(stderr, "%s: %s\n", *ahost, - __strerror_r(errno, - errbuf, sizeof (errbuf))); + (void)__fxprintf(NULL, "%s: %s\n", *ahost, + __strerror_r(errno, errbuf, sizeof (errbuf))); __sigsetmask(oldmask); return -1; } @@ -281,10 +249,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) if (__asprintf (&buf, _("\ rcmd: write (setting up stderr): %m\n")) >= 0) { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf(stderr, L"%s", buf); - else - fputs (buf, stderr); + __fxprintf(NULL, "%s", buf); free (buf); } (void)__close(s2); @@ -303,10 +268,7 @@ rcmd: poll (setting up stderr): %m\n")) >= 0) && __asprintf(&buf, _("\ poll: protocol failure in circuit setup\n")) >= 0)) { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); + __fxprintf (NULL, "%s", buf); free (buf); } (void)__close(s2); @@ -327,12 +289,7 @@ poll: protocol failure in circuit setup\n")) >= 0)) } (void)__close(s2); if (s3 < 0) { - if (_IO_fwide (stderr, 0) > 0) - (void)__fwprintf(stderr, - L"rcmd: accept: %m\n"); - else - (void)fprintf(stderr, - "rcmd: accept: %m\n"); + (void)__fxprintf(NULL, "rcmd: accept: %m\n"); lport = 0; goto bad; } @@ -344,10 +301,7 @@ poll: protocol failure in circuit setup\n")) >= 0)) if (__asprintf(&buf, _("\ socket: protocol failure in circuit setup\n")) >= 0) { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); + __fxprintf (NULL, "%s", buf); free (buf); } goto bad2; @@ -373,10 +327,7 @@ socket: protocol failure in circuit setup\n")) >= 0) || (n != 0 && __asprintf(&buf, "rcmd: %s: %m\n", *ahost) >= 0)) { - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else - fputs (buf, stderr); + __fxprintf (NULL, "%s", buf); free (buf); } goto bad2; @@ -526,7 +477,6 @@ iruserfopen (const char *file, uid_t okuser) /* If not a regular file, if owned by someone other than user or root, if writeable by anyone but the owner, or if hardlinked anywhere, quit. */ - cp = NULL; if (__lxstat64 (_STAT_VER, file, &st)) cp = _("lstat failed"); else if (!S_ISREG (st.st_mode)) |