# Get colour by netgroup.
if [ -z "$colour" ]; then
for netgroup in $(ls "$SSHCOLOURS" | grep ^\@); do
- if netgroups $netgroup ${fqdn%%.*} 2>/dev/null; then
+ if netgroups $netgroup ${fqdn%%.*} &>/dev/null; then
colour=$(readlink "$SSHCOLOURS/$netgroup")
break
fi
--- /dev/null
+#include <netdb.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char **argv) {
+ char *group, *host, *hostp, *userp, *domainp;
+
+ if (argc == 1) {
+ fprintf(stderr, "Usage: netgroups <netgroup> [<hostname>]\n");
+ exit(1);
+ }
+
+ /* What group do we want? */
+ group = argv[1];
+ if (*group == '@') group++;
+
+ /* Do we want to match a host? */
+ host = argv[2];
+
+ if (host) exit(! innetgr(group, host, 0, 0));
+
+ setnetgrent(group);
+ while (getnetgrent(&hostp, &userp, &domainp)) printf("%s\n", hostp);
+ endnetgrent();
+
+ exit(0);
+}