[X2Go-Commits] [x2gobroker] 01/01: more work/testing on x2gobroker-testagent
git-admin at x2go.org
git-admin at x2go.org
Wed Mar 19 00:18:28 CET 2014
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository x2gobroker.
commit b972d9696f97aeab4b392938548a48202d4b8aa4
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date: Wed Mar 19 00:18:32 2014 +0100
more work/testing on x2gobroker-testagent
---
lib/x2gobroker-agent.pl | 15 +++++++--------
sbin/x2gobroker-testagent | 34 +++++++++++++++++++++++-----------
x2gobroker/utils.py | 1 +
3 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/lib/x2gobroker-agent.pl b/lib/x2gobroker-agent.pl
index 7c04a42..ee359bf 100755
--- a/lib/x2gobroker-agent.pl
+++ b/lib/x2gobroker-agent.pl
@@ -117,23 +117,22 @@ if($mode eq 'ping')
exit;
}
-my ($uid, $passwd, $uidNumber, $gidNumber, $quota, $comment, $gcos, $home, $shell, $expire) = getpwnam($username);
-
-if($uidNumber < 1000)
-{
- die 'operation on system user';
-}
-
if($mode eq 'availabletasks')
{
- InitX2GoUser($uid, $uidNumber, $gidNumber, $home);
print "OK\n";
my $available_task;
foreach $available_task (@available_tasks) {
print "$available_task\n";
}
+ exit;
}
+my ($uid, $passwd, $uidNumber, $gidNumber, $quota, $comment, $gcos, $home, $shell, $expire) = getpwnam($username);
+
+if($uidNumber < 1000)
+{
+ die "operation on system user $uidNumber";
+}
if($mode eq 'listsessions')
{
diff --git a/sbin/x2gobroker-testagent b/sbin/x2gobroker-testagent
index 29ca0ed..eef96a8 100755
--- a/sbin/x2gobroker-testagent
+++ b/sbin/x2gobroker-testagent
@@ -50,11 +50,11 @@ setproctitle.setproctitle("%s %s" % (PROG_NAME, " ".join(PROG_OPTIONS)))
if __name__ == "__main__":
agent_options = [
- {'args':['-H','--host'], 'default': 'LOCAL', 'metavar': 'HOSTNAME', 'help': 'Test X2Go Session Broker Agent on this host (default: LOCAL)', },
- {'args':['-p','--port'], 'default': 22, 'metavar': 'PORT', 'help': 'For remote agent calls (via SSH) use this port as SSH port (default: 22)', },
+ {'args':['--list-tasks'], 'default': False, 'action': 'store_true', 'help': 'List available broker agent tasks', },
{'args':['-u','--username', '--user'], 'default': None, 'metavar': 'USERNAME', 'help': 'When testing the broker agent, test on behalf of this user (default: none)', },
{'args':['-t','--task'], 'default': 'PING_ICMP', 'metavar': 'AGENT_TASK', 'help': 'Perform this task on the (remote) broker agent', },
- {'args':['--list-tasks'], 'default': False, 'action': 'store_true', 'help': 'List available broker agent tasks', },
+ {'args':['-H','--host'], 'default': 'LOCAL', 'metavar': 'HOSTNAME', 'help': 'Test X2Go Session Broker Agent on this (remote) host (default: LOCAL)', },
+ {'args':['-p','--port'], 'default': 22, 'metavar': 'PORT', 'help': 'For remote agent calls (via SSH) use this port as SSH port (default: 22)', },
]
misc_options = [
{'args':['-C','--config-file'], 'default': None, 'metavar': 'CONFIG_FILE', 'help': 'Specify a special configuration file name, default is: {default}'.format(default=x2gobroker.defaults.X2GOBROKER_CONFIG), },
@@ -74,6 +74,13 @@ if __name__ == "__main__":
cmdline_args = p.parse_args()
+ if os.getuid() != 0:
+ p.print_help()
+ print
+ print "*** The {progname} tool needs to be run with super-user privileges... ***".format(progname=PROG_NAME)
+ print
+ sys.exit(-1)
+
if cmdline_args.username is None and not cmdline_args.list_tasks:
p.print_help()
print
@@ -104,19 +111,24 @@ query_mode = local_agent and 'LOCAL' or 'SSH'
if local_agent: remote_agent = None
else: remote_agent = {'hostname': hostname, 'port': port, }
-agent_client_tasks = x2gobroker.agent.tasks
-if 'availabletasks' in agent_client_tasks:
- try:
- remote_agent_tasks = x2gobroker.agent.tasks_available(username=username, query_mode=query_mode, remote_agent=remote_agent)
- except x2gobroker.x2gobroker_exceptions.X2GoBrokerAgentException, e:
- print e
- sys.exit(0)
-
def call_agent(task):
return agent_client_tasks[task](username=username, query_mode=query_mode, remote_agent=remote_agent)
if __name__ == "__main__":
+ print
+ print "X2Go Session Broker (Agent Test Utility)"
+ print "----------------------------------------"
+
+ agent_client_tasks = x2gobroker.agent.tasks
+ if 'availabletasks' in agent_client_tasks:
+ try:
+ remote_agent_tasks = x2gobroker.agent.tasks_available(username=username, query_mode=query_mode, remote_agent=remote_agent)
+ except x2gobroker.x2gobroker_exceptions.X2GoBrokerAgentException, e:
+ print e
+ print
+ sys.exit(0)
+
# drop root privileges and run as X2GOBROKER_DAEMON_USER
drop_privileges(uid=x2gobroker.defaults.X2GOBROKER_DAEMON_USER, gid=x2gobroker.defaults.X2GOBROKER_DAEMON_GROUP)
diff --git a/x2gobroker/utils.py b/x2gobroker/utils.py
index 776f380..0d8af2c 100644
--- a/x2gobroker/utils.py
+++ b/x2gobroker/utils.py
@@ -25,6 +25,7 @@ import types
import locale
import netaddr
import distutils.version
+import pwd, grp
def _checkConfigFileDefaults(data_structure):
"""\
--
Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git
More information about the x2go-commits
mailing list