bug-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-inetutils] dnsdomainname, domainname, nisdomainname, ypdomainna


From: Simon Josefsson
Subject: Re: [bug-inetutils] dnsdomainname, domainname, nisdomainname, ypdomainname
Date: Mon, 12 Mar 2012 12:19:02 +0100
User-agent: Gnus/5.130003 (Ma Gnus v0.3) Emacs/24.0.94 (gnu/linux)

Here is an updated patch.  Ok to push?

/Simon

---
 ChangeLog              |   14 ++++++++
 NEWS                   |    3 ++
 configure.ac           |    1 +
 doc/inetutils.texi     |   15 +++++++++
 man/Makefile.am        |   15 ++++++--
 man/dnsdomainname.h2m  |    2 +
 src/.gitignore         |    1 +
 src/Makefile.am        |    4 ++
 src/dnsdomainname.c    |   82 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/Makefile.am      |    4 ++
 tests/dnsdomainname.sh |   50 +++++++++++++++++++++++++++++
 11 files changed, 187 insertions(+), 4 deletions(-)
 create mode 100644 man/dnsdomainname.h2m
 create mode 100644 src/dnsdomainname.c
 create mode 100755 tests/dnsdomainname.sh

diff --git a/ChangeLog b/ChangeLog
index 75f184e..404ff16 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2012-03-12  Simon Josefsson  <address@hidden>
+
+       * NEWS: Mention new dnsdomainname tool.
+       * configure.ac: Add tool dnsdomainname.
+       * doc/inetutils.texi: Document dnsdomainname.
+       * man/Makefile.am: Build dnsdomainname.1.
+       * man/dnsdomainname.h2m: New file.
+       * src/.gitignore: Ignore dnsdomainname.
+       * src/Makefile.am (bin_PROGRAMS): Add $(dnsdomainname_BUILD).
+       (dnsdomainname_SOURCES): New variable.
+       (EXTRA_PROGRAMS): Add dnsdomainname.
+       * src/dnsdomainname.c: New file.
+       * tests/dnsdomainname.sh: New file.
+
 2012-03-10  Mats Erik Andersson  <address@hidden>
 
        * whois/tld_serv_list (.cz, .fo, .gl, .gs, .hk, .ie, .il, .in, .is)
diff --git a/NEWS b/NEWS
index 46da4b8..6631509 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,9 @@ See the end of this file for license conditions.
 
 Please send inetutils bug reports to <address@hidden>.
 
+* New tool 'dnsdomainname'.
+
+
 January 6, 2012
 Version 1.9.1:
 
diff --git a/configure.ac b/configure.ac
index 017d0ac..dde3d7c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -104,6 +104,7 @@ IU_ENABLE_SERVER(tftpd)
 IU_ENABLE_SERVER(uucpd)
 
 IU_ENABLE_CLIENT(ftp)
+IU_ENABLE_CLIENT(dnsdomainname)
 IU_ENABLE_CLIENT(hostname)
 IU_ENABLE_CLIENT(ping)
 IU_ENABLE_CLIENT(ping6)
diff --git a/doc/inetutils.texi b/doc/inetutils.texi
index 0c44e0c..892fb15 100644
--- a/doc/inetutils.texi
+++ b/doc/inetutils.texi
@@ -32,6 +32,7 @@
 * ftp: (inetutils)ftp invocation.                 FTP client.
 * ftpd: (inetutils)ftpd invocation.               FTP Daemon.
 * hostname: (inetutils)hostname invocation.       Show or set system host name.
+* dnsdomainname: (inetutils)dnsdomainname invocation.       Show DNS domain 
name.
 * inetd: (inetutils)inetd invocation.             Interner super-server.
 * logger: (inetutils)logger invocation.           Send messages to the system 
log.
 * ping: (inetutils)ping invocation.               Packets to network hosts.
@@ -99,6 +100,7 @@ Documentation License''.
 Diagnostic programs
 
 * hostname invocation::                Show or set system host name.
+* dnsdomainname invocation::           Show DNS domain name.
 * logger invocation::                  Send messages to system log.
 * ping invocation::                    Packets to network hosts.
 * traceroute invocation::              Trace the route to a host.
@@ -281,6 +283,19 @@ Get short host name.
 Get NIS/YP domain name.
 @end table
 
