Skip to content

Commit

Permalink
Fixes to pure virtual classes, cody style and minor issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciusferrao committed Jul 2, 2023
1 parent e611ed3 commit d5fb7ea
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 31 deletions.
18 changes: 4 additions & 14 deletions src/NFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@

using cloyster::runCommand;

// @TODO: Constructors should be chained and m_permissions should be an enum
NFS::NFS(const std::string& directoryName, const std::string& directoryPath,
const boost::asio::ip::address& address)
: m_directoryName(directoryName)
, m_directoryPath(directoryPath)
, m_address(address)
{
setFullPath();
m_permissions = "ro";
}

NFS::NFS(const std::string& directoryName, const std::string& directoryPath,
const boost::asio::ip::address& address, const std::string& permissions)
: m_directoryName(directoryName)
Expand All @@ -38,13 +27,14 @@ void NFS::setFullPath()

void NFS::configure()
{
std::string_view filename = CHROOT "/etc/exports";
const std::string_view filename = CHROOT "/etc/exports";
cloyster::backupFile(filename);
cloyster::addStringToFile(filename,
// @TODO make fsid dynamic
fmt::format("/home *(rw,no_subtree_check,fsid=10,no_root_squash)\n"
"{} *({},fsid={})\n", m_fullPath, m_permissions, 11));

"{} *({},fsid={})\n",
m_fullPath, m_permissions, 11));

runCommand("exportfs -a");

// @FIXME: Create a file using std::filesystem and not with touch
Expand Down
20 changes: 10 additions & 10 deletions src/NFS.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//
// Created by Lucas Gracioso <[email protected]> on 6/19/23.
//
/*
* Copyright 2023 Vinícius Ferrão <[email protected]>
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef CLOYSTERHPC_NFS_H_
#define CLOYSTERHPC_NFS_H_
Expand All @@ -9,7 +10,7 @@
#include <boost/asio.hpp>
#include <string>

class NFS : IService {
class NFS : public IService {
private:
std::string m_directoryName;
std::string m_directoryPath;
Expand All @@ -18,16 +19,15 @@ class NFS : IService {
boost::asio::ip::address m_address;

public:
NFS(const std::string& directoryName, const std::string& directoryPath,
const boost::asio::ip::address& address);
NFS(const std::string& directoryName, const std::string& directoryPath,
const boost::asio::ip::address& address,
const std::string& permissions);

void configure();
void enable();
void disable();
void start();
void stop();
void enable() final;
void disable() final;
void start() final;
void stop() final;

private:
void setFullPath();
Expand Down
16 changes: 10 additions & 6 deletions src/services/IService.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
//
// Created by Lucas Gracioso <[email protected]> on 6/26/23.
//
/*
* Copyright 2023 Vinícius Ferrão <[email protected]>
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef CLOYSTERHPC_ISERVICE_H_
#define CLOYSTERHPC_ISERVICE_H_

class IService {
public:
protected:
virtual void enable() = 0;
virtual void disable() = 0;
[[maybe_unused]] virtual void disable() = 0;
virtual void start() = 0;
virtual void stop() = 0;
[[maybe_unused]] virtual void stop() = 0;

public:
virtual ~IService() = default;
};

#endif // CLOYSTERHPC_ISERVICE_H_
2 changes: 1 addition & 1 deletion src/services/shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void Shell::configureNetworks(const std::list<Connection>& connections)
std::vector<address> nameservers
= connection.getNetwork()->getNameservers();
std::vector<std::string> formattedNameservers;
for (int i = 0; i < nameservers.size(); i++) {
for (std::size_t i = 0; i < nameservers.size(); i++) {
formattedNameservers.emplace_back(nameservers[i].to_string());
}

Expand Down

0 comments on commit d5fb7ea

Please sign in to comment.