Mercurial > libervia-backend
comparison src/plugins/plugin_misc_account.py @ 954:5925c9ebfcd2
plugin account: reverted patch abd3a75d629c
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 31 Mar 2014 12:35:59 +0200 |
parents | abd3a75d629c |
children | 3a96920c07b7 |
comparison
equal
deleted
inserted
replaced
953:4a577b170809 | 954:5925c9ebfcd2 |
---|---|
62 pass | 62 pass |
63 | 63 |
64 | 64 |
65 class ProsodyRegisterProtocol(protocol.ProcessProtocol): | 65 class ProsodyRegisterProtocol(protocol.ProcessProtocol): |
66 """ Try to register an account with prosody """ | 66 """ Try to register an account with prosody """ |
67 prosody_gid = None | |
68 | 67 |
69 def __init__(self, password=None, deferred=None): | 68 def __init__(self, password=None, deferred=None): |
70 """ | 69 """ |
71 @param password: new user password | 70 @param password: new user password |
72 @param deferred | 71 @param deferred |
73 """ | 72 """ |
74 self.password = password | 73 self.password = password |
75 self.deferred = deferred | 74 self.deferred = deferred |
76 self.data = '' | 75 self.data = '' |
77 if ProsodyRegisterProtocol.prosody_gid is None: | |
78 try: | |
79 import grp | |
80 ProsodyRegisterProtocol.prosody_gid = grp.getgrnam("prosody").gr_gid | |
81 info("prosody gid found: %s" % ProsodyRegisterProtocol.prosody_gid) | |
82 except: | |
83 warning("Can't find prosody gid") | |
84 | |
85 | 76 |
86 def connectionMade(self): | 77 def connectionMade(self): |
87 if self.password is None: | 78 if self.password is None: |
88 return | 79 return |
89 self.transport.write("%s\n%s" % ((self.password.encode('utf-8'),) * 2)) | 80 self.transport.write("%s\n%s" % ((self.password.encode('utf-8'),) * 2)) |
114 """ | 105 """ |
115 d = defer.Deferred() | 106 d = defer.Deferred() |
116 prosody_reg = ProsodyRegisterProtocol(password, d) | 107 prosody_reg = ProsodyRegisterProtocol(password, d) |
117 prosody_exe = join(plugin._prosody_path, plugin.getConfig('prosodyctl')) | 108 prosody_exe = join(plugin._prosody_path, plugin.getConfig('prosodyctl')) |
118 # TODO delete account which are not on the same host | 109 # TODO delete account which are not on the same host |
119 reactor.spawnProcess(prosody_reg, prosody_exe, [prosody_exe, command, "%s@%s" % (profile, plugin.getConfig('new_account_domain'))], path=plugin._prosody_path, gid=ProsodyRegisterProtocol.prosody_gid) | 110 reactor.spawnProcess(prosody_reg, prosody_exe, [prosody_exe, command, "%s@%s" % (profile, plugin.getConfig('new_account_domain'))], path=plugin._prosody_path) |
120 return d | 111 return d |
121 | 112 |
122 | 113 |
123 class MiscAccount(object): | 114 class MiscAccount(object): |
124 """Account plugin: create a SàT + Prosody account, used by Libervia""" | 115 """Account plugin: create a SàT + Prosody account, used by Libervia""" |