Merge lp:~jseutter/landscape-client/better-config-handling into lp:~landscape/landscape-client/trunk

Proposed by Jerry Seutter
Status: Merged
Approved by: Free Ekanayaka
Approved revision: 457
Merge reported by: Jerry Seutter
Merged at revision: not available
Proposed branch: lp:~jseutter/landscape-client/better-config-handling
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 122 lines (+50/-61)
1 file modified
debian/landscape-client.postinst (+50/-61)
To merge this branch: bzr merge lp:~jseutter/landscape-client/better-config-handling
Reviewer Review Type Date Requested Status
Free Ekanayaka (community) Approve
Chad Smith Approve
Review via email: mp+94430@code.launchpad.net

Description of the change

This branch modifies two things:
- client.conf is no longer backed up before modification. This is back to the old behavior after it was recently changed.
- client.conf is only written to by landscape-config. landscape-client.postinst no longer modifies client.conf. This prevents a situation where client.conf would only be partially rewritten.

To post a comment you must log in.
Revision history for this message
Chad Smith (chad.smith) wrote :

+1 This branch behaves as you mentioned in the merge description.

tried feeding bogus values into ping_interval to validate that dpkg-reconfigure crashes and doesn't write the config file if some bogus option values live in /etc/landscape/client.conf and get passed to landscape-config cmdline.

Couple questions:
[1] Since we just now got rid of the static landscape-config header values for log_level & data_path, should these default values be added into debian/landscape-client.templates and pull a db_get $PACKAGE/data_path * log_level to pass on the cmdline to landscape-config?

68 -log_level = info
69 -data_path = /var/lib/landscape/client

[2] Why not validate if REGISTRATION_PASSWORD is non-null too before attempting a registration? I know we've got he --ok-no-register flag set but do we already allow empty registration passwords for clients?
118 + if [ -n "$ACCOUNT_NAME" -a -n "$COMPUTER_TITLE" ]; then

review: Approve
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Nice work, +1!

Regarding Chad's [1], I don't think we need to expose log_level and data_path in debconf, as changing the former is mainly meant for debugging and the latter for development. So I don't really see use cases for preseeding them, if one wants to change those values it's sufficient to edit them manually in client.conf and they will be picked up and preserved.

And regarding [2], the registration password is optional on both hosted and LDS, so the empty string is a legal value.

As for the crashing bogus values maybe we can address it in a separate branch, it doesn't seem critical as we don't prompt the user for those values, neither with debconf or the interactive landscape-config tool. Actually I'm wondering if we should include them in debconf at all.

review: Approve
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Oh Jerry, one thing I forgot to ask. Does landscape-config re-write the file all the times or does it intelligently understand when there's no change to write?

Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Never mind, just noticed that you mention in the bug that it's going to be fixed in a separate branch.

458. By Jerry Seutter

