Merge lp:~mterry/deja-dup/gio-mount-password into lp:deja-dup/22

Proposed by Michael Terry
Status: Merged
Merged at revision: 1306
Proposed branch: lp:~mterry/deja-dup/gio-mount-password
Merge into: lp:deja-dup/22
Diff against target: 208 lines (+61/-16)
7 files modified
common/Backend.vala (+1/-1)
common/BackendAuto.vala (+1/-1)
common/BackendFile.vala (+44/-1)
common/BackendRackspace.vala (+1/-1)
common/BackendS3.vala (+1/-1)
common/BackendU1.vala (+1/-1)
common/Duplicity.vala (+12/-10)
To merge this branch: bzr merge lp:~mterry/deja-dup/gio-mount-password
Reviewer Review Type Date Requested Status
Ken VanDine Approve
Review via email: mp+98561@code.launchpad.net

This proposal supersedes a proposal from 2012-03-19.

Description of the change

If duplicity is run under sudo (as happens when non-home data is backed up), it can't use the user's remote mount. So it previously just aborted. This branch works around that.

To test:
 * Setup Deja Dup like so:
   - Include "/bin"
   - Make your backup location a remote GVFS location that needs a password, like an FTP server or SSH server
 * Make a backup
 * Try to restore (./deja-dup/deja-dup --restore)

Before the patch:
 * You should get prompted for your root password and it will fail with "Connection failed, please check your password: Login dialog cancelled"

After the patch:
 * You should get *not* get prompted for your root password and it will restore, even though nothing got restored (this is a bug -- I need to make it warn about all the files that didn't get restored)

To post a comment you must log in.
Revision history for this message
Michael Terry (mterry) wrote : Posted in a previous version of this proposal

Hrm, this needs some more thinking. If a user mounts the location first, but does not save the mount info in the keyring, we have no way to get to it. Seems awkward that we're being punished for using the standard GNOME mount infrastructure, but there ya go.

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

This is still a work in progress because duplicity doesn't currently report permission errors when restoring... This yak is big.

Revision history for this message
Ken VanDine (ken-vandine) wrote :

The diff looks OK to me, however following your steps to test this I got slightly different results. I chose a remote storage location, SSH and backed up /TEST which was only writtable by root. I removed all the files in /TEST and attempted a restore. I didn't get prompted for a password and it reported a successful restore with no warnings. However, no files were actually restored.

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

Oh! I thought I edited the description of this merge to change what I expected. What you describe is what I expect. :)

