[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Finalized rm hack
Thanks to everyone for their comments on my rm hack. I appreciate the
feedback, particularly the positive stuff. ;-)
I'm submitting below two diffs: one that represents the changes from the
current rm.c, and one that represents changes between the version I
submitted last night and the finalized version. That way, if you've already
patched, you can apply the new patch, and if you've not, you can get up to
speed in one step.
By way of explanation, what I did was read the article pointed out by Damien
Miller on secure deletion, and then incorporate in the values they suggested
into my loop. They're listed out (in decimal instead of hex for simplicity's
sake) in owv[]; my loop goes through and pulls from them, using an entirely
random value from 0-256 every 2-10 loops through (2 so that it's not all
random values, 10 so that some randomness is incorporated into most
overwrites). I'm hoping I've structured my loop properly to acheive this
effect; it seemed to work in testing.
Barring any further bugs discovered by you folks, I'd like to see this added
to -current. How would I go about having that happen?
Thanks,
Alex
68a69
> long owrite;
89a91,92
> extern char *optarg;
> char *endptr;
94c97
< while ((ch = getopt(argc, argv, "dfiPRrW")) != -1)
---
> while ((ch = getopt(argc, argv, "dfiPRrWo:")) != -1)
116a120,125
> case 'o':
> Pflag = 1;
> owrite = strtol(optarg, &endptr, 10);
> if (optarg[0] == 0 || *endptr != '\0')
> usage();
> break;
299c308
< * Overwrite the file 3 times with varying bit patterns.
---
> * Overwrite the file with varying bit patterns.
306a316,321
> *
> * The values in owv[] were taken from the article at
> * http://www.cs.auckland.ac.nz/~pgut001/pubs/secure_del.html, as those
> * which would give the highest probability of a fully secure overwrite.
> * It should be noted, however, that even when using these values, complete
> * deletion cannot be absolutely ensured.
317a333,335
> int z, y;
> int owv[] = {146, 73, 36, 0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 109, 182, 219};
> srand(time(NULL));
343,348c361,377
< PASS(0xff);
< if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET))
< goto err;
< PASS(0x00);
< if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET))
< goto err;
---
> if (owrite == NULL)
> y = 2;
> else
> y = (owrite - 1);
> for (z = 0; z < y; z++)
> {
> if (z/((rand()%10) + 1) == 1)
> {
> PASS((rand())%256);
> }
> else
> {
> PASS(owv[(rand()%22)]);
> }
> if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET))
> goto err;
> }
441c470
< (void)fprintf(stderr, "usage: rm [-dfiPRrW] file ...\n");
---
> (void)fprintf(stderr, "usage: rm [-dfiPRrWo] [n] file ...\n");
308c308
< * Overwrite the file 3 times with varying bit patterns.
---
> * Overwrite the file with varying bit patterns.
315a316,321
> *
> * The values in owv[] were taken from the article at
> * http://www.cs.auckland.ac.nz/~pgut001/pubs/secure_del.html, as those
> * which would give the highest probability of a fully secure overwrite.
> * It should be noted, however, that even when using these values, complete
> * deletion cannot be absolutely ensured.
327a334,335
> int owv[] = {146, 73, 36, 0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 109, 182, 219};
> srand(time(NULL));
359c367,374
< PASS(0xee);
---
> if (z/((rand()%10) + 1) == 1)
> {
> PASS((rand())%256);
> }
> else
> {
> PASS(owv[(rand()%22)]);
> }