summaryrefslogtreecommitdiffstats
path: root/src/Client
diff options
context:
space:
mode:
Diffstat (limited to 'src/Client')
-rw-r--r--src/Client/CommandManager.cpp14
-rw-r--r--src/Client/CommandManager.h1
-rw-r--r--src/Client/CommandParser.cpp28
-rw-r--r--src/Client/CommandParser.h1
-rw-r--r--src/Client/Makefile.in11
-rw-r--r--src/Client/Requests/Makefile.in11
6 files changed, 58 insertions, 8 deletions
diff --git a/src/Client/CommandManager.cpp b/src/Client/CommandManager.cpp
index 3bfc3a6..ad88152 100644
--- a/src/Client/CommandManager.cpp
+++ b/src/Client/CommandManager.cpp
@@ -211,6 +211,20 @@ void CommandManager::statusRequestFinished(const Common::Request &request) {
requestFinished();
}
+void CommandManager::userInfoRequestFinished(const Common::Request &request) {
+ try {
+ const Common::XmlPacket &packet = request.getResult();
+
+ std::cout << " " << (unsigned long)packet["uid"] << ", " << (unsigned long)packet["gid"] << ", " << (const std::string&)packet["username"] << ", "
+ << (const std::string&)packet["fullName"] << std::endl << std::endl;
+ }
+ catch(Common::Exception &exception) {
+ Common::Logger::logf(Common::Logger::ERROR, "An error occurred during your request: %s.", exception.strerror().c_str());
+ }
+
+ requestFinished();
+}
+
void CommandManager::userListRequestFinished(const Common::Request &request) {
try {
const Common::XmlPacket &packet = request.getResult();
diff --git a/src/Client/CommandManager.h b/src/Client/CommandManager.h
index 1c6e5fc..f1689b1 100644
--- a/src/Client/CommandManager.h
+++ b/src/Client/CommandManager.h
@@ -58,6 +58,7 @@ class CommandManager {
void disconnectRequestFinished(const Common::Request &request);
void fsInfoRequestFinished(const Common::Request &request);
void statusRequestFinished(const Common::Request &request);
+ void userInfoRequestFinished(const Common::Request &request);
void userListRequestFinished(const Common::Request &request);
CommandManager() : activeRequests(0), disconnect(false) {}
diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp
index 7e3a90e..8e55c01 100644
--- a/src/Client/CommandParser.cpp
+++ b/src/Client/CommandParser.cpp
@@ -28,6 +28,7 @@
#include <Common/Requests/FSInfoRequest.h>
#include <Common/Requests/DisconnectRequest.h>
#include <Common/Requests/StatusRequest.h>
+#include <Common/Requests/UserInfoRequest.h>
#include <Common/Requests/UserListRequest.h>
#include <Common/Tokenizer.h>
@@ -45,6 +46,7 @@ const CommandParser::Command CommandParser::commands[] = {
{{"reboot", 0}, "reboot *|host...", "Reboot host", "Reboot hosts. * will reboot all hosts.", &CommandParser::rebootCommand},
{{"shutdown", "halt", 0}, "shutdown *|host...", "Shut hosts down", "Shut hosts down. * will shut down all hosts.", &CommandParser::shutdownCommand},
{{"status", "st", 0}, "status [host]", "Display status information", "Display host status information. If no host is given, display server status information.", &CommandParser::statusCommand},
+ {{"user_info", "user", 0}, "user_info uid", "Search for a user id", "Search for a user id.", &CommandParser::userInfoCommand},
{{"list_users", "users", 0}, "list_users", "Show the user account database", "Show the user account database.", &CommandParser::listUsersCommand},
{{"exit", "quit", 0}, "exit", "Close the connection and quit the client", "Closes the connection and quits the client.", &CommandParser::exitCommand},
{{0}, 0, 0, 0, 0}
@@ -255,6 +257,32 @@ void CommandParser::statusCommand(const std::vector<std::string> &args) {
++CommandManager::get()->activeRequests;
}
+void CommandParser::userInfoCommand(const std::vector<std::string> &args) {
+ if(args.size() == 1) {
+ Common::Logger::logf(Common::Logger::ERROR, "%s: No user id given.", args[0].c_str());
+ printUsage("user_info");
+ return;
+ }
+ if(args.size() > 2) {
+ Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
+ printUsage("user_info");
+ return;
+ }
+
+ char *endptr;
+ unsigned long uid = std::strtoul(args[1].c_str(), &endptr, 10);
+ if(args[1].empty() || *endptr != '\0') {
+ Common::Logger::logf(Common::Logger::ERROR, "%s: Unable to parse user id.", args[0].c_str());
+ printUsage("user_info");
+ return;
+ }
+
+ ++CommandManager::get()->activeRequests;
+
+ Common::RequestManager::get()->sendRequest<Common::Requests::UserInfoRequest>(connection,
+ sigc::mem_fun(CommandManager::get(), &CommandManager::userInfoRequestFinished), uid);
+}
+
void CommandParser::listUsersCommand(const std::vector<std::string>&) {
++CommandManager::get()->activeRequests;
diff --git a/src/Client/CommandParser.h b/src/Client/CommandParser.h
index 23330ca..4b44656 100644
--- a/src/Client/CommandParser.h
+++ b/src/Client/CommandParser.h
@@ -63,6 +63,7 @@ class CommandParser {
void rebootCommand(const std::vector<std::string> &args);
void shutdownCommand(const std::vector<std::string> &args);
void statusCommand(const std::vector<std::string> &args);
+ void userInfoCommand(const std::vector<std::string> &args);
void listUsersCommand(const std::vector<std::string> &args);
void exitCommand(const std::vector<std::string>&);
diff --git a/src/Client/Makefile.in b/src/Client/Makefile.in
index 7398cc2..076a181 100644
--- a/src/Client/Makefile.in
+++ b/src/Client/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -219,6 +219,8 @@ ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
+pcrecpp_CFLAGS = @pcrecpp_CFLAGS@
+pcrecpp_LIBS = @pcrecpp_LIBS@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
@@ -231,6 +233,7 @@ srcdir = @srcdir@
sys_symbol_underscore = @sys_symbol_underscore@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = Requests
@@ -246,8 +249,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
- && exit 0; \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
@@ -395,7 +398,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
- $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
diff --git a/src/Client/Requests/Makefile.in b/src/Client/Requests/Makefile.in
index 0e70532..ca43c66 100644
--- a/src/Client/Requests/Makefile.in
+++ b/src/Client/Requests/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -209,6 +209,8 @@ ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
+pcrecpp_CFLAGS = @pcrecpp_CFLAGS@
+pcrecpp_LIBS = @pcrecpp_LIBS@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
@@ -221,6 +223,7 @@ srcdir = @srcdir@
sys_symbol_underscore = @sys_symbol_underscore@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LTLIBRARIES = librequests.la
@@ -234,8 +237,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
- && exit 0; \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
@@ -313,7 +316,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
- $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS