Merge lp:~mterry/duplicity/argv into lp:duplicity/0.6

Proposed by Michael Terry
Status: Merged
Merged at revision: 930
Proposed branch: lp:~mterry/duplicity/argv
Merge into: lp:duplicity/0.6
Diff against target: 12 lines (+1/-1)
1 file modified
bin/duplicity (+1/-1)
To merge this branch: bzr merge lp:~mterry/duplicity/argv
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+186699@code.launchpad.net

Description of the change

When restarting due to an 'impossible' state of more remote manifests than local manifests, there is a typo that would cause duplicity to chop off its first argument when restarting itself.

To post a comment you must log in.
Revision history for this message
edso (ed.so) wrote :

are you sure about this? reading
http://docs.python.org/2/library/os.html#os.execvpe

seems to confirm that the old code should have worked. didn't it?

..ede

On 20.09.2013 03:36, Michael Terry wrote:
> Michael Terry has proposed merging lp:~mterry/duplicity/argv into lp:duplicity.
>
> Requested reviews:
> duplicity-team (duplicity-team)
>
> For more details, see:
> https://code.launchpad.net/~mterry/duplicity/argv/+merge/186699
>
> When restarting due to an 'impossible' state of more remote manifests than local manifests, there is a typo that would cause duplicity to chop off its first argument when restarting itself.
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~duplicity-team
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~duplicity-team
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
Michael Terry (mterry) wrote :

Positive. The first argument to exec* is the actual command to run, the first array item in argv is the "name" of the program passed to the command and is generally chopped off.

You can test this with a simple python script:

#!/usr/bin/python
import os, sys
print sys.argv
if len(sys.argv) > 1:
    os.execve(sys.argv[0], sys.argv[1:], os.environ)

$ chmod +a ./test
$ ./test 1 2 3
['./test.py', '1', '2', '3']
['./test.py', '2', '3']
['./test.py', '3']
['./test.py']

Revision history for this message
edso (ed.so) wrote :

On 20.09.2013 15:18, Michael Terry wrote:
> Positive. The first argument to exec* is the actual command to run, the first array item in argv is the "name" of the program passed to the command and is generally chopped off.
>
> You can test this with a simple python script:
>
> #!/usr/bin/python
> import os, sys
> print sys.argv
> if len(sys.argv) > 1:
> os.execve(sys.argv[0], sys.argv[1:], os.environ)
>
> $ chmod +a ./test
> $ ./test 1 2 3
> ['./test.py', '1', '2', '3']
> ['./test.py', '2', '3']
> ['./test.py', '3']
> ['./test.py']
>

weird you're right! that's strangely not explicitely documented on the help page. ok, now i found something close to a documentation on this.
http://docs.python.org/2/library/os.html#process-management
"
The various exec*() functions take a list of arguments for the new program loaded into the process. In each case, the first of these arguments is passed to the new program as its own name rather than as an argument a user may have typed on a command line. For the C programmer, this is the argv[0] passed to a program’s main(). For example, os.execv('/bin/echo', ['foo', 'bar']) will only print bar on standard output; foo will seem to be ignored.
"

they'd better had documemted that they expect you to deliver a complete sys.argv array _incl_ the program name as argv[0]... tzzz..

anyway, nice catch.. ede

Revision history for this message
Kenneth Loafman (kenneth-loafman) wrote :

Good catch!

On Fri, Sep 20, 2013 at 8:48 AM, edso <email address hidden> wrote:

> On 20.09.2013 15:18, Michael Terry wrote:
> > Positive. The first argument to exec* is the actual command to run, the
> first array item in argv is the "name" of the program passed to the command
> and is generally chopped off.
> >
> > You can test this with a simple python script:
> >
> > #!/usr/bin/python
> > import os, sys
> > print sys.argv
> > if len(sys.argv) > 1:
> > os.execve(sys.argv[0], sys.argv[1:], os.environ)
> >
> > $ chmod +a ./test
> > $ ./test 1 2 3
> > ['./test.py', '1', '2', '3']
> > ['./test.py', '2', '3']
> > ['./test.py', '3']
> > ['./test.py']
> >
>
> weird you're right! that's strangely not explicitely documented on the
> help page. ok, now i found something close to a documentation on this.
> http://docs.python.org/2/library/os.html#process-management
> "
> The various exec*() functions take a list of arguments for the new program
> loaded into the process. In each case, the first of these arguments is
> passed to the new program as its own name rather than as an argument a user
> may have typed on a command line. For the C programmer, this is the argv[0]
> passed to a program’s main(). For example, os.execv('/bin/echo', ['foo',
> 'bar']) will only print bar on standard output; foo will seem to be ignored.
> "
>
> they'd better had documemted that they expect you to deliver a complete
> sys.argv array _incl_ the program name as argv[0]... tzzz..
>
> anyway, nice catch.. ede
>
> --
> https://code.launchpad.net/~mterry/duplicity/argv/+merge/186699
> You are subscribed to branch lp:duplicity.
>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/duplicity'
2--- bin/duplicity 2013-04-27 14:05:34 +0000
3+++ bin/duplicity 2013-09-20 01:35:58 +0000
4@@ -1273,7 +1273,7 @@
5 " backup then restart the backup from the beginning.") %
6 (mf_len, self.start_vol))
7 self.last_backup.delete()
8- os.execve(sys.argv[0], sys.argv[1:], os.environ)
9+ os.execve(sys.argv[0], sys.argv, os.environ)
10
11 def setLastSaved(self, mf):
12 vi = mf.volume_info_dict[self.start_vol]

Subscribers

People subscribed via source and target branches

to all changes: