🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.free.newsservers
Article #150001

Re: If you're on Linux & if Mixmin is working -> please tail the stunnel log file

#150001
From: Avatar
Date: Tue, 30 Apr 2013 06:02
313 lines
11511 bytes
Avatar wrote on Tue, 30 Apr 2013 05:32:26 +0000:

> I think that the "setuid" & "setgid" are what's causing
> stunnel to fail; but I don't know enough about Linux to 
> troubleshoot why.

Here's a running log, in case others need the help.
I'm sorry it's confusing, but, I was confused during the process.
So, while this worked - I'm not quite sure why it had failed initially.

Here's the installation instructions on Centos for installing Pan + Mixmin 

Install the Pan newsreader:
$ sudo yum --enablerepo rpmforge install pan -y

Test Pan by adding a newsserver (e.g., aioe):
[Pan]Edit->Edit News Servers->Add->(see below)->OK
     Address: aioe.org
     Port: 119

Test Pan by adding a user (e.g., foo@bar.com):
[Pan]Edit->Edit Posting Profiles->Add->
     Profile Name: New Profile
     Full Name: Foo Bar
     Email Address: foo@bar.com
     Post Articles Via: aioe.org
     OK

Test Pan setup by reading & sending a message to alt.test.
[Pan]Post->Post to Newsgroup->alt.test

That should immediately be successful (and always is).
Now attempt to set up the Mixmin newsserver, which requires stunnel:
     $ sudo yum install stunnel -y
     $ sudo cp /usr/share/doc/stunnel-4.29/stunnel.conf-sample \
       /etc/stunnel/stunnel.conf
     $ sudo vi  /etc/stunnel/stunnel.conf
                [nntp]
                accept = localhost:119
                connect = news.mixmin.net:563
       Note: When I used the following two lines, stunnel failed:
                setuid = nobody
                setgid = nobody
     $ sudo mkdir /var/log/stunnel
     $ sudo touch /var/log/stunnel/stunnel.log

Now comes the tricky part about setting up stunnel services

Download this stunnel daemon init script:
     http://bugzilla.redhat.com/attachment.cgi?id=325164 
Which came from this stunnel bug report (stunnel lacks an init script):
     https://bugzilla.redhat.com/show_bug.cgi?id=455815

I'm guessing at these installation instructions as there are none available:
     $ sudo cp /tmp/stunnel /etc/init.d/stunnel
     $ sudo chown root /etc/init.d/stunnel
     $ sudo chmod 755 /etc/init.d/stunnel

     $ sudo view /etc/init.d/stunnel
       I see that the following were called but none of these exist:
       /var/run/stunnel (directory)
       /var/run/stunnel/stunnel.pid (process-id file)
       /var/lock/subsys/stunnel (file)
       /usr/sbin/stunnel (executable)

So, I will manually create the /var/run/stunnel directory after
looking for expected ownership in the stunnel.conf file:
     $ grep set.id /etc/stunnel/stunnel.conf
     ==> setuid = nobody
     ==> setgid = nobody

I then made the stunnel directory and changed ownership to that owner:
     $ sudo mkdir /var/run/stunnel
     $ sudo chown nobody /var/run/stunnel
     $ ls -ld /var/run/stunnel

And I modified that init.d script to point to the stunnel executable
which was installed ing /usr/bin/stunnel by the yum command:
     $ which stunnel
       ==> /usr/bin/stunnel
     $ sudo vi /etc/init.d/stunnel
       Change the location of the stunnel execution:
FROM:
daemon --check $servicename '/usr/sbin/stunnel /etc/stunnel/stunnel.conf
&>/dev/null'
TO:
daemon --check $servicename '/usr/bin/stunnel /etc/stunnel/stunnel.conf
&>/dev/null'

As a doublecheck, the following directories & files are called out in the
(slightly modified) default configuration:
$ grep stunnel /etc/{stunnel/stunnel.conf,init.d/stunnel}
REPORTED the following files and directories are needed:
- chroot = /var/run/stunnel/
- output = /var/log/stunnel/stunnel.log
- servicename=stunnel
- processname=stunnel
- pidfile=/var/run/stunnel/stunnel.pid
- /usr/bin/stunnel
- /etc/stunnel/stunnel.conf

Since all of those exist at this point, I then re-tried the suggested command
but it failed this time:
$ su root
# cd /
# chkconfig -add stunnel
REPORTED:
-add: unknown option

Hmmm... Maybe it's already there?
# chkconfig|grep stunnel
REPORTS:
stunnel 0:off 1:off 2:off 3:on 4:on 5:on 6:off

