Merge lp:~bjornt/landscape-client/remove-smart-update into lp:~landscape/landscape-client/trunk

Proposed by Björn Tillenius
Status: Merged
Approved by: Alberto Donato
Approved revision: 573
Merged at revision: 560
Proposed branch: lp:~bjornt/landscape-client/remove-smart-update
Merge into: lp:~landscape/landscape-client/trunk
Prerequisite: lp:~bjornt/landscape-client/remove-smart-methods
Diff against target: 387 lines (+30/-167)
12 files modified
landscape/constants.py (+2/-2)
landscape/manager/aptsources.py (+2/-2)
landscape/manager/tests/test_aptsources.py (+1/-1)
landscape/package/releaseupgrader.py (+2/-2)
landscape/package/reporter.py (+8/-9)
landscape/package/tests/test_changer.py (+2/-3)
landscape/package/tests/test_releaseupgrader.py (+2/-2)
landscape/package/tests/test_reporter.py (+9/-9)
landscape/package/tests/test_taskhandler.py (+1/-1)
landscape/watchdog.py (+1/-1)
smart-update/Makefile (+0/-6)
smart-update/smart-update.c (+0/-129)
To merge this branch: bzr merge lp:~bjornt/landscape-client/remove-smart-update
Reviewer Review Type Date Requested Status
Alberto Donato (community) Approve
Mike Milner (community) Approve
Review via email: mp+105288@code.launchpad.net

Description of the change

Remove the smart-update command and remove all mentions of it in the
client code. I changed all places that mention smart-update to talk
about apt-update instead.

To post a comment you must log in.
573. By Björn Tillenius

Remove some smart references in comments.

Revision history for this message
Mike Milner (milner) wrote :

Yea! One less suid root binary!

Looks great, +1

review: Approve
Revision history for this message
Alberto Donato (ack) wrote :

Looks good, +1!

Just one nitpick:

+ @cvar apt_update_interval: Don't update the Apt index more often

+ The package (apt) cache should be reset between task runs.

"APT" should be uppercase

review: Approve
574. By Björn Tillenius

Typos.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/constants.py'
2--- landscape/constants.py 2012-04-04 14:03:04 +0000
3+++ landscape/constants.py 2012-05-16 08:39:17 +0000
4@@ -26,8 +26,8 @@
5 # package reporter.
6 # 2. We lost some package data, for example by a deb archive becoming
7 # inaccessible for a while. The earliest we can reasonably assume that to be
8-# resolved is in 60 minutes, when the smart cronjob runs again.
9+# resolved is in 60 minutes, when the package reporter runs again.
10
11 # So we'll give the problem one chance to resolve itself, by only waiting for
12-# one run of smart update.
13+# one run of apt-update.
14 UNKNOWN_PACKAGE_DATA_TIMEOUT = 70 * 60
15
16=== modified file 'landscape/manager/aptsources.py'
17--- landscape/manager/aptsources.py 2011-07-07 09:19:59 +0000
18+++ landscape/manager/aptsources.py 2012-05-16 08:39:17 +0000
19@@ -156,8 +156,8 @@
20 """Once the repositories are modified, trigger a reporter run."""
21 reporter = find_reporter_command()
22
23- # Force a smart-update run, because the sources.list has changed
24- args = ["--force-smart-update"]
25+ # Force an apt-update run, because the sources.list has changed
26+ args = ["--force-apt-update"]
27
28 if self.registry.config.config is not None:
29 args.append("--config=%s" % self.registry.config.config)
30
31=== modified file 'landscape/manager/tests/test_aptsources.py'
32--- landscape/manager/tests/test_aptsources.py 2011-12-09 14:18:29 +0000
33+++ landscape/manager/tests/test_aptsources.py 2012-05-16 08:39:17 +0000
34@@ -388,7 +388,7 @@
35
36 def _run_process(command, args, env={}, path=None, uid=None, gid=None):
37 self.assertEqual(find_reporter_command(), command)
38- self.assertEqual(["--force-smart-update", "--config=%s" %
39+ self.assertEqual(["--force-apt-update", "--config=%s" %
40 self.manager.config.config], args)
41 deferred.callback(("ok", "", 0))
42 return deferred
43
44=== modified file 'landscape/package/releaseupgrader.py'
45--- landscape/package/releaseupgrader.py 2012-03-05 14:11:42 +0000
46+++ landscape/package/releaseupgrader.py 2012-05-16 08:39:17 +0000
47@@ -301,8 +301,8 @@
48
49 reporter = find_reporter_command()
50
51- # Force a smart-update run, because the sources.list has changed
52- args = ["--force-smart-update"]
53+ # Force an apt-update run, because the sources.list has changed
54+ args = ["--force-apt-update"]
55
56 if self._config.config is not None:
57 args.append("--config=%s" % self._config.config)
58
59=== modified file 'landscape/package/reporter.py'
60--- landscape/package/reporter.py 2012-05-09 23:55:33 +0000
61+++ landscape/package/reporter.py 2012-05-16 08:39:17 +0000
62@@ -30,9 +30,9 @@
63 reporter-specific options.
64 """
65 parser = super(PackageReporterConfiguration, self).make_parser()
66- parser.add_option("--force-smart-update", default=False,
67+ parser.add_option("--force-apt-update", default=False,
68 action="store_true",
69- help="Force running smart-update.")
70+ help="Force running apt-update.")
71 return parser
72
73
74@@ -40,15 +40,14 @@
75 """Report information about the system packages.
76
77 @cvar queue_name: Name of the task queue to pick tasks from.
78- @cvar smart_update_interval: Time interval in minutes to pass to
79- the C{--after} command line option of C{smart-update}.
80+ @cvar apt_update_interval: Don't update the APT index more often
81+ than the given interval in minutes.
82 """
83 config_factory = PackageReporterConfiguration
84
85 queue_name = "reporter"
86
87- smart_update_interval = 60
88- smart_update_filename = "/usr/lib/landscape/smart-update"
89+ apt_update_interval = 60
90 apt_update_filename = "/usr/lib/landscape/apt-update"
91 sources_list_filename = "/etc/apt/sources.list"
92 sources_list_directory = "/etc/apt/sources.list.d"
93@@ -192,8 +191,8 @@
94
95 @return: a deferred returning (out, err, code)
96 """
97- if (self._config.force_smart_update or self._apt_sources_have_changed()
98- or self._apt_update_timeout_expired(self.smart_update_interval)):
99+ if (self._config.force_apt_update or self._apt_sources_have_changed()
100+ or self._apt_update_timeout_expired(self.apt_update_interval)):
101
102 result = spawn_process(self.apt_update_filename)
103
104@@ -359,7 +358,7 @@
105 def request_unknown_hashes(self):
106 """Detect available packages for which we have no hash=>id mappings.
107
108- This method will verify if there are packages that Apt knows
109+ This method will verify if there are packages that APT knows
110 about but for which we don't have an id yet (no hash => id
111 translation), and deliver a message (unknown-package-hashes)
112 to request them.
113
114=== modified file 'landscape/package/tests/test_changer.py'
115--- landscape/package/tests/test_changer.py 2012-05-08 23:59:09 +0000
116+++ landscape/package/tests/test_changer.py 2012-05-16 08:39:17 +0000
117@@ -435,7 +435,7 @@
118
119 def test_tasks_are_isolated_cache(self):
120 """
121- The package (apt/smart) cache should be reset between task runs.
122+ The package (APT) cache should be reset between task runs.
123 In this test, we try to run two different operations, first
124 installing package 2, then removing package 1. Both tasks will
125 fail for lack of superuser privileges. If the package cache
126@@ -527,7 +527,7 @@
127 """
128 Besides asking for individual changes, the server may also request
129 the client to perform a global upgrade. This would be the equivalent
130- of a "smart upgrade" command being executed in the command line.
131+ of a "apt-get upgrade" command being executed in the command line.
132 """
133 hash1, hash2 = self.set_pkg2_upgrades_pkg1()
134 self.store.set_hash_ids({hash1: 1, hash2: 2})
135@@ -640,7 +640,6 @@
136 getuid_mock()
137 self.mocker.result(0)
138
139- # The order matters (first smart then gid and finally uid)
140 self.mocker.order()
141
142 # We want to return a known gid
143
144=== modified file 'landscape/package/tests/test_releaseupgrader.py'
145--- landscape/package/tests/test_releaseupgrader.py 2012-03-05 14:11:42 +0000
146+++ landscape/package/tests/test_releaseupgrader.py 2012-05-16 08:39:17 +0000
147@@ -655,7 +655,7 @@
148
149 def check_result((out, err, code)):
150 self.assertFalse(os.path.exists(upgrade_tool_directory))
151- self.assertEqual(out, "--force-smart-update\n%s\n"
152+ self.assertEqual(out, "--force-apt-update\n%s\n"
153 % os.getcwd())
154 self.assertEqual(err, "")
155 self.assertEqual(code, 0)
156@@ -738,7 +738,7 @@
157 result = self.upgrader.finish()
158
159 def check_result((out, err, code)):
160- self.assertEqual(out, "--force-smart-update "
161+ self.assertEqual(out, "--force-apt-update "
162 "--config=/some/config\n")
163 self.assertEqual(err, "")
164 self.assertEqual(code, 0)
165
166=== modified file 'landscape/package/tests/test_reporter.py'
167--- landscape/package/tests/test_reporter.py 2012-05-09 23:50:30 +0000
168+++ landscape/package/tests/test_reporter.py 2012-05-16 08:39:17 +0000
169@@ -29,15 +29,15 @@
170
171 class PackageReporterConfigurationTest(unittest.TestCase):
172
173- def test_force_smart_update_option(self):
174+ def test_force_apt_update_option(self):
175 """
176- The L{PackageReporterConfiguration} supports a '--force-smart-update'
177+ The L{PackageReporterConfiguration} supports a '--force-apt-update'
178 command line option.
179 """
180 config = PackageReporterConfiguration()
181- self.assertFalse(config.force_smart_update)
182- config.load(["--force-smart-update"])
183- self.assertTrue(config.force_smart_update)
184+ self.assertFalse(config.force_apt_update)
185+ config.load(["--force-apt-update"])
186+ self.assertTrue(config.force_apt_update)
187
188
189 class PackageReporterTestMixin(object):
190@@ -1136,13 +1136,13 @@
191 reactor.callWhenRunning(do_test)
192 return deferred
193
194- def test_run_apt_update_with_force_smart_update(self):
195+ def test_run_apt_update_with_force_apt_update(self):
196 """
197 L{PackageReporter.run_apt_update} forces an apt-update run if the
198- '--force-smart-update' command line option was passed.
199+ '--force-apt-update' command line option was passed.
200 """
201 self.makeFile("", path=self.config.update_stamp_filename)
202- self.config.load(["--force-smart-update"])
203+ self.config.load(["--force-apt-update"])
204 self._make_fake_apt_update()
205
206 deferred = Deferred()
207@@ -1158,7 +1158,7 @@
208 reactor.callWhenRunning(do_test)
209 return deferred
210
211- def test_run_apt_update_with_force_smart_update_if_sources_changed(self):
212+ def test_run_apt_update_with_force_apt_update_if_sources_changed(self):
213 """
214 L{PackageReporter.run_apt_update} forces an apt-update run if the APT
215 sources.list file has changed.
216
217=== modified file 'landscape/package/tests/test_taskhandler.py'
218--- landscape/package/tests/test_taskhandler.py 2012-05-08 23:25:08 +0000
219+++ landscape/package/tests/test_taskhandler.py 2012-05-16 08:39:17 +0000
220@@ -29,7 +29,7 @@
221 def test_update_stamp_option(self):
222 """
223 L{PackageReporterConfiguration.update_stamp_filename} points
224- to the smart-update stamp file.
225+ to the update-stamp file.
226 """
227 config = PackageTaskHandlerConfiguration()
228 self.assertEqual(
229
230=== modified file 'landscape/watchdog.py'
231--- landscape/watchdog.py 2012-03-06 09:17:51 +0000
232+++ landscape/watchdog.py 2012-05-16 08:39:17 +0000
233@@ -631,7 +631,7 @@
234 In particular unset all variables beginning with DEBIAN_ or DEBCONF_,
235 to avoid any problems when landscape-client is invoked from its
236 postinst script. Some environment variables may be set which would affect
237- *other* maintainer scripts which landscape-client invokes (via smart).
238+ *other* maintainer scripts which landscape-client invokes.
239 """
240 for key in os.environ.keys():
241 if (key.startswith("DEBIAN_")
242
243=== removed directory 'smart-update'
244=== removed file 'smart-update/Makefile'
245--- smart-update/Makefile 2009-06-08 10:51:59 +0000
246+++ smart-update/Makefile 1970-01-01 00:00:00 +0000
247@@ -1,6 +0,0 @@
248-
249-smart-update: smart-update.c
250- $(CC) $(CFLAGS) -Wall $< -o $@
251-
252-clean:
253- rm -f smart-update
254
255=== removed file 'smart-update/smart-update.c'
256--- smart-update/smart-update.c 2010-04-14 14:08:30 +0000
257+++ smart-update/smart-update.c 1970-01-01 00:00:00 +0000
258@@ -1,129 +0,0 @@
259-/*
260-
261- Copyright (c) 2004 Conectiva, Inc.
262- Copyright (c) 2009 Canonical, Ltd.
263-
264- Written by Gustavo Niemeyer <niemeyer@conectiva.com>,
265- Free Ekanayaka <free.ekanayaka@canonical.com>
266-
267- This file is part of Smart Package Manager.
268-
269- Smart Package Manager is free software; you can redistribute it and/or
270- modify it under the terms of the GNU General Public License as published
271- by the Free Software Foundation; either version 2 of the License, or (at
272- your option) any later version.
273-
274- Smart Package Manager is distributed in the hope that it will be useful,
275- but WITHOUT ANY WARRANTY; without even the implied warranty of
276- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
277- General Public License for more details.
278-
279- You should have received a copy of the GNU General Public License
280- along with Smart Package Manager; if not, write to the Free Software
281- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
282-
283-*/
284-#define _GNU_SOURCE
285-#include <sys/resource.h>
286-#include <sys/types.h>
287-#include <sys/stat.h>
288-#include <grp.h>
289-#include <unistd.h>
290-#include <stdlib.h>
291-#include <string.h>
292-#include <errno.h>
293-#include <stdio.h>
294-#include <pwd.h>
295-
296-#define GNUPG_HOME "/root/.gnupg"
297-
298-int main(int argc, char *argv[], char *envp[])
299-{
300- char *smart_argv[] = {"/usr/share/smart/smart", "update", NULL, NULL};
301- char *smart_envp[] = {"PATH=/bin:/usr/bin", NULL, NULL};
302-
303- // Set the HOME environment variable
304- struct passwd *pwd = getpwuid(geteuid());
305- if (!pwd) {
306- fprintf(stderr, "error: Unable to find passwd entry for uid %d (%s)\n",
307- geteuid(), strerror(errno));
308- exit(1);
309- }
310- if (asprintf(&smart_envp[1], "HOME=%s", pwd->pw_dir) == -1) {
311- perror("error: Unable to create HOME environment variable");
312- exit(1);
313- }
314-
315- // Handle the --after command line option
316- if (argc != 1) {
317- if (argc != 3 || strcmp(argv[1], "--after") != 0) {
318- fprintf(stderr, "error: Unsupported command line option\n");
319- exit(1);
320- }
321- char *end;
322- long interval = strtol(argv[2], &end, 10);
323- if (end == argv[2]) {
324- fprintf(stderr, "error: Interval value '%s' not a number\n", argv[2]);
325- exit(1);
326- }
327- if (asprintf(&smart_argv[2], "--after=%ld", interval) == -1) {
328- perror("error: Unable to create argument variable");
329- exit(1);
330- }
331- }
332-
333- // Drop any supplementary group
334- if (setgroups(0, NULL) == -1) {
335- perror("error: Unable to set supplementary groups IDs");
336- exit(1);
337- }
338-
339- // Set real/effective gid and uid
340- if (setregid(pwd->pw_gid, pwd->pw_gid) == -1) {
341- fprintf(stderr, "error: Unable to set real and effective gid (%s)\n",
342- strerror(errno));
343- exit(1);
344- }
345- if (setreuid(pwd->pw_uid, pwd->pw_uid) == -1) {
346- perror("error: Unable to set real and effective uid");
347- exit(1);
348- }
349-
350- // Close all file descriptors except the standard ones
351- struct rlimit rlp;
352- if (getrlimit(RLIMIT_NOFILE, &rlp) == -1) {
353- perror("error: Unable to determine file descriptor limits");
354- exit(1);
355- }
356- int file_max;
357- if (rlp.rlim_max == RLIM_INFINITY || rlp.rlim_max > 4096)
358- file_max = 4096;
359- else
360- file_max = rlp.rlim_max;
361- int file;
362- for (file = 3; file < file_max; file++) {
363- close(file);
364- }
365-
366- // Set umask to 022
367- umask(S_IWGRP | S_IWOTH);
368-
369- if (chdir("/") == -1) {
370- perror("error: Unable to change working directory");
371- exit(1);
372- }
373-
374- // XXX This is a workaround for Bug #562496, that makes the gpg command
375- // invoked by smart fail if the data directory doesn't exist yet
376- struct stat st;
377- if (stat(GNUPG_HOME, &st) != 0)
378- mkdir(GNUPG_HOME, S_IRWXU);
379-
380- // Run smart update
381- execve(smart_argv[0], smart_argv, smart_envp);
382- perror("error: Unable to execute smart");
383- return 1;
384-}
385-
386-/* vim:ts=4:sw=4:et
387-*/

Subscribers

People subscribed via source and target branches

to all changes: