From f5e22c040bb68f9ac2dcfd38cf144c86e54bfdeb Mon Sep 17 00:00:00 2001 From: Vadim Kurland Date: Mon, 20 Jun 2011 14:56:28 -0700 Subject: [PATCH] see #2477 removed transfer agent classes and functions --- doc/ChangeLog | 3 + src/fwtransfer/TransferDevice.cpp | 393 -------------- src/fwtransfer/TransferDevice.h | 395 -------------- src/fwtransfer/fwtransfer.pro | 18 - src/gui/gui.pro | 17 +- src/libgui/FWWindow.cpp | 15 - src/libgui/FWWindow.h | 2 - src/libgui/ObjectManipulator.cpp | 32 -- src/libgui/ObjectManipulator.h | 1 - src/libgui/ObjectManipulator_slots.cpp | 11 - src/libgui/ProjectPanel.cpp | 10 - src/libgui/ProjectPanel.h | 2 - src/libgui/libgui.pro | 8 +- src/libgui/transferDialog.cpp | 482 ------------------ src/libgui/transferDialog.h | 140 ----- src/libgui/transferdialog_q.ui | 393 -------------- src/src.pro | 2 - src/transfer_agents/secuwall/secuwall.pro | 35 -- .../secuwall/transfer_secuwall.cpp | 383 -------------- src/transfer_agents/transfer_agents.pro | 10 - 20 files changed, 16 insertions(+), 2336 deletions(-) delete mode 100644 src/fwtransfer/TransferDevice.cpp delete mode 100644 src/fwtransfer/TransferDevice.h delete mode 100644 src/fwtransfer/fwtransfer.pro delete mode 100644 src/libgui/transferDialog.cpp delete mode 100644 src/libgui/transferDialog.h delete mode 100644 src/libgui/transferdialog_q.ui delete mode 100644 src/transfer_agents/secuwall/secuwall.pro delete mode 100644 src/transfer_agents/secuwall/transfer_secuwall.cpp delete mode 100644 src/transfer_agents/transfer_agents.pro diff --git a/doc/ChangeLog b/doc/ChangeLog index b8fe68351..a10c7c942 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,5 +1,8 @@ 2011-06-20 Vadim Kurland + * src.pro (SUBDIRS): see #2477 removed transfer agent + code. + * gui.pro: see #2506 Removed obsolete localization files (Russian and Japanese). These were incomplete and have never been updated for v4. diff --git a/src/fwtransfer/TransferDevice.cpp b/src/fwtransfer/TransferDevice.cpp deleted file mode 100644 index 923fa5a62..000000000 --- a/src/fwtransfer/TransferDevice.cpp +++ /dev/null @@ -1,393 +0,0 @@ -/* - * TransferDevice.cpp - fwtransfer library implementation - * - * Copyright (c) 2008 secunet Security Networks AG - * Copyright (c) 2008 Adrian-Ken Rueegsegger - * Copyright (c) 2008 Reto Buerki - * - * This work is dual-licensed under: - * - * o The terms of the GNU General Public License as published by the Free - * Software Foundation, either version 2 of the License, or (at your option) - * any later version. - * - * o The terms of NetCitadel End User License Agreement - */ - -#include -#include -#include - -#include -#ifdef HAVE_UNISTD_H -#include -#endif - -#include -#include -#include - -#include "TransferDevice.h" - -using namespace fwtransfer; -using namespace libfwbuilder; - -#ifdef HAVE_QTDBUS - -#include -#include - -QVariant getProperty(QDBusInterface &interface, QString prop) - throw(FWException) -{ - QDBusMessage msg = interface.call("GetProperty", prop); - if (msg.type() == QDBusMessage::ErrorMessage) - { - throw FWException(interface.path().toStdString() + - ": could not get property => " + prop.toStdString()); - } - QVariant ret = msg.arguments()[0]; - return ret; -} - -QString TransferDevice::getVolumeSizeStr() const -{ - // get size in bytes - qlonglong size = getVolumeSize(); - QString size_str; - QString unit = "KB"; - QVariant size_v; - - if (size != 0) - { - // smallest unit is kb - size = size / 1024; - size_v = size; - if (size > 1024) - { - size = size / 1024; - size_v = size; - unit = "MB"; - } - if (size > 1024) - { - float f_size = float(size) / 1024; - size_v = floor(f_size * 100.0 + 0.5) / 100; - unit = "GB"; - } - size_str = size_v.toString() + " " + unit; - } - else - { - size_str = "0"; - } - return size_str; -} - -void TransferDevice::dump() const -{ - // header - qDebug() << "( dump of transfer device " << getDeviceName() << " )"; - - // actual dump - QString mounted = is_mounted ? "yes" : "no"; - QString removable = is_removable ? "yes" : "no"; - QString hotpluggable = is_hotpluggable ? "yes" : "no"; - - qDebug() << "volume UDI\t:\t" + getVolumeUDI(); - qDebug() << "fstype\t\t:\t" + getVolumeFS(); - qDebug() << "size (MB)\t:\t" + getVolumeSizeStr(); - qDebug() << "device UDI\t:\t" + getDeviceUDI(); - qDebug() << "device\t\t:\t" + getDeviceName(); - qDebug() << "bus\t\t:\t" + getDeviceBus(); - qDebug() << "type\t\t:\t" + getDeviceType(); - qDebug() << "mountpoint\t:\t" + getMountpoint(); - qDebug() << "mounted\t:\t" + mounted; - qDebug() << "removable\t:\t" + removable; - qDebug() << "hotpluggable\t:\t" + hotpluggable; - qDebug(); -} - -void TransferDevice::mount() throw(FWException) -{ - // ignore request if already mounted - if (is_mounted) - { - return; - } - - QDBusConnection conn = QDBusConnection::systemBus(); - - QDBusInterface mountiface("org.freedesktop.Hal", getVolumeUDI(), - "org.freedesktop.Hal.Device.Volume", conn); - - QStringList options; - -#ifndef WIN32 - // special mount options for vfat filesystems - if (getVolumeFS() == "vfat") - { - QVariant user_v = getuid(); - QString user = "uid=" + user_v.toString(); - - options << "quiet" << "shortname=mixed" << user << "umask=077"; - } -#endif - - // send mount DBus message - QDBusMessage replyMsg = mountiface.call("Mount", "", "", options); - if (replyMsg.type() == QDBusMessage::ErrorMessage) - { - qDebug() << "Could not mount : " << - replyMsg.errorMessage() << ", " << - replyMsg.errorName(); - throw FWException(replyMsg.errorName().toStdString() + " : " + - replyMsg.errorMessage().toStdString()); - } - else - { - // re-read mountpoint - QDBusInterface volumeiface("org.freedesktop.Hal", getVolumeUDI(), - "org.freedesktop.Hal.Device", conn); - setMountpoint(getProperty(volumeiface, "volume.mount_point").toString()); - } -} - -void TransferDeviceList::init() throw(FWException) -{ - if (!checkDBus()) - { - throw FWException("Cannot connect to the D-BUS system bus."); - } - - QDBusInterface hal("org.freedesktop.Hal", - "/org/freedesktop/Hal/Manager", - "org.freedesktop.Hal.Manager", - QDBusConnection::systemBus()); - - // clear 'old' devices - clear(); - - // get all volumes from HAL - QDBusMessage msg = hal.call("FindDeviceByCapability", "volume"); - - QList volumes = msg.arguments(); - - foreach (QVariant name, volumes) - { - QStringList volume_list = name.toStringList(); - foreach (QString vol, volume_list) - { - addNewVolume(vol); - } - } - - bool success; - // connect HAL signals to our observer slots - success = hal.connection().connect("org.freedesktop.Hal", - "/org/freedesktop/Hal/Manager", - "org.freedesktop.Hal.Manager", - "DeviceAdded", this, - SLOT(newDeviceDetected(const QString &))); - - if (!success) - { - throw FWException("Cannot subscribe to HAL 'DeviceAdded' signal."); - } - - success = hal.connection().connect("org.freedesktop.Hal", - "/org/freedesktop/Hal/Manager", - "org.freedesktop.Hal.Manager", - "DeviceRemoved", this, - SLOT(deviceRemovedDetected(const QString &))); - - if (!success) - { - throw FWException("Cannot subscribe to HAL 'DeviceRemoved' signal."); - } -} - -void TransferDeviceList::dump() const -{ - TransferDeviceList::const_iterator it; - for (it = this->begin(); it != this->end(); it++) - { - (*it).dump(); - } -} - -bool TransferDeviceList::checkDBus() const -{ - if (!QDBusConnection::systemBus().isConnected()) - { - fprintf(stderr, "Cannot connect to the D-BUS system bus.\n"); - return false; - } - return true; -} - -bool TransferDeviceList::addNewVolume(const QString &udi) -{ - QDBusConnection conn = QDBusConnection::systemBus(); - QDBusInterface volume("org.freedesktop.Hal", udi, - "org.freedesktop.Hal.Device", conn); - - // only consider volumes for addition - QVariant is_volume; - try - { - // getProperty throws an exception if property is not there - is_volume = getProperty(volume, "block.is_volume"); - } - catch (FWException &ex) - { - return false; - } - // property is there, but still it is not a volume - if (!is_volume.toBool()) - { - return false; - } - - // read in new volume/device - TransferDevice new_device; - new_device.setVolumeUDI(udi); - - - // get physical device UDI and path for volume - new_device.setDeviceUDI(getProperty(volume, - "block.storage_device").toString()); - new_device.setDeviceName(getProperty(volume, - "block.device").toString()); - - // check if its already mounted - new_device.setMounted(getProperty(volume, - "volume.is_mounted").toBool()); - // if mounted, read mountpoint - if (new_device.isMounted()) - { - new_device.setMountpoint(getProperty(volume, - "volume.mount_point").toString()); - } - - // volume filesystem type - new_device.setVolumeFS(getProperty(volume, - "volume.fstype").toString()); - - // volume size - new_device.setVolumeSize(getProperty(volume, - "volume.size").toLongLong()); - - // get properties for storage device - QDBusInterface device("org.freedesktop.Hal", - new_device.getDeviceUDI(), - "org.freedesktop.Hal.Device", conn); - - new_device.setDeviceBus(getProperty(device, - "storage.bus").toString()); - new_device.setRemovable(getProperty(device, - "storage.removable").toBool()); - new_device.setDeviceType(getProperty(device, - "storage.drive_type").toString()); - new_device.setHotpluggable(getProperty(device, - "storage.hotpluggable").toBool()); - - // only store portable usb based volumes - if (new_device.isHotpluggable() && - new_device.isRemovable() && - new_device.getDeviceBus() == "usb" && - new_device.getDeviceType() == "disk") - { - push_back(new_device); - } - return true; -} - -bool TransferDeviceList::removeVolume(const QString &udi) -{ - TransferDeviceList::iterator it; - PredFindVolumeUDI pred; - pred.setSearchString(udi); - it = find_if(begin(), end(), pred); - - // not found - if (it == end()) - { - return false; - } - // remove volume - erase(it); - return true; -} - -TransferDeviceList::const_iterator -TransferDeviceList::getDeviceByName(const QString &name) const -{ - TransferDeviceList::const_iterator it; - PredFindName pred; - pred.setSearchString(name); - it = find_if(begin(), end(), pred); - return it; -} - -TransferDeviceList::const_iterator -TransferDeviceList::getDeviceByName(const std::string &name) const -{ - return getDeviceByName(QString(name.c_str())); -} - -void TransferDeviceList::newDeviceDetected(const QString &udi) -{ - // add this volume/device to the list - if (addNewVolume(udi)) - { - // qDebug() << "TransferDeviceList : DeviceAdded : " << udi; - emit devicesChanged(); - } -} - -void TransferDeviceList::deviceRemovedDetected(const QString &udi) -{ - if (removeVolume(udi)) - { - // qDebug() << "TransferDeviceList : DeviceRemoved : " << udi; - emit devicesChanged(); - } -} - -#else - -#ifndef _WIN32 -#warning "QT D-BUS support not available!" -#endif - -QString TransferDevice::getVolumeSizeStr() const { return ""; } - -void TransferDevice::dump() const {} - -void TransferDevice::mount() throw(FWException) -{ - throw FWException("Cannot connect to the D-BUS system bus."); -} - -void TransferDeviceList::init() throw(FWException) -{ - throw FWException("Cannot connect to the D-BUS system bus."); -} - -TransferDeviceList::const_iterator -TransferDeviceList::getDeviceByName(const QString&) const -{ - return end(); -} - -TransferDeviceList::const_iterator -TransferDeviceList::getDeviceByName(const std::string&) const -{ - return end(); -} - -void TransferDeviceList::dump() const -{} - -#endif diff --git a/src/fwtransfer/TransferDevice.h b/src/fwtransfer/TransferDevice.h deleted file mode 100644 index c96862a00..000000000 --- a/src/fwtransfer/TransferDevice.h +++ /dev/null @@ -1,395 +0,0 @@ -/* - * TransferDevice.cpp - QDBus based config transfer library - * - * Copyright (c) 2008 secunet Security Networks AG - * Copyright (c) 2008 Adrian-Ken Rueegsegger - * Copyright (c) 2008 Reto Buerki - * - * This work is dual-licensed under: - * - * o The terms of the GNU General Public License as published by the Free - * Software Foundation, either version 2 of the License, or (at your option) - * any later version. - * - * o The terms of NetCitadel End User License Agreement - */ - -#ifndef __TRANSFER_DEVICE_HH__ -#define __TRANSFER_DEVICE_HH__ - -#include -#include -#include - -#include "../../config.h" -#include "fwbuilder/FWException.h" - -namespace fwtransfer -{ - - class DeviceObserver; - - /** - * @class TransferDevice - * - * @brief This class represents a device for firewall config transfer. - * - * The TransferDevice class can be used to store information about transfer - * volumes/devices. TransferDevices provide different setter/getter functions - * to set/get information about devices and volumes. TransferDevice objects - * provides a dump() function to dump the currently stored info and also a - * mount() function to actually mount the volume. - */ - class TransferDevice - { - public: - TransferDevice() : - volume_udi(QString()), - volume_fs(QString()), - volume_size(0), - device_udi(QString()), - device_name(QString()), - device_bus(QString()), - device_type(QString()), - mountpoint(QString()), - is_mounted(false), - is_removable(false), - is_hotpluggable(false) {}; - - /** - * set volume UDI for transfer device. - * - * @param udi volume UDI - */ - void setVolumeUDI(QString udi) { volume_udi = udi; }; - - /** - * get volume UDI for transfer device. - * - * @return volume UDI - */ - QString getVolumeUDI() const { return volume_udi; }; - - /** - * set filesystem type for transfer device (e.g. "ext3"). - * - * @param fs filesystem type - */ - void setVolumeFS(QString fs) { volume_fs = fs; }; - - /** - * get filesystem type of transfer device. - * - * @return filesystem type - */ - QString getVolumeFS() const { return volume_fs; }; - - /** - * set volume size for transfer device. - * - * @param fs filesystem type - */ - void setVolumeSize(qlonglong size) { volume_size = size; }; - - /** - * get volume size for volume of transfer device as qlonglong. - * - * @return filesystem size in bytes - */ - qlonglong getVolumeSize() const { return volume_size; }; - - /** - * get volume size for volume of transfer device as QString. - * - * @return filesystem size in human readable string format - */ - QString getVolumeSizeStr() const; - - /** - * set device UDI for transfer device. - * - * @param udi device UDI - */ - void setDeviceUDI(QString udi) { device_udi = udi; }; - - /** - * get device UDI for transfer device. - * - * @return device UDI - */ - QString getDeviceUDI() const { return device_udi; }; - - /** - * set device name for transfer device (e.g. /dev/sdc1). - * - * @param name device name - */ - void setDeviceName(QString name) { device_name = name; }; - - /** - * get device name of transfer device. - * - * @return device name - */ - QString getDeviceName() const { return device_name; }; - - /** - * set bus type used by transfer device (e.g. "usb"). - * - * @param bus type of bus device is attached to (pci, usb, ...) - */ - void setDeviceBus(QString bus) { device_bus = bus; }; - - /** - * get bus type of transfer device. - * - * @return bus type - */ - QString getDeviceBus() const { return device_bus; }; - - /** - * set transfer device type (e.g. "disk"). - * - * @param type transfer device storage type - */ - void setDeviceType(QString type) { device_type = type; }; - - /** - * get storage type of this transfer device. - * - * @return storage device type - */ - QString getDeviceType() const { return device_type; }; - - /** - * set mount point for transfer device (e.g. "/media/disk"). - * - * @param path mount point of transfer device - */ - void setMountpoint(QString path) { mountpoint = path; }; - - /** - * get mount point path of transfer device. - * - * @return mount point path - */ - QString getMountpoint() const { return mountpoint; }; - - /** - * set mounted flag to true or false depending on whether transfer - * device volume is mounted or not. - * - * @param flag mounted status of volume - */ - void setMounted(bool flag) { is_mounted = flag; }; - - /** - * determines whether transfer device volume is already mounted or not. - * - * @return true if mounted, false if not - */ - bool isMounted() const { return is_mounted; }; - - /** - * set removable flag to true or false depending on whether device can - * be removed or not. - * - * @param flag removable status flag of device - */ - void setRemovable(bool flag) { is_removable = flag; }; - - /** - * determines whether device can be removed or not. - * - * @return true if portable, false if not - */ - bool isRemovable() const { return is_removable; }; - - /** - * set hotpluggable flag to true or false depending on whether device is - * hotpluggable. - * - * @param flag hotpluggable status flag of device - */ - void setHotpluggable(bool flag) { is_hotpluggable = flag; }; - - /** - * determines whether device is hotpluggable. - * - * @return true if yes, false if not - */ - bool isHotpluggable() const { return is_hotpluggable; }; - - /** - * debug function to dump transfer device settings. - */ - void dump() const; - - /** - * mount transfer device - * - * @throw libfwbuilder::FWException could not mount exception - */ - void mount() throw(libfwbuilder::FWException); - - private: - QString volume_udi; - QString volume_fs; - qlonglong volume_size; - QString device_udi; - QString device_name; - QString device_bus; - QString device_type; - QString mountpoint; - bool is_mounted; - bool is_removable; - bool is_hotpluggable; - }; - - /** - * @class TransferDeviceList - * - * @brief An TransferDeviceList is used to manage transfer devices of a system. - * - * An TransferDeviceList stores all available transfer volumes. It also - * provides a devicesChanged signal which can be used to track list changes. - * This signal is emitted when HAL detects a new device (DeviceAdded) or - * a device has vanished (DeviceRemoved). Users of an TransferDeviceList - * object can connect a slot to this signal to react to this event. - */ - class TransferDeviceList : public QObject, public std::list - { - Q_OBJECT - - public: - /** TransferDeviceList ctor */ - TransferDeviceList(QObject * parent = 0) : QObject(parent) {}; - - /** TransferDeviceList dtor */ - virtual ~TransferDeviceList() {}; - - /** - * init list of volumes/devices. only usb based, portable volumes - * are added to the list. Previously added transfer devices will be - * cleared from the list before adding new ones. - * - * @throw libfwbuilder::FWException DBus not available exception - */ - void init() throw(libfwbuilder::FWException); - - /** - * return specific TransferDevice identified by volume name. - * - * @param volumeid id of volume as QString (e.g. /dev/sdc1) - * @return iterator pointing to requested TransferDevice - * - */ - TransferDeviceList::const_iterator - getDeviceByName(const QString &name) const; - - /** - * return specific TransferDevice identified by volume name. - * - * @param volumeid id of volume as string (e.g. /dev/sdc1) - * @return iterator pointing to requested TransferDevice - * - */ - TransferDeviceList::const_iterator - getDeviceByName(const std::string &name) const; - - /** - * dump data of all managed transfer devices. - */ - void dump() const; - - private: - -#ifdef HAVE_QTDBUS - /** - * check DBus availability. - */ - bool checkDBus() const; - - /** - * add a new transfer volume with given volume UDI. - * - * @param udi UDI of the volume to add. - * @return true if successfully added, false if not - */ - bool addNewVolume(const QString &udi); - - /** - * remove an existing volume identified by UDI from the list. - * - * @param udi UDI of the volume to add. - * @return true if successfully removed, false if not found - */ - bool removeVolume(const QString &udi); - - private slots: - void newDeviceDetected(const QString &udi); - void deviceRemovedDetected(const QString &udi); - - signals: - void devicesChanged(); - -#endif - }; - - /** - * @class PredFindName - * - * @brief Predicate class to find device name in TransferDevice. - * - * PredFindName can be used e.g. as parameter in find_if() function to - * compare TransferDevices in TransferDeviceList with a given device name - * specified by setSearchString(). - */ - class PredFindName - { - protected: - QString search_string; - public: - PredFindName() {}; - - bool operator()(const TransferDevice dev) const - { - return (dev.getDeviceName() == search_string); - } - - void setSearchString(const QString &string) - { - search_string = string; - } - }; - - /** - * @class PredFindVolumeUDI - * - * @brief Predicate class to find volume UDI in TransferDevice. - * - * PredFindVolumeUDI can be used e.g. as parameter in find_if() function to - * compare TransferDevices in TransferDeviceList with a given volume UDI - * specified by setSearchString(). - */ - class PredFindVolumeUDI - { - protected: - QString search_string; - public: - PredFindVolumeUDI() {}; - - bool operator()(const TransferDevice dev) const - { - return (dev.getVolumeUDI() == search_string); - } - - void setSearchString(const QString &string) - { - search_string = string; - } - }; -} - -#endif /* __TRANSFER_DEVICE_HH__ */ - diff --git a/src/fwtransfer/fwtransfer.pro b/src/fwtransfer/fwtransfer.pro deleted file mode 100644 index 290d2a334..000000000 --- a/src/fwtransfer/fwtransfer.pro +++ /dev/null @@ -1,18 +0,0 @@ -#-*- mode: makefile; tab-width: 4; -*- -# -include(../../qmake.inc) -# -TEMPLATE = lib -# -INCLUDEPATH += ../libfwbuilder/src -DEPENDPATH += ../libfwbuilder/src - -SOURCES = TransferDevice.cpp - -HEADERS = TransferDevice.h - -CONFIG += staticlib - -TARGET = fwtransfer - -INSTALLS -= target diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 12f8c2bd7..baacaaf85 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -14,7 +14,7 @@ SOURCES += main.cpp IMPORT_LIB = ../import/$$BINARY_SUBDIR/libimport.a FWBPARSER_LIB = ../parsers/$$BINARY_SUBDIR/libfwbparser.a -FWTRANSFER_LIB = ../fwtransfer/$$BINARY_SUBDIR/libfwtransfer.a +# FWTRANSFER_LIB = ../fwtransfer/$$BINARY_SUBDIR/libfwtransfer.a INCLUDEPATH += $$ANTLR_INCLUDEPATH DEFINES += $$ANTLR_DEFINES @@ -23,13 +23,14 @@ STATIC_LIBS += ../libgui/$$BINARY_SUBDIR/libgui.a \ $$IMPORT_LIB $$FWBPARSER_LIB $$ANTLR_LIBS # fwtransfer lib. Add this before adding -lQtDBus to LIBS below -STATIC_LIBS += $$FWTRANSFER_LIB -contains( HAVE_QTDBUS, 1 ):unix { - !macx:QT += network \ - dbus - macx:STATIC_LIBS += -framework \ - QtDBus -} +# STATIC_LIBS += $$FWTRANSFER_LIB + +# contains( HAVE_QTDBUS, 1 ):unix { +# !macx:QT += network \ +# dbus +# macx:STATIC_LIBS += -framework \ +# QtDBus +# } # !macx:STATIC_LIBS += -lQtDBus # workaround for QT += dbus not working with Qt < 4.4.0 diff --git a/src/libgui/FWWindow.cpp b/src/libgui/FWWindow.cpp index 80eaeed94..ba2f5e274 100644 --- a/src/libgui/FWWindow.cpp +++ b/src/libgui/FWWindow.cpp @@ -69,8 +69,6 @@ #include "HttpGet.h" #include "StartTipDialog.h" -#include "transferDialog.h" - #include "events.h" #include "importAddressListWizard/ImportAddressListWizard.h" @@ -1780,19 +1778,6 @@ void FWWindow::inspect() } } -void FWWindow::transferfw(set vf) -{ - transferDialog *ed = new transferDialog(NULL, vf); - ed->show(); -} - -void FWWindow::transferfw() -{ - std::set emp; - transferDialog *ed = new transferDialog(NULL, emp); - ed->show(); -} - void FWWindow::addNewObjectMenu(QMenu *m) { QMenu *old_menu = m_mainWindow->newObjectAction->menu(); diff --git a/src/libgui/FWWindow.h b/src/libgui/FWWindow.h index dfeea78a5..b702aa217 100644 --- a/src/libgui/FWWindow.h +++ b/src/libgui/FWWindow.h @@ -204,8 +204,6 @@ public slots: virtual void install(std::set vf); virtual void install(); virtual void inspect(); - virtual void transferfw(std::set vf); - virtual void transferfw(); virtual void insertRule(); virtual void addRuleAfterCurrent(); diff --git a/src/libgui/ObjectManipulator.cpp b/src/libgui/ObjectManipulator.cpp index ab9d1d883..c042bb8a7 100644 --- a/src/libgui/ObjectManipulator.cpp +++ b/src/libgui/ObjectManipulator.cpp @@ -820,38 +820,6 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos) popup_menu->addAction( tr("Compile"), this, SLOT( compile())); popup_menu->addAction( tr("Install"), this, SLOT( install())); popup_menu->addAction( tr("Inspect"), this, SLOT( inspect())); - - if (Firewall::cast(currentObj)!=NULL) - { - Resources* os_res = Resources::os_res[currentObj->getStr("host_OS")]; - if (os_res) - { - string transfer = os_res->getTransferAgent(); - if (!transfer.empty()) - popup_menu->addAction( tr("Transfer"), this, SLOT(transferfw())); - } - } - - if (ObjectGroup::cast(currentObj)!=NULL && - currentObj->getName()=="Firewalls") - { - // Config transfer is currently only supported for Secuwall. - // Check if we have any - bool have_transfer_support = false; - for (FWObject::iterator it=currentObj->begin(); - it!=currentObj->end(); ++it) - { - FWObject *fw = *it; - Resources* os_res = Resources::os_res[fw->getStr("host_OS")]; - if (os_res) - { - string transfer = os_res->getTransferAgent(); - have_transfer_support = have_transfer_support || (!transfer.empty()); - } - } - if (have_transfer_support) - popup_menu->addAction( tr("Transfer"), this, SLOT(transferfw())); - } } popup_menu->addSeparator(); diff --git a/src/libgui/ObjectManipulator.h b/src/libgui/ObjectManipulator.h index 42c426894..da5b54e84 100644 --- a/src/libgui/ObjectManipulator.h +++ b/src/libgui/ObjectManipulator.h @@ -251,7 +251,6 @@ public slots: void compile(); void install(); void inspect(); - void transferfw(); void duplicateObj(QAction*); void moveObj(QAction*); diff --git a/src/libgui/ObjectManipulator_slots.cpp b/src/libgui/ObjectManipulator_slots.cpp index 8e9c7d94e..4bd9262eb 100644 --- a/src/libgui/ObjectManipulator_slots.cpp +++ b/src/libgui/ObjectManipulator_slots.cpp @@ -412,17 +412,6 @@ void ObjectManipulator::inspect() m_project->inspect(fwset); } -void ObjectManipulator::transferfw() -{ - if (getCurrentObjectTree()->getNumSelected()==0) return; - - vector so = getCurrentObjectTree()->getSimplifiedSelection(); - set fo; - filterFirewallsFromSelection(so, fo); - - m_project->transferfw(fo); -} - void ObjectManipulator::find() { if (getCurrentObjectTree()->getNumSelected()==0) return; diff --git a/src/libgui/ProjectPanel.cpp b/src/libgui/ProjectPanel.cpp index 64a36550a..b529e2889 100644 --- a/src/libgui/ProjectPanel.cpp +++ b/src/libgui/ProjectPanel.cpp @@ -991,16 +991,6 @@ void ProjectPanel::inspect(set fws) viewer->show(); } -void ProjectPanel::transferfw(set vf) -{ - mainW->transferfw(vf); -} - -void ProjectPanel::transferfw() -{ - mainW->transferfw(); -} - QString ProjectPanel::printHeader() { QString headerText = rcs->getFileName().section("/",-1,-1); diff --git a/src/libgui/ProjectPanel.h b/src/libgui/ProjectPanel.h index dae78abba..91a390463 100644 --- a/src/libgui/ProjectPanel.h +++ b/src/libgui/ProjectPanel.h @@ -277,8 +277,6 @@ public: virtual void install(std::set vf); virtual void install(); virtual void inspect(std::set vf); - virtual void transferfw(std::set vf); - virtual void transferfw(); void splitterMoved ( int pos, int index ); diff --git a/src/libgui/libgui.pro b/src/libgui/libgui.pro index c268ded1c..24ba8a4c2 100644 --- a/src/libgui/libgui.pro +++ b/src/libgui/libgui.pro @@ -578,9 +578,9 @@ FORMS = FWBMainWindow_q.ui \ # fwtransfer stuff. -HEADERS += transferDialog.h -SOURCES += transferDialog.cpp -FORMS += transferdialog_q.ui +# HEADERS += transferDialog.h +# SOURCES += transferDialog.cpp +# FORMS += transferdialog_q.ui # !macx:LIBS += -lQtDBus # workaround for QT += dbus not working with Qt < 4.4.0 @@ -590,8 +590,8 @@ INCLUDEPATH += \ ../pflib \ ../cisco_lib \ ../compiler_lib \ - ../fwtransfer \ ../libfwbuilder/src + DEPENDPATH += \ ../import \ ../iptlib \ diff --git a/src/libgui/transferDialog.cpp b/src/libgui/transferDialog.cpp deleted file mode 100644 index 97a37a6a2..000000000 --- a/src/libgui/transferDialog.cpp +++ /dev/null @@ -1,482 +0,0 @@ -/* - * transferDialog.cpp - config transfer dialog implementation - * - * Copyright (c) 2008 secunet Security Networks AG - * Copyright (c) 2008 Adrian-Ken Rueegsegger - * Copyright (c) 2008 Reto Buerki - * - * This work is dual-licensed under: - * - * o The terms of the GNU General Public License as published by the Free - * Software Foundation, either version 2 of the License, or (at your option) - * any later version. - * - * o The terms of NetCitadel End User License Agreement - */ - -#include -#include - -#include "transferDialog.h" -#include "utils.h" -#include "utils_no_qt.h" -#include "global.h" - -#include "fwbuilder/FWObjectDatabase.h" -#include "fwbuilder/FWException.h" -#include "fwbuilder/Resources.h" -#include "fwbuilder/Cluster.h" - -#include "TransferDevice.h" - -#include "FWWindow.h" -#include "FWBSettings.h" - -#include -#include -#include - -#define SEARCHSTRING "Transfer firewall " - -using namespace std; -using namespace fwtransfer; -using namespace libfwbuilder; - -transferDialog::transferDialog(QWidget *parent, set fws) - : QDialog(parent), transferDevices(NULL) -{ - // setup ui - m_dialog = new Ui::transferDialog_q; - m_dialog->setupUi(this); - - // init external process handling - connect(&proc, SIGNAL(readyReadStandardOutput()), - this, SLOT(readFromStdout())); - connect(&proc, SIGNAL(finished(int, QProcess::ExitStatus)), - this, SLOT(processExited(int))); - proc.setProcessChannelMode(QProcess::MergedChannels); - - // disable transfer button until a volume is selected - m_dialog->transferButton->setEnabled(false); - - // handle cluster selections - foreach(Firewall* fw, fws) - { - if (Cluster::isA(fw)) - { - list members; - Cluster::cast(fw)->getMembersList(members); - firewalls.insert(firewalls.begin(), members.begin(), members.end()); - - } else - { - firewalls.push_back(fw); - } - } - - if (firewalls.empty()) - { - QMessageBox::critical(this, "Firewall Config Transfer", - tr("No firewalls selected for transfer"), - tr("&Continue"), QString::null, QString::null, - 0, 1); - return; - } - firewalls.sort(FWObjectNameCmpPredicate()); - - // init volume list - transferDevices = new TransferDeviceList; - try - { - transferDevices->init(); - } - catch (FWException &ex) - { - QMessageBox::critical(this, "Firewall Config Transfer", - tr("Transfer error: %1").arg(ex.toString().c_str()), - tr("&Continue"), QString::null, QString::null, - 0, 1); - return; - } - // display available volumes (if any) - updateVolumeView(); - - // connect transferDevices signals to our slots - connect(transferDevices, SIGNAL(devicesChanged()), - this, SLOT(updateDeviceList())); - - // display selected firewalls - displayFirewalls(); -} - -transferDialog::~transferDialog() -{ - if (transferDevices != NULL) - { - delete transferDevices; - transferDevices = NULL; - } - delete m_dialog; -} - -void transferDialog::displayFirewalls() -{ - m_dialog->fwWorkList->clear(); - - QTreeWidgetItem *titem; - list::const_iterator i; - for (i = firewalls.begin(); i != firewalls.end(); ++i) - { - titem = new QTreeWidgetItem; - titem->setText(0, (*i)->getName().c_str()); - - // initial state is 'Waiting' - titem->setText(1, tr("Waiting")); - m_dialog->fwWorkList->insertTopLevelItem(0, titem); - - // store mapping - opListMapping[(*i)] = titem; - } - m_dialog->fwWorkList->resizeColumnToContents(0); - m_dialog->fwWorkList->sortByColumn(0, Qt::AscendingOrder); -} - -void transferDialog::updateVolumeView() -{ - // set row count to fit transferDevices size - m_dialog->transferTable->setRowCount(transferDevices->size()); - - // display appropriate label, if no volumes -> return - if (transferDevices->empty()) - { - m_dialog->volumeLabel->setText("No volumes found! Please connect" - " any usbdisk to update the volume list."); - m_dialog->transferTable->setEnabled(false); - m_dialog->transferButton->setEnabled(false); - return; - } - else - { - m_dialog->volumeLabel->setText("Select usbstick volume to start " - "firewall config transfer:"); - m_dialog->transferTable->setEnabled(true); - } - - // fill in available sticks, disable auto-sort first - m_dialog->transferTable->setSortingEnabled(false); - QTableWidgetItem *citem; - int row = 0; - TransferDeviceList::const_iterator it; - for (it = transferDevices->begin(); it != transferDevices->end(); it++) - { - // name - citem = new QTableWidgetItem; - citem->setText((*it).getDeviceName()); - m_dialog->transferTable->setItem(row, 0, citem); - - // size (in MB) - citem = new QTableWidgetItem; - citem->setText((*it).getVolumeSizeStr()); - m_dialog->transferTable->setItem(row, 1, citem); - - // mounted? - QString mounted = (*it).isMounted() ? "Yes" : "No"; - citem = new QTableWidgetItem; - citem->setText(mounted); - m_dialog->transferTable->setItem(row, 2, citem); - - // mountpoint, if any - citem = new QTableWidgetItem; - citem->setText((*it).getMountpoint()); - m_dialog->transferTable->setItem(row, 3, citem); - - // filesystem - citem = new QTableWidgetItem; - citem->setText((*it).getVolumeFS()); - m_dialog->transferTable->setItem(row, 4, citem); - row++; - } - m_dialog->transferTable->setSortingEnabled(true); - m_dialog->transferTable->sortByColumn(0, Qt::AscendingOrder); - m_dialog->transferTable->resizeColumnToContents(0); -} - -bool transferDialog::runTransfer(Firewall *fw, const QString &volume) -{ - // process events to update display first - // important when transfering multiple firewalls - qApp->processEvents(); - - // prepare args for transfer agent call - QStringList args; - if (!prepareArgs(args, fw, volume)) - { - return false; - } - - log(QObject::tr("Executing:")); - log(args.join(" ")); - - // execute binary - QString path = args.at(0); - args.pop_front(); - proc.start(path, args); - - if (!proc.waitForStarted()) - { - log(tr("Error: Failed to start program")); - setTreeStatus(fw, "Failure"); - return false; - } - args.push_front(path); - - if (!proc.waitForFinished()) - { - log(tr("Error: Waiting for program termination")); - setTreeStatus(fw, "Failure"); - return false; - } - - if (proc.exitCode()) - { - log(tr("Error: Program returned failure status")); - setTreeStatus(fw, "Failure"); - return false; - } - - setTreeStatus(fw, "Success"); - - return true; -} - -bool transferDialog::prepareArgs(QStringList &args, libfwbuilder::Firewall *fw, - const QString &volume) -{ - - FWOptions *fwopt = fw->getOptionsObject(); - - // try to find suitable config transfer agent - string agent = fwopt->getStr("agent"); - if (agent.empty()) - { - agent = Resources::os_res[fw->getStr("host_OS")]->getTransferAgent(); - } - - if (agent.empty()) - { - // no transfer agent for this host_OS found - log("Cannot find suitable transfer agent"); - setTreeStatus(fw, "Failure"); - return false; - } - log(QObject::tr("Using transfer agent '%1'").arg(agent.c_str())); - - QString wdir = getFileDir(mw->getRCS()->getFileName()); - - // fill argument list - args.push_back(agent.c_str()); - QString qs = fwopt->getStr("cmdline").c_str(); - args += qs.split(" ", QString::SkipEmptyParts); - args.push_back("-f"); - args.push_back(fw->getRoot()->getFileName().c_str()); - if (!wdir.isEmpty()) - { - args.push_back("-d"); - args.push_back(wdir); - } - args.push_back("-v"); - args.push_back(volume); - - // append fw object name to tarball when writing multiple configs - // to a volume - if (firewalls.size() > 1) - { - log(QObject::tr("Appending fw object name to tarball")); - args.push_back("-n"); - } - - // append template directory content to transfer tarball - if (fwopt->getBool("secuwall_add_files")) - { - QString tmpldir = fwopt->getStr("secuwall_add_files_dir").c_str(); - args.push_back("-a"); - args.push_back(tmpldir); - } - - args.push_back(QString::fromUtf8(fw->getName().c_str())); - - return true; -} - -void transferDialog::log(const QString message) -{ - if (message.isEmpty()) - { - return; - } - - QString txt = message; - if (!txt.endsWith("\n")) - { - txt += "
"; - } - else - { - txt.replace('\n', "
"); - } - m_dialog->procLogDisplay->insertHtml(txt); - m_dialog->procLogDisplay->ensureCursorVisible(); -} - -void transferDialog::setTreeStatus(Firewall *fw, const QString &status) -{ - QTreeWidgetItem* item = opListMapping[fw]; - if (item == NULL) - { - return; - } - - item->setText(1, status); -} - -QString transferDialog::getVolumeName() const -{ - QList itemlist; - itemlist = m_dialog->transferTable->selectedItems(); - - return itemlist[0]->text(); -} - -void transferDialog::accept() -{ - int current = m_dialog->transferTable->currentRow(); - if (current == -1) - { - QMessageBox::information(this, "Transfer", - "Please select volume or press 'Cancel' button."); - return; - } - else - { - // start the transfer - - // move cursor to the end of log widget - m_dialog->procLogDisplay->moveCursor(QTextCursor::End); - - QString volume = getVolumeName(); - log("Using volume : " + volume + "
"); - - Firewall *fw; - list::const_iterator i; - for (i = firewalls.begin(); i != firewalls.end(); ++i) - { - fw = *i; - QString fwname = fw->getName().c_str(); - - log("
" + QString(SEARCHSTRING) + fwname + ":"); - setTreeStatus(fw, "Transfering ..."); - if (!runTransfer(fw, volume)) - { - log(QObject::tr("Could not transfer %1 config to '%2'"). - arg(fwname).arg(volume)); - } - } - - // enable save log button after first run - if (!m_dialog->saveLogButton->isEnabled()) - { - m_dialog->saveLogButton->setEnabled(true); - } - } -} - -void transferDialog::saveLog() -{ - QString dir; - dir = st->getWDir(); - - if (dir.isEmpty()) - { - dir = st->getOpenFileDir(); - } - if (dir.isEmpty()) - { - dir = "~"; - } - - QString logText; - logText = m_dialog->procLogDisplay->toPlainText(); - - QString s = QFileDialog::getSaveFileName(this, "Choose a file", - dir, "Text file (*.txt)"); - - if (fwbdebug) - { - qDebug("Saving log to file %s", s.toAscii().constData()); - } - - if (!s.isEmpty()) - { - if (!s.endsWith(".txt")) - { - s += ".txt"; - } - - QFile f(s); - if (f.open(QIODevice::WriteOnly)) - { - QTextStream str(&f); - str << logText; - f.close(); - } - } -} - -void transferDialog::selected() -{ - m_dialog->transferButton->setEnabled(true); -} - -void transferDialog::readFromStdout() -{ - QString buf = proc.readAllStandardOutput(); - - if (fwbdebug) - { - qDebug("transferDialog::readFromStdout: %s", - buf.toAscii().constData()); - } - - log(buf); -} - -void transferDialog::processExited(int res) -{ - if (fwbdebug) - { - qDebug("transferDialog::processExited, exit code = %d", res); - } - - readFromStdout(); -} - -void transferDialog::findFirewallInLog(QTreeWidgetItem* item) -{ - if (fwbdebug) - { - qDebug("transferDialog::findFirewallInLog"); - } - - qApp->processEvents(); - m_dialog->procLogDisplay->moveCursor(QTextCursor::End); - m_dialog->procLogDisplay->find(QString(SEARCHSTRING) + item->text(0) + ":", - QTextDocument::FindWholeWords | - QTextDocument::FindCaseSensitively | - QTextDocument::FindBackward); -} - -void transferDialog::updateDeviceList() -{ - updateVolumeView(); -} - diff --git a/src/libgui/transferDialog.h b/src/libgui/transferDialog.h deleted file mode 100644 index c58786680..000000000 --- a/src/libgui/transferDialog.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * transferDialog.h - firewall config transfer dialog - * - * Copyright (c) 2008 secunet Security Networks AG - * Copyright (c) 2008 Adrian-Ken Rueegsegger - * Copyright (c) 2008 Reto Buerki - * - * This work is dual-licensed under: - * - * o The terms of the GNU General Public License as published by the Free - * Software Foundation, either version 2 of the License, or (at your option) - * any later version. - * - * o The terms of NetCitadel End User License Agreement - */ - -#ifndef __TRANSFERDIALOG_H_ -#define __TRANSFERDIALOG_H_ - -#include "../../config.h" -#include - -#include "fwbuilder/Firewall.h" - -#include - -namespace fwtransfer -{ - class TransferDeviceList; -}; - -typedef std::map t_listMap; - -/** - * @class transferDialog - * - * @brief This class is the users view to config transfer operations. - * - * The transferDialog class/UI is used to display transfer information to the user. - * The user can select an usb-storage volume to transfer specific firewall - * configs. Progress about running transfer operations is displayed in a status - * log. - */ -class transferDialog : public QDialog -{ - Q_OBJECT - -private: - /** - * display all selected firewalls in tree widget. - */ - void displayFirewalls(); - - /** - * display all available usb-storage based volumes. This function is - * also called when a devicesChanged signal is received from the - * transferDevices list to update the volumes view. - */ - void updateVolumeView(); - - /** - * perform an transfer of a specific firewall. - * - * @param fw firewall to transfer - * @param volume volume name to transfer config to - * @return true if transfer was successful, false if not - */ - bool runTransfer(libfwbuilder::Firewall *fw, const QString &volume); - - /** - * prepare argument list for transfer agent call. - * - * @param args argument list as QStringList to prepare - * @param fw firewall to build transfer agent argument list for - * @param volume volume name used for transfer - * @return true if suitable transfer agent found, false if not - */ - bool prepareArgs(QStringList &args, libfwbuilder::Firewall *fw, - const QString &volume); - - /** - * write a message to the log widget. - * - * @param message log message to write - */ - void log(const QString message); - - /** - * set status of a firewall given by fw to status 'status', this status - * is displayed in the firewall tree widget. - * - * @param fw firewall to change status - * @param status free-text status message - */ - void setTreeStatus(libfwbuilder::Firewall *fw, const QString &status); - - /** selected volume id */ - QString volume_name; - - /** firewalls to transfer */ - std::list firewalls; - - /** Available transfer devices are stored here */ - fwtransfer::TransferDeviceList *transferDevices; - - /** external process handler */ - QProcess proc; - - /** mapping between tree items and firewalls */ - t_listMap opListMapping; - - /** transferDialog UI */ - Ui::transferDialog_q *m_dialog; - -public: - /** transferDialog ctor */ - transferDialog(QWidget *parent, std::set fws); - - /** transferDialog dtor */ - ~transferDialog(); - - /** - * return chosen volume name to caller. - * - * @return selected volume name (e.g. /dev/sdc1) - */ - QString getVolumeName() const; - -protected slots: - virtual void accept(); - virtual void saveLog(); - void selected(); - void readFromStdout(); - void processExited(int code); - void findFirewallInLog(QTreeWidgetItem*); - void updateDeviceList(); -}; - -#endif /* __TRANSFERDIALOG_H_ */ - diff --git a/src/libgui/transferdialog_q.ui b/src/libgui/transferdialog_q.ui deleted file mode 100644 index 26ff8e487..000000000 --- a/src/libgui/transferdialog_q.ui +++ /dev/null @@ -1,393 +0,0 @@ - - transferDialog_q - - - - 0 - 0 - 547 - 627 - - - - - 0 - 0 - - - - - 32767 - 32767 - - - - Qt::StrongFocus - - - Config transfer options - - - false - - - - - - - 0 - 0 - - - - - 32767 - 32767 - - - - QFrame::Panel - - - QFrame::Raised - - - 1 - - - 0 - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:x-large; font-weight:600;">Export firewall configs to transfer device</span></p></body></html> - - - false - - - - - - - - - - - 0 - 0 - - - - QFrame::Box - - - QFrame::Sunken - - - - - - Select usbstick volume to start firewall config transfer: - - - - - - - false - - - Select a portable disk volume to transfer firewall configs - - - QAbstractItemView::NoEditTriggers - - - false - - - false - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - Qt::ElideMiddle - - - true - - - false - - - - Device - - - - - Size - - - - - Mounted - - - - - Mountpoint - - - - - Filesystem - - - - - - - - Double click on a firewall in this tree to jump to the corresponding process log entry - - - false - - - - Firewall - - - - - Progress - - - - - - - - 6 - - - 0 - - - - - Process log - - - - 0 - - - 6 - - - - - Qt::Horizontal - - - QSizePolicy::MinimumExpanding - - - - 176 - 20 - - - - - - - - false - - - Save log to file - - - - :/Icons/save_25.png:/Icons/save_25.png - - - - - - - true - - - - - - - - - - - - - - - - 0 - 0 - - - - - 32767 - 32767 - - - - QFrame::Panel - - - QFrame::Raised - - - - - - Start the export! - - - Transfer - - - - - - - Close - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - transferButton - closeButton - - - - - - - transferButton - clicked() - transferDialog_q - accept() - - - 407 - 601 - - - 20 - 20 - - - - - closeButton - clicked() - transferDialog_q - reject() - - - 493 - 601 - - - 20 - 20 - - - - - transferTable - cellClicked(int,int) - transferDialog_q - selected() - - - 277 - 185 - - - 277 - 301 - - - - - saveLogButton - clicked() - transferDialog_q - saveLog() - - - 540 - 362 - - - 277 - 301 - - - - - fwWorkList - itemActivated(QTreeWidgetItem*,int) - transferDialog_q - findFirewallInLog(QTreeWidgetItem*) - - - 143 - 411 - - - 277 - 301 - - - - - diff --git a/src/src.pro b/src/src.pro index 94e934ed3..0874a12eb 100644 --- a/src/src.pro +++ b/src/src.pro @@ -16,7 +16,6 @@ SUBDIRS = libfwbuilder \ import \ common \ compiler_lib \ - fwtransfer \ iptlib \ ipt \ pflib \ @@ -27,7 +26,6 @@ SUBDIRS = libfwbuilder \ iosacl \ pix \ procurve_acl \ - transfer_agents \ libgui \ fwbedit \ gui \ diff --git a/src/transfer_agents/secuwall/secuwall.pro b/src/transfer_agents/secuwall/secuwall.pro deleted file mode 100644 index 765764cbd..000000000 --- a/src/transfer_agents/secuwall/secuwall.pro +++ /dev/null @@ -1,35 +0,0 @@ -#-*- mode: makefile; tab-width: 4; -*- -# -# -include(../../../qmake.inc) - -SOURCES = transfer_secuwall.cpp - -HEADERS = ../../../config.h - -INCLUDEPATH += ../../libfwbuilder/src -DEPENDPATH += ../../libfwbuilder/src - -contains( HAVE_QTDBUS, 1 ):unix { - !macx: QT += network dbus - macx: LIBS += -framework QtDBus -#!macx:LIBS += -lQtDBus # workaround for QT += dbus not working with Qt < 4.4.0 -} - -!win32 { - QMAKE_COPY = ../../../install.sh -m 0755 -s - LIBS = ../../fwtransfer/libfwtransfer.a \ # -lQtDBus - ../../libfwbuilder/src/fwcompiler/libfwcompiler.a \ - ../../libfwbuilder/src/fwbuilder/libfwbuilder.a \ - $$LIBS -} - -win32 { - CONFIG += console - LIBS += ../../fwtransfer/release/libfwtransfer.a \ # -lQtDBus - ../../libfwbuilder/src/fwcompiler/release/libfwcompiler.a \ - ../../libfwbuilder/src/fwbuilder/release/libfwbuilder.a -} - -TARGET = transfer_secuwall - diff --git a/src/transfer_agents/secuwall/transfer_secuwall.cpp b/src/transfer_agents/secuwall/transfer_secuwall.cpp deleted file mode 100644 index 45aa33848..000000000 --- a/src/transfer_agents/secuwall/transfer_secuwall.cpp +++ /dev/null @@ -1,383 +0,0 @@ -/* - * transfer_secuwall.cpp - secunet wall config transfer agent - * - * Copyright (c) 2008 secunet Security Networks AG - * Copyright (c) 2008 Adrian-Ken Rueegsegger - * Copyright (c) 2008 Reto Buerki - * - * This work is dual-licensed under: - * - * o The terms of the GNU General Public License as published by the Free - * Software Foundation, either version 2 of the License, or (at your option) - * any later version. - * - * o The terms of NetCitadel End User License Agreement - */ - -#include "../../../config.h" - -#include -#include -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#ifdef _WIN32 -#include -#include -#include -#endif - -#ifdef HAVE_GETOPT_H -#include -#else -#ifdef _WIN32 -#include -#else -//#include -#endif -#endif - -#include "fwbuilder/FWException.h" - -#include "fwtransfer/TransferDevice.h" - -// tarball base name and suffix (e.g. config.tar.gz) -#define BASENAME "config" -#define SUFFIX "tar" - -using namespace std; -using namespace fwtransfer; -using namespace libfwbuilder; - -int fwbdebug = 0; - -// object database filename: not used at the moment -static string filename = ""; -// workdir of firewall to export -static string workdir = ""; -// templates dir to use -static string tmpldir = ""; -// volumeid (e.g. /dev/sdc1) to use as transfer partition -static string volumeid = ""; -// object name of firewall to export (e.g. fw1) -static string fwobjectname = ""; - -// append fwobjectname to transfer tarball -static bool appendname = false; - -/** - * init portable usb device list. - * - * @param devices device list to init, only portable devices are valid. - * @return true if successful, false if not - */ -bool init_usbdisks(TransferDeviceList &devices) -{ - try - { - devices.init(); - } - catch (FWException &ex) - { - cout << "Could not init list of usbdisks!" << endl; - cout << "Error: " << ex.toString() << endl; - return false; - } - - TransferDeviceList::const_iterator it; - it = devices.begin(); - if (it == devices.end()) - { - cout << "No usable transfer volumes found! " << endl; - return false; - } - - return true; -} - -/** - * display transfer_secuwall usage. - */ -void usage(const char *name) -{ - cout << "Firewall Builder: config transfer agent for " - "secunet wall host OS" << endl; - cout << ("Version : ") << VERSION << endl; - cout << ("Usage : ") << name << - " [-l] [-h] [-n] -v volumeid [-f filename.xml] [-d workdir] " - "[-a templatedir] firewall_object_name" << endl; -} - -/** - * list all available transfer volumes. - */ -void list_volumes() -{ - TransferDeviceList devices; - - if (!init_usbdisks(devices)) - { - exit(EXIT_FAILURE); - } - - TransferDeviceList::const_iterator it; - it = devices.begin(); - cout << endl; - for (; it != devices.end(); it++) - { - TransferDevice dev = *it; - dev.dump(); - } - - exit(EXIT_SUCCESS); -} - -/** - * copy file specified by src to dst - * - * @param src source filepath - * @param dst destination filepath - * @return true if successfully copied, false if not - */ -bool copy_file(const string &src, const string &dst) -{ - std::ifstream infile(src.c_str(), std::ios_base::binary); - std::ofstream outfile(dst.c_str(), std::ios_base::binary); - - if (!infile) - { - cout << "File not found: " << src << endl; - return false; - } - - if (!outfile) - { - cout << "Could not create: " << dst << endl; - return false; - } - - try - { - outfile << infile.rdbuf(); - } - catch (...) - { - cout << "Error while writing to: " << dst << endl; - infile.close(); - outfile.close(); - return false; - } - infile.close(); - outfile.close(); - return true; -} - -/** - * secunet wall config transfer agent - * - * used to export fw config tarball to a portable usb medium. - */ -int main(int argc, char **argv) -{ - if (argc <= 1) - { - usage(argv[0]); - exit(EXIT_FAILURE); - } - - int opt; - - while ((opt = getopt(argc, argv, "lhnv:f:d:a:")) != EOF) - { - switch (opt) - { - case 'd': - workdir = string(optarg); - break; - case 'a': - tmpldir = string(optarg); - break; - case 'f': - filename = string(optarg); - break; - case 'v': - volumeid = string(optarg); - break; - case 'l': - list_volumes(); - break; - case 'h': - usage(argv[0]); - exit(EXIT_FAILURE); - case 'n': - appendname = true; - break; - default: - usage(argv[0]); - exit(EXIT_FAILURE); - } - } - - if ((argc - 1) != optind) - { - usage(argv[0]); - exit(EXIT_FAILURE); - } - - fwobjectname = string(argv[optind++]); - - if (workdir.empty()) - { - workdir = "./"; - } - - if (filename.empty()) - { - filename = workdir + fwobjectname + ".fwb"; - } - - if (fwbdebug) - { - cout << "Volume\t: " << volumeid << endl; - cout << "Object\t: " << fwobjectname << endl; - cout << "Workdir\t: " << workdir << endl; - cout << "DB\t: " << filename << endl; - } - - if ( -#ifdef _WIN32 - _chdir(workdir.c_str()) -#else - chdir(workdir.c_str()) -#endif - ) - { - cout << "Can't change directory to: " << workdir << endl; - exit(EXIT_FAILURE); - } - - // check for existence of fwobjectname subdir - struct stat buffer; - if (stat(fwobjectname.c_str(), &buffer)) - { - cout << "Config subdir not found for " << fwobjectname << endl; - exit(EXIT_FAILURE); - } - - // check templates directory (with -a flag only) - if (!tmpldir.empty()) - { - if (stat(tmpldir.c_str(), &buffer)) - { - cout << "Templates directory '" << tmpldir << "' not found" << endl; - exit(EXIT_FAILURE); - } - } - - // try to mount volume - TransferDeviceList devices; - if (!init_usbdisks(devices)) - { - exit(EXIT_FAILURE); - } - - TransferDeviceList::const_iterator it; - it = devices.getDeviceByName(volumeid); - if (it == devices.end()) - { - cout << "Could not find volume " << volumeid << endl; - exit(EXIT_FAILURE); - } - TransferDevice dev = *it; - - if (!dev.isMounted()) - { - try - { - dev.mount(); - } - catch (FWException &ex) - { - cout << "Could not mount volume " << volumeid << endl; - cout << "Error: " << ex.toString() << endl; - exit(EXIT_FAILURE); - } - } - string mountpoint = dev.getMountpoint().toStdString(); - cout << "Device mounted to " << mountpoint << endl; - - // copy firewall script to fwobjectname subdir, we assume the script name - // to be: 'fwobjectname + fw suffix'. the file will be copied to 'sysconfig' - // subdirectory. - string fwscriptname = fwobjectname + ".fw"; - string fwscriptdst = fwobjectname + "/sysconfig/" + fwscriptname; - if (!copy_file(fwscriptname, fwscriptdst)) - { - cout << "Firewall config script file not found for '" - << fwobjectname << "'" << endl; - exit(EXIT_FAILURE); - } - - // construct tarball name depending on appendname flag - string tarball; - if (appendname) - { - tarball = string(BASENAME) + "-" + fwobjectname + "." + string(SUFFIX); - } - else - { - tarball = string(BASENAME) + "." + string(SUFFIX); - } - - // tell tar to change into fwobjectname subdir and create tarball - // force file ownership to root:root - string cmd = "tar cCf " + fwobjectname + " " + tarball + " --owner=0 --group=0 ."; - if (system(cmd.c_str()) != 0) - { - cout << "Could not create tarball '" << tarball << "'" << endl; - exit(EXIT_FAILURE); - } - - // append templates to tarball - if (!tmpldir.empty()) - { - cout << "Adding templates from '" << tmpldir << "'" << endl; - cmd = "tar rCf " + tmpldir + " " + tarball + " --owner=0 --group=0 ."; - if (system(cmd.c_str()) != 0) - { - cout << "Could not append templates to tarball '" << tarball - << "'" << endl; - exit(EXIT_FAILURE); - } - } - - // compress tarball - cmd = "gzip -f " + tarball; - if (system(cmd.c_str()) != 0) - { - cout << "Could not compress tarball '" << tarball << "'" << endl; - cout << "Missing gzip binary?" << endl; - exit(EXIT_FAILURE); - } - - // copy compressed archive to volume - string compressed = tarball + ".gz"; - string outpath = mountpoint + "/" + compressed; - if (!copy_file(compressed, outpath)) - { - cout << "Could not copy '" << compressed << "' to '" - << outpath << "'" << endl; - exit(EXIT_FAILURE); - } - -#ifndef _WIN32 - sync(); -#endif - - cout << "Exported '" << fwobjectname << "' config to " << outpath << endl; - exit(EXIT_SUCCESS); -} diff --git a/src/transfer_agents/transfer_agents.pro b/src/transfer_agents/transfer_agents.pro deleted file mode 100644 index 07fc4f879..000000000 --- a/src/transfer_agents/transfer_agents.pro +++ /dev/null @@ -1,10 +0,0 @@ -#-*- mode: makefile; tab-width: 4; -*- -# -# - -TEMPLATE = subdirs - -CONFIG += ordered - -TARGET = transfer_agents -SUBDIRS = secuwall