Bug 9422 - apparmor changes should not be run if apparmor is not installed
: apparmor changes should not be run if apparmor is not installed
Status: CLOSED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Platform Support
: 7.2
: Other Ubuntu Linux
: -- normal with 2 votes (vote)
: 7.x
Assigned To: Matt Wise
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-09-06 21:34 UTC by Erland Isaksson
Modified: 2009-07-31 10:29 UTC (History)
4 users (show)

See Also:
Category: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erland Isaksson 2008-09-06 21:34:41 UTC
I tried to install the Debian package from debian.slimdevices.com stable repository on a Ubuntu JeOS distribution (Ubuntu customized for running in a Virtual machine).

At the end of the installation with apt-get I get the following error which seems to indicate that there is a dependency to apparmor missing in the deb package.

===================
Not creating home directory `/usr/share/squeezecenter'.
/var/lib/dpkg/info/squeezecenter.postinst: 74: /etc/init.d/apparmor: not found
dpkg: error processing squeezecenter (--configure):
 subprocess post-installation script returned error exit status 127
Processing triggers for libc6 ...
ldconfig deferred processing now taking place
Errors were encountered while processing:
 squeezecenter
E: Sub-process /usr/bin/dpkg returned an error code (1)
===================

If I install apparmor manually before squeezecenter everything works correctly.
Comment 1 Mark Miksis 2008-09-07 16:46:58 UTC
The proper solution is probably to modify the postinst script to be smart enough to skip the apparmor stuff if it's not installed.  There's no real reason to make apparmor a dependency.
Comment 2 Chris Owens 2008-09-22 12:19:32 UTC
So it seems like maybe we added something to help us with our apparmor problems, but we try it whether or not apparmor is installed.  

Since support gets lots of calls about apparmor, I would say having people install it as a dependency is NOT the right solution.  :)
Comment 3 des 2008-10-29 15:12:45 UTC
(In reply to comment #1)
> The proper solution is probably to modify the postinst script to be smart
> enough to skip the apparmor stuff if it's not installed.  There's no real
> reason to make apparmor a dependency.


It should be very straightforward to do.

Change:

		/etc/init.d/apparmor restart

to:
             if [ -x /etc/init.d/apparmor ] then
		/etc/init.d/apparmor restart
             fi
Comment 4 M. LaPlante 2008-10-29 22:29:06 UTC
*** Bug 9848 has been marked as a duplicate of this bug. ***
Comment 5 James Richardson 2008-11-07 09:39:21 UTC
Ross:  can you work with Matt to give him access to an image with AppArmor installed so he can verify the patch.
Comment 6 Matt Wise 2008-11-10 09:35:26 UTC
We already do this check.. in the squeezecenter.postinst code we have this:

        if [ -f /etc/apparmor.d/usr.sbin.mysqld ]; then
                ## Remove the end-bracket so we can input our data into the file...
                sed -e 's/}//' /etc/apparmor.d/usr.sbin.mysqld > /etc/apparmor.d/usr.sbin.mysqld.squeezecenter.new
                echo "  # SqueezeCenter Apparmor Changes for MySqld
  /var/lib/squeezecenter/cache/ r,
  /var/lib/squeezecenter/cache/my.cnf r,
  /var/lib/squeezecenter/cache/mysql.startup rw,
  /var/lib/squeezecenter/cache/mysql-error-log.txt rw,
  /var/lib/squeezecenter/cache/squeezecenter-mysql.pid w,
  /var/lib/squeezecenter/cache/squeezecenter-mysql.sock w,
  /var/lib/squeezecenter/cache/MySQL/ r,
  /var/lib/squeezecenter/cache/MySQL/** rwk,
 } " >> /etc/apparmor.d/usr.sbin.mysqld.squeezecenter.new

                mv /etc/apparmor.d/usr.sbin.mysqld /var/lib/squeezecenter/usr.sbin.mysqld.orig
                mv /etc/apparmor.d/usr.sbin.mysqld.squeezecenter.new /etc/apparmor.d/usr.sbin.mysqld
                /etc/init.d/apparmor restart
                echo "\n"
        fi


We don't modify any files, or restart Apparmor unless we found an apparmor.d directory and the usr.sbin.mysqld file is actually in place. Seems like a pretty good solution to me... 
Comment 7 M. LaPlante 2008-11-10 09:47:30 UTC
(In reply to comment #6)
> We already do this check.. in the squeezecenter.postinst code we have this:
>         if [ -f /etc/apparmor.d/usr.sbin.mysqld ]; then
>                 ## Remove the end-bracket so we can input our data into the
> file...
>                 sed -e 's/}//' /etc/apparmor.d/usr.sbin.mysqld >
> /etc/apparmor.d/usr.sbin.mysqld.squeezecenter.new
>                 echo "  # SqueezeCenter Apparmor Changes for MySqld
>   /var/lib/squeezecenter/cache/ r,
>   /var/lib/squeezecenter/cache/my.cnf r,
>   /var/lib/squeezecenter/cache/mysql.startup rw,
>   /var/lib/squeezecenter/cache/mysql-error-log.txt rw,
>   /var/lib/squeezecenter/cache/squeezecenter-mysql.pid w,
>   /var/lib/squeezecenter/cache/squeezecenter-mysql.sock w,
>   /var/lib/squeezecenter/cache/MySQL/ r,
>   /var/lib/squeezecenter/cache/MySQL/** rwk,
>  } " >> /etc/apparmor.d/usr.sbin.mysqld.squeezecenter.new
>                 mv /etc/apparmor.d/usr.sbin.mysqld
> /var/lib/squeezecenter/usr.sbin.mysqld.orig
>                 mv /etc/apparmor.d/usr.sbin.mysqld.squeezecenter.new
> /etc/apparmor.d/usr.sbin.mysqld
>                 /etc/init.d/apparmor restart
>                 echo "\n"
>         fi
> We don't modify any files, or restart Apparmor unless we found an apparmor.d
> directory and the usr.sbin.mysqld file is actually in place. Seems like a
> pretty good solution to me... 


What about a random /etc configuration file implies that a daemon is installed?  

Configuration files are often preserved even after applications are removed, and this is a perfect example.  In fact, the file in question isn't even part of the apparmor deb; it's part of the mysql-server deb.  So you're testing a file from the mysql package to determine if the apparmor application is installed, and not surprisingly, the test falls on its face when apparmor is not present.

A pretty good solution would be to test for /etc/init.d/apparmor before calling it.
Comment 8 Matt Wise 2008-11-10 09:56:33 UTC
Checked in as change #23887. Tested installing MySQL without installing Apparmor and sure enough, it creates the file regardless of whether apparmor is there or not. 
Comment 9 James Richardson 2008-12-15 12:07:23 UTC
This bug has been fixed in the 7.3.0 release version of SqueezeCenter!

Please download the new version from http://www.slimdevices.com/su_downloads.html if you haven't already.  

If you are still experiencing this problem, feel free to reopen the bug with your new comments and we'll have another look.
Comment 10 Chris Owens 2009-07-31 10:29:17 UTC
Reduce number of active targets for SC