diff options
Diffstat (limited to 'inet/rcmd.c')
-rw-r--r-- | inet/rcmd.c | 100 |
1 files changed, 75 insertions, 25 deletions
diff --git a/inet/rcmd.c b/inet/rcmd.c index 341304a..0bcb731 100644 --- a/inet/rcmd.c +++ b/inet/rcmd.c @@ -137,13 +137,21 @@ 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) - __fxprintf(NULL, "%s: Unknown host\n", *ahost); - else - __fxprintf(NULL, "rcmd: getaddrinfo: %s\n", - gai_strerror(error)); - - return -1; + 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); } pfd[0].events = POLLIN; @@ -153,9 +161,13 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) free (ahostbuf); ahostbuf = strdup (res->ai_canonname); if (ahostbuf == NULL) { - __fxprintf(NULL, "%s", - _("rcmd: Cannot allocate memory\n")); - return -1; + 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); } *ahost = ahostbuf; } else @@ -168,12 +180,20 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) s = rresvport_af(&lport, ai->ai_family); if (s < 0) { - if (errno == EAGAIN) - __fxprintf(NULL, "%s", _("\ -rcmd: socket: All ports in use\n")); - else - __fxprintf(NULL, "rcmd: socket: %m\n"); - + 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"); + } __sigsetmask(oldmask); freeaddrinfo(res); return -1; @@ -200,7 +220,10 @@ rcmd: socket: All ports in use\n")); if (__asprintf (&buf, _("connect to address %s: "), paddr) >= 0) { - __fxprintf(NULL, "%s", buf); + if (_IO_fwide (stderr, 0) > 0) + __fwprintf(stderr, L"%s", buf); + else + fputs (buf, stderr); free (buf); } __set_errno (oerrno); @@ -212,7 +235,10 @@ rcmd: socket: All ports in use\n")); NI_NUMERICHOST); if (__asprintf (&buf, _("Trying %s...\n"), paddr) >= 0) { - __fxprintf (NULL, "%s", buf); + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else + fputs (buf, stderr); free (buf); } continue; @@ -225,8 +251,14 @@ rcmd: socket: All ports in use\n")); continue; } freeaddrinfo(res); - (void)__fxprintf(NULL, "%s: %s\n", *ahost, - __strerror_r(errno, errbuf, sizeof (errbuf))); + 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))); __sigsetmask(oldmask); return -1; } @@ -249,7 +281,10 @@ rcmd: socket: All ports in use\n")); if (__asprintf (&buf, _("\ rcmd: write (setting up stderr): %m\n")) >= 0) { - __fxprintf(NULL, "%s", buf); + if (_IO_fwide (stderr, 0) > 0) + __fwprintf(stderr, L"%s", buf); + else + fputs (buf, stderr); free (buf); } (void)__close(s2); @@ -268,7 +303,10 @@ rcmd: poll (setting up stderr): %m\n")) >= 0) && __asprintf(&buf, _("\ poll: protocol failure in circuit setup\n")) >= 0)) { - __fxprintf (NULL, "%s", buf); + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else + fputs (buf, stderr); free (buf); } (void)__close(s2); @@ -289,7 +327,12 @@ poll: protocol failure in circuit setup\n")) >= 0)) } (void)__close(s2); if (s3 < 0) { - (void)__fxprintf(NULL, "rcmd: accept: %m\n"); + if (_IO_fwide (stderr, 0) > 0) + (void)__fwprintf(stderr, + L"rcmd: accept: %m\n"); + else + (void)fprintf(stderr, + "rcmd: accept: %m\n"); lport = 0; goto bad; } @@ -301,7 +344,10 @@ poll: protocol failure in circuit setup\n")) >= 0)) if (__asprintf(&buf, _("\ socket: protocol failure in circuit setup\n")) >= 0) { - __fxprintf (NULL, "%s", buf); + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else + fputs (buf, stderr); free (buf); } goto bad2; @@ -327,7 +373,10 @@ socket: protocol failure in circuit setup\n")) >= 0) || (n != 0 && __asprintf(&buf, "rcmd: %s: %m\n", *ahost) >= 0)) { - __fxprintf (NULL, "%s", buf); + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else + fputs (buf, stderr); free (buf); } goto bad2; @@ -477,6 +526,7 @@ 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)) |