From: Jaemin Ryu Date: Wed, 2 Jan 2019 02:09:59 +0000 (+0900) Subject: Replace namespace name to klay X-Git-Tag: submit/tizen/20190219.012108~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=78e2f69d01dcb85a8d592fb6609174da8285183b;p=platform%2Fcore%2Fsecurity%2Fklay.git Replace namespace name to klay Change-Id: I3db4e497a20b729883c01bc0272f420473c199da Signed-off-by: Jaemin Ryu --- diff --git a/include/klay/audit/audit-trail.h b/include/klay/audit/audit-trail.h index 850699f..22020ca 100644 --- a/include/klay/audit/audit-trail.h +++ b/include/klay/audit/audit-trail.h @@ -34,11 +34,11 @@ public: void start(); void stop(); - void subscribe(const int fd, const runtime::Mainloop::Event events, runtime::Mainloop::Callback&& callback); + void subscribe(const int fd, const klay::Mainloop::Event events, klay::Mainloop::Callback&& callback); void unsubscribe(const int fd); private: - runtime::Mainloop mainloop; + klay::Mainloop mainloop; std::thread dispatcher; }; diff --git a/include/klay/mainloop.h b/include/klay/mainloop.h index 2557828..7550c56 100644 --- a/include/klay/mainloop.h +++ b/include/klay/mainloop.h @@ -53,7 +53,7 @@ private: Mutex mutex; int pollFd; std::atomic stopped; - runtime::EventFD wakeupSignal; + klay::EventFD wakeupSignal; void prepare(); }; diff --git a/include/klay/rmi/client.h b/include/klay/rmi/client.h index 96e7716..8401144 100644 --- a/include/klay/rmi/client.h +++ b/include/klay/rmi/client.h @@ -57,7 +57,7 @@ public: private: std::string address; std::shared_ptr connection; - runtime::Mainloop mainloop; + klay::Mainloop mainloop; std::thread dispatcher; }; @@ -72,7 +72,7 @@ RemoteAccessClient::~RemoteAccessClient() { try { disconnect(); - } catch (runtime::Exception& e) {} + } catch (klay::Exception& e) {} } template @@ -98,7 +98,7 @@ int RemoteAccessClient::subscribe(const std::string& provider, c request.packParameters(name); connection->send(request); - runtime::FileDescriptor response; + klay::FileDescriptor response; Message reply = connection->dispatch(); if (reply.isError()) { std::string klass; @@ -134,7 +134,7 @@ int RemoteAccessClient::subscribe(const std::string& provider, c std::shared_ptr transport = std::make_shared(id); - auto callback = [handler, transport, this](int fd, runtime::Mainloop::Event event) { + auto callback = [handler, transport, this](int fd, klay::Mainloop::Event event) { if ((event & EPOLLHUP) || (event & EPOLLRDHUP)) { mainloop.removeEventSource(fd); return; diff --git a/include/klay/rmi/message.h b/include/klay/rmi/message.h index f0e606f..52d1569 100644 --- a/include/klay/rmi/message.h +++ b/include/klay/rmi/message.h @@ -149,7 +149,7 @@ private: MessageSignature signature; MessageComposer buffer; - std::deque fileDescriptors; + std::deque fileDescriptors; static std::atomic sequence; }; @@ -183,16 +183,16 @@ void Message::unpackParameters(F& first, R&... rest) template void Message::enclose(DataType&& data) { - runtime::Serializer serializer(buffer); - runtime::SerializableArgument arg(std::forward(data)); + klay::Serializer serializer(buffer); + klay::SerializableArgument arg(std::forward(data)); arg.accept(serializer); } template void Message::disclose(DataType& data) { - runtime::Deserializer deserializer(buffer); - runtime::DeserializableArgument arg(data); + klay::Deserializer deserializer(buffer); + klay::DeserializableArgument arg(data); arg.accept(deserializer); } @@ -210,7 +210,7 @@ void Message::encode(const T& device) const device.write(buffer.begin(), header.length); int i = 0, fds[fileDescriptors.size()]; - for (const runtime::FileDescriptor& fd : fileDescriptors) { + for (const klay::FileDescriptor& fd : fileDescriptors) { fds[i++] = fd.fileDescriptor; } @@ -229,14 +229,14 @@ void Message::decode(const T& device) device.receiveFileDescriptors(fds, header.ancillary); for (unsigned int i = 0; i < header.ancillary; i++) { - fileDescriptors.emplace_back(runtime::FileDescriptor(fds[i])); + fileDescriptors.emplace_back(klay::FileDescriptor(fds[i])); } disclose(signature); } -template<> void Message::enclose(runtime::FileDescriptor&& fd); -template<> void Message::disclose(runtime::FileDescriptor& fd); +template<> void Message::enclose(klay::FileDescriptor&& fd); +template<> void Message::disclose(klay::FileDescriptor& fd); } // namespae rmi } // namespae klay diff --git a/include/klay/rmi/notification.h b/include/klay/rmi/notification.h index b2bec9a..ad46788 100644 --- a/include/klay/rmi/notification.h +++ b/include/klay/rmi/notification.h @@ -65,7 +65,7 @@ void Notification::notify(Args&&... args) for (const std::shared_ptr& subscriber : subscribers) { try { msg.encode(*subscriber); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { ERROR(KSINK, e.what()); } } diff --git a/include/klay/rmi/service.h b/include/klay/rmi/service.h index 5fe2748..dc55c95 100644 --- a/include/klay/rmi/service.h +++ b/include/klay/rmi/service.h @@ -189,7 +189,7 @@ public: return processingContext.credentials.gid; } - runtime::Mainloop mainloop; + klay::Mainloop mainloop; private: struct ProcessingContext { @@ -237,7 +237,7 @@ private: std::string address; - runtime::ThreadPool workqueue; + klay::ThreadPool workqueue; std::mutex stateLock; std::mutex notificationLock; std::mutex methodRegistryLock; @@ -261,7 +261,7 @@ void Service::setMethodHandler(const std::string& privilege, const std::string& std::lock_guard lock(methodRegistryLock); if (methodRegistry.count(method)) { - throw runtime::Exception("Method handler already registered"); + throw klay::Exception("Method handler already registered"); } methodRegistry[method] = std::make_shared(privilege, dispatchMethod); diff --git a/include/klay/rmi/socket.h b/include/klay/rmi/socket.h index 21208e8..e881206 100644 --- a/include/klay/rmi/socket.h +++ b/include/klay/rmi/socket.h @@ -23,9 +23,9 @@ namespace klay { namespace rmi { -class KLAY_EXPORT SocketException: public runtime::Exception { +class KLAY_EXPORT SocketException: public klay::Exception { public: - SocketException(const std::string& msg) : runtime::Exception(msg) {} + SocketException(const std::string& msg) : klay::Exception(msg) {} }; struct KLAY_EXPORT Credentials { diff --git a/src/audit/audit-trail.cpp b/src/audit/audit-trail.cpp index 0de4ac2..1b6a606 100644 --- a/src/audit/audit-trail.cpp +++ b/src/audit/audit-trail.cpp @@ -39,7 +39,7 @@ void AuditTrail::stop() } } -void AuditTrail::subscribe(const int fd, const runtime::Mainloop::Event events, runtime::Mainloop::Callback&& callback) +void AuditTrail::subscribe(const int fd, const klay::Mainloop::Event events, klay::Mainloop::Callback&& callback) { mainloop.addEventSource(fd, events, std::move(callback)); } diff --git a/src/auth/group.cpp b/src/auth/group.cpp index b61aaf2..e65cf3b 100644 --- a/src/auth/group.cpp +++ b/src/auth/group.cpp @@ -48,9 +48,9 @@ Group::Group(const std::string& group) ret = ::getgrnam_r(group.c_str(), &grp, buf.get(), bufsize, &result); if (result == NULL) { if (ret == 0) - throw runtime::Exception("Group doesn't exist"); + throw klay::Exception("Group doesn't exist"); else - throw runtime::Exception(runtime::GetSystemErrorMessage(ret)); + throw klay::Exception(klay::GetSystemErrorMessage(ret)); } name = result->gr_name; @@ -71,9 +71,9 @@ Group::Group(const gid_t group) ret = ::getgrgid_r(group, &grp, buf.get(), bufsize, &result); if (result == NULL) { if (ret == 0) - throw runtime::Exception("Group doesn't exist"); + throw klay::Exception("Group doesn't exist"); else - throw runtime::Exception(runtime::GetSystemErrorMessage(ret)); + throw klay::Exception(klay::GetSystemErrorMessage(ret)); } name = result->gr_name; diff --git a/src/auth/user.cpp b/src/auth/user.cpp index 3e825f4..8677759 100644 --- a/src/auth/user.cpp +++ b/src/auth/user.cpp @@ -48,9 +48,9 @@ User::User(const std::string& user) ret = ::getpwnam_r(user.c_str(), &pwd, buf.get(), bufsize, &result); if (result == NULL) { if (ret == 0) - throw runtime::Exception("User " + user + " doesn't exist"); + throw klay::Exception("User " + user + " doesn't exist"); else - throw runtime::Exception(runtime::GetSystemErrorMessage(ret)); + throw klay::Exception(klay::GetSystemErrorMessage(ret)); } name = result->pw_name; @@ -71,9 +71,9 @@ User::User(const uid_t user) ret = ::getpwuid_r(user, &pwd, buf.get(), bufsize, &result); if (result == NULL) { if (ret == 0) - throw runtime::Exception("User " + std::to_string(user) + "doesn't exist"); + throw klay::Exception("User " + std::to_string(user) + "doesn't exist"); else - throw runtime::Exception(runtime::GetSystemErrorMessage(ret)); + throw klay::Exception(klay::GetSystemErrorMessage(ret)); } name = result->pw_name; diff --git a/src/cgroup.cpp b/src/cgroup.cpp index d643e69..ef04aa3 100644 --- a/src/cgroup.cpp +++ b/src/cgroup.cpp @@ -39,15 +39,15 @@ bool Cgroup::existSubsystem(const std::string& name) return false; } } catch (std::runtime_error &e) { - throw runtime::Exception("Unexpected regex error"); + throw klay::Exception("Unexpected regex error"); } - runtime::File dir("/sys/fs/cgroup/" + name); + klay::File dir("/sys/fs/cgroup/" + name); if (dir.exists()) { if (dir.isDirectory()) { return true; } - throw runtime::Exception("Invalid subsystem name"); + throw klay::Exception("Invalid subsystem name"); } return false; @@ -57,21 +57,21 @@ void Cgroup::createSubsystem(const std::string& name) { try { if (!std::regex_match(name, std::regex(NAME_PATTERN))) { - throw runtime::Exception("Invalid subsystem name"); + throw klay::Exception("Invalid subsystem name"); } } catch (std::runtime_error &e) { - throw runtime::Exception("Unexpected regex error"); + throw klay::Exception("Unexpected regex error"); } if (existSubsystem(name)) { return; } - runtime::File subsystem("/sys/fs/cgroup/" + name); + klay::File subsystem("/sys/fs/cgroup/" + name); if (::mount(NULL, "/sys/fs/cgroup/", NULL, MS_REMOUNT | MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_STRICTATIME, "mode=755")) { - throw runtime::Exception("Failed to remount cgroupfs as the writable"); + throw klay::Exception("Failed to remount cgroupfs as the writable"); } if (!subsystem.exists()) { @@ -82,29 +82,29 @@ void Cgroup::createSubsystem(const std::string& name) "cgroup", MS_NODEV | MS_NOSUID | MS_NOEXEC, ("none,name=" + name).c_str())) { subsystem.remove(false); - throw runtime::Exception("Failed to mount cgroup subsystem"); + throw klay::Exception("Failed to mount cgroup subsystem"); } if (::mount(NULL, "/sys/fs/cgroup/", NULL, MS_REMOUNT | MS_RDONLY | MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_STRICTATIME, "mode=755")) { - throw runtime::Exception("Failed to remount cgroupfs as the read-only"); + throw klay::Exception("Failed to remount cgroupfs as the read-only"); } } void Cgroup::destroySubsystem(const std::string& name) { if (!existSubsystem(name)) { - throw runtime::Exception("No such subsystem"); + throw klay::Exception("No such subsystem"); } if (::mount(NULL, "/sys/fs/cgroup/", NULL, MS_REMOUNT | MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_STRICTATIME, "mode=755")) { - throw runtime::Exception("Failed to remount cgroupfs as the writable"); + throw klay::Exception("Failed to remount cgroupfs as the writable"); } - runtime::File subsystem("/sys/fs/cgroup/" + name); + klay::File subsystem("/sys/fs/cgroup/" + name); ::umount2(subsystem.getPath().c_str(), MNT_EXPIRE); subsystem.remove(false); @@ -112,7 +112,7 @@ void Cgroup::destroySubsystem(const std::string& name) if (::mount(NULL, "/sys/fs/cgroup/", NULL, MS_REMOUNT | MS_RDONLY | MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_STRICTATIME, "mode=755")) { - throw runtime::Exception("Failed to remount cgroupfs as the read-only"); + throw klay::Exception("Failed to remount cgroupfs as the read-only"); } } @@ -123,15 +123,15 @@ bool Cgroup::exist(const std::string& subsystem, const std::string& path) return false; } } catch (std::runtime_error &e) { - throw runtime::Exception("Unexpected regex error"); + throw klay::Exception("Unexpected regex error"); } - runtime::File dir("/sys/fs/cgroup/" + subsystem + "/" + path); + klay::File dir("/sys/fs/cgroup/" + subsystem + "/" + path); if (dir.exists()) { if (dir.isDirectory()) { return true; } - throw runtime::Exception("Invalid path"); + throw klay::Exception("Invalid path"); } return false; @@ -141,34 +141,34 @@ void Cgroup::create(const std::string& subsystem, const std::string& path) { try { if (!std::regex_match(path, std::regex(PATH_PATTERN))) { - throw runtime::Exception("Invalid path"); + throw klay::Exception("Invalid path"); } } catch (std::runtime_error &e) { - throw runtime::Exception("Unexpected regex error"); + throw klay::Exception("Unexpected regex error"); } if (exist(subsystem, path)) { return; } - runtime::File dir("/sys/fs/cgroup/" + subsystem + "/" + path); + klay::File dir("/sys/fs/cgroup/" + subsystem + "/" + path); dir.makeDirectory(true); } void Cgroup::destroy(const std::string& subsystem, const std::string& path) { if (!exist(subsystem, path)) { - throw runtime::Exception("No such path in subsystem"); + throw klay::Exception("No such path in subsystem"); } - runtime::File dir("/sys/fs/cgroup/" + subsystem + "/" + path); + klay::File dir("/sys/fs/cgroup/" + subsystem + "/" + path); dir.remove(false); } void Cgroup::addProcess(const std::string& subsystem, const std::string& path, const pid_t pid) { if (!exist(subsystem, path)) { - throw runtime::Exception("No such path in subsystem"); + throw klay::Exception("No such path in subsystem"); } std::ofstream ofs("/sys/fs/cgroup/" + subsystem + "/" + path + diff --git a/src/db/connection.cpp b/src/db/connection.cpp index e39255f..d1af8ab 100644 --- a/src/db/connection.cpp +++ b/src/db/connection.cpp @@ -25,7 +25,7 @@ Connection::Connection(const std::string& name, const int flags, bool integrityC handle(nullptr), filename(name) { if (::sqlite3_open_v2(filename.c_str(), &handle, flags, NULL)) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } if (integrityCheck) { @@ -45,7 +45,7 @@ Connection::Connection(const std::string& name, const int flags, bool integrityC if (!verified) { ::sqlite3_close(handle); - throw runtime::Exception("Malformed database"); + throw klay::Exception("Malformed database"); } } } @@ -58,7 +58,7 @@ Connection::~Connection() int Connection::exec(const std::string& query) { if (::sqlite3_exec(handle, query.c_str(), NULL, NULL, NULL) != SQLITE_OK) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } return ::sqlite3_changes(handle); diff --git a/src/db/statement.cpp b/src/db/statement.cpp index 9e03809..a04efe0 100644 --- a/src/db/statement.cpp +++ b/src/db/statement.cpp @@ -35,7 +35,7 @@ Statement::Statement(const Connection& db, const std::string& query) : query.size(), &statement, NULL)) { - throw runtime::Exception(db.getErrorMessage()); + throw klay::Exception(db.getErrorMessage()); } columnCount = sqlite3_column_count(statement); @@ -49,14 +49,14 @@ Statement::~Statement() void Statement::reset() { if (::sqlite3_reset(statement) != SQLITE_OK) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } } void Statement::clearBindings() { if (::sqlite3_clear_bindings(statement) != SQLITE_OK) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } } @@ -91,7 +91,7 @@ int Statement::exec() Column Statement::getColumn(const int index) { if (!validRow || (index >= columnCount)) { - throw runtime::Exception(getErrorMessage(SQLITE_RANGE)); + throw klay::Exception(getErrorMessage(SQLITE_RANGE)); } return Column(*this, index); @@ -100,7 +100,7 @@ Column Statement::getColumn(const int index) bool Statement::isNullColumn(const int index) const { if (!validRow || (index >= columnCount)) { - throw runtime::Exception(getErrorMessage(SQLITE_RANGE)); + throw klay::Exception(getErrorMessage(SQLITE_RANGE)); } return (SQLITE_NULL == sqlite3_column_type(statement, index)); @@ -109,7 +109,7 @@ bool Statement::isNullColumn(const int index) const std::string Statement::getColumnName(const int index) const { if (index >= columnCount) { - throw runtime::Exception(getErrorMessage(SQLITE_RANGE)); + throw klay::Exception(getErrorMessage(SQLITE_RANGE)); } return sqlite3_column_name(statement, index); @@ -119,28 +119,28 @@ std::string Statement::getColumnName(const int index) const void Statement::bind(const int index, const int& value) { if (SQLITE_OK != ::sqlite3_bind_int(statement, index, value)) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } } void Statement::bind(const int index, const sqlite3_int64& value) { if (SQLITE_OK != ::sqlite3_bind_int64(statement, index, value)) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } } void Statement::bind(const int index, const double& value) { if (SQLITE_OK != ::sqlite3_bind_double(statement, index, value)) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } } void Statement::bind(const int index, const char* value) { if (SQLITE_OK != ::sqlite3_bind_text(statement, index, value, -1, SQLITE_TRANSIENT)) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } } @@ -148,21 +148,21 @@ void Statement::bind(const int index, const std::string& value) { if (SQLITE_OK != ::sqlite3_bind_text(statement, index, value.c_str(), static_cast(value.size()), SQLITE_TRANSIENT)) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } } void Statement::bind(const int index, const void* value, const int size) { if (SQLITE_OK != ::sqlite3_bind_blob(statement, index, value, size, SQLITE_TRANSIENT)) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } } void Statement::bind(const int index) { if (SQLITE_OK != ::sqlite3_bind_null(statement, index)) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } } @@ -170,7 +170,7 @@ void Statement::bind(const std::string& name, const int& value) { int index = sqlite3_bind_parameter_index(statement, name.c_str()); if (SQLITE_OK != sqlite3_bind_int(statement, index, value)) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } } @@ -178,7 +178,7 @@ void Statement::bind(const std::string& name, const sqlite3_int64& value) { int index = sqlite3_bind_parameter_index(statement, name.c_str()); if (SQLITE_OK != ::sqlite3_bind_int64(statement, index, value)) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } } @@ -186,7 +186,7 @@ void Statement::bind(const std::string& name, const double& value) { int index = sqlite3_bind_parameter_index(statement, name.c_str()); if (SQLITE_OK != ::sqlite3_bind_double(statement, index, value)) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } } @@ -195,7 +195,7 @@ void Statement::bind(const std::string& name, const std::string& value) int index = sqlite3_bind_parameter_index(statement, name.c_str()); if (SQLITE_OK != ::sqlite3_bind_text(statement, index, value.c_str(), static_cast(value.size()), SQLITE_TRANSIENT)) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } } @@ -203,7 +203,7 @@ void Statement::bind(const std::string& name, const char* value) { int index = sqlite3_bind_parameter_index(statement, name.c_str()); if (SQLITE_OK != ::sqlite3_bind_text(statement, index, value, -1, SQLITE_TRANSIENT)) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } } @@ -211,7 +211,7 @@ void Statement::bind(const std::string& name, const void* value, const int size) { int index = sqlite3_bind_parameter_index(statement, name.c_str()); if (SQLITE_OK != ::sqlite3_bind_blob(statement, index, value, size, SQLITE_TRANSIENT)) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } } @@ -219,7 +219,7 @@ void Statement::bind(const std::string& name) { int index = sqlite3_bind_parameter_index(statement, name.c_str()); if (SQLITE_OK != ::sqlite3_bind_null(statement, index)) { - throw runtime::Exception(getErrorMessage()); + throw klay::Exception(getErrorMessage()); } } diff --git a/src/dbus/connection.cpp b/src/dbus/connection.cpp index 9724830..9a4dc5b 100644 --- a/src/dbus/connection.cpp +++ b/src/dbus/connection.cpp @@ -50,7 +50,7 @@ Connection::Connection(const std::string& address) : connection = g_dbus_connection_new_for_address_sync(address.c_str(), flags, NULL, NULL, &error); if (error) { ERROR(KSINK, error->message); - throw runtime::Exception(error->message); + throw klay::Exception(error->message); } } @@ -130,7 +130,7 @@ Variant Connection::methodcall(const std::string& busName, if (error) { ERROR(KSINK, error->message); - throw runtime::Exception(error->message); + throw klay::Exception(error->message); } return result; @@ -159,7 +159,7 @@ void Connection::emitSignal(const std::string& busName, &error); if (error) { ERROR(KSINK, error->message); - throw runtime::Exception(error->message); + throw klay::Exception(error->message); } } @@ -192,7 +192,7 @@ Connection::ObjectId Connection::registerObject(const std::string& object, } if (error) { - throw runtime::Exception(error->message); + throw klay::Exception(error->message); } GDBusInterfaceInfo* inf = node->interfaces[0]; @@ -211,7 +211,7 @@ Connection::ObjectId Connection::registerObject(const std::string& object, g_dbus_node_info_unref(node); if (error) { ERROR(KSINK, error->message); - throw runtime::Exception(error->message); + throw klay::Exception(error->message); } return id; @@ -300,7 +300,7 @@ void Connection::onMethodCall(GDBusConnection* connection, try { Variant variant = callbackSet.methodcall(objectPath, interface, method, Variant(parameters)); g_dbus_method_invocation_return_value(invocation, &variant); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { ERROR(KSINK, "Error on metod handling"); g_dbus_method_invocation_return_dbus_error(invocation, (interface + std::string(".Error")).c_str(), e.what()); } diff --git a/src/dbus/introspection.cpp b/src/dbus/introspection.cpp index 22f752e..36048a8 100644 --- a/src/dbus/introspection.cpp +++ b/src/dbus/introspection.cpp @@ -52,12 +52,12 @@ Introspection::~Introspection(void) BusNode Introspection::getBusNode(const std::string &xmlData) { if (xmlData.empty()) - throw runtime::Exception("Invalid argument."); + throw klay::Exception("Invalid argument."); dbus::Error error; auto busNode = ::g_dbus_node_info_new_for_xml(xmlData.c_str(), &error); if (busNode == nullptr || error) - throw runtime::Exception("Failed to get BusNode."); + throw klay::Exception("Failed to get BusNode."); return busNode; } @@ -65,7 +65,7 @@ BusNode Introspection::getBusNode(const std::string &xmlData) Interface Introspection::getInterface(const std::string &name) const { if (name.empty()) - throw runtime::Exception("Invalid argument."); + throw klay::Exception("Invalid argument."); return ::g_dbus_node_info_lookup_interface(busNode, name.c_str()); } @@ -75,7 +75,7 @@ Method Introspection::getMethod(const std::string &interfaceName, { auto interface = getInterface(interfaceName); if (interface == nullptr || methodName.empty()) - throw runtime::Exception("Invalid argument."); + throw klay::Exception("Invalid argument."); return ::g_dbus_interface_info_lookup_method(interface, methodName.c_str()); } @@ -85,7 +85,7 @@ Signal Introspection::getSignal(const std::string &interfaceName, { auto interface = getInterface(interfaceName); if (interface == nullptr || signalName.empty()) - throw runtime::Exception("Invalid argument."); + throw klay::Exception("Invalid argument."); return ::g_dbus_interface_info_lookup_signal(interface, signalName.c_str()); } @@ -95,7 +95,7 @@ Property Introspection::getProperty(const std::string &interfaceName, { auto interface = getInterface(interfaceName); if (interface == nullptr || propertyName.empty()) - throw runtime::Exception("Invalid argument."); + throw klay::Exception("Invalid argument."); return ::g_dbus_interface_info_lookup_property(interface, propertyName.c_str()); } @@ -108,7 +108,7 @@ std::string Introspection::getXmlData(unsigned int indent) ::g_string_free(ptr, TRUE); }); if (buf == nullptr) - throw runtime::Exception("Out of memory."); + throw klay::Exception("Out of memory."); ::g_dbus_node_info_generate_xml(busNode, indent, buf.get()); return std::string(buf->str); @@ -116,7 +116,7 @@ std::string Introspection::getXmlData(unsigned int indent) std::string Introspection::createXmlDataFromFile(const std::string &path) { - runtime::File manifest(path); + klay::File manifest(path); if (!manifest.exists()) { manifest.create(0644); manifest.lock(); @@ -133,7 +133,7 @@ std::string Introspection::createXmlDataFromFile(const std::string &path) void Introspection::writeXmlDataToFile(const std::string &path, const std::string &xmlData) { - runtime::File manifest(path); + klay::File manifest(path); manifest.open(O_WRONLY | O_TRUNC); manifest.lock(); manifest.write(xmlData.c_str(), xmlData.length()); @@ -143,11 +143,11 @@ void Introspection::writeXmlDataToFile(const std::string &path, void Introspection::addInterface(const std::string &name) { if (getInterface(name) != nullptr) - throw runtime::Exception("Interface is already exist:" + name); + throw klay::Exception("Interface is already exist:" + name); std::size_t offset = xmlData.find(""); if (offset == std::string::npos) - throw runtime::Exception("Failed to find ."); + throw klay::Exception("Failed to find ."); XmlProperties properties; properties.emplace_back(std::make_pair("name", name)); @@ -189,16 +189,16 @@ std::string Introspection::getXmlEndTag(const std::string &node) const void Introspection::checkDataFormat(const std::string &data) const { if (data.empty() || data.length() < 3) - throw runtime::Exception("Invalid argument."); + throw klay::Exception("Invalid argument."); const std::string beginChar = "<"; if (data.compare(0, beginChar.length(), beginChar) != 0) - throw runtime::Exception("Xml data should be begin as: " + beginChar); + throw klay::Exception("Xml data should be begin as: " + beginChar); const std::string endChar = "/>"; if (data.compare(data.length() - endChar.length(), endChar.length(), endChar) != 0 && data.find("/") == std::string::npos) - throw runtime::Exception("Xml data should be contain '/' or end as: " + endChar); + throw klay::Exception("Xml data should be contain '/' or end as: " + endChar); } void Introspection::addMethod(const std::string &interfaceName, @@ -257,7 +257,7 @@ void Introspection::addInternalData(const std::string &interfaceName, std::string iTemplate = getXmlBeginTag(INTERFACE_NODE, properties); std::size_t offset = xmlData.find(iTemplate); if (offset == std::string::npos) - throw runtime::Exception("Failed to find interface xml node: " + interfaceName); + throw klay::Exception("Failed to find interface xml node: " + interfaceName); xmlData.insert(offset + iTemplate.length() + 1, data); update(); diff --git a/src/eventfd.cpp b/src/eventfd.cpp index dd81c38..1d937a9 100644 --- a/src/eventfd.cpp +++ b/src/eventfd.cpp @@ -29,7 +29,7 @@ EventFD::EventFD(unsigned int initval, int flags) { fd = ::eventfd(initval, flags); if (fd == -1) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } } @@ -49,7 +49,7 @@ void EventFD::send() { const std::uint64_t val = 1; if (::write(fd, &val, sizeof(val)) == -1) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } } @@ -57,7 +57,7 @@ void EventFD::receive() { std::uint64_t val; if (::read(fd, &val, sizeof(val)) == -1) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } } diff --git a/src/file-user.cpp b/src/file-user.cpp index 038f05a..a2a9393 100644 --- a/src/file-user.cpp +++ b/src/file-user.cpp @@ -33,16 +33,16 @@ bool FileUser::isUsedAsFD(const std::string &filePath, const pid_t pid, bool isM try { File file(filePath); - for (runtime::DirectoryIterator iter(path), end; iter != end;) { + for (klay::DirectoryIterator iter(path), end; iter != end;) { File cur(File((++iter)->getPath()).readlink()); try { if ((cur.getInode() == file.getInode() || isMount) && cur.getDevice() == file.getDevice()) { return true; } - } catch (runtime::Exception &e) {} + } catch (klay::Exception &e) {} } - } catch (runtime::Exception &e) {} + } catch (klay::Exception &e) {} return false; } @@ -72,7 +72,7 @@ bool FileUser::isUsedAsMap(const std::string &filePath, const pid_t pid, bool is } } } - } catch (runtime::Exception &e) {} + } catch (klay::Exception &e) {} return false; } @@ -88,7 +88,7 @@ bool FileUser::isUsedAsCwd(const std::string &filePath, const pid_t pid, bool is cwd.getDevice() == file.getDevice()) { return true; } - } catch (runtime::Exception &e) {} + } catch (klay::Exception &e) {} return false; } @@ -104,7 +104,7 @@ bool FileUser::isUsedAsRoot(const std::string &filePath, const pid_t pid, bool i root.getDevice() == file.getDevice()) { return true; } - } catch (runtime::Exception &e) {} + } catch (klay::Exception &e) {} return false; } @@ -114,7 +114,7 @@ std::vector FileUser::getList(const std::string &path, bool isMount) pid_t currentPid = ::getpid(); std::vector list; - for (runtime::DirectoryIterator iter("/proc"), end; iter != end;) { + for (klay::DirectoryIterator iter("/proc"), end; iter != end;) { const std::string name = iter->getName(); if (!std::isdigit(name[0])) { ++iter; diff --git a/src/filesystem.cpp b/src/filesystem.cpp index fa8484c..a98c7cd 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -82,7 +82,7 @@ bool File::isLink() const { struct stat st; if (::lstat(path.c_str(), &st) != 0) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } return S_ISLNK(st.st_mode); @@ -92,7 +92,7 @@ bool File::isFile() const { struct stat st; if (::lstat(path.c_str(), &st) != 0) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } return S_ISREG(st.st_mode); @@ -102,7 +102,7 @@ bool File::isDirectory() const { struct stat st; if (::lstat(path.c_str(), &st) != 0) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } return S_ISDIR(st.st_mode); @@ -112,7 +112,7 @@ bool File::isDevice() const { struct stat st; if (::lstat(path.c_str(), &st) != 0) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } return (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)); @@ -122,7 +122,7 @@ mode_t File::getMode() const { struct stat st; if (::lstat(path.c_str(), &st) != 0) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } return st.st_mode; @@ -132,7 +132,7 @@ uid_t File::getUid() const { struct stat st; if (::lstat(path.c_str(), &st) != 0) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } return st.st_uid; @@ -142,7 +142,7 @@ gid_t File::getGid() const { struct stat st; if (::lstat(path.c_str(), &st) != 0) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } return st.st_gid; @@ -152,7 +152,7 @@ ino_t File::getInode() const { struct stat st; if (::lstat(path.c_str(), &st) != 0) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } return st.st_ino; @@ -162,7 +162,7 @@ dev_t File::getDevice() const { struct stat st; if (::lstat(path.c_str(), &st) != 0) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } return st.st_dev; @@ -172,7 +172,7 @@ off_t File::size() const { struct stat st; if (::lstat(path.c_str(), &st) != 0) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } return st.st_size; @@ -190,7 +190,7 @@ void File::create(mode_t mode) if (errno == EINTR) { continue; } - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } return; } @@ -208,7 +208,7 @@ void File::create(int flags, mode_t mode) if (errno == EINTR) { continue; } - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } return; } @@ -226,7 +226,7 @@ void File::open(int flags) if (errno == EINTR) { continue; } - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } return; } @@ -251,7 +251,7 @@ void File::read(void *buffer, const size_t size) const } else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) { continue; } else { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } } } @@ -267,7 +267,7 @@ void File::write(const void *buffer, const size_t size) const } else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) { continue; } else { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } } } @@ -275,7 +275,7 @@ void File::write(const void *buffer, const size_t size) const void File::lseek(off_t offset, int whence) const { if (::lseek(descriptor, offset, whence) == -1) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } } @@ -303,7 +303,7 @@ File File::copyTo(const std::string& destDir) ssize_t ret; ret = ::sendfile(destFile.descriptor, descriptor, &s, size() - s); if (ret < 0) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } } destFile.close(); @@ -324,11 +324,11 @@ void File::remove(bool recursive) } } if (::rmdir(path.c_str()) != 0) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } } else { if (::unlink(path.c_str()) != 0) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } } } @@ -345,11 +345,11 @@ void File::makeBaseDirectory(uid_t uid, gid_t gid) } else if (ret == 0) { if ((uid | gid) != 0) { if (::chown(substr.c_str(), uid, gid) == -1) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } } } else { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } } } @@ -361,7 +361,7 @@ void File::makeDirectory(bool recursive, uid_t uid, gid_t gid) } if (::mkdir(path.c_str(), 0777) == -1) { - throw runtime::Exception("mkdir failed in makeDirectory: " + path); + throw klay::Exception("mkdir failed in makeDirectory: " + path); } if ((uid | gid) != 0) { @@ -372,7 +372,7 @@ void File::makeDirectory(bool recursive, uid_t uid, gid_t gid) void File::chown(uid_t uid, gid_t gid, bool recursive) { if (::chown(path.c_str(), uid, gid) != 0) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } if (recursive && isDirectory()) { @@ -387,7 +387,7 @@ void File::chown(uid_t uid, gid_t gid, bool recursive) void File::chmod(mode_t mode, bool recursive) { if (::chmod(path.c_str(), mode) != 0) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } if (recursive && isDirectory()) { @@ -404,7 +404,7 @@ const std::string File::readlink() const char buf[PATH_MAX + 1]; ssize_t ret = ::readlink(path.c_str(), buf, PATH_MAX); if (ret == -1) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } buf[ret] = '\0'; @@ -414,14 +414,14 @@ const std::string File::readlink() const void File::lock() const { if (::flock(descriptor, LOCK_EX) == -1) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } } void File::unlock() const { if (::flock(descriptor, LOCK_UN) == -1) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } } @@ -448,7 +448,7 @@ void DirectoryIterator::reset(const std::string& dir) basename = dir; directoryHandle = ::opendir(basename.c_str()); if (directoryHandle == nullptr) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } next(); @@ -579,7 +579,7 @@ void Mount::mountEntry(const std::string& src, const std::string& dest, const st } if (ret) { - throw runtime::Exception("failed to mount " + src + " on " + dest); + throw klay::Exception("failed to mount " + src + " on " + dest); } } } diff --git a/src/namespace.cpp b/src/namespace.cpp index 1b16ef1..2890c6d 100644 --- a/src/namespace.cpp +++ b/src/namespace.cpp @@ -53,12 +53,12 @@ void Namespace::attach(const pid_t pid) if (fd == -1) { if (errno != ENOENT) { - throw runtime::Exception("Failed to open namesapce: " + nspath); + throw klay::Exception("Failed to open namesapce: " + nspath); } } else { if (::setns(fd, ns.second)) { ::close(fd); - throw runtime::Exception("Failed to set namespace: " + nspath); + throw klay::Exception("Failed to set namespace: " + nspath); } ::close(fd); } @@ -68,12 +68,12 @@ void Namespace::attach(const pid_t pid) void Namespace::unshare(int flags) { if (::unshare(flags)) { - throw runtime::Exception("Failed to unshare namespace"); + throw klay::Exception("Failed to unshare namespace"); } if (flags & CLONE_NEWNS && ::mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) == -1) { - throw runtime::Exception("Failed to mount root filesystem"); + throw klay::Exception("Failed to mount root filesystem"); } } diff --git a/src/netlink/netlink.cpp b/src/netlink/netlink.cpp index 9199d0a..ea67f5f 100644 --- a/src/netlink/netlink.cpp +++ b/src/netlink/netlink.cpp @@ -33,12 +33,12 @@ Netlink::Netlink(int protocol) : { fd = ::socket(PF_NETLINK, SOCK_RAW, protocol); if (fd < 0) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } if (::fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) { ::close(fd); - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } } @@ -89,14 +89,14 @@ void Netlink::send(int type, const std::vector& data) } while (ret < 0 && errno == EINTR); if (ret < 0) { - throw runtime::Exception("Failed to send a netlink message"); + throw klay::Exception("Failed to send a netlink message"); } if (recv(MSG_PEEK).first == NLMSG_ERROR) { auto reply = recv().second; auto err = (struct nlmsgerr*)reply.data(); if (err->error) - throw runtime::Exception("Netlink error: " + + throw klay::Exception("Netlink error: " + std::to_string(err->error)); } else { WARN("Missing ack of netlink message"); @@ -114,7 +114,7 @@ Netlink::Message Netlink::recv(int options) } while (ret < 0 && errno == EINTR); if (ret < 0) { - throw runtime::Exception("Failed to get the size of netlink message"); + throw klay::Exception("Failed to get the size of netlink message"); } struct sockaddr_nl nladdr; @@ -130,19 +130,19 @@ Netlink::Message Netlink::recv(int options) ::memcpy(msg.second.data(), NLMSG_DATA(buf), msg.second.size()); if (ret < 0) { - throw runtime::Exception("Failed to receive audit packet"); + throw klay::Exception("Failed to receive audit packet"); } if (nladdrlen != sizeof(nladdr)) { - throw runtime::Exception("Bad address size in netlink socket"); + throw klay::Exception("Bad address size in netlink socket"); } if (nladdr.nl_pid) { - throw runtime::Exception("Spoofed packet received on netlink socket"); + throw klay::Exception("Spoofed packet received on netlink socket"); } return msg; } -} // namespace runtime +} // namespace klay } // namespace klay diff --git a/src/pam.cpp b/src/pam.cpp index 84cb6f3..0ac705c 100644 --- a/src/pam.cpp +++ b/src/pam.cpp @@ -31,7 +31,7 @@ PAM::PAM(const std::string& service, const std::string& user) int error = ::pam_start(service.c_str(), user.c_str(), &pamc, &pamh); if (error != PAM_SUCCESS) { - throw runtime::Exception("PAM Error"); + throw klay::Exception("PAM Error"); } } @@ -39,7 +39,7 @@ PAM::~PAM() { int error = ::pam_end(pamh, PAM_SUCCESS); if (error != PAM_SUCCESS) { - throw runtime::Exception("PAM Error"); + throw klay::Exception("PAM Error"); } } @@ -47,7 +47,7 @@ void PAM::setData(const std::string &name, void* data, void (*cleanup)(pam_handl { int error = ::pam_set_data(pamh, name.c_str(), data, cleanup); if (error != PAM_SUCCESS) { - throw runtime::Exception("PAM Error"); + throw klay::Exception("PAM Error"); } } @@ -56,7 +56,7 @@ const void* PAM::getData(const std::string &name) const const void* ret; int error = ::pam_get_data(pamh, name.c_str(), &ret); if (error != PAM_SUCCESS) { - throw runtime::Exception("PAM Error"); + throw klay::Exception("PAM Error"); } return ret; } @@ -65,7 +65,7 @@ void PAM::setItem(int item, void* data) { int error = ::pam_set_item(pamh, item, data); if (error != PAM_SUCCESS) { - throw runtime::Exception("PAM Error"); + throw klay::Exception("PAM Error"); } } @@ -74,7 +74,7 @@ const void* PAM::getItem(int item) const const void* ret; int error = ::pam_get_item(pamh, item, &ret); if (error != PAM_SUCCESS) { - throw runtime::Exception("PAM Error"); + throw klay::Exception("PAM Error"); } return ret; } @@ -84,7 +84,7 @@ const std::string PAM::getUser(const std::string &prompt) const const char* user; int error = ::pam_get_user(pamh, &user, prompt.c_str()); if (error != PAM_SUCCESS) { - throw runtime::Exception("PAM Error"); + throw klay::Exception("PAM Error"); } return std::string(user); } @@ -93,7 +93,7 @@ void PAM::putEnv(const std::string &name_value) { int error = ::pam_putenv(pamh, name_value.c_str()); if (error != PAM_SUCCESS) { - throw runtime::Exception("PAM Error"); + throw klay::Exception("PAM Error"); } } @@ -101,7 +101,7 @@ const std::string PAM::getEnv(const std::string &name) const { const char* value = ::pam_getenv(pamh, name.c_str()); if (value == NULL) { - throw runtime::Exception("PAM Error"); + throw klay::Exception("PAM Error"); } return value; } @@ -111,7 +111,7 @@ const std::vector PAM::getEnvList() const std::vector ret; char** array = ::pam_getenvlist(pamh); if (array == NULL) { - throw runtime::Exception("PAM Error"); + throw klay::Exception("PAM Error"); } for (int i = 0; array[i] != NULL; i++) { ret.push_back(array[i]); @@ -149,7 +149,7 @@ void PAM::openSession(int flags) { int error = ::pam_open_session(pamh, flags); if (error != PAM_SUCCESS) { - throw runtime::Exception("PAM Error"); + throw klay::Exception("PAM Error"); } } @@ -157,7 +157,7 @@ void PAM::closeSession(int flags) { int error = ::pam_close_session(pamh, flags); if (error != PAM_SUCCESS) { - throw runtime::Exception("PAM Error"); + throw klay::Exception("PAM Error"); } } diff --git a/src/process.cpp b/src/process.cpp index 9b2f583..dbb2e42 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -86,14 +86,14 @@ bool Process::isRunning() const void Process::kill() { if (::kill(pid, SIGKILL) == -1) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } } void Process::terminate() { if (::kill(pid, SIGINT) == -1) { - throw runtime::Exception(runtime::GetSystemErrorMessage()); + throw klay::Exception(klay::GetSystemErrorMessage()); } } diff --git a/src/rmi/client.cpp b/src/rmi/client.cpp index d29c75a..d40c5df 100644 --- a/src/rmi/client.cpp +++ b/src/rmi/client.cpp @@ -22,23 +22,23 @@ namespace rmi { void DefaultExceptionModel::raise(const std::string& target, const std::string& msg) { if (target == "InvalidArgumentException") - throw runtime::InvalidArgumentException(msg); + throw klay::InvalidArgumentException(msg); else if (target == "NotImplementedException") - throw runtime::InvalidArgumentException(msg); + throw klay::InvalidArgumentException(msg); else if (target == "RangeException") - throw runtime::RangeException(msg); + throw klay::RangeException(msg); else if (target == "NotFoundException") - throw runtime::NotFoundException(msg); + throw klay::NotFoundException(msg); else if (target == "UnsupportedException") - throw runtime::UnsupportedException(msg); + throw klay::UnsupportedException(msg); else if (target == "NoPermissionException") - throw runtime::NoPermissionException(msg); + throw klay::NoPermissionException(msg); else if (target == "IOException") - throw runtime::IOException(msg); + throw klay::IOException(msg); else if (target == "OutOfMemoryException") - throw runtime::OutOfMemoryException(msg); + throw klay::OutOfMemoryException(msg); else - throw runtime::Exception(msg); + throw klay::Exception(msg); } } // namespace rmi diff --git a/src/rmi/message.cpp b/src/rmi/message.cpp index e09329f..e007e38 100644 --- a/src/rmi/message.cpp +++ b/src/rmi/message.cpp @@ -90,16 +90,16 @@ Message Message::createErrorMessage(const std::string& target, const std::string return error; } -template<> void Message::enclose(runtime::FileDescriptor&& fd) +template<> void Message::enclose(klay::FileDescriptor&& fd) { if (fd.fileDescriptor == -1) { - throw runtime::Exception("Invalid file descriptor"); + throw klay::Exception("Invalid file descriptor"); } fileDescriptors.push_back(std::move(fd)); } -template<> void Message::disclose(runtime::FileDescriptor& fd) +template<> void Message::disclose(klay::FileDescriptor& fd) { if (!fileDescriptors.empty()) { fd.fileDescriptor = std::move(fileDescriptors.front()).fileDescriptor; diff --git a/src/rmi/notification.cpp b/src/rmi/notification.cpp index f071777..7cc78b5 100644 --- a/src/rmi/notification.cpp +++ b/src/rmi/notification.cpp @@ -43,7 +43,7 @@ SubscriptionId Notification::createSubscriber() { int fds[2] = {-1, -1}; if (::socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == -1) { - throw runtime::Exception("Failed to create socket pair"); + throw klay::Exception("Failed to create socket pair"); } std::lock_guard lock(subscriberLock); diff --git a/src/rmi/service.cpp b/src/rmi/service.cpp index 3265291..99a7e26 100644 --- a/src/rmi/service.cpp +++ b/src/rmi/service.cpp @@ -50,7 +50,7 @@ Service::~Service() void Service::prepare(bool activation) { socket.reset(new Socket(Socket::create(address, activation))); - auto accept = [&](int fd, runtime::Mainloop::Event event) { + auto accept = [&](int fd, klay::Mainloop::Event event) { onNewConnection(std::make_shared(socket->accept())); }; @@ -93,7 +93,7 @@ void Service::setAuditTrail(const AuditTrail& trail) void Service::setNewConnectionCallback(const ConnectionCallback& connectionCallback) { auto callback = [connectionCallback, this](const std::shared_ptr& connection) { - auto handle = [&](int fd, runtime::Mainloop::Event event) { + auto handle = [&](int fd, klay::Mainloop::Event event) { std::lock_guard lock(stateLock); auto iter = getConnectionIterator(fd); @@ -142,7 +142,7 @@ void Service::createNotification(const std::string& name) std::lock_guard lock(notificationLock); if (notificationRegistry.count(name)) { - throw runtime::Exception("Notification already registered"); + throw klay::Exception("Notification already registered"); } notificationRegistry.emplace(name, Notification(name)); @@ -150,7 +150,7 @@ void Service::createNotification(const std::string& name) int Service::subscribeNotification(const std::string& name) { - auto closeHandler = [&, name, this](int fd, runtime::Mainloop::Event event) { + auto closeHandler = [&, name, this](int fd, klay::Mainloop::Event event) { if ((event & EPOLLHUP) || (event & EPOLLRDHUP)) { unsubscribeNotification(name, fd); return; @@ -170,7 +170,7 @@ int Service::subscribeNotification(const std::string& name) SubscriptionId slot = notification.createSubscriber(); mainloop.addEventSource(slot.first, EPOLLHUP | EPOLLRDHUP, closeHandler); return slot.second; - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { ERROR(KSINK, e.what()); return -1; } @@ -205,7 +205,7 @@ void Service::onMessageProcess(const std::shared_ptr& connection) auto process = [&, connection](Message& request) { try { if (!methodRegistry.count(request.target())) - throw runtime::NotFoundException("Method not found"); + throw klay::NotFoundException("Method not found"); std::shared_ptr methodContext = methodRegistry.at(request.target()); @@ -213,11 +213,11 @@ void Service::onMessageProcess(const std::shared_ptr& connection) bool allowed = onPrivilegeCheck(processingContext.credentials, methodContext->privilege); onAuditTrail(processingContext.credentials, request.target(), allowed); if (!allowed) { - throw runtime::NoPermissionException("Permission denied"); + throw klay::NoPermissionException("Permission denied"); } connection->send(methodContext->dispatcher(request)); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { try { // Forward the exception to the peer connection->send(request.createErrorMessage(e.className(), e.what())); diff --git a/src/rmi/socket.cpp b/src/rmi/socket.cpp index 3e2e372..9889acb 100644 --- a/src/rmi/socket.cpp +++ b/src/rmi/socket.cpp @@ -39,7 +39,7 @@ const int MAX_BACKLOG_SIZE = 100; void setCloseOnExec(int fd) { if (::fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) { - throw SocketException(runtime::GetSystemErrorMessage()); + throw SocketException(klay::GetSystemErrorMessage()); } } @@ -50,11 +50,11 @@ Credentials getCredentials(int fd) struct ucred cred; socklen_t credsz = sizeof(cred); if (::getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &credsz)) { - throw SocketException(runtime::GetSystemErrorMessage()); + throw SocketException(klay::GetSystemErrorMessage()); } if (::getsockopt(fd, SOL_SOCKET, SO_PEERSEC, buf, &length)) { - throw SocketException(runtime::GetSystemErrorMessage()); + throw SocketException(klay::GetSystemErrorMessage()); } return {cred.pid, cred.uid, cred.gid, buf}; @@ -85,7 +85,7 @@ Socket Socket::accept() { int sockfd = ::accept(socketFd, nullptr, nullptr); if (sockfd == -1) { - throw SocketException(runtime::GetSystemErrorMessage()); + throw SocketException(klay::GetSystemErrorMessage()); } setCloseOnExec(sockfd); @@ -114,7 +114,7 @@ void Socket::read(void *buffer, const size_t size) const } else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) { continue; } else { - throw SocketException(runtime::GetSystemErrorMessage()); + throw SocketException(klay::GetSystemErrorMessage()); } } } @@ -130,7 +130,7 @@ void Socket::write(const void *buffer, const size_t size) const } else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) { continue; } else { - throw SocketException(runtime::GetSystemErrorMessage()); + throw SocketException(klay::GetSystemErrorMessage()); } } } @@ -170,7 +170,7 @@ void Socket::sendFileDescriptors(const int* fds, const size_t nr) const if (ret >= 0) { written += ret; } else if ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINTR)) { - throw SocketException(runtime::GetSystemErrorMessage()); + throw SocketException(klay::GetSystemErrorMessage()); } } } @@ -203,7 +203,7 @@ void Socket::receiveFileDescriptors(int* fds, const size_t nr) const bytes += ret; } else { if ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINTR)) { - throw SocketException(runtime::GetSystemErrorMessage()); + throw SocketException(klay::GetSystemErrorMessage()); } } } @@ -240,12 +240,12 @@ int Socket::createSystemdSocket(const std::string& path) int Socket::createRegularSocket(const std::string& path) { if (path.size() >= sizeof(sockaddr_un::sun_path)) { - throw SocketException(runtime::GetSystemErrorMessage(ENAMETOOLONG)); + throw SocketException(klay::GetSystemErrorMessage(ENAMETOOLONG)); } int sockfd = ::socket(AF_UNIX, SOCK_STREAM, 0); if (sockfd == -1) { - throw SocketException(runtime::GetSystemErrorMessage()); + throw SocketException(klay::GetSystemErrorMessage()); } setCloseOnExec(sockfd); @@ -262,18 +262,18 @@ int Socket::createRegularSocket(const std::string& path) if (::bind(sockfd, reinterpret_cast(&addr), sizeof(struct sockaddr_un)) == -1) { ::close(sockfd); - throw SocketException(runtime::GetSystemErrorMessage()); + throw SocketException(klay::GetSystemErrorMessage()); } int optval = 1; if (::setsockopt(sockfd, SOL_SOCKET, SO_PASSCRED, &optval, sizeof(optval)) == -1) { ::close(sockfd); - throw SocketException(runtime::GetSystemErrorMessage()); + throw SocketException(klay::GetSystemErrorMessage()); } if (::listen(sockfd, MAX_BACKLOG_SIZE) == -1) { ::close(sockfd); - throw SocketException(runtime::GetSystemErrorMessage()); + throw SocketException(klay::GetSystemErrorMessage()); } return sockfd; @@ -295,12 +295,12 @@ Socket Socket::create(const std::string& path, bool activation) Socket Socket::connect(const std::string& path) { if (path.size() >= sizeof(sockaddr_un::sun_path)) { - throw SocketException(runtime::GetSystemErrorMessage(ENAMETOOLONG)); + throw SocketException(klay::GetSystemErrorMessage(ENAMETOOLONG)); } int fd = ::socket(AF_UNIX, SOCK_STREAM, 0); if (fd == -1) { - throw SocketException(runtime::GetSystemErrorMessage()); + throw SocketException(klay::GetSystemErrorMessage()); } setCloseOnExec(fd); @@ -315,7 +315,7 @@ Socket Socket::connect(const std::string& path) if (::connect(fd, reinterpret_cast(&addr), sizeof(struct sockaddr_un)) == -1) { ::close(fd); - throw SocketException(runtime::GetSystemErrorMessage()); + throw SocketException(klay::GetSystemErrorMessage()); } return Socket(fd); diff --git a/src/xml/document.cpp b/src/xml/document.cpp index b49d7a7..4d9ab57 100644 --- a/src/xml/document.cpp +++ b/src/xml/document.cpp @@ -29,7 +29,7 @@ Document::Document(const std::string& root, const std::string& version) : implementation(xmlNewDoc((const xmlChar*)version.c_str())) { if (implementation == nullptr) { - throw runtime::Exception("Failed to create document"); + throw klay::Exception("Failed to create document"); } implementation->_private = this; @@ -60,7 +60,7 @@ Document::~Document() Node& Document::getRootNode() { if (rootNode == nullptr) { - throw runtime::Exception("Empty document"); + throw klay::Exception("Empty document"); } return *rootNode; @@ -70,20 +70,20 @@ Node::NodeList Document::evaluate(const std::string& xpath) { auto ctxt = xmlXPathNewContext(implementation); if (ctxt == nullptr) { - throw runtime::Exception("Failed to create XPath context for " + xpath); + throw klay::Exception("Failed to create XPath context for " + xpath); } auto result = xmlXPathEval((const xmlChar*)xpath.c_str(), ctxt); if (result == nullptr) { xmlXPathFreeContext(ctxt); - throw runtime::Exception("Invalid XPath: " + xpath); + throw klay::Exception("Invalid XPath: " + xpath); } if (result ->type != XPATH_NODESET) { xmlXPathFreeObject(result); xmlXPathFreeContext(ctxt); - throw runtime::Exception("Only nodeset result types are supported"); + throw klay::Exception("Only nodeset result types are supported"); } auto nodeset = result->nodesetval; @@ -128,7 +128,7 @@ void Document::write(const std::string& filename, const std::string& encoding, b encoding.c_str(), formatted); if (result == 0) { - throw runtime::Exception("Failed to write XML document"); + throw klay::Exception("Failed to write XML document"); } } diff --git a/src/xml/node.cpp b/src/xml/node.cpp index a0055d0..83b8742 100644 --- a/src/xml/node.cpp +++ b/src/xml/node.cpp @@ -50,7 +50,7 @@ Node Node::addNewChild(const std::string& name) { xmlNode* nodePtr = xmlNewNode(NULL, xmlStrdup((const xmlChar*)name.c_str())); if (nodePtr == nullptr) { - throw runtime::Exception("Can not create a new node"); + throw klay::Exception("Can not create a new node"); } xmlAddChild(implementation, nodePtr); @@ -86,7 +86,7 @@ void Node::setContent(const std::string& content) std::string Node::getProp(const std::string& name) const { if (implementation->type != XML_ELEMENT_NODE) { - throw runtime::Exception("This node type does not have properties"); + throw klay::Exception("This node type does not have properties"); } xmlChar* prop = xmlGetProp(implementation, (xmlChar*)name.c_str()); @@ -102,7 +102,7 @@ std::string Node::getProp(const std::string& name) const void Node::setProp(const std::string& name, const std::string& val) { if (implementation->type != XML_ELEMENT_NODE) { - throw runtime::Exception("Can not set properties for this node type"); + throw klay::Exception("Can not set properties for this node type"); } xmlSetProp(implementation, (xmlChar*)name.c_str(), (xmlChar*)val.c_str()); diff --git a/src/xml/parser.cpp b/src/xml/parser.cpp index ddae583..86ba1db 100644 --- a/src/xml/parser.cpp +++ b/src/xml/parser.cpp @@ -25,7 +25,7 @@ namespace xml { Document* Parser::parseContext(xmlParserCtxt* context, bool validate) { if (context == nullptr) { - throw runtime::Exception("Could not create parser context"); + throw klay::Exception("Could not create parser context"); } KeepBlanks(false); @@ -42,7 +42,7 @@ Document* Parser::parseContext(xmlParserCtxt* context, bool validate) if (xmlParseDocument(context) < 0) { xmlFreeParserCtxt(context); - throw runtime::Exception("Parsing failed"); + throw klay::Exception("Parsing failed"); } xmlDoc* document = context->myDoc; @@ -59,7 +59,7 @@ Document* Parser::parseFile(const std::string& filename, bool validate) { xmlParserCtxt* context = xmlCreateFileParserCtxt(filename.c_str()); if (context == nullptr) { - throw runtime::Exception("Could not create parser context"); + throw klay::Exception("Could not create parser context"); } if (context->directory == nullptr) { @@ -74,7 +74,7 @@ Document* Parser::parseString(const std::string& xml, bool validate) xmlParserCtxt* context = xmlCreateMemoryParserCtxt(xml.c_str(), xml.size() + 1); if (context == nullptr) { - throw runtime::Exception("Could not create parser context"); + throw klay::Exception("Could not create parser context"); } return parseContext(context, validate); diff --git a/test/auth.cpp b/test/auth.cpp index 4df527f..3a5c574 100644 --- a/test/auth.cpp +++ b/test/auth.cpp @@ -28,9 +28,9 @@ TESTCASE(GetGroupTest) { try { - runtime::Group group("users"); - runtime::Group another(group); - } catch (runtime::Exception& e) { + klay::Group group("users"); + klay::Group another(group); + } catch (klay::Exception& e) { TEST_FAIL(e.what()); } } @@ -38,9 +38,9 @@ TESTCASE(GetGroupTest) TESTCASE(GetUserTest) { try { - runtime::User user("root"); - runtime::User another(user); - } catch (runtime::Exception& e) { + klay::User user("root"); + klay::User another(user); + } catch (klay::Exception& e) { TEST_FAIL(e.what()); } } @@ -48,49 +48,49 @@ TESTCASE(GetUserTest) TESTCASE(GetGroupNegativeTest) { try { - runtime::Group group("invalid"); - } catch (runtime::Exception& e) { + klay::Group group("invalid"); + } catch (klay::Exception& e) { } } TESTCASE(GetGroupNegativeTest2) { try { - runtime::Group group(-1); - } catch (runtime::Exception& e) { + klay::Group group(-1); + } catch (klay::Exception& e) { } } TESTCASE(GetUserNegativetest) { try { - runtime::User user("invalid"); - } catch (runtime::Exception& e) { + klay::User user("invalid"); + } catch (klay::Exception& e) { } } TESTCASE(GetUserNegativetest2) { try { - runtime::User user(-1); - } catch (runtime::Exception& e) { + klay::User user(-1); + } catch (klay::Exception& e) { } } TESTCASE(GetCurrentGroupTest) { try { - runtime::Group group; - runtime::Group another(group.getGid()); - } catch (runtime::Exception& e) { + klay::Group group; + klay::Group another(group.getGid()); + } catch (klay::Exception& e) { } } TESTCASE(GetCurrentUserTest) { try { - runtime::User user; - runtime::User another(user.getUid()); - } catch (runtime::Exception& e) { + klay::User user; + klay::User another(user.getUid()); + } catch (klay::Exception& e) { } } diff --git a/test/database.cpp b/test/database.cpp index 05b2b41..04bc332 100644 --- a/test/database.cpp +++ b/test/database.cpp @@ -45,7 +45,7 @@ TESTCASE(DatabaseTest) try { database::Connection db(TestbenchDataSource, database::Connection::ReadWrite | database::Connection::Create); db.exec(query); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { TEST_FAIL(e.what()); } } @@ -55,7 +55,7 @@ TESTCASE(InvalidStatementTest) try { database::Connection db(TestbenchDataSource, database::Connection::ReadWrite | database::Connection::Create); database::Statement stmt(db, "INVALID STATEMENT"); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } } @@ -64,7 +64,7 @@ TESTCASE(InvalidStatementTest2) try { database::Connection db(TestbenchDataSource, database::Connection::ReadWrite | database::Connection::Create); db.exec("INVALID"); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } } @@ -91,7 +91,7 @@ TESTCASE(ColumnBindTestWithIndex1) TEST_EXPECT(5, select.getColumnCount()); stmt.clearBindings(); stmt.reset(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { TEST_FAIL(e.what()); } } @@ -108,7 +108,7 @@ TESTCASE(ColumnBindTestWithIndex2) stmt.bind(3, false); stmt.bind(4, 5001); stmt.exec(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { TEST_FAIL(e.what()); } } @@ -125,7 +125,7 @@ TESTCASE(ColumnBindTestWithName1) stmt.bind(":IS_USED", true); stmt.bind(":USER", 5001); stmt.exec(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { TEST_FAIL(e.what()); } } @@ -139,7 +139,7 @@ TESTCASE(ColumnBindNullTest) database::Statement stmt(db, query); stmt.bind(":PKG"); stmt.bind(2); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { TEST_FAIL(e.what()); } } @@ -162,7 +162,7 @@ TESTCASE(ColumnBindTestWithName2) stmt.bind(":IS_USED", used); stmt.bind(":USER", user); stmt.exec(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { TEST_FAIL(e.what()); } } @@ -191,7 +191,7 @@ TESTCASE(ColumnTest) key.getName(); key.getText(); key.getType(); key.getBytes(); key.getBlob(); used.getName(); used.getInt(); used.getInt64(); used.getDouble(); used.getType(); used.getBytes(); } - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { TEST_FAIL(e.what()); } } @@ -203,7 +203,7 @@ TESTCASE(ColumnOutRange1) database::Statement select(db, "SELECT * FROM CLIENT"); select.step(); database::Column column = select.getColumn(32); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } } @@ -214,7 +214,7 @@ TESTCASE(ColumnOutRange2) database::Statement select(db, "SELECT * FROM CLIENT"); select.step(); select.isNullColumn(32); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } } @@ -225,7 +225,7 @@ TESTCASE(ColumnOutRange3) database::Statement select(db, "SELECT * FROM CLIENT"); select.step(); select.getColumnName(32); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } } @@ -238,46 +238,46 @@ TESTCASE(ColumnBindOutRange1) database::Statement stmt(db, query); try { stmt.bind(":TPK", "TEST PACKAGE"); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { stmt.bind(":TPK", (int)10); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { stmt.bind(":TPK", (sqlite3_int64)10); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { stmt.bind(":TPK", (double)10); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { stmt.bind(":TPK", "invalid"); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { stmt.bind(":TPK", std::string("invalid")); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { stmt.bind(":TPK", (void *)NULL, 12); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { stmt.bind(":TPK"); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } stmt.exec(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } } @@ -290,46 +290,46 @@ TESTCASE(ColumnBindOutRange2) database::Statement stmt(db, query); try { stmt.bind(32, "TEST PACKAGE"); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { stmt.bind(32, (int)10); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { stmt.bind(32, (sqlite3_int64)10); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { stmt.bind(32, (double)10); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { stmt.bind(32, "invalid"); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { stmt.bind(32, std::string("invalid")); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { stmt.bind(32, (void *)NULL, 12); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { stmt.bind(32); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } stmt.exec(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } } @@ -337,6 +337,6 @@ TESTCASE(InvalidDB) { try { database::Connection db("/tmp/invalid.db", database::Connection::ReadWrite); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } } diff --git a/test/dbus.cpp b/test/dbus.cpp index d7c985c..14b97b5 100644 --- a/test/dbus.cpp +++ b/test/dbus.cpp @@ -97,13 +97,13 @@ TESTCASE(DbusRegisterObjectTest) { ScopedGMainLoop mainloop; mainloop.dispatch([&](){ - runtime::Latch nameAcquired; + klay::Latch nameAcquired; auto handler = [](const std::string& objectPath, const std::string& interface, const std::string& methodName, dbus::Variant parameters) { if (objectPath != TESTSVC_OBJECT_PATH || interface != TESTSVC_INTERFACE) { - throw runtime::Exception("Unknown Method"); + throw klay::Exception("Unknown Method"); } if (methodName == TESTSVC_METHOD_NOOP) { return dbus::Variant(); diff --git a/test/eventfd.cpp b/test/eventfd.cpp index 2401d75..7720551 100644 --- a/test/eventfd.cpp +++ b/test/eventfd.cpp @@ -27,18 +27,18 @@ TESTCASE(EventFdHandleNegative) { try { - runtime::EventFD evtfd(0, -1); - } catch (runtime::Exception& e) { + klay::EventFD evtfd(0, -1); + } catch (klay::Exception& e) { } } TESTCASE(EventFdSendPositive) { try { - runtime::EventFD evtfd; + klay::EventFD evtfd; evtfd.send(); evtfd.receive(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { TEST_FAIL(e.what()); } } @@ -46,20 +46,20 @@ TESTCASE(EventFdSendPositive) TESTCASE(EventFdSendNegative) { try { - runtime::EventFD evtfd; + klay::EventFD evtfd; evtfd.close(); evtfd.send(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } } TESTCASE(EventFdReceiveNegative) { try { - runtime::EventFD evtfd; + klay::EventFD evtfd; evtfd.close(); evtfd.receive(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } } diff --git a/test/filesystem.cpp b/test/filesystem.cpp index 8789f01..165de8d 100644 --- a/test/filesystem.cpp +++ b/test/filesystem.cpp @@ -32,8 +32,8 @@ TESTCASE(DirectoryIteration) { - runtime::DirectoryIterator iter("/dev"); - runtime::DirectoryIterator end; + klay::DirectoryIterator iter("/dev"); + klay::DirectoryIterator end; TEST_EXPECT(false, iter == end); @@ -45,7 +45,7 @@ TESTCASE(DirectoryIteration) TESTCASE(FileIO) { char testbuf[100] = "Test Data"; - runtime::File tmp("/tmp/test-file"); + klay::File tmp("/tmp/test-file"); try { tmp.create(0755); tmp.lock(); @@ -53,43 +53,43 @@ TESTCASE(FileIO) tmp.lseek(10, SEEK_SET); tmp.unlock(); tmp.close(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { TEST_FAIL(e.what()); } char readbuf[100]; try { - runtime::File tmpFile("/tmp/test-file", O_RDWR); + klay::File tmpFile("/tmp/test-file", O_RDWR); tmpFile.read(readbuf, ::strlen(testbuf)); tmpFile.close(); tmpFile.remove(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { TEST_FAIL(e.what()); } } TESTCASE(DirOperation) { - runtime::File testDir("/tmp/dpm-unit-test/dir"); + klay::File testDir("/tmp/dpm-unit-test/dir"); try { testDir.makeDirectory(true, ::getuid(), ::getgid()); testDir.chown(::getuid(), ::getgid(), false); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { TEST_FAIL(e.what()); } - runtime::File dir("/tmp/dpm-unit-test"); + klay::File dir("/tmp/dpm-unit-test"); try { dir.chmod(777, true); dir.remove(true); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { TEST_FAIL(e.what()); } } TESTCASE(FileAttribute) { - runtime::File tmp("/tmp"); + klay::File tmp("/tmp"); TEST_EXPECT(true, tmp.exists()); TEST_EXPECT(true, tmp.canRead()); @@ -111,7 +111,7 @@ TESTCASE(FileAttribute) TESTCASE(FileAttributeNegative) { try { - runtime::File tmp("/unknown"); + klay::File tmp("/unknown"); TEST_EXPECT(false, tmp.exists()); TEST_EXPECT(false, tmp.canRead()); @@ -120,43 +120,43 @@ TESTCASE(FileAttributeNegative) try { tmp.isLink(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { tmp.isFile(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { tmp.isDirectory(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { tmp.isDevice(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } } TESTCASE(FileDevice) { - runtime::File tmp("/dev/kmem"); + klay::File tmp("/dev/kmem"); TEST_EXPECT(true, tmp.isDevice()); } TESTCASE(FileSymlinkTest) { - runtime::File tmp("/var"); + klay::File tmp("/var"); TEST_EXPECT(true, tmp.isLink()); } TESTCASE(FileReferenceTest) { - runtime::File one("/tmp"); - runtime::File two(one); + klay::File one("/tmp"); + klay::File two(one); } diff --git a/test/logger.cpp b/test/logger.cpp index 0363344..b215f20 100644 --- a/test/logger.cpp +++ b/test/logger.cpp @@ -39,7 +39,7 @@ TESTCASE(LogSeverityTest) { try { audit::LogLevelToString((audit::LogLevel)-1); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } } diff --git a/test/misc.cpp b/test/misc.cpp index 16bf79a..519d58d 100644 --- a/test/misc.cpp +++ b/test/misc.cpp @@ -25,5 +25,5 @@ TESTCASE(ErrorMessage) { - std::cout << "Error Message: " << runtime::GetSystemErrorMessage(EINTR) << std::endl; + std::cout << "Error Message: " << klay::GetSystemErrorMessage(EINTR) << std::endl; } diff --git a/test/proc.cpp b/test/proc.cpp index 429ff43..034e666 100644 --- a/test/proc.cpp +++ b/test/proc.cpp @@ -30,61 +30,61 @@ TESTCASE(ProcWithArg) "-l", "-a" }; - runtime::Process proc("/bin/ls > /dev/null", args); + klay::Process proc("/bin/ls > /dev/null", args); TEST_EXPECT(true, proc.execute() != -1); proc.waitForFinished(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } } TESTCASE(ProcKill) { try { - runtime::Process proc("/opt/data/unittest-proc.sh"); + klay::Process proc("/opt/data/unittest-proc.sh"); TEST_EXPECT(true, proc.execute() != -1); if (proc.isRunning()) { proc.kill(); proc.waitForFinished(); } - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } } TESTCASE(ProcTerminate) { try { - runtime::Process proc("/opt/data/unittest-proc.sh"); + klay::Process proc("/opt/data/unittest-proc.sh"); TEST_EXPECT(true, proc.execute() != -1); if (proc.isRunning()) { proc.terminate(); proc.waitForFinished(); } - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } } TESTCASE(ProcInvalidProcess) { try { - runtime::Process proc(TEST_DATA_DIR "test-proc.sh"); + klay::Process proc(TEST_DATA_DIR "test-proc.sh"); TEST_EXPECT(true, proc.execute() != -1); proc.terminate(); proc.waitForFinished(); TEST_EXPECT(false, proc.isRunning()); try { proc.kill(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { proc.terminate(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } try { proc.waitForFinished(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } } diff --git a/test/rmi.cpp b/test/rmi.cpp index d8b0a33..b1563c2 100644 --- a/test/rmi.cpp +++ b/test/rmi.cpp @@ -54,8 +54,8 @@ public: service->expose(this, "", (std::string)(TestServer::method3)(std::string, std::string, std::string)); service->expose(this, "", (std::string)(TestServer::method4)(std::string, std::string, std::string, std::string)); - service->expose(this, "", (runtime::FileDescriptor)(TestServer::signalProvider)(std::string)); - service->expose(this, "", (runtime::FileDescriptor)(TestServer::policyNotificationProvider)(std::string)); + service->expose(this, "", (klay::FileDescriptor)(TestServer::signalProvider)(std::string)); + service->expose(this, "", (klay::FileDescriptor)(TestServer::policyNotificationProvider)(std::string)); service->expose(this, "", (int)(TestServer::sendSignal)()); service->expose(this, "", (int)(TestServer::sendPolicyChangeNotification)()); @@ -103,12 +103,12 @@ public: return 0; } - runtime::FileDescriptor signalProvider(const std::string& name) + klay::FileDescriptor signalProvider(const std::string& name) { return service->subscribeNotification(name); } - runtime::FileDescriptor policyNotificationProvider(const std::string& name) + klay::FileDescriptor policyNotificationProvider(const std::string& name) { return service->subscribeNotification(name); } @@ -303,7 +303,7 @@ public: TestClient client; client.connect(); client.disconnect(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { ERROR(KSINK, e.what()); } } @@ -318,7 +318,7 @@ public: client.requestPolicyChangeNotification(); client.disconnect(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { ERROR(KSINK, e.what()); } } @@ -343,7 +343,7 @@ public: client.requestPolicyChangeNotification(); client.disconnect(); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { ERROR(KSINK, e.what()); } } diff --git a/test/xml.cpp b/test/xml.cpp index b0812f4..4de40f9 100644 --- a/test/xml.cpp +++ b/test/xml.cpp @@ -45,7 +45,7 @@ TESTCASE(XPath) while (iter != nodes.end()) { ++iter; } - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { TEST_FAIL(e.what()); } } @@ -65,7 +65,7 @@ TESTCASE(XmlDomTree) while (iter != list.end()) { ++iter; } - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { TEST_FAIL(e.what()); } } @@ -88,7 +88,7 @@ TESTCASE(XmlGenerate) TEST_EXPECT("Value", node.getProp("Prop")); doc.write("/tmp/test.xml", "UTF-8", true); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { TEST_FAIL(e.what()); } } @@ -97,6 +97,6 @@ TESTCASE(XmlException) { try { xml::Parser::parseFile("Invalid Source"); - } catch (runtime::Exception& e) { + } catch (klay::Exception& e) { } }