This is a read-only archive of the Mumble forums.

This website archives and makes accessible historical state. It receives no updates or corrections. It is provided only to keep the information accessible as-is, under their old address.

For up-to-date information please refer to the Mumble website and its linked documentation and other resources. For support please refer to one of our other community/support channels.

Jump to content

Simple Machines Forum (SMF) Ice Auth Python Script


theanomaly
 Share

Recommended Posts

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

smfauth.zip

Edited by theanomaly
Link to comment
Share on other sites

  • 2 weeks later...
  • Administrators

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/mumble-scripts/trees/master/Authenticators

Link to comment
Share on other sites

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.

 

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

 

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.

Link to comment
Share on other sites

  • Administrators

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

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 3 months later...

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:

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.

Link to comment
Share on other sites

and i almost forgot regarding my second question:

is there any chance to make this script some thing like cron - to run it automatically for example each hour or 30 mins, but do not get duplicates in murmur users DB? Also question how to make such option like ban user in mumble if it was banned on SMF board? or maybe i'm really stuipid and this potions already done?

Link to comment
Share on other sites

and btw i've tryed wiciu script and installed all what was required, and getting this error:

./smfauth.py
Traceback (most recent call last):
 File "./smfauth.py", line 867, in <module>
   do_main_program()
 File "./smfauth.py", line 248, in do_main_program
   Ice.loadSlice('', ['-I' + Ice.getSliceDir(), cfg.ice.slice])
AttributeError: 'module' object has no attribute 'getSliceDir'

Link to comment
Share on other sites

 Share

×
×
  • Create New...