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
=== modified file 'debian/landscape-client.postinst'
--- debian/landscape-client.postinst 2012-02-13 21:07:42 +0000
+++ debian/landscape-client.postinst 2012-02-23 18:35:24 +0000
@@ -27,68 +27,57 @@
27 configure)27 configure)
2828
29 CONFIG_FILE=/etc/landscape/client.conf29 CONFIG_FILE=/etc/landscape/client.conf
30 if [ -f $CONFIG_FILE ]; then30 # Get configuration values from debconf
31 mv --backup=numbered $CONFIG_FILE $CONFIG_FILE.bak31 db_get $PACKAGE/computer_title
32 fi32 COMPUTER_TITLE="${RET}"
33 db_get $PACKAGE/account_name
34 ACCOUNT_NAME="${RET}"
35 db_get $PACKAGE/registration_password
36 REGISTRATION_PASSWORD="${RET}"
37 db_get $PACKAGE/url
38 URL="${RET}"
39 db_get $PACKAGE/exchange_interval
40 EXCHANGE_INTERVAL="${RET}"
41 db_get $PACKAGE/urgent_exchange_interval
42 URGENT_EXCHANGE_INTERVAL="${RET}"
43 db_get $PACKAGE/ping_url
44 PING_URL="${RET}"
45 db_get $PACKAGE/ping_interval
46 PING_INTERVAL="${RET}"
47 db_get $PACKAGE/http_proxy
48 HTTP_PROXY="${RET}"
49 db_get $PACKAGE/https_proxy
50 HTTPS_PROXY="${RET}"
51 db_get $PACKAGE/otp
52 OTP="${RET}"
53 db_get $PACKAGE/tags
54 TAGS="${RET}"
55
33 if [ ! -f $CONFIG_FILE ]; then56 if [ ! -f $CONFIG_FILE ]; then
34 # Get configuration values from debconf57 touch $CONFIG_FILE
35 db_get $PACKAGE/computer_title58 fi
36 COMPUTER_TITLE="${RET}"59 chown landscape $CONFIG_FILE
37 db_get $PACKAGE/account_name60 # Fix non-private permissions
38 ACCOUNT_NAME="${RET}"61 chmod 0600 $CONFIG_FILE
39 db_get $PACKAGE/registration_password62
40 REGISTRATION_PASSWORD="${RET}"63 # Configure landscape
41 db_get $PACKAGE/url64 landscape-config --silent --no-start \
42 URL="${RET}"65 --computer-title "$COMPUTER_TITLE" \
43 db_get $PACKAGE/exchange_interval66 --account-name "$ACCOUNT_NAME" \
44 EXCHANGE_INTERVAL="${RET}"67 --registration-password "$REGISTRATION_PASSWORD" \
45 db_get $PACKAGE/urgent_exchange_interval68 --url "$URL" \
46 URGENT_EXCHANGE_INTERVAL="${RET}"69 --exchange-interval "$EXCHANGE_INTERVAL" \
47 db_get $PACKAGE/ping_url70 --urgent-exchange-interval "$URGENT_EXCHANGE_INTERVAL" \
48 PING_URL="${RET}"71 --ping-url "$PING_URL" \
49 db_get $PACKAGE/ping_interval72 --ping-interval "$PING_INTERVAL" \
50 PING_INTERVAL="${RET}"73 --http-proxy "$HTTP_PROXY" \
51 db_get $PACKAGE/http_proxy74 --https-proxy "$HTTPS_PROXY" \
52 HTTP_PROXY="${RET}"75 --otp "$OTP" \
53 db_get $PACKAGE/https_proxy76 --tags "$TAGS"
54 HTTPS_PROXY="${RET}"77
55 db_get $PACKAGE/otp78 # If we got the needed information, actually do the registration.
56 OTP="${RET}"79 if [ -n "$ACCOUNT_NAME" -a -n "$COMPUTER_TITLE" ]; then
57 db_get $PACKAGE/tags80 landscape-config --silent --ok-no-register
58 TAGS="${RET}"
59
60 # Create new configuration, with private mode
61 TEMPFILE=$(mktemp -p /etc/landscape)
62 cat > $TEMPFILE <<END
63[client]
64log_level = info
65data_path = /var/lib/landscape/client
66END
67 chown landscape $TEMPFILE
68 mv $TEMPFILE $CONFIG_FILE
69
70 # Configure landscape
71 landscape-config --silent --no-start \
72 --computer-title "$COMPUTER_TITLE" \
73 --account-name "$ACCOUNT_NAME" \
74 --registration-password "$REGISTRATION_PASSWORD" \
75 --url "$URL" \
76 --exchange-interval "$EXCHANGE_INTERVAL" \
77 --urgent-exchange-interval "$URGENT_EXCHANGE_INTERVAL" \
78 --ping-url "$PING_URL" \
79 --ping-interval "$PING_INTERVAL" \
80 --http-proxy "$HTTP_PROXY" \
81 --https-proxy "$HTTPS_PROXY" \
82 --otp "$OTP" \
83 --tags "$TAGS"
84
85 # If we got the needed information, actually do the registration.
86 if [ -n "$ACCOUNT_NAME" -a -n "$COMPUTER_TITLE" ]; then
87 landscape-config --silent --ok-no-register
88 fi
89 else
90 # Fix non-private permissions
91 chmod 0600 $CONFIG_FILE
92 fi81 fi
9382
94 # old monolithic clients have a single persist data file and a single83 # old monolithic clients have a single persist data file and a single

Subscribers

People subscribed via source and target branches

to all changes: