Simple Machines Forum (SMF) Ice Auth Python Script

Ice/DBus, Web-Interfaces, Management tools

Simple Machines Forum (SMF) Ice Auth Python Script

Postby theanomaly » Tue Dec 07, 2010 6:54 pm

Hey all,

I found out recently that the dbus interface is deprecated/unsupported, and so I rewrote the script in python to use the Ice interface to mumble. I have attached it here in case anyone wants to use it, or have a ready example of a forum auth script.

Here's a quick overview of the config options:

proxy = "Meta:tcp -h 127.0.0.1 -p 6502"
slice = "-I /usr/share/Ice/slice /etc/php/ice/Murmur.ice"

The setup of these first two options is essential for the Ice interface to work at all. My options will likely not work for you, so make sure to check http://mumble.sourceforge.net/ICE for an indication on how to set these up.

ID_OFFSET=20000000
This has the same function as in the original perl dbusauth.pl -- this allows the registrations for regularly registered mumble users to not interfere with externally authenticated ones. Not necessary if you only use external authentication.
HOSTNAME="localhost"
USERNAME="dbusername"
PASSWORD="dbpass"
DATABASE="dbname"
The mysql database info for your simple machines forum. Note, I assume that you are using the default smf_ table prefix -- if not, you'll want to search this script for smf_ and replace with your prefix accordingly.
MAX_AVATAR_SIZE=1024000 #Maximum avatar size in bytes, or 0 for unlimited
This is the maximum sized image that the server will download for a user's avatar, so someone doesn't use a 50MB avatar and make the server download it.
FORUM_URL="http://www.smf-forum.com" #No trailing slash here.
SMF has (at least?) two ways of doing attachments -- one is by a simple external URL, and the other is by the forum attachments system -- this lets the script build URLs for the latter type.

### Warning, enabling avatar support has the potential to lag the server while images ###
### are downloading. However, images are cached once downloaded to speed things up. ###
### Set this to False if it causes any problems. ###

DOWNLOAD_AVATARS=True

This option lets you disable avatar support completely. Basically, when the Mumble server is busy downloading an avatar, it is unable to do anything else, and so will lag the server if the download doesn't happen quickly. This is mitigated by the fact that you can limit the max download size, and that most avatars download rather quickly. However, if you want to play it safe, you can disable avatar support altogether.

Hope this helps somebody.

Cheers,

Anom
Attachments
smfauth.zip
(2.24 KiB) Downloaded 101 times
Last edited by theanomaly on Mon Dec 27, 2010 11:53 pm, edited 1 time in total.
theanomaly
 
Posts: 3
Joined: Tue Dec 07, 2010 6:49 pm

Re: Simple Machines Forum (SMF) Ice Auth Python Script

Postby wiciu » Tue Dec 21, 2010 6:25 pm

Hi !
Thanx for script.. but.. when i tried run smfauth.py

python smfauth.py

i got this

Code: Select all
Traceback (most recent call last):
  File "smfauth.py", line 23, in ?
    import Murmur
ImportError: No module named Murmur


Is it this module :
http://pypi.python.org/pypi/Murmur/
?

Sorry for maybe stupid question but i am not python programmer.
--
wiciu
wiciu
 
Posts: 3
Joined: Wed Dec 08, 2010 11:16 pm

Re: Simple Machines Forum (SMF) Ice Auth Python Script

Postby hacst » Tue Dec 21, 2010 9:05 pm

That script is kinda upsidedown. You have to move the configure section before the imports and the Ice.loadSlice(slice) line has to be before the import Murmur but after the import Ice or it won't work.

On another note: I wrote authenticators for SMF and a phpBB3 some time ago. You can find them on http://gitorious.org/mumble-scripts/mum ... enticators
hacst
Team member
Team member
 
Posts: 339
Joined: Wed Sep 23, 2009 4:28 pm

Re: Simple Machines Forum (SMF) Ice Auth Python Script

Postby wiciu » Tue Dec 21, 2010 10:40 pm

dd0t wrote:On another note: I wrote authenticators for SMF and a phpBB3 some time ago. You can find them on http://gitorious.org/mumble-scripts/mum ... enticators


I tried your script but i found some errors
Code: Select all
line 467
    @fortifyIceFu((-1 if cfg.user.reject_on_error else -2, None, None))
                       ^
SyntaxError: invalid syntax


Any help ? :)
wiciu
 
Posts: 3
Joined: Wed Dec 08, 2010 11:16 pm

Re: Simple Machines Forum (SMF) Ice Auth Python Script

Postby hacst » Tue Dec 21, 2010 10:47 pm

Python 2.4 is pretty old by now ;-) That feature (inline if) was added in 2.5 iirc.
hacst
Team member
Team member
 
Posts: 339
Joined: Wed Sep 23, 2009 4:28 pm

Re: Simple Machines Forum (SMF) Ice Auth Python Script

Postby theanomaly » Sat Dec 25, 2010 12:14 am

dd0t wrote:That script is kinda upsidedown. You have to move the configure section before the imports and the Ice.loadSlice(slice) line has to be before the import Murmur but after the import Ice or it won't work.


It works just fine for me as-is... though it would certainly be prettier the other way. Also, I noticed that for some reason the DB methods aren't rock solid, I had to add a self.conn.ping() before returning the cursor to make sure the DB was still there. I'd republish that, but the version you made seems more complete so maybe there's no need.

dd0t wrote:On another note: I wrote authenticators for SMF and a phpBB3 some time ago. You can find them on http://gitorious.org/mumble-scripts/mum ... enticators


Is there some wiki page / database / something about these? I looked in this forum, but didn't find any mention of the smf authenticator. It seems there is a bunch of stuff that is just plain undocumented... If you want, I'd be happy to hack some stuff into the wiki about things I notice, but I don't know if it's already somewhere and I'm just not finding it or what.
theanomaly
 
Posts: 3
Joined: Tue Dec 07, 2010 6:49 pm

Re: Simple Machines Forum (SMF) Ice Auth Python Script

Postby hacst » Sat Dec 25, 2010 1:16 am

Hm. I didn't try to run the script so I might be mistaken but my python-spidy-senses strongly react to that part of the script
Code: Select all
import Murmur

texturecache = dict()
Ice.loadSlice(slice)

##########   Configure your options here   ############

proxy = "Meta:tcp -h 127.0.0.1 -p 6502"
slice = "-I /usr/share/Ice/slice /etc/php/ice/Murmur.ice"

As python, to my knowledge, executes in order import Murmur should fail because this (virtual) module is only created by Ice.loadSlice(slice) call and Ice.loadSlice(slice) should fail because the slice variable is only assigned a few lines down...that working would be...confusing to me.

Anyway. No. There's not really any documentation on mumble scripts. I added a forum sticky to make it more visible but it could definitely need some referencing in our wiki or documentation of its own. Would be awesome if you'd be willing to do something in that area.
hacst
Team member
Team member
 
Posts: 339
Joined: Wed Sep 23, 2009 4:28 pm

Re: Simple Machines Forum (SMF) Ice Auth Python Script

Postby wiciu » Mon Dec 27, 2010 12:10 pm

Hi !
Thx guys for scripts:
Conslusion:
All your's scripts needs python 2.6 i think - (In CentOS 5.5 default is Python 2.4)
1) Script by theanomaly not working for me, even with python2.6
2) Script by dd0t not working .. because it's dedicated for older version of SMF.
3) Here is my modification od dd0t's smfauth.py for SMF 2.0 RC2 and greater.
http://pliki.g4g.pl/mumble/smfauth.zip
And it's working like a charm :)
wiciu
 
Posts: 3
Joined: Wed Dec 08, 2010 11:16 pm

Re: Simple Machines Forum (SMF) Ice Auth Python Script

Postby theanomaly » Tue Dec 28, 2010 12:00 am

Hey guys,

Looks like I spoke too soon. Apparently the version I uploaded here was an older version than the one I was running, in which the Ice.loadSlice and Import Murmur were in the proper order (so yeah, sorry, looks like i was talking out of my arse, it looks like I debugged the script on my server without re-downloading it to my desktop). I have edited the original post with the updated version of the script, so that version should work now too!

Also, thanks wiciu!

Cheers,

Anomaly
theanomaly
 
Posts: 3
Joined: Tue Dec 07, 2010 6:49 pm

Re: Simple Machines Forum (SMF) Ice Auth Python Script

Postby devorian » Mon Apr 04, 2011 12:21 pm

heya guys, looks like i'm kind a stupid here and i'm not php programmer, but i get problems with this script....
I've entered all data in configuration area, but when i'm trying to run this script throught SSH client? (am i write that i need to run it throught SSH?)
i'm getting such errors in console:
Code: Select all
Traceback (most recent call last):
  File "./smfauth.py", line 45, in <module>
    import Ice
ImportError: No module named Ice


plz help me fix it. I'm currently using SMF 2.0RC5


thanks.
devorian
 
Posts: 6
Joined: Mon Apr 04, 2011 9:40 am

Next

Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest

cron