I'll assume that indicates that this step above is no longer needed.
Moving onward, let's now start the stunnel service:
# service stunnel start
REPORTS:
Starting stunnel services: [ OK ]

$ /sbin/chkconfig --list | awk '{ print $1 }' | sort | grep stunnel
REPORTS (installed services):
stunnel

$ /sbin/chkconfig --list | grep :on | grep stunnel
REPORTS (services configured to run):
stunnel 0:off 1:off 2:off 3:on 4:on 5:on 6:off

$ for S in $(/sbin/chkconfig --list | awk '/:on/ { print $1 }' | sort); do
echo $S; /sbin/service $S status; echo; done | grep stunnel
REPORTS:
stunnel
stunnel (pid 2825) is running...

# service --status-all | grep stunnel
REPORTS:
stunnel (pid 2825) is running...

# netstat -tulpn | grep stunnel
REPORTS:
tcp 0 0 ::1:119 :::* LISTEN 2825/stunnel

# ntsysv
REPORTS: stunnel is automatically started.

$ telnet 127.0.0.1 119
REPORTS: 
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused

Repeat that command as folks have reported the second time works 
(mine didn't work no matter how many times I repeated it):
$ !!
$ !!
$ !!

Looking at my hosts file, I have:
$ head /etc/hosts
127.0.0.1 NAME localhost localhost.localdomain localhost4 localhost4.localdomain4

$ grep -i mixmin /etc/hosts
  REPORTS: nothing

$ netstat -antp | grep 119
REPORTS: 
  netstat -antp | grep 119
  (Not all processes could be identified, non-owned process info
   will not be shown, you would have to be root to see it all.)
  tcp 0 0 ::1:119 :::* LISTEN -                   

$ sudo netstat -antp | grep 119
REPORTS: 
  tcp 0 0 ::1:119 :::* LISTEN 2723/stunnel       

---- skipping over to Pan setup -----

[Pan]Edit->Edit News Servers->Add->(see below)->OK
     Address: news.mixmin.net
     Port: 563

[Pan]Edit->Edit News Servers->Add->(see below)->OK
     Address: localhost
     Port: 119

Then refresh groups:
[Pan]Groups->Refresh Group List

Then try to post to alt.test using the Mixmin news server:
Test Pan setup by reading & sending a message to alt.test.
[Pan]Post->Post to Newsgroup->alt.test

The error will always be:
  There were problems with this post.
  Warning: The posting profile's server doesn't carry newsgroup alt.test.

At this point, I have no error message.
So, seeking an error message, I look at the log file:

$ sudo tail -f /var/log/stunnel/stunnel.log
: Created pid file /stunnel.pid
: nntp accepted FD=13 from ::1:47349
: nntp started
: FD 13 in non-blocking mode
: TCP_NODELAY option set on local socket
: Waiting for a libwrap process
: Acquired libwrap process #0
: Releasing libwrap process #0
: Released libwrap process #0
: nntp permitted by libwrap from ::1:47349
: nntp accepted connection from ::1:47349
: Error resolving 'news.mixmin.net': 
  Neither nodename nor servname known (EAI_NONAME)
: No host resolved
: Connection reset: 0 bytes sent to SSL, 0 bytes sent to socket
: nntp finished (0 left)

The first error says stunnel can't resolve news.mixmin.net.

I test if my DNS server can resolve it, and it can:

$ ping news.mixmin.net
PING news.mixmin.net (188.40.76.149) 56(84) bytes of data.
64 bytes from snorky.mixmin.net (188.40.76.149): icmp_seq=1 ttl=47 time=175 ms
64 bytes from snorky.mixmin.net (188.40.76.149): icmp_seq=2 ttl=47 time=193 ms
64 bytes from snorky.mixmin.net (188.40.76.149): icmp_seq=3 ttl=47 time=184 ms

$ openssl s_client -connect news.mixmin.net:563
  REPORTS: 
   CONNECTED(00000003)
   ... stuff ... 
   200 news.mixmin.net InterNetNews NNRP server INN 2.6.0 (20120622 prerelease)
   ready (posting ok)
post
   340 Ok, recommended message-ID <krr5gb$mbf$1@news.mixmin.net>
From: foo <foo@bar.com>
Newsgroups: alt.test
Subject: test

Test?
..
   240 Article received <krr5gb$mbf$1@news.mixmin.net>
quit
   205 Bye!
closed

At this point I decided to minimize my stunnel.conf file to the following:

$ cat /etc/stunnel/stunnel.conf
REPORTS:
client = yes
[nntp]
accept = localhost:2119
connect = news.mixmin.net:563

To test using Telnet, try this first:
$ telnet news.mixmin.net 119
  Trying 188.40.76.149...
  Connected to news.mixmin.net.
  Escape character is '^]'.
  200 news.mixmin.net InterNetNews NNRP server INN 2.6.0 (20120622 prerelease)
  ready (posting ok)
quit
  205 Bye!
  Connection closed by foreign host.

If that works, try this:
$ telnet localhost 2119 <== use whatever port you used in stunnel.conf
  Trying 127.0.0.1...
  Connected to localhost.
  Escape character is '^]'.
  200 news.mixmin.net InterNetNews NNRP server INN 2.6.0 (20120622 prerelease)
  ready (posting ok)
quit
  205 Bye!
  Connection closed by foreign host.

If that worked, then you can create an actual post:
$ telnet localhost 2119 
  Trying ::1...
  telnet: connect to address ::1: Connection refused
  Trying 127.0.0.1...
  Connected to localhost.
  Escape character is '^]'.
  200 news.mixmin.net InterNetNews NNRP server INN 2.6.0 (20120622 prerelease)
  ready (posting ok)
post
  340 Ok, recommended message-ID <knlm4l$e57$1@news.mixmin.net>
From: foo <foo@bar.com>
Newsgroups: alt.test
Subject: This is a test
  
This is a test of stunnel to mixmin.
..
240 Article received <knlm4l$e57$1@news.mixmin.net>
quit
205 Bye!
Connection closed by foreign host.

---- skipping back to Pan setup -----

[Pan]Edit->Edit News Servers->Add->(see below)->OK
     Address: localhost
     Port: 2119

Then refresh groups:
[Pan]Groups->Refresh Group List

Test Pan setup by reading & sending a message to alt.test.
[Pan]Post->Post to Newsgroup->alt.test

This finally worked for me at this point!
Woo hoo!
Technical Details
Message-ID: <klnmpk$ueg$2@news.albasani.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.free.newsservers.20150605.mbox.gz!border1.nntp.dca3.giganews.com!border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!217.73.144.44.MISMATCH!feeder.ecngs.de!ecngs!feeder2.ecngs.de!feeder.erje.net!eu.feeder.erje.net!news.albasani.net!.POSTED!not-for-mail
References: <klkq3s$eiv$2@news.albasani.net> <slrnknspa6.1nb.catwheezel@ID-107770.user.individual.net> <klmikr$vat$1@news.albasani.net> <klnl19$80b$2@news.albasani.net>

Show Full Headers
Complete Article Headers
Message-ID: <klnmpk$ueg$2@news.albasani.net>
Subject: Re: If you're on Linux & if Mixmin is working -> please tail the stunnel log file
Date: Tue, 30 Apr 2013 06:02:28 +0000
From: Avatar <Avatar@hbgyisasesaew.com>
References: <klkq3s$eiv$2@news.albasani.net> <slrnknspa6.1nb.catwheezel@ID-107770.user.individual.net> <klmikr$vat$1@news.albasani.net> <klnl19$80b$2@news.albasani.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.free.newsservers.20150605.mbox.gz!border1.nntp.dca3.giganews.com!border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!217.73.144.44.MISMATCH!feeder.ecngs.de!ecngs!feeder2.ecngs.de!feeder.erje.net!eu.feeder.erje.net!news.albasani.net!.POSTED!not-for-mail
Newsgroups: alt.free.newsservers,alt.comp.freeware,alt.os.linux
Organization: albasani.net
Lines: 313
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.albasani.net
 GPegm6lhE+q5Kpv+6uvCjvMl7at7HrQhRBO1PyAnuXFIK9+R2PzAjl1h2ttie8ZeiWsPeX2BVRLJMTtyEV8zTe1MbFa+LLn5AnuIXlQpSoedzXXE6OgaZ5WkVEBcwtTc
NNTP-Posting-Date: Tue, 30 Apr 2013 06:02:28 +0000 (UTC)
Injection-Info: news.albasani.net;
 logging-data="VoAtm5PBWZ9je6pdPyHgGVLJhMZwkh4iRGsyei/xM+U3Gnl+vbIyUpFl+9cpobB7wm10rbvrhcz3uYA8LxRvWtxtR+O1xycukzySa/u7abesOYlnIHx0BSfa0YybVLY1";
 mail-complaints-to="abuse@albasani.net"
Cancel-Lock: sha1:LJcnf03E0hKBujn6OUQWB2rZS90=
X-Original-Bytes: 11206