🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #72366

Re: Authentication advice

#72366
From: Jeffrey M. Vinocur
Date: Sun, 02 Oct 2005 19:16
66 lines
3712 bytes
In article <7MJ%e.353849$5N3.165070@bgtnsc05-news.ops.worldnet.att.net>,
John F. Morse <xanadu.bbs@invalid.net> wrote:
>
>I had the "username:password:misc" data file encrypted with the perl 
>script you provided. Today, when I was checking the file using the 
>example in ckpasswd(8), to wit:

Hmm, that looks like an old version of the ckpasswd manpage, btw.
Or maybe it goes with an old version of ckpasswd?  A while back
Russ added support for `ckpasswd -u username -p password` as a
handy way to test without having to do echo commands like that.
But your problem report below is still relevant regardless.


>sh: line 1: K8?: command not found
>bschneider:esVfW2VF4fFGK:Bob Schneider
>
>This was for a user with the following info:
>
>bschneider:r7&K8$g51?:Bob Schneider

Whoa, you're absolutely right, my script didn't handle passwords
with shell metacharacters in them.  It's easy to fix the script,
just adjust the line that calls htpasswd to have single quotes:

        my $out = `htpasswd2 -ndb '$user' '$pass'`;


>I tried the single and double quotes around the whole password 
>"r7&K8$g51?" but that did no good.

Adjusting the script as above should take care of it.

When you're using htpasswd and providing the password on the
commandline (but not when you let htpasswd prompt you for the
password), you'll want to put single quotes around passwords like
that.  Same goes for using ckpasswd for testing as mentioned
above.

But users wouldn't have to put them in their news clients -- the
issue is whether or not the unix shell lays hands on the data,
since that's what's misinterpreting them all.  So in the Perl
script I wrote you, using the `` backticks leads to a shell
interpreting the strings.

The intricacies of shell quoting are painful and tedious to
learn, unfortunately, and I'm sure you'll encounter them again.
Get in the habit of using single quotes unless you have a
specific need for double quotes, and you'll be much happier in
the end.  (For example, if your user had put a $ in the password,
and you used double quotes, it still wouldn't work properly
because the shell would be interpreting the $ as a variable
reference, even inside double quotes -- but not single quotes.)


>Then I started wondering what if a user wanted to use a single or double 
>quote, or the backslash, as part of their password?

They could, but it would require a much more careful job in that
script.  The underlying INN software would manage it correctly in
the end, but it probably wouldn't be worth the trouble.


-- 
Jeffrey M. Vinocur
jeff@litech.org
Technical Details
Message-ID: <dhpbmh$va2$3@puck.litech.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20140818.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.glorb.com!news.litech.org!not-for-mail
References: <2b9f5$4335ae05$4097152a$18719@EVERESTKC.NET> <dh4dmf$d5u$1@puck.litech.org> <7MJ%e.353849$5N3.165070@bgtnsc05-news.ops.worldnet.att.net>

Show Full Headers
Complete Article Headers
Message-ID: <dhpbmh$va2$3@puck.litech.org>
Subject: Re: Authentication advice
Date: Sun, 02 Oct 2005 19:16:33 +0000
From: jeff@litech.org (Jeffrey M. Vinocur)
References: <2b9f5$4335ae05$4097152a$18719@EVERESTKC.NET> <dh4dmf$d5u$1@puck.litech.org> <7MJ%e.353849$5N3.165070@bgtnsc05-news.ops.worldnet.att.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20140818.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.glorb.com!news.litech.org!not-for-mail
Newsgroups: news.software.nntp
Organization: Litech Systems Design
Lines: 66
Sender: jeff@litech.org
NNTP-Posting-Host: puck.litech.org
X-Trace: puck.litech.org 1128280593 32066 66.218.0.75 (2 Oct 2005 19:16:33 GMT)
X-Complaints-To: usenet@litech.org
NNTP-Posting-Date: Sun, 2 Oct 2005 19:16:33 +0000 (UTC)
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
Originator: jeff@litech.org (Jeffrey M. Vinocur)