[bug #24100] Can't specify the root directory ('c:\') as src in native win32 binary.

View: New views
14 Messages — Rating Filter:   Alert me  

[bug #24100] Can't specify the root directory ('c:\') as src in native win32 binary.

by John Tartar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


URL:
  <http://savannah.nongnu.org/bugs/?24100>

                 Summary: Can't specify the root directory ('c:\') as src in
native win32 binary.
                 Project: rdiff-backup
            Submitted by: ahd71
            Submitted on: tis 19 aug 2008 01.01.16
                Category: None
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

The native win32 binary, release 1.2, can't use the root directory of a
windows file system as source directory without a exception on execution.

Exception 'Unexpected end to file description c:\' raised of class '<class
'rdiff_backup.SetConnections.SetConnectionsException'>':
  File "rdiff_backup\Main.pyc", line 302, in error_check_Main
  File "rdiff_backup\Main.pyc", line 317, in Main
  File "rdiff_backup\SetConnections.pyc", line 59, in get_cmd_pairs
  File "rdiff_backup\SetConnections.pyc", line 107, in parse_file_desc
  File "rdiff_backup\SetConnections.pyc", line 98, in check_len

The function 'parse_file_desc()' in 'SetConnection.py' works with 'c:\dir'
but not with 'c:\' or 'c:\dir1\'

The problem is strings which ends with a backslash (as the logic thinks that
it is a escape character which it isn't in this case and that will generate an
index out of bound error)





    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?24100>

_______________________________________________
  Meddelandet skickades via/av Savannah
  http://savannah.nongnu.org/



_______________________________________________
Rdiff-backup-bugs mailing list
Rdiff-backup-bugs@...
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-bugs

[bug #24100] Can't specify the root directory ('c:\') as src in native win32 binary.

by John Tartar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Update of bug #24100 (project rdiff-backup):

                  Status:                    None => In Progress            
             Assigned to:                    None => owsla                  
                 Summary: Can't specify the root directory ('c:\') as src in
native win32 binary. => Can't specify the root directory ('c:') as src in
native win32 binary.

    _______________________________________________________

Follow-up Comment #1:

Out of curiosity, what happens if you try switching all of the '' characters
to '/' ?

Python on Windows is smart enough to translate automatically, for example:

f = open("C:/Documents and Settings/Administrator/Desktop/test.txt", "w")
f.write("test file")
f.close()

works perfectly to create a test file on my desktop.

I admit it's unintuitive, however, it may be the most simple solution.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?24100>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
Rdiff-backup-bugs mailing list
Rdiff-backup-bugs@...
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-bugs

[bug #24100] Can't specify the root directory ('c:\') as src in native win32 binary.

by John Tartar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #2, bug #24100 (project rdiff-backup):

Sorry, it didn't work to use a regular slash instead of a backslash. I got
the following stack trace then:

Data: {'type': None}' raised of class '<type 'exceptions.AssertionError'>':
  File "rdiff_backupMain.pyc", line 302, in error_check_Main
  File "rdiff_backupMain.pyc", line 322, in Main
  File "rdiff_backupMain.pyc", line 278, in take_action
  File "rdiff_backupMain.pyc", line 332, in Backup
  File "rdiff_backupfs_abilities.pyc", line 779, in backup_set_globals
  File "rdiff_backupfs_abilities.pyc", line 522, in get_readonly_fsa
  File "rdiff_backupfs_abilities.pyc", line 128, in init_readonly
  File "rdiff_backupfs_abilities.pyc", line 342, in
set_case_sensitive_readonly

  File "rdiff_backupfs_abilities.pyc", line 325, in test_triple


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?24100>

_______________________________________________
  Meddelandet skickades via/av Savannah
  http://savannah.nongnu.org/



_______________________________________________
Rdiff-backup-bugs mailing list
Rdiff-backup-bugs@...
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-bugs

[bug #24100] Can't specify the root directory ('c:\') as src in native win32 binary.

by John Tartar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #4, bug #24100 (project rdiff-backup):


c:\ and c:/ did not work (Fatal Error: Source directory ... does not exist)

However the combination c:/ did work.

Thanks for your time and effort in resolving this issue!

BR/ahd71




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?24100>

_______________________________________________
  Meddelandet skickades via/av Savannah
  http://savannah.nongnu.org/



_______________________________________________
Rdiff-backup-bugs mailing list
Rdiff-backup-bugs@...
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-bugs

[bug #24100] Can't specify the root directory ('c:\') as src in native win32 binary.

by John Tartar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #5, bug #24100 (project rdiff-backup):

Hi,

It's the function parse_file_desc() which is the problem (which never were a
problem as long as it was used in linux or cygwin as a single trailing
backslash won't occur in real life).

Just call the function parse_file_desc("c:") and you will see the problem
which results in a "index out of range" because of the logic which increases
the index and assumes that a single backslash can't occur in a string.

BR / Ahd71

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?24100>

_______________________________________________
  Meddelandet skickades via/av Savannah
  http://savannah.nongnu.org/



_______________________________________________
Rdiff-backup-bugs mailing list
Rdiff-backup-bugs@...
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-bugs

[bug #24100] Can't specify the root directory ('c:\') as src in native win32 binary.

by John Tartar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #8, bug #24100 (project rdiff-backup):

Hi,

I don't have a compile/build environment to make the code changes myself and
test. I was thinking of a command line similar like this example:

rdiff-backup --include 'c:documents' --include 'c:images' --exclude '**' c:
d:backup

Can't the function use file_desc.split("::") in some way?

BR /ahd71

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?24100>

_______________________________________________
  Meddelandet skickades via/av Savannah
  http://savannah.nongnu.org/



_______________________________________________
Rdiff-backup-bugs mailing list
Rdiff-backup-bugs@...
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-bugs

[bug #24100] Can't specify the root directory ('c:\') as src in native win32 binary.

by John Tartar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #9, bug #24100 (project rdiff-backup):

the quoting around directory names would be nice to have but not nescesary,
but some way to use directories with spaces in the name must of course exist.
One solution is to use the globbing options and a file list in a file maybe?

the folder in windows called:
c:documents and settings
could be written at command line as either
'c:documents and settings'
or as
c:\documents and settings
but the last option requires windows users to learn new habits if they are
unfamiliar with linux escape syntax.

BR / ahd71

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?24100>

_______________________________________________
  Meddelandet skickades via/av Savannah
  http://savannah.nongnu.org/



_______________________________________________
Rdiff-backup-bugs mailing list
Rdiff-backup-bugs@...
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-bugs

[bug #24100] Can't specify the root directory ('c:\') as src in native win32 binary.

by John Tartar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #10, bug #24100 (project rdiff-backup):

All these three combination works...
rdiff-backup-1.2.0-win32.exe c:\. c:tmp1
rdiff-backup-1.2.0-win32.exe c:\ c:tmp2
rdiff-backup-1.2.0-win32.exe c:. c:tmp3

...But not the following one...
rdiff-backup-1.2.0-win32.exe c: c:tmp4

At the same time, none of the three first variants works if an option like
--include c:data
is added. This will then result in an error like:

Fatal Error: Fatal Error: The file specification
    'c:data'
cannot match any files in the base directory
    'c:\'

BR /ahd71

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?24100>

_______________________________________________
  Meddelandet skickades via/av Savannah
  http://savannah.nongnu.org/



_______________________________________________
Rdiff-backup-bugs mailing list
Rdiff-backup-bugs@...
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-bugs

[bug #24100] Can't specify the root directory ('c:\') as src in native win32 binary.

by John Tartar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #14, bug #24100 (project rdiff-backup):

Hi,

Sorry for beeing absent a few days.

Yes, and no, working from the root folder works with a syntax like
c:programrdiff-backuprdiff-backup-1.2.0-win32.exe c:/ c:level1level2
(where the first c:/ is a valid replacement for c: which currently doesn't
work).

That leads me to think that  isn't a problem and "unescaped" in this
situation as the  between level1 and level2 in this example works.

I think, but you know the code much better, that the only thing that needs to
be fixed is to modify the procedure so it's allows a trailing  without
generating an "out of range error".

However another problem that will come - sooner or later - is the fact that
Windows doesn't have escapecharacters the way that linux has. Because of that
it makes it hard to use folder names with spaces in if this should be allowed
on the command line. One way of solving this is to optionally allow '
surrounding directory names, but maybe this will lead to unwanted effects in
linux where this is a possible character in a filename. Am I right? Another
way of solving it is to use the globbing file list which don't need to have
this problem.

BR /ahd71

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?24100>

_______________________________________________
  Meddelandet skickades via/av Savannah
  http://savannah.nongnu.org/



_______________________________________________
Rdiff-backup-bugs mailing list
Rdiff-backup-bugs@...
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-bugs

[bug #24100] Can't specify the root directory ('c:\') as src in native win32 binary.

by John Tartar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #15, bug #24100 (project rdiff-backup):

In the procedure 'parse_file_desc' there are a source code comment which I
don't fully understand.

>> "The complication is to allow for quoting of : by a .

Can somebody explain why/when this is needed? Otherwise I suppose the use of
file_desc.split("::") could be helpful to simplify the procedure?

Regarding the handling of long filenames in windows containing spaces i guess
that the easiest thing is that the user call rdiff-backup using pathnames in
the DOS convention naming style (8.3 syntax) where "c:long folder name" is
equal to "C:LONGFO~1". (Spaces removed and strings longer then 8 characters
are normally truncated to 6 characters and a tilde and digit is added to
differentiate potential naming conflicts)

If i make a 'unit test' of the procudure which testcases should I add more
then the following? (some are similiar I know but rather too many then too
few! I wanted to highligh some variants like windows using front OR backslash
and also that it should work using an optional traling backslash after a
folder name; unfortunantly not using a trailing backslash of a root folder
does not give it the same meaning and thats why this
ticket is still open, the posibility to use "c:")

testcases:

singleword
/linux/path/
c:/program1
c:program2
one:colon   << no real case, i don't know why i added it...
two::colons
server.domain::/destdir1
user@...::/destdir2
c:dir1
c:dir2    << currently failing because of trailing backslash
c:         << currently failing because of trailing backslash

BR / ahd71

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?24100>

_______________________________________________
  Meddelandet skickades via/av Savannah
  http://savannah.nongnu.org/



_______________________________________________
Rdiff-backup-bugs mailing list
Rdiff-backup-bugs@...
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-bugs

[bug #24100] Can't specify the root directory ('c:\') as src in native win32 binary.

by John Tartar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #16, bug #24100 (project rdiff-backup):

Hi,

I think that I have a very small adjustment of the code that might solve the
problem.

If we modify the the procedure 'parse_file_desc(file_desc)' in
SetConnections.py and alter...

>> if file_desc[i] == '\':

...to also have a second criteria that exclude the corner case when the
backslash is in the last position of an input string like this...

>> if (file_desc[i] == '\' and len(file_desc)<>i+1):

...it makes all my previous listed test cases to pass without the out of
range error, and hopefully solves the problem (don't have the build
environment for Windows myself yet to prove that it works the but I guess it
will)

As asked just before, I don't realy understand why we can't just search for
:: and split the string which would make the code much more readable.

What do you think about the patch? Is it a practical way of solving the
problem or does we only work around it or even worse introduce any new
potential problem?

Is it better to crash with the out of index problem then at a later stage in
some case as the "Unexpected end to file" error message explicitly just
triggers on that behaviour?

Another, but not so beautiful solution is to just cover Windows OS for this
workaround as backslash as a "escape characters" isn't relevant in Windows.

BR / Anders

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?24100>

_______________________________________________
  Meddelandet skickades via/av Savannah
  http://savannah.nongnu.org/



_______________________________________________
Rdiff-backup-bugs mailing list
Rdiff-backup-bugs@...
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-bugs

[bug #24100] Can't specify the root directory ('c:\') as src in native win32 binary.

by John Tartar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #19, bug #24100 (project rdiff-backup):

Andrew,

Thanks for the explanation of "Windows-long-path-names-with-spaces-in". Great
- both that it works and that it is already supported!

Regarding my testcase with "two::colon" it was just the worst possible names
choosen by me, it should have been written as "server::path" of course and
that passes the test (both with and without the patch).

I didn't know that :: was allowed in linux file names, but of course then the
.split method is a bad way to do it.

Take your time and give the proposed patch a second thought because I still
think that it may solve the problem. The only thing that the patch does is
that if a trailing slash exist in the string, rdiff-backup will not go thru
the following lines where the out of range error occur.
The only drawback i can think of, and you may know if there are a use case
there, is if there is a good reason to raise an error if a trailing slash
exists when used from Linux. (I suspect that the already existing error
handling are there for a reason?).
It may be neccessary to have a linux case and a windows case with an OS check
as in some other places of the code to allow/disallow a trailing slash?

BR / Anders

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?24100>

_______________________________________________
  Meddelandet skickades via/av Savannah
  http://savannah.nongnu.org/



_______________________________________________
Rdiff-backup-bugs mailing list
Rdiff-backup-bugs@...
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-bugs

[bug #24100] Can't specify the root directory ('c:\') as src in native win32 binary.

by John Tartar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #21, bug #24100 (project rdiff-backup):

Hi,

No I don't have a build environment for Windows yet, so yes please post a
link to a updated version when it's availible.

Thankyou once again for all effort you are putting into this lovely piece of
software!

BR / Anders

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?24100>

_______________________________________________
  Meddelandet skickades via/av Savannah
  http://savannah.nongnu.org/



_______________________________________________
Rdiff-backup-bugs mailing list
Rdiff-backup-bugs@...
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-bugs

[bug #24100] Can't specify the root directory ('c:\') as src in native win32 binary.

by John Tartar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #23, bug #24100 (project rdiff-backup):

Hi Andrew,

Now I know more and it seems to work good with / instead of .

In your first reply you asked me to try with / instead of  and I did, however
I did one serious mistake when doing that test. I only had access to one drive
on that computer and did something simlar to this: "rdiff-backup -v5 c:/
c:/tmp24" which didn't work as I replied but the reason is that it is on the
same drive and not because of the regular slash.

If I do the same thing but between different drives it works ("rdiff-backup
-v5 d:/ c:/tmp25") which solves the problem if the user are aware of inverting
slashes from standard windows syntax, espacially when it's a trailing slash
from a root folder.  

But, that is not a problem when it's documented which I know you already have
done (six days after that this bug report was written according to CVS).

I'm sorry to have bothered you with this discussion but I guess we have
learned something and other users might find the thread in the future if they
encounter the same problem as I did (and they didn't read the
Windows-README.txt)

You may close the bug report if you like. Have a nice weekend!

Thanks / Anders

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?24100>

_______________________________________________
  Meddelandet skickades via/av Savannah
  http://savannah.nongnu.org/



_______________________________________________
Rdiff-backup-bugs mailing list
Rdiff-backup-bugs@...
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-bugs
LightInTheBox - Buy quality products at wholesale price!