Merge lp:~benji/landscape-client/bug-1546743-postinst-creates-file-in-non-existent-directory into lp:~landscape/landscape-client/trunk

Proposed by Benji York
Status: Merged
Approved by: Benji York
Approved revision: 831
Merged at revision: 830
Proposed branch: lp:~benji/landscape-client/bug-1546743-postinst-creates-file-in-non-existent-directory
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 31 lines (+3/-5)
2 files modified
debian/landscape-client.init (+1/-4)
debian/landscape-client.postinst (+2/-1)
To merge this branch: bzr merge lp:~benji/landscape-client/bug-1546743-postinst-creates-file-in-non-existent-directory
Reviewer Review Type Date Requested Status
Adam Collard (community) Approve
Bogdana Vereha (community) Approve
Review via email: mp+286509@code.launchpad.net

Commit message

This branch fixes bug 1546743 which affects fresh client installs.

The client postinst script was attempting to create a file in the data
directory, but that directory is created by the client itself so if
the client had never been run before, the file creation would fail.

This branch modifies the postinst script to create the directory if
needed.

Description of the change

This branch fixes bug 1546743 which affects fresh client installs.

The client postinst script was attempting to create a file in the data
directory, but that directory is created by the client itself so if
the client had never been run before, the file creation would fail.

This branch modifies the postinst script to create the directory if
needed.

Testing instructions:

- build a new set of packages (see "make package")
- stop the client on the test machine
- remove the data_path directory (found in your client configuration)
- install -common and -client packages
- verify that the packages installed without error
- verify that the data_path directory exists
- verify that the data_path directory is owned by "landscape"

To post a comment you must log in.
Revision history for this message
Bogdana Vereha (bogdana) wrote :

One minor comment inline.

review: Approve
Revision history for this message
Adam Collard (adam-collard) wrote :

I was going to say that you should use "install -o landscape -d $DATA_PATH" instead of the separate mkdir; chown. But then I realised that all we're trying to do is make a file in a directory, so we should be using "install -D -o landscape user-update-flag $DATA_PATH/user-update-flag" and drop the test for directory existence and all the chowns

Check the man page for install if you're not aware of it, it's used extensively in debian packages to avoid just these kinds of bugs :)

review: Needs Fixing
831. By Benji York

use install instead of bashing on files and ownership ourselves

Revision history for this message
Benji York (benji) wrote :

> I was going to say that you should use "install -o landscape -d $DATA_PATH"
> instead of the separate mkdir; chown. But then I realised that all we're
> trying to do is make a file in a directory, so we should be using "install -D
> -o landscape user-update-flag $DATA_PATH/user-update-flag" and drop the test
> for directory existence and all the chowns

I didn't want to create the file and then move it (since the contents are mostly irrelevant anyway) so I went with creating the directory and file separately.

I also changed another instance of check-create-chmod to use install.

Revision history for this message
Adam Collard (adam-collard) wrote :

Looks good, +1

review: Approve
Revision history for this message
Benji York (benji) wrote :

Thanks for the good reviews.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/landscape-client.init'
2--- debian/landscape-client.init 2014-07-10 18:51:49 +0000
3+++ debian/landscape-client.init 2016-02-18 15:58:51 +0000
4@@ -40,10 +40,7 @@
5 start)
6 check_config
7 log_daemon_msg "Starting the $NAME daemon"
8- if [ ! -e $PIDDIR ]; then
9- mkdir $PIDDIR
10- chown landscape $PIDDIR
11- fi
12+ install --owner=landscape --directory $PIDDIR
13 # Cleanup leftover sockets if there's no other landscape process
14 # running. This shouldn't be usually necessary, but it can
15 # happen in case the client crashed badly and the socket points
16
17=== modified file 'debian/landscape-client.postinst'
18--- debian/landscape-client.postinst 2016-02-10 19:12:36 +0000
19+++ debian/landscape-client.postinst 2016-02-18 15:58:51 +0000
20@@ -123,9 +123,10 @@
21 # user information. The flag file will be removed by the client when
22 # the update completes.
23 DATA_PATH="`grep ^data_path /etc/landscape/client.conf | cut -d= -f2 | tr -d '[[:space:]]'`"
24+ install --owner=landscape --directory $DATA_PATH
25 USER_UPDATE_FLAG_FILE="$DATA_PATH/user-update-flag"
26+ install --owner=landscape /dev/null $USER_UPDATE_FLAG_FILE
27 echo "This file indicates that the Landscape client needs to send updated user information to the server." >> $USER_UPDATE_FLAG_FILE
28- chown landscape $USER_UPDATE_FLAG_FILE
29 ;;
30
31 abort-upgrade|abort-remove|abort-deconfigure)

Subscribers

People subscribed via source and target branches

to all changes: