moving files from a location to other, preventing to move incomplete files
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
moving files from a location to other, preventing to move incomplete files
Hi:
OS: Ubuntu Intrepid Ibex
Need help in moving files from location 1 to location 2, in linux, using some sort of code in order to avoid moving incomplete files. The funtion needs to be recursive in order to continue trying to move the file and do so as soon as possible.
As an example: when using the unrar function in a rar password protected file, the process will extract the file before asking for the password, the file is completely extracted and for a second or two stays in the directory completely available, after that the unrar program then ask you for the password and begins to erase the file. What I am trying to accomplish is to exploit this weakness in the process in order to move the files before the unrar routines is able to destroy the file.
I do not understand this---what do you mean by moving an "incomplete file"? How would--eg--mv know the file was incomplete? If a process has a file open for writing, I'm not sure mv will move it at all.
You could experiment with dd, but to try to do things with a file as it is being written could give some very interesting results.
And---when you decline to say WHY you are doing something, you'll turn off a lot of potential help.
Iwhen you decline to say WHY you are doing something, you'll turn off a lot of potential help.
Should be clear, right?:
Quote:
Originally Posted by pogo123
the process will extract the file before asking for the password, the file is completely extracted and for a second or two stays in the directory completely available (..) exploit this weakness in the process in order to move the files before the unrar routines is able to destroy the file.
*Very* doubtful this will work the way he perceives it will work and since this is circumvention I strongly doubt we should be aiding in any case.
Moving wouldn't do any good unless you moved it to a different filesystem/partition (in which case its a copy) because it'll retain its inode and the original process will go on accessing/writing/unlinking with no problems.
For the general problem an easy solution is to have the creating process also make a checksum file (md5, sha, ...) when its done, so you not only know when the file is complete you can also verify your move/copy against the checksum file.
The file is not decrypted - there is little point but anyway you should look into inotify tools - wait for "close write" event and then trigger mv.
There is nothing dubious but also nothing useful in this approach.
That is the way to do what it wants: inotify.
However, as I said on the duplicated thread and as you also say, there's no point in doing so, such "vulnerability" doesn't exits. The files are encrypted, and can't be decrypted without the password. There's absolutely no way to get the original contents back without the password that was used to crypt it. You will only get an useless heap of bytes.
The only way to get the contents back is with a password.
And yes, there's something dubious. Breaking encryption is non-legal in some -or most- countries, even weak encryptions like DVD's (which is not the case here, since rar uses AES128).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.