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: Fri, 09 Mar 2012 00:43:27 +0100
User-agent: Gnus/5.130003 (Ma Gnus v0.3) Emacs/24.0.94 (gnu/linux)

After looking at Debian's 'dnsdomainname' tool and reading its man page,
I believe that sharing code with InetUtils hostname.c make no sense.
None of the other parameters applies to that tool, and they would only
be confusing.  Thus here is a completely new tool.  What do you think?
Please review and we can hopefully work towards pushing this eventually.

One thing that strikes me is that possibly the tool should fail rather
than printing "(none)".  Another idea is that it should use getaddrinfo
instead of gethostbyname.  Thoughts?

/Simon

>From e4db8639d5dd8ff69f8cb19c10385a8e762f106a Mon Sep 17 00:00:00 2001
From: Simon Josefsson <address@hidden>
Date: Fri, 9 Mar 2012 00:28:51 +0100
Subject: [PATCH] Add new tool dnsdomainname.

---
 ChangeLog             |   13 ++++++++
 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   |   75 +++++++++++++++++++++++++++++++++++++++++++++++++
 9 files changed, 125 insertions(+), 4 deletions(-)
 create mode 100644 man/dnsdomainname.h2m
 create mode 100644 src/dnsdomainname.c

diff --git a/ChangeLog b/ChangeLog
index dc95090..d2516c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2012-03-09  Simon Josefsson  <address@hidden>
+
+       * NEWS: Mention new dnsdomainname tool.
+       * configure.ac: Add tool dnsdomainname.
+       * doc/inetutils.texi: Document new tool 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 tool.
+
 2012-03-06  Mats Erik Andersson  <address@hidden>
 
        * ping/ping6.c (print_echo): Use flag NI_NUMERICHOST in call
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..12c73d7 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  This is the same as running @code{hostname -d}.
+
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..4a399f4
--- /dev/null
+++ b/src/dnsdomainname.c
@@ -0,0 +1,75 @@
+/*
+   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 };
+
+int
+main (int argc, char *argv[])
+{
+  char *host_name;
+  struct hostent *ht;
+  const char *pos;
+
+  set_program_name (argv[0]);
+
+  /* Parse command line */
+  iu_argp_init ("dnsdomainname", program_authors);
+  argp_parse (&argp, argc, argv, 0, NULL, NULL);
+
+  host_name = xgethostname ();
+  if (!host_name)
+    error (EXIT_FAILURE, errno, "cannot determine host name");
+
+  ht = gethostbyname (host_name);
+  if (ht == NULL)
+    {
+      puts ("(none)");
+      return EXIT_SUCCESS;
+    }
+
+  pos = strchr (ht->h_name, '.');
+  if (pos == NULL)
+    {
+      puts ("(none)");
+      return EXIT_SUCCESS;
+    }
+
+  puts (pos + 1);
+
+  return EXIT_SUCCESS;
+}
-- 
1.7.2.5




reply via email to

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