address@hidden dnsdomainname invocation
address@hidden @command{dnsdomainname}: Show DNS domain name
address@hidden dnsdomainname
+
address@hidden is a program to show the domain part of the
+system's fully qualified domain name.  For example, if the FQDN of the
+system is @code{name.example.org} the command will show
address@hidden
+
address@hidden
+dnsdomainname address@hidden@dots{}]
address@hidden example
+
 @node logger invocation
 @chapter @command{logger}: Send messages to system log
 @cindex logger
diff --git a/man/Makefile.am b/man/Makefile.am
index 5572afa..c39f8a1 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -16,10 +16,10 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see `http://www.gnu.org/licenses/'.
 
-all = hostname.1 ifconfig.1 inetd.8 ftp.1 ftpd.8 logger.1 ping.1       \
-      ping6.1 rcp.1 rexec.1 rexecd.8 rlogin.1 rlogind.8 rsh.1 rshd.8   \
-      syslogd.8 talk.1 talkd.8 telnet.1 telnetd.8 tftp.1 tftpd.8       \
-      traceroute.1 uucpd.8 whois.1
+all = hostname.1 dnsdomainname.1 ifconfig.1 inetd.8 ftp.1 ftpd.8       \
+      logger.1 ping.1 ping6.1 rcp.1 rexec.1 rexecd.8 rlogin.1          \
+      rlogind.8 rsh.1 rshd.8 syslogd.8 talk.1 talkd.8 telnet.1         \
+      telnetd.8 tftp.1 tftpd.8 traceroute.1 uucpd.8 whois.1
 
 dist_man_MANS =
 
@@ -27,6 +27,10 @@ if ENABLE_hostname
 dist_man_MANS += hostname.1
 endif
 
+if ENABLE_dnsdomainname
+dist_man_MANS += dnsdomainname.1
+endif
+
 if ENABLE_ifconfig
 dist_man_MANS += ifconfig.1
 endif
@@ -133,6 +137,8 @@ ftpd.8: ftpd.h2m $(top_srcdir)/ftpd/ftpd.c 
$(top_srcdir)/configure.ac
 
 hostname.1: hostname.h2m $(top_srcdir)/src/hostname.c 
$(top_srcdir)/configure.ac
 
+dnsdomainname.1: dnsdomainname.h2m $(top_srcdir)/src/dnsdomainname.c 
$(top_srcdir)/configure.ac
+
 ifconfig.1: ifconfig.h2m $(top_srcdir)/ifconfig/options.c 
$(top_srcdir)/configure.ac
 
 inetd.8: inetd.h2m $(top_srcdir)/src/inetd.c $(top_srcdir)/configure.ac
@@ -186,6 +192,7 @@ whois.1: whois.h2m $(top_srcdir)/whois/whois.c 
$(top_srcdir)/configure.ac
 mapped_name = `echo ../$(TOOL)/$(TOOL) \
 | sed s,../ping6/ping6,../ping/ping6,\
 | sed s,../hostname/hostname,../src/hostname,\
+| sed s,../dnsdomainname/dnsdomainname,../src/dnsdomainname,\
 | sed s,../inetd/inetd,../src/inetd,\
 | sed s,../logger/logger,../src/logger,\
 | sed s,../rcp/rcp,../src/rcp,\
diff --git a/man/dnsdomainname.h2m b/man/dnsdomainname.h2m
new file mode 100644
index 0000000..afcf637
--- /dev/null
+++ b/man/dnsdomainname.h2m
@@ -0,0 +1,2 @@
+[NAME]
+dnsdomainname \- show DNS domain name
diff --git a/src/.gitignore b/src/.gitignore
index a41cd45..d07a8db 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1,3 +1,4 @@
+dnsdomainname
 hostname
 inetd
 logger
diff --git a/src/Makefile.am b/src/Makefile.am
index e05ffd4..a98272b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -32,6 +32,10 @@ bin_PROGRAMS += $(hostname_BUILD)
 hostname_SOURCES = hostname.c
 EXTRA_PROGRAMS += hostname
 
+bin_PROGRAMS += $(dnsdomainname_BUILD)
+dnsdomainname_SOURCES = dnsdomainname.c
+EXTRA_PROGRAMS += dnsdomainname
+
 bin_PROGRAMS += $(logger_BUILD)
 logger_SOURCES = logger.c logprio.h
 EXTRA_PROGRAMS += logger
diff --git a/src/dnsdomainname.c b/src/dnsdomainname.c
new file mode 100644
index 0000000..8e1af02
--- /dev/null
+++ b/src/dnsdomainname.c
@@ -0,0 +1,82 @@
+/*
+  Copyright (C) 2012 Free Software Foundation, Inc.
+
+  This file is part of GNU Inetutils.
+
+  GNU Inetutils is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or (at
+  your option) any later version.
+
+  GNU Inetutils is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see `http://www.gnu.org/licenses/'. */
+
+#include <config.h>
+
+#include <argp.h>
+#include <error.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <netdb.h>
+
+#include "libinetutils.h"
+#include "progname.h"
+#include "xgethostname.h"
+
+const char doc[] =
+  "Show domain part of the system's fully qualified domain name.";
+const char *program_authors[] = {
+  "Simon Josefsson",
+  NULL
+};
+
+static struct argp argp = { NULL, NULL, NULL, doc };
+
+void
+dnsdomainname (void)
+{
+  char *host_name;
+  struct addrinfo hints, *res;
+  const char *dn;
+  int rc;
+
+  host_name = xgethostname ();
+  if (!host_name)
+    error (EXIT_FAILURE, errno, "cannot determine host name");
+
+  memset (&hints, 0, sizeof (struct addrinfo));
+  hints.ai_flags = AI_CANONNAME;
+
+  rc = getaddrinfo (host_name, NULL, &hints, &res);
+  if (rc != 0)
+    error (EXIT_FAILURE, 0, "%s", gai_strerror (rc));
+
+  dn = strchr (res->ai_canonname, '.');
+  if (dn == NULL)
+    error (EXIT_FAILURE, 0, "cannot qualify host name: %s", host_name);
+  dn++;
+
+  puts (dn);
+
+  free (host_name);
+  freeaddrinfo (res);
+}
+
+int
+main (int argc, char *argv[])
+{
+  set_program_name (argv[0]);
+
+  iu_argp_init ("dnsdomainname", program_authors);
+  argp_parse (&argp, argc, argv, 0, NULL, NULL);
+
+  dnsdomainname ();
+
+  exit (EXIT_SUCCESS);
+}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 043e790..a5edd92 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -64,6 +64,10 @@ if ENABLE_hostname
 dist_check_SCRIPTS += hostname.sh
 endif
 
+if ENABLE_dnsdomainname
+dist_check_SCRIPTS += dnsdomainname.sh
+endif
+
 TESTS = $(check_PROGRAMS) $(dist_check_SCRIPTS)
 
 TESTS_ENVIRONMENT = EXEEXT=$(EXEEXT)
diff --git a/tests/dnsdomainname.sh b/tests/dnsdomainname.sh
new file mode 100755
index 0000000..e30e1e1
--- /dev/null
+++ b/tests/dnsdomainname.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# Copyright (C) 2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Inetutils.
+#
+# GNU Inetutils is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or (at
+# your option) any later version.
+#
+# GNU Inetutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see `http://www.gnu.org/licenses/'.
+
+set -e
+
+DNSDOMAINNAME=${DNSDOMAINNAME:-../src/dnsdomainname$EXEEXT}
+
+if ! test -x $DNSDOMAINNAME; then
+    echo "No executable $DNSDOMAINNAME available.  Skipping test."
+    exit 77
+fi
+
+$DNSDOMAINNAME > /dev/null
+rc=$?
+if test $rc -ne 0; then
+    echo "invoking $DNSDOMAINNAME failed with error code $rc"
+    exit 1
+fi
+
+$DNSDOMAINNAME --version > /dev/null
+rc=$?
+if test $rc -ne 0; then
+    echo "invoking $DNSDOMAINNAME --version failed with error code $rc"
+    exit 1
+fi
+
+$DNSDOMAINNAME --help > /dev/null
+rc=$?
+if test $rc -ne 0; then
+    echo "invoking $DNSDOMAINNAME --help failed with error code $rc"
+    exit 1
+fi
+
+exit 0
-- 
1.7.2.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]