annotate lisp/erc/erc-identd.el @ 85829:92e80e71cd95

*** empty log message ***
author Juanma Barranquero <lekktu@gmail.com>
date Wed, 31 Oct 2007 10:24:20 +0000
parents 4ee03308c9b6
children 107ccd98fa12
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1 ;;; erc-identd.el --- RFC1413 (identd authentication protocol) server
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
2
75346
7a3f13e2dd57 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 71883
diff changeset
3 ;; Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc.
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
4
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
5 ;; Author: John Wiegley <johnw@gnu.org>
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
6 ;; Keywords: comm, processes
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
7
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
9
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
78219
85d67fae9a94 Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 76856
diff changeset
12 ;; the Free Software Foundation; either version 3, or (at your option)
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
13 ;; any later version.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
14
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
19
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
23 ;; Boston, MA 02110-1301, USA.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
24
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
26
71883
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
27 ;; This module allows you to run a local identd server on port 8113.
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
28 ;; You will need to set up DNAT to bind 113->8113, or use a proxy.
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
29
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
30 ;; To use this module, add identd to `erc-modules' and run
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
31 ;; `erc-update-modules'.
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
32
71883
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
33 ;; Here is an example /etc/inetd.conf rule that forwards identd
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
34 ;; traffic to port 8113. You will need simpleproxy installed for it
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
35 ;; to work.
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
36
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
37 ;; 113 stream tcp nowait nobody /usr/sbin/tcpd /usr/bin/simpleproxy simpleproxy -i -R 127.0.0.1:8113
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
38
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
39 ;;; Code:
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
40
71883
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
41 (require 'erc)
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
42
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
43 (defvar erc-identd-process nil)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
44
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
45 (defgroup erc-identd nil
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
46 "Run a local identd server."
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
47 :group 'erc)
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
48
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
49 (defcustom erc-identd-port 8113
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
50 "Port to run the identd server on if not specified in the argument for
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
51 `erc-identd-start'.
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
52
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
53 This can be either a string or a number."
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
54 :group 'erc-identd
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
55 :type '(choice (const :tag "None" nil)
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
56 (integer :tag "Port number")
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
57 (string :tag "Port string")))
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
58
71883
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
59 ;;;###autoload (autoload 'erc-identd-mode "erc-identd")
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
60 (define-erc-module identd nil
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
61 "This mode launches an identd server on port 8113."
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
62 ((add-hook 'erc-connect-pre-hook 'erc-identd-quickstart)
71883
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
63 (add-hook 'erc-disconnected-hook 'erc-identd-stop))
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
64 ((remove-hook 'erc-connect-pre-hook 'erc-identd-quickstart)
71883
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
65 (remove-hook 'erc-disconnected-hook 'erc-identd-stop)))
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
66
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
67 (defun erc-identd-filter (proc string)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
68 "This filter implements RFC1413 (identd authentication protocol)."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
69 (let ((erc-identd-process proc))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
70 (when (string-match "\\([0-9]+\\)\\s-*,\\s-*\\([0-9]+\\)" string)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
71 (let ((port-on-server (match-string 1 string))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
72 (port-on-client (match-string 2 string)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
73 (send-string erc-identd-process
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
74 (format "%s, %s : USERID : %s : %s\n"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
75 port-on-server port-on-client
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
76 system-type (user-login-name)))
84387
4ee03308c9b6 Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents: 78219
diff changeset
77 (stop-process erc-identd-process)
4ee03308c9b6 Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents: 78219
diff changeset
78 (delete-process proc)))))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
79
69690
a90c92cb9783 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-179
Miles Bader <miles@gnu.org>
parents: 68822
diff changeset
80 ;;;###autoload
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
81 (defun erc-identd-start (&optional port)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
82 "Start an identd server listening to port 8113.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
83 Port 113 (auth) will need to be redirected to port 8113 on your
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
84 machine -- using iptables, or a program like redir which can be
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
85 run from inetd. The idea is to provide a simple identd server
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
86 when you need one, without having to install one globally on your
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
87 system."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
88 (interactive (list (read-string "Serve identd requests on port: " "8113")))
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
89 (unless port (setq port erc-identd-port))
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
90 (when (stringp port)
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
91 (setq port (string-to-number port)))
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
92 (when erc-identd-process
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
93 (delete-process erc-identd-process))
69690
a90c92cb9783 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-179
Miles Bader <miles@gnu.org>
parents: 68822
diff changeset
94 (setq erc-identd-process
a90c92cb9783 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-179
Miles Bader <miles@gnu.org>
parents: 68822
diff changeset
95 (make-network-process :name "identd"
71883
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
96 :buffer nil
69690
a90c92cb9783 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-179
Miles Bader <miles@gnu.org>
parents: 68822
diff changeset
97 :host 'local :service port
71883
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
98 :server t :noquery t :nowait t
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
99 :filter 'erc-identd-filter))
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69690
diff changeset
100 (set-process-query-on-exit-flag erc-identd-process nil))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
101
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
102 (defun erc-identd-quickstart (&rest ignored)
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
103 "Start the identd server with the default port.
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
104 The default port is specified by `erc-identd-port'."
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
105 (erc-identd-start))
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
106
69690
a90c92cb9783 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-179
Miles Bader <miles@gnu.org>
parents: 68822
diff changeset
107 ;;;###autoload
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
108 (defun erc-identd-stop (&rest ignore)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
109 (interactive)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
110 (when erc-identd-process
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
111 (delete-process erc-identd-process)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
112 (setq erc-identd-process nil)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
113
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
114 (provide 'erc-identd)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
115
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
116 ;;; erc-identd.el ends here
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
117 ;;
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
118 ;; Local Variables:
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
119 ;; indent-tabs-mode: t
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
120 ;; tab-width: 8
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
121 ;; End:
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
122
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
123 ;; arch-tag: e0b5f926-0f35-40b9-8ddb-ca06b62a7544