14 Commits

Author SHA1 Message Date
a35cb111ee simple ipc send 2025-06-21 11:32:41 +02:00
575cb73d95 send dummy ipc 2025-06-08 23:00:38 +02:00
1ceffa56f8 Merge pull request 'Ignore system drives as live image' (#71) from bugfix/systemdrive_live into master
Reviewed-on: #71
2024-08-19 16:30:09 +02:00
4ff1888333 ignore system drives as live image 2024-08-19 15:35:22 +02:00
4b33fb6fdb update live image info 2024-08-17 16:02:58 +02:00
87a859f187 skip delete if drive was shredded before 2024-08-16 10:29:12 +02:00
952e8c8eeb add new flag 2024-08-16 10:29:12 +02:00
1055ef57ee Disable delete after shred was once started. (#69)
documented here: #65

Reviewed-on: #69
Co-authored-by: localhorst <localhorst@mosad.xyz>
Co-committed-by: localhorst <localhorst@mosad.xyz>
2024-08-16 10:26:49 +02:00
6dd4c44688 Merge pull request 'fix deletion of dialog' (#68) from bugfix/segmentationfault into master
Reviewed-on: #68
2024-06-23 11:13:53 +02:00
feed1b4a97 fix deletion of dialog 2024-06-23 11:11:20 +02:00
5d2094939b Merge pull request 'feature/ignore_systemdrive' (#64) from feature/ignore_systemdrive into master
Reviewed-on: #64
2024-06-02 10:00:39 +02:00
b1b9870150 remove dryrun 2024-06-02 09:57:12 +02:00
77b322d47d ignore system drive 2024-06-02 09:51:22 +02:00
a665f8638e find system drive 2024-06-02 09:31:55 +02:00
9 changed files with 129 additions and 14 deletions

View File

@ -9,7 +9,7 @@
* process multiple drives at once
## Download USB Image ##
[2.5GB image v1.0.0](https://schuttercloud.com/s/ggxGH9sA326aRfK) (`wget` is your friend)
See reHDD-Bootable how the live image created: https://git.mosad.xyz/localhorst/reHDD-Bootable
Use [Etcher](https://www.balena.io/etcher/#download) or `dd` to create an bootable USB drive .

View File

@ -34,6 +34,7 @@ public:
} sShredSpeed;
bool bWasShredded = false; // all shred iterations done
bool bWasShredStarted = false; // shred was atleast once started
bool bWasChecked = false; // all shred iterations and optional checking done
bool bWasDeleted = false;
bool bIsOffline = false;

View File

@ -8,7 +8,7 @@
#ifndef REHDD_H_
#define REHDD_H_
#define REHDD_VERSION "V1.1.2"
#define REHDD_VERSION "V1.1.3"
// Drive handling Settings
#define WORSE_HOURS 19200 // mark drive if at this limit or beyond
@ -31,7 +31,7 @@
#endif
// Logic
//#define DRYRUN //don´t touch the drives
//#define DRYRUN // don't touch the drives
#define FROZEN_ALERT // show alert if drive is frozen
#define ZERO_CHECK // check drive after shred if all bytes are zero, show alert if this fails
@ -101,6 +101,7 @@ private:
static void handleESC();
static void handleAbort();
static Drive *getSelectedDrive();
static bool getSystemDrive(string &systemDrive);
};
#endif // REHDD_H_

View File

@ -32,11 +32,15 @@ void Delete::deleteDrive(Drive *drive)
const char *cpComand = sCMD.c_str();
// cout << "delete: " << cpComand << endl;
FILE *deleteCmdOutput = popen(cpComand, "r");
while ((getline(&cLine, &len, deleteCmdOutput)) != -1)
if (drive->bWasShredStarted == false)
{
// wipefs running
//only start delete if the drive was not shredded before
FILE *deleteCmdOutput = popen(cpComand, "r");
while ((getline(&cLine, &len, deleteCmdOutput)) != -1)
{
// wipefs running
}
pclose(deleteCmdOutput);
}
pclose(deleteCmdOutput);
}

View File

@ -6,6 +6,7 @@
*/
#include "../include/reHDD.h"
#include "../include/printer.h"
/**
* \brief app entry point
@ -14,9 +15,32 @@
*/
int main(void)
{
// cout << "refurbishingHddTool" << endl;
cout << "refurbishingHddTool" << endl;
reHDD *app = new reHDD();
app->app_logic();
Drive *tmpDrive = new Drive("/dev/");
tmpDrive->setActionStartTimestamp();
tmpDrive->bWasShredded = true;
tmpDrive->setDriveSMARTData("modelFamily",
"modelName",
"serial",
420000,
43,
44,
45,
46);
while(true){
cout << "send" << endl;
Printer::getPrinter()->print(tmpDrive);
sleep(5); // sleep 5 sec
break;
}
cout << "exit" << endl;
// reHDD *app = new reHDD();
// app->app_logic();
return EXIT_SUCCESS;
}

View File

@ -344,6 +344,26 @@ void reHDD::searchDrives(list<Drive> *plistDrives)
*/
void reHDD::filterIgnoredDrives(list<Drive> *plistDrives)
{
string systemDrivePath;
if (getSystemDrive(systemDrivePath))
{
// Logger::logThis()->info("Found system drive: " + systemDrivePath);
list<Drive>::iterator it;
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
{
if (it->getPath().find(systemDrivePath) != std::string::npos) // compare found system drive and current drive
{
// system drive found --> ignore this drive
#ifdef LOG_LEVEL_HIGH
Logger::logThis()->info("system drive found --> ignore this drive: " + it->getPath());
#endif
it = plistDrives->erase(it);
it--;
}
}
}
list<tuple<string>> vtlIgnoredDevices; // store drives from ignore file
ifstream input("ignoreDrives.conf"); // read ignore file
@ -605,3 +625,59 @@ void reHDD::handleAbort()
}
}
}
bool reHDD::getSystemDrive(string &systemDrive)
{
char *cLine = NULL;
size_t len = 0;
bool systemDriveFound = false;
FILE *outputfileHwinfo = popen("lsblk -e 11 -o NAME,MOUNTPOINT", "r");
if (outputfileHwinfo == NULL)
{
Logger::logThis()->error("Unable to scan attached drives for system drive");
exit(EXIT_FAILURE);
}
while ((getline(&cLine, &len, outputfileHwinfo)) != -1)
{
string currentLine = cLine;
if (currentLine.find("NAME") != std::string::npos)
{
continue;
}
// Logger::logThis()->info(currentLine);
if ((cLine[0U] != '|') && (cLine[0U] != '`'))
{
systemDrive = currentLine;
systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), '\n'), systemDrive.end()); // remove newline
systemDrive.erase(std::remove(systemDrive.begin(), systemDrive.end(), ' '), systemDrive.end()); // remove spaces
// Logger::logThis()->info("Drive found: " + systemDrive);
}
if (currentLine.ends_with(" /boot/efi\n"s))
{
systemDriveFound = true;
break;
}
if (currentLine.ends_with(" /run/overlay/live\n"s))
{
systemDriveFound = true;
break;
}
if (currentLine.ends_with(" /\n"s))
{
systemDriveFound = true;
break;
}
}
pclose(outputfileHwinfo);
return systemDriveFound;
}

View File

@ -36,6 +36,7 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
ostringstream address;
address << (void const *)&(*drive);
Logger::logThis()->info("Shred-Task started - Drive: " + drive->getModelName() + "-" + drive->getSerial() + " @" + address.str());
drive->bWasShredStarted = true; //Mark drive as partly shredded
#ifdef DRYRUN
for (int i = 0; i <= 500; i++)
@ -48,6 +49,7 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
write(*ipSignalFd, "A", 1);
usleep(20000);
}
drive->bWasShredded = true;
#endif
#ifndef DRYRUN

View File

@ -36,7 +36,7 @@ void SMART::readSMARTData(Drive *drive)
sCMD.append(drive->getPath());
const char *cpComand = sCMD.c_str();
// Logger::logThis()->info(cpComand);
//Logger::logThis()->info(cpComand);
FILE *outputfileSmart = popen(cpComand, "r");
size_t len = 0U; // length of found line
@ -63,7 +63,7 @@ void SMART::readSMARTData(Drive *drive)
if (status == 0U)
{
// Found S.M.A.R.T. data with this command
// Logger::logThis()->info("Found S.M.A.R.T. data with this command");
//Logger::logThis()->info("Found S.M.A.R.T. data with this command");
break;
}
}

View File

@ -613,6 +613,7 @@ void TUI::vTruncateText(string *psText, uint16_t u16MaxLenght)
void TUI::displaySelectedDrive(Drive drive, int stdscrX, int stdscrY)
{
struct MenuState menustate;
static bool dialogIsActive;
menustate.bAbort = false;
menustate.bConfirmDelete = false;
menustate.bConfirmShred = false;
@ -659,15 +660,21 @@ void TUI::displaySelectedDrive(Drive drive, int stdscrX, int stdscrY)
{
dialog = createDialog(40, 10, ((stdscrX) - (int)(stdscrX / 3) - 7) - (int)((stdscrX / 3) + 5) / 2, (int)(stdscrY / 2) - 5, "Confirm SHRED", "Press ENTER for SHRED", "Press ESC for cancel");
wrefresh(dialog);
dialogIsActive = true;
}
else if (menustate.bConfirmDelete == true)
{
dialog = createDialog(40, 10, ((stdscrX) - (int)(stdscrX / 3) - 7) - (int)((stdscrX / 3) + 5) / 2, (int)(stdscrY / 2) - 5, "Confirm DELETE", "Press ENTER for DELETE", "Press ESC for cancel");
wrefresh(dialog);
dialogIsActive = true;
}
else
{
delwin(dialog);
if (dialogIsActive)
{
delwin(dialog);
dialogIsActive = false;
}
}
}