#include <string.h>
#include <libintl.h>
#include <stdlib.h>
-#ifdef USE_IN_LIBIO
-# include <wchar.h>
-#endif
+#include <wchar.h>
#include <sys/uio.h>
(void)__snprintf(num, sizeof(num), "%d", ntohs(rport));
error = getaddrinfo(*ahost, num, &hints, &res);
if (error) {
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- __fwprintf(stderr, L"rcmd: getaddrinfo: %s\n",
- gai_strerror(error));
- else
-#endif
- fprintf(stderr, "rcmd: getaddrinfo: %s\n",
- gai_strerror(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);
}
free (ahostbuf);
ahostbuf = strdup (res->ai_canonname);
if (ahostbuf == NULL) {
-#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
__fwprintf(stderr, L"%s",
_("rcmd: Cannot allocate memory\n"));
else
-#endif
fputs(_("rcmd: Cannot allocate memory\n"),
stderr);
return (-1);
s = rresvport_af(&lport, ai->ai_family);
if (s < 0) {
if (errno == EAGAIN) {
-#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
__fwprintf(stderr, L"%s",
_("rcmd: socket: All ports in use\n"));
else
-#endif
fputs(_("rcmd: socket: All ports in use\n"),
stderr);
} else {
-#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
__fwprintf(stderr,
L"rcmd: socket: %m\n");
else
-#endif
fprintf(stderr, "rcmd: socket: %m\n");
}
__sigsetmask(oldmask);
if (__asprintf (&buf, _("connect to address %s: "),
paddr) >= 0)
{
-#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
__fwprintf(stderr, L"%s", buf);
else
-#endif
fputs (buf, stderr);
free (buf);
}
NI_NUMERICHOST);
if (__asprintf (&buf, _("Trying %s...\n"), paddr) >= 0)
{
-#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
__fwprintf (stderr, L"%s", buf);
else
-#endif
fputs (buf, stderr);
free (buf);
}
continue;
}
freeaddrinfo(res);
-#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
(void)__fwprintf(stderr, L"%s: %s\n", *ahost,
__strerror_r(errno,
errbuf, sizeof (errbuf)));
else
-#endif
(void)fprintf(stderr, "%s: %s\n", *ahost,
__strerror_r(errno,
errbuf, sizeof (errbuf)));
if (__asprintf (&buf, _("\
rcmd: write (setting up stderr): %m\n")) >= 0)
{
-#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
__fwprintf(stderr, L"%s", buf);
else
-#endif
fputs (buf, stderr);
free (buf);
}
&& __asprintf(&buf, _("\
poll: protocol failure in circuit setup\n")) >= 0))
{
-#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
__fwprintf (stderr, L"%s", buf);
else
-#endif
fputs (buf, stderr);
free (buf);
}
}
(void)__close(s2);
if (s3 < 0) {
-#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
(void)__fwprintf(stderr,
L"rcmd: accept: %m\n");
else
-#endif
(void)fprintf(stderr,
"rcmd: accept: %m\n");
lport = 0;
if (__asprintf(&buf, _("\
socket: protocol failure in circuit setup\n")) >= 0)
{
-#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
__fwprintf (stderr, L"%s", buf);
else
-#endif
fputs (buf, stderr);
free (buf);
}
|| (n != 0
&& __asprintf(&buf, "rcmd: %s: %m\n", *ahost) >= 0))
{
-#ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
__fwprintf (stderr, L"%s", buf);
else
-#endif
fputs (buf, stderr);
free (buf);
}
-#!/bin/sh
+#!/bin/bash
#
# nscd: Starts the Name Switch Cache Daemon
#
-# chkconfig: - 30 80
+# chkconfig: - 30 74
# description: This is a daemon which handles passwd and group lookups \
# for running programs and cache the results for the next \
-# query. You should start this daemon only if you use \
-# slow Services like NIS or NIS+
-# processname: nscd
+# query. You should start this daemon if you use \
+# slow naming services like NIS, NIS+, LDAP, or hesiod.
+# processname: /usr/sbin/nscd
# config: /etc/nscd.conf
#
[ -x /usr/sbin/nscd ] || exit 0
# Source function library.
-. /etc/rc.d/init.d/functions
+. /etc/init.d/functions
# nscd does not run on any kernel lower than 2.2.0 because of threading
# problems, so we require that in first place.
esac
RETVAL=0
+prog=nscd
+
+start () {
+ [ -d /var/run/nscd ] || mkdir /var/run/nscd
+ secure=""
+# for table in passwd group hosts
+# do
+# if egrep -q '^'$table':.*nisplus' /etc/nsswitch.conf; then
+# /usr/lib/nscd_nischeck $table || secure="$secure -S $table,yes"
+# fi
+# done
+ echo -n $"Starting $prog: "
+ daemon /usr/sbin/nscd $secure
+ RETVAL=$?
+ echo
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd
+ return $RETVAL
+}
+
+stop () {
+ echo -n $"Stopping $prog: "
+ /usr/sbin/nscd -K
+ RETVAL=$?
+ if [ $RETVAL -eq 0 ]; then
+ rm -f /var/lock/subsys/nscd
+ # nscd won't be able to remove these if it is running as
+ # a non-privileged user
+ rm -f /var/run/nscd/nscd.pid
+ rm -f /var/run/nscd/.socket
+ success $"$prog shutdown"
+ else
+ failure $"$prog shutdown"
+ fi
+ echo
+ return $RETVAL
+}
+
+restart() {
+ stop
+ start
+}
# See how we were called.
case "$1" in
start)
- secure=""
-# for table in passwd group
-# do
-# if egrep '^'$table':.*nisplus' /etc/nsswitch.conf >/dev/null
-# then
-# /usr/lib/nscd_nischeck $table ||
-# secure="$secure -S $table,yes"
-# fi
-# done
- echo -n "Starting Name Switch Cache Daemon: "
- daemon nscd $secure
+ start
RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd
;;
stop)
- echo -n "Stopping Name Switch Cache Daemon: "
- /usr/sbin/nscd -K
+ stop
RETVAL=$?
- if [ $RETVAL -eq 0 ]; then
- rm -f /var/lock/subsys/nscd
- echo nscd
- else
- echo
- fi
;;
- status)
+ status)
status nscd
RETVAL=$?
;;
- restart)
- $0 stop
- $0 start
+ restart)
+ restart
+ RETVAL=$?
+ ;;
+ condrestart)
+ [ -e /var/lock/subsys/nscd ] && restart
RETVAL=$?
;;
- reload)
- killproc -HUP nscd
+ reload)
+ killproc /usr/sbin/nscd -HUP
RETVAL=$?
;;
*)
- echo "Usage: $0 {start|stop|status|restart}"
+ echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
+ RETVAL=1
;;
esac
exit $RETVAL