LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-13-2008, 09:42 AM   #1
pogo123
LQ Newbie
 
Registered: Nov 2008
Posts: 3

Rep: Reputation: 0
Exclamation 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.

Thanks in advance for your help in this matter.
 
Old 11-13-2008, 01:58 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Can you please elaborate on the WHY? I find this idea
very dubious indeed....



Cheers,
Tink
 
Old 11-13-2008, 03:34 PM   #3
pogo123
LQ Newbie
 
Registered: Nov 2008
Posts: 3

Original Poster
Rep: Reputation: 0
ok

very well, lets forget about the rar proc... any ideas on how to accomplish the process.

just for the sake of trying to help a fellow member
 
Old 11-13-2008, 04:14 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
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.
 
Old 11-13-2008, 04:54 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,310
Blog Entries: 54

Rep: Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860
Quote:
Originally Posted by pixellany View Post
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 View Post
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.
 
Old 11-13-2008, 07:07 PM   #6
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,094
Blog Entries: 2

Rep: Reputation: 111Reputation: 111
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.
 
Old 11-13-2008, 10:59 PM   #7
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Why not just hack the unrar source code?
ta0kira
 
Old 11-14-2008, 05:46 AM   #8
comm2k
LQ Newbie
 
Registered: Jul 2008
Posts: 28

Rep: Reputation: 16
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.
 
Old 11-14-2008, 06:21 AM   #9
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,040

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
Quote:
Originally Posted by comm2k View Post
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).
 
  


Reply

Tags
ubuntu


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
move files without overwriting files nathan2225 Linux - General 1 04-11-2008 04:01 PM
How do I move files without overwrite exitng files? nadavvin Linux - General 10 11-03-2006 02:49 PM
how to move location to store temp device and socket files? hedpe Linux - General 1 03-09-2006 06:41 AM
Squid - cache incomplete downloaded files zsolt_tuser Linux - Networking 3 08-13-2005 01:24 PM
P2P (xmule) and incomplete files peeples Linux - Software 1 05-08-2004 10:19 AM


All times are GMT -5. The time now is 01:23 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration