54
56
self.tacix_manager = tacix_manager
55
57
logger.debug("NXProvider Started")
59
def __get_resumable_sessions(self, user, options):
60
for session in self.tacix_manager._get_sessions_by_type('nx'):
61
properties = session.get_properties()
62
if properties['persistent'] == '0':
64
if properties['user'] != user:
66
if 'status' in options:
67
if options['status'].find(properties['state']) == -1:
69
logger.debug("Adding session %s" % properties)
70
sessions[session.get_property('display')] = properties
73
def __start_sessions(self, users):
74
server = SessionRunner(users)
57
78
#### DBUS Methods/Signals
58
79
@dbus.service.method( dbus_interface=PROVIDER_INTERFACE,
59
80
in_signature='s', out_signature='a{ss}', sender_keyword='sender', connection_keyword='conn' )
60
81
def GetNXProxyOptions( self, session_id, sender, conn ):
83
Gets everything needed by nxproxy to run.
84
This method is or test porpuse, invoking should be restricted.
63
87
dbus-send --system --dest=org.tacix.nx \
64
88
--type=method_call --print-reply --reply-timeout=2000 \
69
93
properties = self.tacix_manager._get_session(session_id).nxoptions.get_properties_secure()
70
94
ret = parse_parameters_dict(properties)
97
@dbus.service.method( dbus_interface=PROVIDER_INTERFACE,
98
in_signature='as', out_signature='b', sender_keyword='sender', connection_keyword='conn' )
99
def StartSessions( self, users, sender, conn ):
101
Creates a new session and starts it on a hidden X server.
102
This method is or test porpuse, invoking should be restricted.
105
dbus-send --system --dest=org.tacix.nx \
106
--type=method_call --print-reply --reply-timeout=2000 \
107
/org/tacix/nx/provider \
108
org.tacix.nx.provider \
111
return self.__start_session(users)
113
@dbus.service.method( dbus_interface=PROVIDER_INTERFACE,
114
in_signature='a{ss}', out_signature='a{sa{ss}}', sender_keyword='sender', connection_keyword='conn' )
115
def GetResumableSessions(self, options, sender=None, conn=None):
118
dbus-send --system --dest=org.tacix \
119
--type=method_call --print-reply --reply-timeout=2000 \
120
/org/tacix/nx/provider \
121
org.tacix.nx.provider.GetResumableSessions
123
self._check_polkit_privilege(sender, conn, 'org.tacix.sessionmanager.resume')
124
return self.__get_resumable_sessions(options['user'], options)
126
@dbus.service.method( dbus_interface=PROVIDER_INTERFACE,
127
in_signature='', out_signature='a{sa{ss}}', sender_keyword='sender', connection_keyword='conn' )
128
def GetShadowableSessions(self, sender=None, conn=None):
131
dbus-send --system --dest=org.tacix \
132
--type=method_call --print-reply --reply-timeout=2000 \
133
/org/tacix/nx/provider \
134
org.tacix.nx.provider.GetShadowableSessions
137
self._check_polkit_privilege(sender, conn, 'org.tacix.sessionmanager.resume')
139
ck_sessions = self.ck_manager.GetSessions()
140
for ck_op_session in ck_sessions:
141
ck_session_obj = self.bus.get_object ('org.freedesktop.ConsoleKit', ck_op_session)
142
ck_session = dbus.Interface (ck_session_obj, 'org.freedesktop.ConsoleKit.Session')
143
display = ck_session.GetX11Display().replace(':', '')
144
if display != '' and int(display) < 100:
145
session_opts = {'display': display,
148
'cli_opts': '--------',
151
'available': 'Running',
153
'session': 'X%s (Local)' % display}
154
sessions[session_opts['display']] = session_opts
156
for session_key in self.manager_sessions.keys():
157
session = self.manager_sessions[session_key]
158
props = session.get_properties()
159
props['available'] = 'Yes'
160
props['session'] = props['uniqueid']
161
sessions[session.get_property('display')] = props
164
@dbus.service.method( dbus_interface=PROVIDER_INTERFACE,
165
in_signature='s', out_signature='', sender_keyword='sender', connection_keyword='conn' )
166
def CreateShadowAuthority(self, ck_session_id, sender, conn):
169
dbus-send --system --dest=org.tacix \
170
--type=method_call --print-reply --reply-timeout=2000 \
172
org.tacix.Manager.AskShadowPermission
174
logger.debug('Asking for shadow permission')
175
session = self.tacix_manager._get_session_for_ck_id (ck_session_id)
176
#dialog = ShadowDialog (setup_func, callback, self.logger)
178
authority_file = session.AddUserAuthorization('nx')
180
shadow_session = self.tacix_manager._get_session_for_session_worker(sender)
181
shadow_session.nxoptions.set_property('shadowdisplay', session.nxoptions.get_property('display'))
182
shadow_session.nxoptions.set_property('shadow_authority_file', authority_file)
184
#session_worker = dbus.Interface (self.bus.get_object (sender, '/Session'), 'org.tacix.session.worker')
185
#session_worker.SetShadowAuthority(authority_file)
187
def _dialog_result (self, error_code):
188
if shadowed_id is not None:
189
session = self.tacix_manager.get_session(shadowed_id)
191
logger.debug('Shadowed session not found')
193
cookie = session.ask_cookie()
196
authority_file = self.nxoptions.get_property('authority_file')
197
return xauth.add_cookie_to_xauthority(authority_file, ":" + self.nxoptions.get_property('shadowdisplay'), cookie)
199
logger.debug('Shadowing a local session')
200
return self.ask_console_authority(sender)
202
@dbus.service.method( dbus_interface=PROVIDER_INTERFACE,
203
in_signature='', out_signature='b', sender_keyword='sender', connection_keyword='conn' )
204
def CreateShadow(self, user, sender, conn):
207
dbus-send --system --dest=org.tacix \
208
--type=method_call --print-reply --reply-timeout=2000 \
210
org.tacix.Manager.CreateShadow
212
file = xauth.create_xauthority_file_for_user(user, self.nxoptions.get_property('cookie'), self.nxoptions.get_property('display'))
214
raise TaciXSessionException('Could not create the authority file')