The big difference in this branch is just not asking for a password. The restore will have no effect, but will say it succeeded (which is a whole 'nother problem).

Revision history for this message
Ken VanDine (ken-vandine) wrote :

OK, it looks good then. Certainly an improvement over the previous behavior :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'common/Backend.vala'
2--- common/Backend.vala 2012-03-21 02:54:21 +0000
3+++ common/Backend.vala 2012-03-21 03:04:22 +0000
4@@ -31,7 +31,7 @@
5 public abstract bool is_native(); // must be callable when nothing is mounted, nothing is prepared
6 public virtual Icon? get_icon() {return null;}
7
8- public abstract string get_location();
9+ public abstract string get_location(ref bool as_root);
10 public abstract string get_location_pretty(); // short description for user
11
12 public virtual async bool is_ready(out string when) {when = null; return true;} // must be callable when nothing is mounted, nothing is prepared
13
14=== modified file 'common/BackendAuto.vala'
15--- common/BackendAuto.vala 2012-03-21 02:54:21 +0000
16+++ common/BackendAuto.vala 2012-03-21 03:04:22 +0000
17@@ -40,7 +40,7 @@
18 return false;
19 }
20
21- public override string get_location() {
22+ public override string get_location(ref bool as_root) {
23 return "invalid";
24 }
25
26
27=== modified file 'common/BackendFile.vala'
28--- common/BackendFile.vala 2012-03-21 02:54:21 +0000
29+++ common/BackendFile.vala 2012-03-21 03:04:22 +0000
30@@ -64,9 +64,52 @@
31 }
32
33 // Location will be mounted by this time
34- public override string get_location()
35+ public override string get_location(ref bool as_root)
36 {
37 var file = get_file_from_settings();
38+
39+ if (as_root && !file.is_native()) {
40+ // OK... Root can't use GVFS URIs as-is because it would need access to
41+ // our GVFS mounts which are only available on our session dbus. Which
42+ // root can't talk to. Possible workarounds:
43+ // * Some magic to let root talk to our gvfs daemons (haven't found yet)
44+ // * Use FUSE local paths (root also isn't given access to these mounts)
45+ // * Have duplicity notice that it needs root to write to a file, and
46+ // then restart itself under sudo. But then we'd just hit the same
47+ // problem again but now duplicity has to solve it...
48+ // * Restore to a temporary folder and move files over with sudo. This
49+ // is what we used to always do in older deja-dup. But it had
50+ // several problems with consuming the hard drive, especially if the
51+ // user had partitioned in ways we didn't expect. Hard to know where
52+ // a safe spot is to hoard all the files.
53+ // * Pass mount username/password to duplicity as environment variables
54+ // and have root do the mount itself. This could work... if we had
55+ // a reliable way to get the username/password. We could get it from
56+ // keyring (even then, only a guess, since the daemon could have set
57+ // the 'object' or 'authtype' fields, which we don't know if it did)
58+ // or from a MountOperation. But a user could have mounted it earlier
59+ // in session without saving password in keyring. And we can't force
60+ // an unmount on the user just so we can remount it.
61+ // * Have duplicity try to mount and ask user for password. We'd need
62+ // to add functionality to duplicity to allow a conversation between a
63+ // driving app like deja-dup and itself, to be able to proxy these
64+ // prompts and questions to the user. This would work nicely, but is
65+ // a very different interaction model than duplicity uses today.
66+ // Much more deja-dup-focused. If we're going down this direction,
67+ // there are all sorts of two-way interactions that we could stand to
68+ // benefit from. Would require a deep rethink of our driving model.
69+ //
70+ // So in the absence of an actually good solution, we'll just disable
71+ // running under sudo if the location is remote. :( Maybe our
72+ // over-eager needs-root algorithm got it wrong anyway. Regardless, this
73+ // way the user will get a permissions denied error that will point them
74+ // in the direction of trying to restore in a new folder rather than on
75+ // top of their running system, which, let's be honest, is probably not
76+ // a good idea anyway. BTW, where does Napolean keep his armies?
77+ // In his sleevies!
78+ as_root = false;
79+ }
80+
81 return file.get_uri();
82 }
83
84
85=== modified file 'common/BackendRackspace.vala'
86--- common/BackendRackspace.vala 2012-03-21 02:54:21 +0000
87+++ common/BackendRackspace.vala 2012-03-21 03:04:22 +0000
88@@ -50,7 +50,7 @@
89 return yield Network.get().can_reach ("http://%s/".printf(RACKSPACE_SERVER));
90 }
91
92- public override string get_location()
93+ public override string get_location(ref bool as_root)
94 {
95 var settings = get_settings(RACKSPACE_ROOT);
96 var container = get_folder_key(settings, RACKSPACE_CONTAINER_KEY);
97
98=== modified file 'common/BackendS3.vala'
99--- common/BackendS3.vala 2012-03-21 02:54:21 +0000
100+++ common/BackendS3.vala 2012-03-21 03:04:22 +0000
101@@ -60,7 +60,7 @@
102 return yield Network.get().can_reach ("http://%s/".printf(S3_SERVER));
103 }
104
105- public override string get_location()
106+ public override string get_location(ref bool as_root)
107 {
108 var settings = get_settings(S3_ROOT);
109
110
111=== modified file 'common/BackendU1.vala'
112--- common/BackendU1.vala 2012-03-21 02:54:21 +0000
113+++ common/BackendU1.vala 2012-03-21 03:04:22 +0000
114@@ -151,7 +151,7 @@
115 return yield Network.get().can_reach ("https://one.ubuntu.com/");
116 }
117
118- public override string get_location()
119+ public override string get_location(ref bool as_root)
120 {
121 var settings = get_settings(U1_ROOT);
122 var folder = get_folder_key(settings, U1_FOLDER_KEY);
123
124=== modified file 'common/Duplicity.vala'
125--- common/Duplicity.vala 2012-03-21 02:54:21 +0000
126+++ common/Duplicity.vala 2012-03-21 03:04:22 +0000
127@@ -82,7 +82,6 @@
128
129 DuplicityInstance inst;
130
131- string remote;
132 List<string> backend_argv;
133 List<string> saved_argv;
134 List<string> saved_envp;
135@@ -166,7 +165,6 @@
136 {
137 // save arguments for calling duplicity again later
138 mode = original_mode;
139- this.remote = backend.get_location();
140 this.backend = backend;
141 saved_argv = new List<string>();
142 saved_envp = new List<string>();
143@@ -206,6 +204,11 @@
144 return 0;
145 }
146
147+ string get_remote ()
148+ {
149+ return backend.get_location(ref needs_root);
150+ }
151+
152 void expand_links_in_file(File file, ref List<File> all, bool include, List<File>? seen = null)
153 {
154 // For symlinks, we want to add the link and its target to the list.
155@@ -558,7 +561,7 @@
156 var cleanup_argv = new List<string>();
157 cleanup_argv.append("cleanup");
158 cleanup_argv.append("--force");
159- cleanup_argv.append(this.remote);
160+ cleanup_argv.append(get_remote());
161
162 set_status(_("Cleaning up…"));
163 connect_and_start(null, null, cleanup_argv);
164@@ -572,7 +575,7 @@
165 argv.append("remove-all-but-n-full");
166 argv.append("%d".printf(cutoff));
167 argv.append("--force");
168- argv.append(this.remote);
169+ argv.append(get_remote());
170
171 set_status(_("Cleaning up…"));
172 connect_and_start(null, null, argv);
173@@ -1013,8 +1016,7 @@
174 case "S3CreateError":
175 if (text.contains("<Code>BucketAlreadyExists</Code>")) {
176 if (((BackendS3)backend).bump_bucket()) {
177- remote = backend.get_location();
178- if (restart())
179+ if (restart()) // get_remote() will eventually grab new bucket name
180 return;
181 }
182
183@@ -1375,21 +1377,21 @@
184 argv.prepend("full");
185 argv.append("--volsize=%d".printf(get_volsize()));
186 argv.append(local_arg.get_path());
187- argv.append(remote);
188+ argv.append(get_remote());
189 break;
190 case Operation.Mode.RESTORE:
191 argv.prepend("restore");
192 argv.append("--force");
193- argv.append(remote);
194+ argv.append(get_remote());
195 argv.append(local_arg.get_path());
196 break;
197 case Operation.Mode.STATUS:
198 argv.prepend("collection-status");
199- argv.append(remote);
200+ argv.append(get_remote());
201 break;
202 case Operation.Mode.LIST:
203 argv.prepend("list-current-files");
204- argv.append(remote);
205+ argv.append(get_remote());
206 break;
207 }
208 }

Subscribers

People subscribed via source and target branches