<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[PunBB Forums — Use punbb user records with pam]]></title>
		<link>https://punbb.informer.com/forums/topic/22842/use-punbb-user-records-with-pam/</link>
		<atom:link href="https://punbb.informer.com/forums/feed/rss/topic/22842/" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Use punbb user records with pam.]]></description>
		<lastBuildDate>Mon, 08 Feb 2010 10:41:43 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Use punbb user records with pam]]></title>
			<link>https://punbb.informer.com/forums/post/133766/#p133766</link>
			<description><![CDATA[<p>Thanks for the forum software <img src="https://punbb.informer.com/forums/img/smilies/wink.png" width="15" height="15" alt="wink" /></p>]]></description>
			<author><![CDATA[null@example.com (Loa)]]></author>
			<pubDate>Mon, 08 Feb 2010 10:41:43 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/133766/#p133766</guid>
		</item>
		<item>
			<title><![CDATA[Re: Use punbb user records with pam]]></title>
			<link>https://punbb.informer.com/forums/post/133763/#p133763</link>
			<description><![CDATA[<p>Thanks for this hack!</p>]]></description>
			<author><![CDATA[null@example.com (Slavok)]]></author>
			<pubDate>Mon, 08 Feb 2010 09:44:46 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/133763/#p133763</guid>
		</item>
		<item>
			<title><![CDATA[Re: Use punbb user records with pam]]></title>
			<link>https://punbb.informer.com/forums/post/133749/#p133749</link>
			<description><![CDATA[<p>To sanitize just change in the code to following:</p><div class="codebox"><pre><code># Get userinformation
cursor.execute(
    &quot;SELECT username, password, salt from punbb_users WHERE username = &#039;&quot;
    + MySQLdb.escape(os.getenv(&quot;AUTHD_ACCOUNT&quot;)))</code></pre></div><p>Enjoy!</p>]]></description>
			<author><![CDATA[null@example.com (Loa)]]></author>
			<pubDate>Sun, 07 Feb 2010 19:00:33 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/133749/#p133749</guid>
		</item>
		<item>
			<title><![CDATA[Re: Use punbb user records with pam]]></title>
			<link>https://punbb.informer.com/forums/post/133747/#p133747</link>
			<description><![CDATA[<p>I solved my problem.</p><p>I changed to pure-ftpd instead which have support for custom authentication modules. So I wrote a small script in python <em>(easy to make in php aswell)</em> that access my punbb installation and validate the user.</p><p>Go to <a href="http://download.pureftpd.org/pub/pure-ftpd/doc/README.Authentication-Modules">Pure-ftpd Docs Authentication modules</a> to read how this works and how to start pure-ftpd with the module.</p><p>Here is a simple example I managed to put together so far, you can make it more extensible by adding columns for own user directories, throttling, user size quota etc in database and then write an punbb extension to edit the settings with.</p><p><em>(do notice that this script is very simple and doesn&#039;t sanitize user input from ftp client!)</em></p><div class="codebox"><pre><code>#!/usr/bin/python

import MySQLdb
import os
import hashlib

# Create connection to forum database
conn = MySQLdb.connect(
    host = &quot;localhost&quot;,
    user = &quot;dbuser&quot;,
    passwd = &quot;dbpassword&quot;,
    db = &quot;database&quot;)

# Create cursor
cursor = conn.cursor()

# Get userinformation
cursor.execute(
    &quot;SELECT username, password, salt from punbb_users WHERE username = &#039;&quot;
    + os.getenv(&quot;AUTHD_ACCOUNT&quot;))

# Fetch one row
row = cursor.fetchone()

# Make sure we got a row
if row != None:
    # Create hasher
    hashed_pwd = hashlib.sha1(os.getenv(&quot;AUTHD_PASSWORD&quot;)).hexdigest()
    hashed_pwd = hashlib.sha1(row[2] + hashed_pwd).hexdigest()

    if hashed_pwd == row[1]:
        # Logg in user
         print &#039;auth_ok:1&#039;
         print &#039;uid:33&#039;
         print &#039;gid:33&#039;
         print &#039;dir:/var/www/public.hostname.com&#039;
    else:
        # Password didn&#039;t match
        print &#039;auth_ok:0&#039;
else:
    # Username not found
    print &#039;auth_ok:0&#039;
print &#039;end&#039;

cursor.close ()
conn.close ()</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Loa)]]></author>
			<pubDate>Sun, 07 Feb 2010 18:11:19 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/133747/#p133747</guid>
		</item>
		<item>
			<title><![CDATA[Use punbb user records with pam]]></title>
			<link>https://punbb.informer.com/forums/post/133745/#p133745</link>
			<description><![CDATA[<p>Yo!</p><p>I&#039;m trying to figure out how to use the user information from punbb to give my users ftp access.</p><div class="codebox"><pre><code>auth required pam_mysql.so user=vsftpd passwd=ftpdpass host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=0
account required pam_mysql.so user=vsftpd passwd=ftpdpass host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=0</code></pre></div><p>The example pam configuration just fetches the user info from the database and uses plain passwords as configuration. You can also use shaX and md5 from the documentation I read so far. </p><p>The problem is that punbb stores salt in the user table, so for pam to be able to compare the passwords it needs to hash the user inputed password with the salt before comparing it to the password stored in the user table.</p><p>I wonder have anyone achieved to do this yet? Are there any other practical solutions for this? <em>I could ofc write together a extension that stores an individual ftp password but it would really be sleak with the same password <img src="https://punbb.informer.com/forums/img/smilies/wink.png" width="15" height="15" alt="wink" /></em></p>]]></description>
			<author><![CDATA[null@example.com (Loa)]]></author>
			<pubDate>Sun, 07 Feb 2010 14:13:09 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/133745/#p133745</guid>
		</item>
	</channel>
</rss>
