with-authinfo-kludge.1: Fix the various lies in the manual.
[with-authinfo-kludge] / with-authinfo-kludge.1
CommitLineData
b3370918
MW
1.\" -*-nroff-*-
2.\"
3.\" Manual page for `with-authinfo-kludge'.
4.\"
5.\" (c) 2016 Mark Wooding
6.\"
7.
8.\"----- Licensing notice ---------------------------------------------------
9.\"
10.\" This program is free software; you can redistribute it and/or modify
11.\" it under the terms of the GNU General Public License as published by
12.\" the Free Software Foundation; either version 2 of the License, or
13.\" (at your option) any later version.
14.\"
15.\" This program is distributed in the hope that it will be useful,
16.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18.\" GNU General Public License for more details.
19.\"
20.\" You should have received a copy of the GNU General Public License
21.\" along with this program; if not, write to the Free Software Foundation,
22.\" Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23.
24.ie t \{\
25. ds o \(bu
26.\}
27.el \{\
28. ds o o
29.\}
30.
31.de hP
32.IP
33\h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c
34..
35.
36.de VS
37.sp 1
38.RS
39.nf
40.ft B
41..
42.de VE
43.ft R
44.fi
45.RE
46.sp 1
47..
48.
49.TH with-authinfo-kludge 1 "23 April 2016"
50.
51.\"--------------------------------------------------------------------------
52.SH NAME
53with-authinfo-kludge \- run a newsreader with AUTHINFO GENERIC support
54.
55.SH SYNOPSIS
56with-authinfo-kludge
57.RB [ \-v ]
58.RB [ \-d
59.IR dir ]
60.RB [ \-f
61.IR conf ]
62.RB [ \-t
63.IR tag ]
64.br
65\h'5m'\c
66[
67.BI + server
68.RI [ param \fR= value
69\&...] \&...]
70.RB [ + ]
71.br
72\h'5m'\c
73.I command
74.RI [ args
75\&...]
76.
77.\"--------------------------------------------------------------------------
78.SH DESCRIPTION
79.
80The
81.B with-authinfo-kludge
82program is an
83.I adverbial modifier
84which runs another command
85(typically a newsreader)
b352adb0 86in an environment in which it can,
b3370918
MW
87transparently to it,
88make connections to certain NNTP servers
89which usually require
90.B AUTHINFO GENERIC
91authentication before they'll permit clients to read or post.
92This is useful because support for
93.B AUTHINFO GENERIC
b352adb0 94has never been especially widely implemented by newsreaders
b3370918
MW
95and now seems to be being withdrawn from those newsreaders
96which used to support it.
97.PP
98In the simple case, you say something like
99.VS
100with-authinfo-kludge slrn
101.VE
102and then
103.B slrn
104will start up,
105connect to your default NNTP server
106(as named in the
107.B NNTPSERVER
108environment variable),
109authenticate to it as needed,
110and let you read and post news.
111In more complicated cases,
112.B with-authinfo-kludge
113can handle multiple NNTP servers,
114set up SSH forwarding for them,
115offer different authentication credentials to them,
116and hide the fact that they might be running on nonstandard ports.
117.PP
118The
119.B with-authinfo-kludge
120program doesn't do all of this itself:
121it depends on some other tools existing on the system in which it runs.
122(It doesn't need anything special running on the server system.)
123The external dependencies are as follows.
124.hP \*o
125The
126.B authinfo-kludge
127program, by Richard Kettlewell,
128is a simple proxy which relays commands and responses
129between the client (on stdin/stdout) and server (over TCP),
130and responds transparently to authentication requests from the server.
131.hP \*o
132The
133.B noip
134hack, by Mark Wooding,
135is an
136.B LD_PRELOAD
137library which selectively uses Unix-domain sockets
138in place of IPv4 or IPv6 sockets.
139.
140.SS "Command line"
141The
142.B with-authinfo-kludge
143program accepts a small number of options
144before its main command-line arguments.
145.TP
146.B \-h
147Write help about the command-line syntax to standard output,
148and exit with status zero.
149.TP
150.BI "\-d " dir
151Use
152.I dir
153as the `runtime directory',
154which is used to store sockets and other working files
155while
156.B with-authinfo-kludge
157is running.
158By default, it will choose an appropriate place
159in a moderately complicated manner described below;
160this option lets you override its choice
161in order to achieve special effects.
162.TP
163.BI "\-f " conf
164Read configuration from
165.IR conf .
166The default is somewhat complicated;
167see below.
168.TP
169.BI "\-t " tag
170Use
171.I tag
172to distinguish this usage of
173.B with-authinfo-kludge
174from others.
175The tag is used to select default configuration files
176and runtime directories.
177By default, the basename of the
178.I command
179is used.
180.TP
181.B "\-v"
182Print messages explaining what
183.B with-authinfo-kludge
184is doing to standard error.
185By default,
186.B with-authinfo-kludge
187does its thing silently unless there are problems.
188.PP
189The
190.I command
191argument names the command which should be run
192with the various proxy arrangements which it is the task of
193.B with-authinfo-kludge
194to arrange; it will be passed the
195.IR args ,
196if any.
197The command name and arguments are not subject to
198interpretation by the shell;
199if, for some reason, you wanted to make use of shell features,
200you should specify a command of the form
201.B /bin/sh
202.B \-c
203.IR shell-fragment .
204.PP
205Between the options (if any) and the
206.I command
207name,
208there may be a number of server configurations.
209If any are present, they take the place of any configuration file:
210an error is reported if a
211.B \-f
212option was passed.
afaf8da0 213A server configuration starts with
b3370918
MW
214an argument consisting of a server name prefixed by a
215.RB ` + '
216character:
217.IP
218.BI + server
219.PP
220This may be followed by assignments
221.IP
222.IB param = value
223.PP
224which set configuration parameters
225for the previously-named server.
226Such a server configuration on the command line
227is treated exactly the same as a configuration-file section
228.IP
229.BI [ server ]
230.br
231.IB param = value
232.br
233\&...
234.PP
235See below for details about the configuration file.
236.PP
89a1cc74 237To hedge against the
b3370918 238.IR command 's
89a1cc74
MW
239name containing an
240.RB ` = '
241or, less plausibly, beginning with
b3370918
MW
242.RB ` + ',
243an argument consisting of a
244.RB ` + '
245sign on its own marks the end of the server configurations:
246the following argument will be interpreted as the command name
247regardless of its syntactic form.
248If there is a
249.RB ` + '
250marker, but no server configurations,
251then the configuration file is read,
252or the default configuration is used,
253as usual.
254.
255.SS "Configuration file"
256The
257.B with-authinfo-kludge
258program reads configuration from a standard-ish
259.RB ` .ini '-format
260file.
261The file consists of parameter settings of the form
262.IP
263.I param
264.B =
265.I value
266.PP
267divided into sections by headers of the form
268.IP
269.BI [ name ]
270.PP
271Whitespace around the
272.IR name ,
273.I param
274and
275.I value
276strings is discarded.
277A section
278.I name
279may itself contain square brackets,
280and they need not be properly nested.
281There is no syntax for continuing values over more than one line.
282.PP
283The file may also contain blank lines,
284and comment lines whose first non-whitespace character is either
285.RB ` # '
286or
287.RB ` ; '.
288All such lines are ignored.
289.PP
290Parameter settings apply to the section named in the most recent
291setion header.
292Settings appearing before the first section header apply to
293the special section named
294.BR @GLOBAL ,
295just as if a line
296.IP
297.B [@GLOBAL]
298.PP
299appeared at the very top of the file.
300It is permitted (though not usually expected)
301for several section headers to have the same name;
302in this case,
303all of the settings following any of the occurrences are gathered together,
304just as if they'd all appeared under a single header,
305in the same order.
306If the same parameter is assigned more than once,
307then only the
308.I last
309assignment has any effect.
310.PP
311With the exception of the
312.B @GLOBAL
313section,
314each section header should name an NNTP server.
315.PP
316The following server parameters are recognized.
317.TP
318.BI local= host\fR[ : port \fR]
319Sets the NNTP server address which the newsreader command
320expects to connect to.
321This does
322.I not
323have to be an address local to the machine on which
324.B with-authinfo-kludge
325runs.
326It defaults to the
327.I server
328name from the section heading
329(which must therefore be in the appropriate format),
330and may be equal to the
331.I remote
332address (below) without causing difficulty.
838ff5e9
MW
333Note that
334.B with-authinfo-kludge
335will not do anything to encourage the client
336to connect to the right address;
337its caller must arrange to configure the client correctly,
338e.g., by setting the
339.B NNTPSERVER
340environment variable appropriately.
b3370918
MW
341.TP
342.BI nntpauth= "parameter arguments\fR..."
343Set the AUTHINFO GENERIC authentication parameter and arguments
344to use for this server.
345The default is to use the settings from the
346.B NNTPAUTH
347environment variable.
348.TP
349.BI remote= host\fR[ : port \fR]
350Sets the real address of the NNTP server which
351.BR with-authinfo-kludge 's
352proxy (or the SSH tunnel) should connect to.
353It defaults to the
354.I server
355name from the section heading
356(which must therefore be in the appropriate format).
357.TP
358.BI sshbind= host\fR[ : port\fR]
359Change the address and port number
360of the local end of the SSH tunnel
361set up by the
362.B via
363parameter.
364The default is to use
49ae1f48
MW
365127.1.0.1:1119,
366because OpenSSH refuses to try to listen on low-numbered ports
367rather than trying it and seeing whether it would work
368(which it would, in this case).
b3370918
MW
369It is
370.I not
371a problem for multiple servers to use the same address:
372.B with-authinfo-kludge
373uses the
374.BR noip (1)
375library to keep them
376separate.
377.TP
378.BI via= gateway
379Use SSH connection forwarding to reach the server.
380The
381.I gateway
382is passed to
383.BR ssh (1)
384as its hostname parameter,
385so may be a hostname or IP address,
386possibly prefixed by
387.IB user @
388to choose a different login name;
389or it may name a
390.BR ssh_config (1)
391stanza providing detailed configuration.
392Note that the local end of the tunnel will
393.I not
394be exposed to other users of the local machine,
395since this instance of SSH is run under the control of
396.BR noip (1).
397.PP
398The various parameters which take network addresses
399accept a common syntax:
400.IP
401.IR host \c
402.RB [ : \c
403.IR port ]
404.PP
405The
406.I host
407may be a hostname;
408an IPv4 address in dotted-quad notation; or
409an IPv6 address in hex-and-colons notation,
410which must contain at least
411.I two
412colons to be valid.
413Raw IP addresses may be surrounded by square brackets;
414this is necessary to disambiguate a trailing
415.BI : port
416following an IPv6 address because the IPv6 address syntax is stupid.
417.PP
418The
419.B @GLOBAL
420section may set the following parameters.
421.TP
422.BI rundir= dir
423Set the runtime directory to be
424.IR dir .
425This directory (but not its parent directories)
426will be created automatically if necessary.
427The default runtime directory is chosen in a complicated way;
428see below.
429.PP
430The configuration file is found as follows.
431.hP 1.
432If server configurations are provided on the command line,
433then they are used instead of any configuration file.
434.hP 2.
435If a
436.B \-f
437option is given, then it is read as a configuration file.
438A fatal error is reported if the file does not exist,
439or cannot be read for some other reason.
440.hP 3.
b3370918
MW
441Let
442.I home
49ae1f48
MW
443be the value of the environment variable
444.BR HOME ;
445if this variable is not set, then
446.I home
447is not defined.
b3370918 448.hP 4.
49ae1f48 449A `configuration path' is built, as follows.
b3370918
MW
450If the environment variable
451.B XDG_CONFIG_HOME
49ae1f48
MW
452is set, then its value is the first entry in the path;
453otherwise the first entry is
b3370918
MW
454.IB home /.config \fR;
455a fatal error is reported at this point
456if no home directory was determined.
49ae1f48
MW
457If the environment variable
458.B XDG_CONFIG_DIRS
459is defined,
460then the
461.RB ` : '-separated
462entries in its value are appended to the path;
463otherwise, the single entry
464.B /etc/xdg
465is appended.
b3370918
MW
466.hP 5.
467A `tag' is chosen, as follows.
468If the
469.B \-t
470option is given, then its value is used;
471otherwise the tag is the basename of the
472.I command
473(i.e., the part following the last
474.RB ` / ',
475if any).
476Let
477.I tag
478denote the tag so chosen.
479.hP 6.
49ae1f48
MW
480A search is made for a file
481.IB dir /with-authinfo-kludge/ tag .conf
482for each directory
483.I dir
484in the configuration path established in step 4,
485in order.
486If such a file exists exists,
487then it is read as a configuration file.
b3370918
MW
488(If it can't be read, then a fatal error is reported.)
489.hP 7.
49ae1f48
MW
490A similar search is made for
491.IB dir /with-authinfo-kludge/@default.conf \fR.
492If such a file exists,
493then it is read as a configuration file.
b3370918
MW
494(If it can't be read, then a fatal error is reported.)
495.hP 8.
496No configuration file could be found,
497so a default configuration is constructed, as follows.
498Let
499.I nntp-server
afaf8da0 500be the value of the
b3370918
MW
501.B NNTPSERVER
502environment variable;
503if it is not set, then a fatal error is reported.
504The default configuration is as follows.
505.RS
506.IP
507.BI [ nntp-server ]
508.RE
509.
510.SS "The runtime directory"
511(This section is technical, and can safely be skipped by most users.
512It may be useful to know this stuff if
513.B with-authinfo-kludge
514is behaving confusingly and you're trying to understand why.)
515.PP
516The runtime directory is chosen as follows.
517.hP 1.
518If the
519.B \-d
520option is present, then its value is used.
e365c82b
MW
521Otherwise, if the configuration file specifies
522a value for the global
523.B rundir
524parameter then that it used.
b3370918
MW
525.hP 2.
526If the environment variable
527.B XDG_RUNTIME_DIR
528is set, then let
529.I run
530denote its value;
531then
532.IB run /with-authinfo-kludge
533is used as the runtime directory.
d9c763dc 534.hP 3
b3370918
MW
535If the environment variable
536.B TMPDIR
537is set, then let
538.I tmp
539be its value;
540otherwise, let
541.I tmp
542be
543.BR /tmp .
d9c763dc
MW
544Let
545.I uid
546be the current effective uid, in decimal,
547without leading zeroes
548(if the superuser is foolish enough to run this program then
549.I uid
550is
551.BR 0 ).
b3370918 552If
d9c763dc 553.IB tmp/ with-authinfo-kludge- uid
b3370918
MW
554exists,
555is a directory (and not a symbolic link),
556is owned by the current effective uid,
557and has no permissions for group or others;
558or if it does not exist but can be created with the above properties;
559then it is used as the runtime directory.
d9c763dc 560.hP 4.
b3370918
MW
561Let
562.I home
49ae1f48
MW
563be the value of the environment variable
564.BR HOME ;
565if this variable is not set, then
566.I home
567is not defined.
d9c763dc 568.hP 5.
b3370918
MW
569A `cache home' directory is determined, as follows.
570If the environment variable
571.B XDG_CACHE_HOME
572is set, then its value is used.
573Otherwise, the configuration home is
574.IB home /.cache \fR;
575a fatal error is reported at this point
576if no home directory was determined.
577Let
578.I cache-home
579denote the cache home directory so determined.
580If the cache home directory does not exist,
581then it is created with mode 0777 (as modified by the umask).
d9c763dc 582.hP 6.
b3370918
MW
583Let
584.I hostname
585be the local machine's hostname,
586as reported by
587.BR gethostname (2).
e365c82b 588Then
b3370918 589.IB cache-home /with-authinfo-kludge. hostname
e365c82b
MW
590is used as the runtime directory.
591.PP
592If the directory chosen by the above procedure does not exist,
b3370918
MW
593then it is created as a directory,
594with mode 0700 (and modified by the umask).
b3370918
MW
595(If it exists, but is not in fact a directory,
596then later operations will fail.)
597.PP
49ae1f48
MW
598The runtime directory contains a number of other directories.
599There are a small number of shared directories,
600and zero or more
601.I session
602directories,
603each one corresponding to a running
b3370918
MW
604(or failed)
605instance of
49ae1f48
MW
606.BR with-authinfo-kludge .
607.PP
608The shared directories are as follows.
609.TP
610.B new/
611This is the `nursery' directory:
612new session directories are created and populated in here.
613Subdirectories have names of the form
614.BI n. time . pid . rand /
615where
616.I time
617is the time
618(seconds since the POSIX epoch)
619at which the directory was created;
b3370918 620.I pid
49ae1f48
MW
621is the creator's process id; and
622.I rand
623is a random number chosen to minimize conflicts.
624Directories in the nursery older than 300 seconds
625may be deleted.
626The creation protocol is to
627create a directory with an appropriate name;
628create a file within it named
629.BR lock ;
630take out a
631.BR fcntl (2)-style
632exclusive lock on this file;
633and then move the directory to be a direct child
634of the runtime directory.
635.TP
636.B junk/
637Session and nursery directories are deleted in two stages:
638the first stage is to make them be subdirectories of
639.BR junk/ .
640Once there, any process may delete them.
641Note that nursery directories can be junked
642even if they're locked:
643moving them to
644.B junk/
645prevents them from being promoted to proper sessions.
646.PP
647Session directories are named
648.BI s. tag . pid /
649where the
b3370918
MW
650.I tag
651is the tag summarizing its purpose
652(as determined in step 5 of the procedure
49ae1f48
MW
653for finding a configuration file), and
654the
655.I pid
656is the creator's process-id,
657which distinguishes this session from others with the same tag.
b3370918 658.PP
49ae1f48 659The contents of a session directory are as follows.
b3370918
MW
660.TP
661.B client.pid
662The process-id of the client command run by
663.BR with-authinfo-kludge .
664.TP
665.B lock
666An empty file.
667A
668running
669.B with-authinfo-kludge
49ae1f48
MW
670process holds a
671.BR fcntl (2)-style
672lock on this file.
b3370918
MW
673It is used simply to tell other processes that
674the directory is still in use and shouldn't be cleaned up.
675.TP
49ae1f48
MW
676.B noip-client/
677A directory containing Unix-domain sockets created by
678.BR with-authinfo-kludge ;
679the
b3370918 680.B noip
49ae1f48
MW
681library arranges for the client program
682to connect to these Unix-domain sockets
683rather than to the real remote NNTP servers.
684.TP
685.BR noip-ssh. server /
686This directory also contains Unix-domain sockets ;
687they are created by
688.BR ssh (1)
689and
690.B authinfo-kludge
691connects to them,
692both under the influence of
693.BR noip .
b3370918 694.TP
49ae1f48 695.BI ssh- server .pid
b3370918
MW
696The process-id of the SSH process started to satisfy a
697.B via
698server parameter.
699.
700.\"--------------------------------------------------------------------------
701.SH BUGS
702.
703The program is probably too complicated for many uses,
704but the author finds the various bells and whistles useful.
705.PP
706There isn't a good way to get two or more NNTP clients
707to share the same proxy machinery.
708This is somewhat wasteful.
709Fixing this would necessitate some other way of
710orchestrating the setup and teardown of runtime directories.
b3370918
MW
711.
712.\"--------------------------------------------------------------------------
713.SH SEE ALSO
714.
715.BR authinfo-kludge (1),
716.BR noip (1).
717.PP
718S. Barber,
719.IR "RFC2980, Common NNTP Extensions",
720.if !t \{\
721.br
722\h'5m'\c
723.\}
724.BR "https://www.ietf.org/rfc/rfc2980.txt" .
725.
726.SH AUTHOR
727Mark Wooding,
728<mdw@distorted.org.uk>
729.
730.\"----- That's all, folks --------------------------------------------------