Merge from trunk.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/landscape-client.postinst'
2--- debian/landscape-client.postinst 2012-02-13 21:07:42 +0000
3+++ debian/landscape-client.postinst 2012-02-23 18:35:24 +0000
4@@ -27,68 +27,57 @@
5 configure)
6
7 CONFIG_FILE=/etc/landscape/client.conf
8- if [ -f $CONFIG_FILE ]; then
9- mv --backup=numbered $CONFIG_FILE $CONFIG_FILE.bak
10- fi
11+ # Get configuration values from debconf
12+ db_get $PACKAGE/computer_title
13+ COMPUTER_TITLE="${RET}"
14+ db_get $PACKAGE/account_name
15+ ACCOUNT_NAME="${RET}"
16+ db_get $PACKAGE/registration_password
17+ REGISTRATION_PASSWORD="${RET}"
18+ db_get $PACKAGE/url
19+ URL="${RET}"
20+ db_get $PACKAGE/exchange_interval
21+ EXCHANGE_INTERVAL="${RET}"
22+ db_get $PACKAGE/urgent_exchange_interval
23+ URGENT_EXCHANGE_INTERVAL="${RET}"
24+ db_get $PACKAGE/ping_url
25+ PING_URL="${RET}"
26+ db_get $PACKAGE/ping_interval
27+ PING_INTERVAL="${RET}"
28+ db_get $PACKAGE/http_proxy
29+ HTTP_PROXY="${RET}"
30+ db_get $PACKAGE/https_proxy
31+ HTTPS_PROXY="${RET}"
32+ db_get $PACKAGE/otp
33+ OTP="${RET}"
34+ db_get $PACKAGE/tags
35+ TAGS="${RET}"
36+
37 if [ ! -f $CONFIG_FILE ]; then
38- # Get configuration values from debconf
39- db_get $PACKAGE/computer_title
40- COMPUTER_TITLE="${RET}"
41- db_get $PACKAGE/account_name
42- ACCOUNT_NAME="${RET}"
43- db_get $PACKAGE/registration_password
44- REGISTRATION_PASSWORD="${RET}"
45- db_get $PACKAGE/url
46- URL="${RET}"
47- db_get $PACKAGE/exchange_interval
48- EXCHANGE_INTERVAL="${RET}"
49- db_get $PACKAGE/urgent_exchange_interval
50- URGENT_EXCHANGE_INTERVAL="${RET}"
51- db_get $PACKAGE/ping_url
52- PING_URL="${RET}"
53- db_get $PACKAGE/ping_interval
54- PING_INTERVAL="${RET}"
55- db_get $PACKAGE/http_proxy
56- HTTP_PROXY="${RET}"
57- db_get $PACKAGE/https_proxy
58- HTTPS_PROXY="${RET}"
59- db_get $PACKAGE/otp
60- OTP="${RET}"
61- db_get $PACKAGE/tags
62- TAGS="${RET}"
63-
64- # Create new configuration, with private mode
65- TEMPFILE=$(mktemp -p /etc/landscape)
66- cat > $TEMPFILE <<END
67-[client]
68-log_level = info
69-data_path = /var/lib/landscape/client
70-END
71- chown landscape $TEMPFILE
72- mv $TEMPFILE $CONFIG_FILE
73-
74- # Configure landscape
75- landscape-config --silent --no-start \
76- --computer-title "$COMPUTER_TITLE" \
77- --account-name "$ACCOUNT_NAME" \
78- --registration-password "$REGISTRATION_PASSWORD" \
79- --url "$URL" \
80- --exchange-interval "$EXCHANGE_INTERVAL" \
81- --urgent-exchange-interval "$URGENT_EXCHANGE_INTERVAL" \
82- --ping-url "$PING_URL" \
83- --ping-interval "$PING_INTERVAL" \
84- --http-proxy "$HTTP_PROXY" \
85- --https-proxy "$HTTPS_PROXY" \
86- --otp "$OTP" \
87- --tags "$TAGS"
88-
89- # If we got the needed information, actually do the registration.
90- if [ -n "$ACCOUNT_NAME" -a -n "$COMPUTER_TITLE" ]; then
91- landscape-config --silent --ok-no-register
92- fi
93- else
94- # Fix non-private permissions
95- chmod 0600 $CONFIG_FILE
96+ touch $CONFIG_FILE
97+ fi
98+ chown landscape $CONFIG_FILE
99+ # Fix non-private permissions
100+ chmod 0600 $CONFIG_FILE
101+
102+ # Configure landscape
103+ landscape-config --silent --no-start \
104+ --computer-title "$COMPUTER_TITLE" \
105+ --account-name "$ACCOUNT_NAME" \
106+ --registration-password "$REGISTRATION_PASSWORD" \
107+ --url "$URL" \
108+ --exchange-interval "$EXCHANGE_INTERVAL" \
109+ --urgent-exchange-interval "$URGENT_EXCHANGE_INTERVAL" \
110+ --ping-url "$PING_URL" \
111+ --ping-interval "$PING_INTERVAL" \
112+ --http-proxy "$HTTP_PROXY" \
113+ --https-proxy "$HTTPS_PROXY" \
114+ --otp "$OTP" \
115+ --tags "$TAGS"
116+
117+ # If we got the needed information, actually do the registration.
118+ if [ -n "$ACCOUNT_NAME" -a -n "$COMPUTER_TITLE" ]; then
119+ landscape-config --silent --ok-no-register
120 fi
121
122 # old monolithic clients have a single persist data file and a single

Subscribers

People subscribed via source and target branches

to all changes: