Skip to content

fix(main/nwipe): package belongs to root-repo #25269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2025
Merged

Conversation

sylirre
Copy link
Member

@sylirre sylirre commented Jul 6, 2025

This package refuses to run without root permissions and should be placed to the root-repo.

@robertkirkman
Copy link
Contributor

robertkirkman commented Jul 6, 2025

I'm not sure if I have an SD card to actually test the erasing functionality on at the moment, but I did notice this error and several other errors during startup on my rooted device:

error: Failed to create /etc/nwipe/nwipe.conf

Let's also try to prepend @TERMUX_PREFIX@ to any absolute paths in the code of this program which aren't too difficult to find, and which shouldn't already be covered by termux-exec automatically (like /usr/bin paths).

Here's a patch I made that fixes the above error, replacing it with this message:

diff --git a/packages/nwipe/fix-hardcoded-paths.patch b/packages/nwipe/fix-hardcoded-paths.patch
index eff2184e95..2c6c9c056d 100644
--- a/packages/nwipe/fix-hardcoded-paths.patch
+++ b/packages/nwipe/fix-hardcoded-paths.patch
@@ -104,3 +104,22 @@
              {
                  nwipe_log( NWIPE_LOG_WARNING, "modprobe command not found. Install kmod package (modprobe)) !" );
                  nwipe_log( NWIPE_LOG_WARNING, "Most temperature monitoring may be unavailable as module drivetemp" );
+--- a/src/conf.c
++++ b/src/conf.c
+@@ -38,11 +38,11 @@
+ config_t nwipe_cfg;
+ config_setting_t *nwipe_conf_setting, *group_organisation, *root, *group, *previous_group, *setting;
+ const char* nwipe_conf_str;
+-char nwipe_config_directory[] = "/etc/nwipe";
+-char nwipe_config_file[] = "/etc/nwipe/nwipe.conf";
+-char nwipe_customers_file[] = "/etc/nwipe/nwipe_customers.csv";
+-char nwipe_customers_file_backup[] = "/etc/nwipe/nwipe_customers.csv.backup";
+-char nwipe_customers_file_backup_tmp[] = "/etc/nwipe/nwipe_customers.csv.backup.tmp";
++char nwipe_config_directory[] = "@TERMUX_PREFIX@/etc/nwipe";
++char nwipe_config_file[] = "@TERMUX_PREFIX@/etc/nwipe/nwipe.conf";
++char nwipe_customers_file[] = "@TERMUX_PREFIX@/etc/nwipe/nwipe_customers.csv";
++char nwipe_customers_file_backup[] = "@TERMUX_PREFIX@/etc/nwipe/nwipe_customers.csv.backup";
++char nwipe_customers_file_backup_tmp[] = "@TERMUX_PREFIX@/etc/nwipe/nwipe_customers.csv.backup.tmp";
+ 
+ /*
+  * Checks for the existence of nwipe.conf and nwipe_customers.csv
info: Sucessfully written nwipe config to /data/data/com.termux/files/usr/etc/nwipe/nwipe.conf

If you would like you can put this in this PR, or if you prefer this to be in a different PR, I could open a separate one after this one is completed.

@sylirre sylirre force-pushed the nwipe-root-pkg branch 2 times, most recently from 98d34e1 to dcce296 Compare July 6, 2025 21:44
@sylirre
Copy link
Member Author

sylirre commented Jul 6, 2025

Fix added, thanks. Although this package is kind of useless and I think no one actually used it.

nwipe doesn't work without hdparm, smartmontools may be required too.

I think it should be moved rather to disabled packages now.

@robertkirkman
Copy link
Contributor

Fix added, thanks. Although this package is kind of useless and I think no one actually used it.

nwipe doesn't work without hdparm, smartmontools may be required too.

I think it should be moved rather to disabled packages now.

If you believe it should be disabled, probably that's ok and you're likely correct that not many people need to secure erase a drive using rooted Android and don't have a different device to do the erasing, so I don't think anyone would mind this,

but I don't agree exactly with all the same reasons as you, because it should be noted that hdparm can be obtained very easily without any patches using these commands:

wget https://downloads.sourceforge.net/sourceforge/hdparm/hdparm-9.65.tar.gz
tar xvf hdparm-9.65.tar.gz
cd hdparm-9.65/
make
sudo ./hdparm -I /dev/block/sda

and smartmontools can be obtained very easily without any patches using these commands:

git clone https://github.com/smartmontools/smartmontools.git
cd smartmontools
./autogen.sh
./configure --prefix="$PREFIX" \
            --sbindir="$PREFIX/bin" \
            --with-scriptpath="$PREFIX/bin"
make LDFLAGS="-landroid-glob"
src/smartctl -h

however, nwipe is one that required patches, so maybe that's why it was packaged but not the others.

@robertkirkman
Copy link
Contributor

robertkirkman commented Jul 6, 2025

Actually, I realized that there are open requests for hdparm and smartmontools, so I will add them, then if you decide to keep this package and put it in the root repo, it could be marked as depending on them.

AUR's package has hdparm as Depends and smartmontools as Optional Depends. https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=nwipe#n10

@sylirre
Copy link
Member Author

sylirre commented Jul 6, 2025

Yes, let's add these packages.

@robertkirkman
Copy link
Contributor

The packages are now available, after installing them and also installing the artifact from here, sudo nwipe successfully opened for me and displayed my device storage,

image

It did show this in the log:

..Warning: Unable to open /dev/block/sdb read-write (Read-only file system).  /dev/block/sdb has been opened read-only.

however I believe it can be assumed that if someone has an SD card and tries to erase it, this will work now.

so it seems like, now you could just add the package hdparm to TERMUX_PKG_DEPENDS and add smartmontools to TERMUX_PKG_SUGGESTS, and this would be ready.

This package refuses to run without root permissions and should be
placed to the root-repo.

Additionally add more fixes for hardcoded paths to prevent errors
related to configuration files.
@sylirre sylirre merged commit 6200d80 into master Jul 8, 2025
13 checks passed
@sylirre sylirre deleted the nwipe-root-pkg branch July 8, 2025 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants