Thread View: news.software.readers
3 messages
3 total messages
Started by Kevin Maguire
Wed, 21 Dec 1994 12:55
gnus and authentication
Author: Kevin Maguire
Date: Wed, 21 Dec 1994 12:55
Date: Wed, 21 Dec 1994 12:55
30 lines
2092 bytes
2092 bytes
How do I use gnus to post via a NNTP server which requires
authentication. I use tin normally, but I've heard good things
about gnus. However when I try and post I get refused, although
my ~/.newsauth file is there as ever. I can't find any
pointers to variables/hooks that may require setting in the info
files on gnus, but surely it is possible. The only gnus stuff
in my .emacs is::
(setq gnus-local-domain "cs.qub.ac.uk")
(setq gnus-local-organization "Queens University, Belfast")
(setq gnus-default-nntp-server "<my-server>")
(setq gnus-default-article-saver "gnus-summary-save-in-file")
I'm not certain that these are set correctly, my machine name
(main) should get pre-pended to 'gnu-local-domain to get the
FQDN? I think there might be some weird behaviour with the case
of my host coming through as main.CS.qub.ac.uk, or something
equally confusing, but case should not matter here should it?
I'm using X-emacs 19.11, on Solaris 2.3.
Cheers
Kevin
--
\|/
(o o)
===================oOO==(_)==OOo===================
Kevin Maguire Research Fellow
Dept. Computer Science Queen's Univ of Belfast
e-mail k.maguire@qub.ac.uk
===================================================
Re: gnus and authentication
Author: Chris Lewis
Date: Thu, 22 Dec 1994 21:16
Date: Thu, 22 Dec 1994 21:16
25 lines
1960 bytes
1960 bytes
In article <3d98ks$h6i@lorne.stir.ac.uk>, Kevin Maguire <k.maguire@qub.ac.uk> wrote: >How do I use gnus to post via a NNTP server which requires >authentication. I use tin normally, but I've heard good things >about gnus. However when I try and post I get refused, although >my ~/.newsauth file is there as ever. ~/.newsauth is specific to tin, as far as I am aware, no other reader supports it. Further, gnus doesn't support AUTHINFO (which is what a NNTP server requiring authentication is going to need), so unless you want to hack gnus itself, you're SOL. [A quick protocol overview. AUTHINFO USER/PASS is probably what you need. When a newsreader sees "480 Authentication required", it must use authentication. You probably need to respond with "AUTHINFO USER <userid>", then after it accepts that, respond with "AUTHINFO PASS <password>". It will return "281" when it succeeds. Then, if 480 was returned as a result of issuing a command, you have to reissue the command. You can experiment with this via telnet <your server> 119"] -- Chris Lewis: _Una confibula non sat est_ Phone: Canada 613 832-0541 Latest psroff: FTP://ftp.uunet.ca/distrib/chris_lewis/psroff3.0pl17/* Latest hp2pbm: FTP://ftp.uunet.ca/distrib/chris_lewis/hp2pbm/*
Re: gnus and authentication
Author: Hallvard B Furuseth
Date: Fri, 23 Dec 1994 13:58
Date: Fri, 23 Dec 1994 13:58
163 lines
6589 bytes
6589 bytes
Here is a package I wrote recently. A lot of the stuff
(unwind-protects, nntp-send-command-and-erase) just attempts to erase
the nntp password from memory (and thus from core dumps); it would be
much simpler without this. I don't know how it fits into xemacs.
;;; nntp-auth.el -- use the nntp AUTHINFO command
;;
;; This file is in the public domain.
;;
;; NNTP will send the AUTHINFO command, and terminate if it fails.
;; However, the "500" (not implemented) error is ignored.
;;
;; Usage:
;;
;; (setq gnus-open-server-hook '((lambda () (require 'nntp-auth))))
;; (setq nntp-server-opened-hook '(nntp-try-authinfo))
;;
;; Put your nntp password in ~/.nntp-authinfo and do `chmod og-rwx' on it.
;;
;; Last modified: Nov 1994, Hallvard B Furuseth <h.b.furuseth@usit.uio.no>
;;
;; BUGS:
;; process-send-string or garbage collection may cause the nntp password
;; to be retained in memory after it has been sent to nntp.
(require 'nntp)
(defvar nntp-authinfo-file "~/.nntp-authinfo"
"The name of the file containing your nntp AUTHINFO password")
;; Override nntp.el: Add nntp-server-opened-hook.
(defvar nntp-server-opened-hook)
(defun nntp-open-server (host &optional service)
"Open news server on HOST.
If HOST is nil, use value of environment variable `NNTPSERVER'.
If optional argument SERVICE is non-nil, open by the service name."
(let ((host (or host (getenv "NNTPSERVER")))
(status nil))
(setq nntp-status-string "")
(cond ((and host (nntp-open-server-internal host service))
(setq status (nntp-wait-for-response "^[23].*\r$"))
;; Do check unexpected close of connection.
;; Suggested by feldmark@hanako.stars.flab.fujitsu.junet.
(if status
(progn
(set-process-sentinel nntp-server-process
'nntp-default-sentinel)
;; Added by h.b.furuseth@usit.uio.no
(run-hooks 'nntp-server-opened-hook))
;; We have to close connection here, since function
;; `nntp-server-opened' may return incorrect status.
(nntp-close-server-internal)
))
((null host)
(setq nntp-status-string "NNTP server is not specified."))
)
status
))
;; Copied from nntp-send-command
(defun nntp-send-command-and-erase (response cmd &rest args)
"As `nntp-send-command', but tries not to leave temporary memory
containing the command or argument string. Useful to send password commands."
(save-excursion
;; Clear communication buffer.
(set-buffer nntp-server-buffer)
(erase-buffer)
(let (str)
(unwind-protect
(progn
(setq str (mapconcat 'identity (cons cmd (append args '("\r\n")))
" "))
(process-send-string nntp-server-process str))
(nntp-auth-memzero str)))
(if response
(nntp-wait-for-response response)
t)))
(defun nntp-try-authinfo ()
(let (password success)
(unwind-protect
(progn
(cond ((assoc (setq password (nntp-read-authinfo)) '((nil) (""))))
((not (and (nntp-send-command "^[23].*\r$" "AUTHINFO USER"
(user-real-login-name))
;; 381 PASS required
(string-match "^3" nntp-status-string)))
;;Fail unless AUTHINFO command was not implemented
(or (string-match "^500" nntp-status-string)
(error "Authinfo failed: %s" (nntp-status-text))))
((not (and (nntp-send-command-and-erase
"^[23].*\r$" "AUTHINFO PASS" password)
(string-match "^2" nntp-status-string))) ; 281 Ok
(error "Authentication failed: %s" (nntp-status-text))))
(setq success t))
(nntp-auth-memzero password)
(or success
(nntp-close-server)))))
(defun nntp-status-text ()
(substring nntp-status-string 0 (string-match "[\n\r]" nntp-status-string)))
(defun nntp-read-authinfo ()
(let (buf password)
;; If file exists, and is not readable or writeable by group
;; or other and can be opened for reading and we get the
;; username, try the authinfo command.
(cond ((assq (user-real-login-name) '((nil) ("unknown"))) ;got username?
nil)
((not ;File does not exist
(setq buf (file-attributes nntp-authinfo-file)))
nil)
((or (car buf) ;Not regular file
(not (string-match "^-r..--.--.$" (nth 8 buf)))) ;unprotected
(error "Bad file protection or type on %s" nntp-authinfo-file))
((> (nth 7 buf) 400)
;; It's illegal to send NNTP lines longer than 512 chars incl. CRLF.
(error "Password too long in %s" nntp-authinfo-file))
(t
(prog1
;; Get the password from the authinfo file.
;; Overwrite the buffer memory afterwards.
(save-excursion
(let ((default-major-mode 'fundamental-mode))
(set-buffer (get-buffer-create " *gnus authinfo*")))
(setq buf (current-buffer))
(erase-buffer)
(buffer-flush-undo (current-buffer)) ;No passwds in undo list
;; Insert the file in the middle of the buffer, not at
;; one end. Then the buffer gap can't fool us when we
;; try to overwrite the password in the buffer's memory.
(insert "\n\n")
(forward-char -1)
(unwind-protect
(progn
;; Insert the file, extract the password
(insert-file-contents nntp-authinfo-file nil)
(end-of-line)
(skip-chars-backward " \t\r")
(buffer-substring (1+ (point-min)) (point)))
;; Overwrite the memory without moving the buffer gap
(insert-char (prog1 (- (buffer-size) 2)
(delete-region (1+ (point-min))
(1- (point-max)))) ?A)))
(kill-buffer buf))))))
(defun nntp-auth-memzero (array-variable)
"Erase the contents of a string (typically a password)"
(let ((i (length array-variable)))
(while (>= (setq i (1- i)) 0)
(aset array-variable i 0))))
(provide 'nntp-auth)
--
Hallvard
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads