On 09/24/2012 12:55 PM, Sebastian Dransfeld wrote:
On 09/22/2012 08:29 PM, Enlightenment SVN wrote:
Log:
E17: Added secure delete option (experimental !). Wait for discomfitor to add
it to EFM conf panel
When removing a file, we store a E_FM_OP_DESTROY task,
which overwrites file with 3 passes of (~)randomized
data, and when we store a E_FM_OP_REMOVE task, to remove
the randomized file.
If it's a dir, skip E_FM_OP_DESTROY.
Patch by Maxime Villard (rustyBSD)
Isn't it better to mmap the file when writing? Instead of doing a
theoretically (if ((buf = malloc(st2.st_size)) == NULL)) huge malloc?
S.
Something like this (untested!!).
S.
diff --git a/e/src/bin/e_fm_op.c b/e/src/bin/e_fm_op.c
index 8104acd..59a1a09 100644
--- a/e/src/bin/e_fm_op.c
+++ b/e/src/bin/e_fm_op.c
@@ -1677,13 +1677,15 @@ static int
_e_fm_op_destroy_atom(E_Fm_Op_Task *task)
{
if (_e_fm_op_abort) goto finish;
- static int fd = -1;
+ static Eina_File *ef = NULL;
static char *buf = NULL;
- if (fd == -1)
+ if (ef == NULL)
{
E_FM_OP_DEBUG("Secure remove: %s\n", task->src.name);
+#if 0
struct stat st2;
+#endif
if (!S_ISREG(task->src.st.st_mode))
goto finish;
@@ -1691,9 +1693,10 @@ _e_fm_op_destroy_atom(E_Fm_Op_Task *task)
if (task->src.st.st_nlink > 1)
goto finish;
- if ((fd = open(task->src.name, O_WRONLY|O_NONBLOCK|O_NOFOLLOW, 0)) == -1)
+ if (!(ef = eina_file_open(task->src.name, EINA_FALSE)))
goto finish;
+#if 0
if (fstat(fd, &st2) == -1)
goto finish;
@@ -1701,22 +1704,16 @@ _e_fm_op_destroy_atom(E_Fm_Op_Task *task)
st2.st_ino != task->src.st.st_ino ||
!S_ISREG(st2.st_mode))
goto finish;
+#endif
- if ((buf = malloc(st2.st_size)) == NULL)
+ if ((buf = eina_file_map_all(ef, EINA_FILE_SEQUENTIAL)) == NULL)
goto finish;
- task->src.st.st_size = st2.st_size;
+ task->src.st.st_size = eina_file_size_get(ef);
}
- if (lseek(fd, SEEK_SET, 0) == -1)
- goto finish;
-
if (_e_fm_op_random_buf(buf, task->src.st.st_size) == -1)
memset(buf, 0xFF, task->src.st.st_size);
- if (write(fd, buf, task->src.st.st_size) != task->src.st.st_size)
- goto finish;
- if (fsync(fd) == -1)
- goto finish;
task->dst.done++;
_e_fm_op_update_progress_report_simple((double)task->dst.done/NB_PASS*100, "/dev/urandom", task->src.name);
@@ -1727,9 +1724,10 @@ _e_fm_op_destroy_atom(E_Fm_Op_Task *task)
return 1;
finish:
- close(fd);
- fd = -1;
- E_FREE(buf);
+ if (buf) eina_file_map_free(ef, buf);
+ buf = NULL;
+ if (ef) eina_file_close(ef);
+ ef = NULL;
task->finished = 1;
return 1;
}
@@ -1742,7 +1740,7 @@ _e_fm_op_random_buf(char *buf, ssize_t len)
if ((f = open("/dev/urandom", O_RDONLY)) == -1)
{
- for (i=0; i < len; i++)
+ for (i = 0; i < len; i++)
{
buf[i] = _e_fm_op_random_char();
}
@@ -1751,7 +1749,7 @@ _e_fm_op_random_buf(char *buf, ssize_t len)
if (read(f, buf, len) != len)
{
- for (i=0; i < len; i++)
+ for (i = 0; i < len; i++)
{
buf[i] = _e_fm_op_random_char();
}
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel