Package: userv
Version: 1.1.1
The userv spec's documentation of the escaping system used by
'include-lookup' is very inaccurate.
/usr/share/doc/userv/spec.html/ch-config.html claims, in section 4.2.1
under 'include-lookup':
A translation will be applied to values before they are used to
construct a filename, so that the lookup cannot access dotfiles or
files in other directories: values starting with full stops will have
a colon prepended (making ':.'), colons will be doubled, and each
slash will be replaced with a colon followed by a hyphen ':-'.
In fact, reading the code and double-checking against the results of
stracing uservd to see what files it actually tries to open, the rules
appear to be:
- First, if the value starts with a dot, an initial colon is written to
the output string. This does not exempt that leading dot from the
subsequent escaping treatment.
- Thereafter, only digits, lowercase letters, hyphen and underscore are
emitted literally; _every_ other character (including uppercase
letters!) is prefixed by a colon, with the exception that the forward
slash becomes colon-hyphen.
This differs from the documented behaviour in its treatment of
_everything_ other than lowercase alphanumerics, colon and slash. The
dot is always prefixed with at least one colon, and at the start of the
string it gets a second one (where the spec claims it is colon-prefixed
only once, and _only_ at the start of the string). All other punctuation
characters, and uppercase letters, are colon-prefixed, where the spec
says nothing about that.
For example, on my machine, where ~simon/.userv/rc reads
include-lookup service .userv/services
if I run the command
userv simon '.Hello, world!'
and watch the userv daemon using 'strace -f -p <pid>', I see it do this:
open(".userv/services/::.:Hello:,: world:!", O_RDONLY) = -1 ENOENT (No such
file or directory)
whereas the documented escaping behaviour would have led me to expect
the pathname argument to be ".userv/services/:.Hello, world!".
Cheers,
Simon
--
import hashlib; print (lambda p,q,g,y,r,s,m: m if (lambda w:(pow(g,int(hashlib.
sha1(m).hexdigest(),16)*w%q,p)*pow(y,r*w%q,p)%p)%q)(pow(s,q-2,q))==r else "!"
)(0xb80b5dacabab6145, 0xf70027d345023, 0x7643bc4018957897, 0x11c2e5d9951130c9,
0xa54d9cbe4e8ab, 0x746c50eaa1910, "Simon Tatham <[email protected]>")