aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2015-12-04 19:49:07 -0500
committerGlenn Morris2015-12-04 19:49:07 -0500
commit156ad50b9146b4b517bcb7908cb75cc3863ba2c4 (patch)
tree86413063b7b63b8c208f432e7b78601862b6a073
parent15b050eca91bc1da879acf5fabdc7f7d9c326008 (diff)
downloademacs-156ad50b9146b4b517bcb7908cb75cc3863ba2c4.tar.gz
emacs-156ad50b9146b4b517bcb7908cb75cc3863ba2c4.zip
* lisp/net/net-utils.el: Small improvements.
(net-utils--executable-find-sbin): New function. (ifconfig-program): Check sbin directories. Fallback to "ip". (Bug#22091) (ifconfig-program-options): Check the actual program in use. (arp-program): Check sbin directories.
-rw-r--r--lisp/net/net-utils.el35
1 files changed, 22 insertions, 13 deletions
diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el
index c6d40b62415..c43d48e514c 100644
--- a/lisp/net/net-utils.el
+++ b/lisp/net/net-utils.el
@@ -35,15 +35,19 @@
35;; * Support connections to HOST/PORT, generally for debugging and the like. 35;; * Support connections to HOST/PORT, generally for debugging and the like.
36;; In other words, for doing much the same thing as "telnet HOST PORT", and 36;; In other words, for doing much the same thing as "telnet HOST PORT", and
37;; then typing commands. 37;; then typing commands.
38;;
39;; PATHS
40;;
41;; On some systems, some of these programs are not in normal user path,
42;; but rather in /sbin, /usr/sbin, and so on.
43
44 38
45;;; Code: 39;;; Code:
46 40
41;; On some systems, programs like ifconfig are not in normal user
42;; path, but rather in /sbin, /usr/sbin, etc (but non-root users can
43;; still use them for queries). Actually the trend these
44;; day is for /sbin to be a symlink to /usr/sbin, but we still need to
45;; search both for older systems.
46(defun net-utils--executable-find-sbin (command)
47 "Return absolute name of COMMAND if found in an sbin directory."
48 (let ((exec-path '("/sbin" "/usr/sbin" "/usr/local/sbin")))
49 (executable-find command)))
50
47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 51;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
48;; Customization Variables 52;; Customization Variables
49;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 53;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -85,10 +89,13 @@ These options can be used to limit how many ICMP packets are emitted."
85(define-obsolete-variable-alias 'ipconfig-program 'ifconfig-program "22.2") 89(define-obsolete-variable-alias 'ipconfig-program 'ifconfig-program "22.2")
86 90
87(defcustom ifconfig-program 91(defcustom ifconfig-program
88 (if (eq system-type 'windows-nt) 92 (cond ((eq system-type 'windows-nt) "ipconfig")
89 "ipconfig" 93 ((executable-find "ifconfig") "ifconfig")
90 "ifconfig") 94 ((net-utils--executable-find-sbin "ifconfig"))
95 ((net-utils--executable-find-sbin "ip"))
96 (t "ip"))
91 "Program to print network configuration information." 97 "Program to print network configuration information."
98 :version "25.1" ; add ip
92 :group 'net-utils 99 :group 'net-utils
93 :type 'string) 100 :type 'string)
94 101
@@ -96,10 +103,12 @@ These options can be used to limit how many ICMP packets are emitted."
96 'ifconfig-program-options "22.2") 103 'ifconfig-program-options "22.2")
97 104
98(defcustom ifconfig-program-options 105(defcustom ifconfig-program-options
99 (list 106 (cond ((string-match "ipconfig\\'" ifconfig-program) '("/all"))
100 (if (eq system-type 'windows-nt) 107 ((string-match "ifconfig\\'" ifconfig-program) '("-a"))
101 "/all" "-a")) 108 ((string-match "ip\\'" ifconfig-program) '("addr")))
102 "Options for the ifconfig program." 109 "Options for the ifconfig program."
110 :version "25.1"
111 :set-after '(ifconfig-program)
103 :group 'net-utils 112 :group 'net-utils
104 :type '(repeat string)) 113 :type '(repeat string))
105 114
@@ -126,7 +135,7 @@ These options can be used to limit how many ICMP packets are emitted."
126 :group 'net-utils 135 :group 'net-utils
127 :type '(repeat string)) 136 :type '(repeat string))
128 137
129(defcustom arp-program "arp" 138(defcustom arp-program (or (net-utils--executable-find-sbin "arp") "arp")
130 "Program to print IP to address translation tables." 139 "Program to print IP to address translation tables."
131 :group 'net-utils 140 :group 'net-utils
132 :type 'string) 141 :type 'string)