-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, once more, I provide a patch. This time it closes #600050. I modified lighty-enabled-mod to take care of a magic line for modules placed in the conf-available folder.
That is, if it contains a special dependency reference that indicates modules that must be loaded as well, when activating the chosen module. Those are then automagically loaded. For example as referenced in the bug, fastcgi-php needs fastcgi loaded as well. So one would configure the dependency in 15-fastcgi-php.conf as follows: <snip> # -*- depends: fastcgi -*- # /usr/share/doc/lighttpd-doc/fastcgi.txt.gz # http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions#mod_fastcgi-fastcgi ## Start an FastCGI server for php (needs the php5-cgi package) fastcgi.server += ( ".php" => ... <snip> The dependency magic line has the following syntax (Perl regular expression): # -\*- depends: ([-\w, ]+) -\*-/ That is: - - it starts with a comment (#) - - it contains the line -*- depends: MODULE_LISTING -*- where MODULE_LISTING is one or more module base names separated by a comma (,) and one or more optional whitespace caracters. Therefore valid dependency magic lines are: # -*- depends: foo -*- # -*- depends: foo, bar -*- # -*- depends: foo,bar -*- # -*- depends: foo, bar,baz -*- The attached patch contains a working example for fastcgi-php configuration, that depends as pointed out on fastcgi like this: # -*- depends: fastcgi -*- I briefly checked other modules as well, but it rather seems to me that none of them needs a dependency line. If needed, my patch works for other necessary dependencies as well though, even if my diff doesn't change anything else besides 15-fastcgi-php. lighty-enable-mod (for reference: also lighty-disable-mod which is nothing but a symlink) now behaves like this when a dependency is found: r...@test1:~# lighty-enable-mod fastcgi-php Available modules: auth accesslog cgi fastcgi no-www proxy rrdtool simple-vhost ssi ssl status userdir fastcgi-php debian-doc Already enabled modules: Met dependency: fastcgi Enabling fastcgi-php: ok Enabling fastcgi: ok This change is backward compatible, that means it does not fail if there is no dependency line. Note that this also implies that the user won't profit from this change unless they reinstall the package by installing the new configuration files which do provide the new magic line. Moreover the patch doesn't do anything if there is already an enabled module from a previous installation. For example, if one already has enabled fastcgi-php but not fastcgi (which causes this bug), even after enabling it again lighty-enable-mod won't do anything. This is by design (as it does not do anything if symlinks do already exist, this is a feature, one of the previous contributors introduced). Note, that the reverse problem applies if one disables, say, fastcgi. This renders fastcgi-php unusable. Thanks to the magic line, lighty-enable-mod also takes care: r...@test1:~# lighty-disable-mod fastcgi-php Available modules: auth accesslog cgi fastcgi no-www proxy rrdtool simple-vhost ssi ssl status userdir fastcgi-php debian-doc Already enabled modules: fastcgi fastcgi-php Disabling fastcgi-php Run /etc/init.d/lighttpd force-reload to enable changes r...@test1:~# Nothing happened here, as it is perfectly ok to disable fastcgi-php but not fastcgi. So enable it again: r...@test1:~# lighty-enable-mod fastcgi-php Available modules: auth accesslog cgi fastcgi no-www proxy rrdtool simple-vhost ssi ssl status userdir fastcgi-php debian-doc Already enabled modules: fastcgi Enabling fastcgi-php: ok Run /etc/init.d/lighttpd force-reload to enable changes Now let's disable fastcgi. This breaks a dependency for fastcgi-php: r...@test1:~# lighty-disable-mod fastcgi Available modules: auth accesslog cgi fastcgi no-www proxy rrdtool simple-vhost ssi ssl status userdir fastcgi-php debian-doc Already enabled modules: fastcgi fastcgi-php Disabling fastcgi Reverse dependency met: Disabling fastcgi-php too Disabling fastcgi-php Run /etc/init.d/lighttpd force-reload to enable changes r...@test1:~# The attached patch changes debian/lighty-enable-mod and debian/conf-available/15-fastcgi-php.conf. For the code changes there is to note: * The code already contained a module dependency stub. That was not functional (because of an empty dependency list). I removed that code, as I found it a bad design decision to hard link dependency lists directly into the lighty-enable-mod code. * I added depdendency checks for enable/disable as explained above * This time I provide the patch only, not a full patch changing debian/changelog as well. * lighty-enable-mod will skip processing now (non fatal), if a given module does not exist. The current version does not even indicate this, but silently assume user's won't provide broken links. For example: r...@test1:~# lighty-disable-mod foo Available modules: auth accesslog cgi fastcgi no-www proxy rrdtool simple-vhost ssi ssl status userdir fastcgi-php debian-doc Already enabled modules: Already disabled foo Run /etc/init.d/lighttpd force-reload to enable changes Now it indicates an error: r...@test1:~# lighty-disable-mod Available modules: auth accesslog cgi fastcgi no-www proxy rrdtool simple-vhost ssi ssl status userdir fastcgi-php debian-doc Already enabled modules: Disable module: foo Ignoring unknown module: foo Run /etc/init.d/lighttpd force-reload to enable changes - -- with kind regards, Arno Töll GnuPG Key-ID: 0x8408D4C4 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBAgAGBQJNI2o6AAoJELBdpXvEXpo9Qd4P/RnXqozatvzTU6p7MZcVulZL 1Nkw98WzGz9IjyW2Zyafga1WW/nzpCda8d8AFVE68R542Ic3xSZrZQWVlIv7MEv3 Tmts5X6HfGEEwA1t1mMVu3WrEU+Dm0DshqFY7AYq3Z5kX6/UFJzJvGTGDybpA/6b YlOAdnQQ1eHI73AfPlvImRKSsg+9AKf7ATT5DfQE/ACcfcW/hvAz9GcpIETofbaJ vLMC1XpeZuycI1T3QJky1dLu3CQNnA8RBsUuxoAW11pbsKXKTJSM0rLVv3v4SJl8 wollhSmw1qc6qbuvKd5O9bT1xKc6wSJcJV67pJMPRoYqycHg5vawPqzbfzTkD+Ex 1yylwU1r5wq6QtzXTGwejyfP+kdgYlL6qFviXu4mGyR6a++/2C7/ZNrjcPXH2YTY 9KPCqJRQzZg8POkQ88yEZKeg5AaF80TWTHLtUzHvEb/M+eDA/yMDpY9oXGlTCSdf 8OdbcHtu+ht6i+yEBW/OKV0iD4r4HWFN3TS6LDypGhFN3brQjpCTjWN7kaFD+J7a bu1EQP7H6cBexnzV1Fcv/prU9DhMHi01S14Bx0jmBCUM/dQY5UzvaXqSeSxNEqlt /SN36BbfDm2kzF6O1L0rE4UDCXFw6EKl0fbUw5m/BUmBFs0TANbdza/u74LxZJtg iQ3bRUKbLnypOdx+nM85 =2f1N -----END PGP SIGNATURE-----
diff -ruN lighttpd-1.4.28/debian/conf-available/15-fastcgi-php.conf lighttpd-1.4.28-patched/debian/conf-available/15-fastcgi-php.conf --- lighttpd-1.4.28/debian/conf-available/15-fastcgi-php.conf 2010-08-30 20:48:29.000000000 +0200 +++ lighttpd-1.4.28-patched/debian/conf-available/15-fastcgi-php.conf 2011-01-04 18:39:43.943036409 +0100 @@ -1,3 +1,4 @@ +# -*- depends: fastcgi -*- # /usr/share/doc/lighttpd-doc/fastcgi.txt.gz # http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions#mod_fastcgi-fastcgi diff -ruN lighttpd-1.4.28/debian/lighty-enable-mod lighttpd-1.4.28-patched/debian/lighty-enable-mod --- lighttpd-1.4.28/debian/lighty-enable-mod 2010-08-30 20:48:29.000000000 +0200 +++ lighttpd-1.4.28-patched/debian/lighty-enable-mod 2011-01-04 18:39:29.459035867 +0100 @@ -4,6 +4,7 @@ # # Contains changes from: # - Tobias Gruetzmacher <[email protected]> +# - Arno Toell <[email protected]> # # You may distribute under the terms of either the GNU General Public # License[1] or the Artistic License[2]. @@ -24,8 +25,6 @@ my %enabled = (); my @todo = (); -my %moduledeps = (); - my $enabling = 1; @@ -71,17 +70,42 @@ #--- activate (link) or deactivate (remove) module foreach my $do (@todo) { - + if (! exists($available{$do})) { + print("Ignoring unknown module: $do\n"); + next; + } if ($enabling) { next unless defined($available{$do}); my $target = sprintf("%s/conf-enabled/%s", $confdir,basename($available{$do})); - print qq{Enabling $do: }; + my $source = $available{$do}; my $st = stat($target); unless ( -f $target ) { + # scan for a dependency line + local *MOD; + open(MOD, "< $source") || die("can't read $source: $!"); + while(my $i = <MOD>) { + if ($i =~ m/# -\*- depends: ([-\w, ]+) -\*-/) { + my @matches = split(/,\s+/, $1); + for my $module (@matches) { + if (exists $available{$module} and ! exists $enabled{$module}) { + print("Met dependency: $module\n"); + push(@todo, $module); + } + elsif (exists $available{$module} and exists $enabled{$module}) { + # Do nothing + } + else { + die("Unresolved dependency: $module\n"); + } + } + last; + } + } + close(MOD); if (symlink($available{$do}, $target)) { - print "ok\n"; + print "Enabling $do: ok\n"; } else { print "failure: $!\n"; @@ -90,20 +114,35 @@ else { print "already enabled\n"; } - - #--- check dependencies - for my $module (@{$moduledeps{$do}}) - { - unless ( -f $target && -l $target ) - { - print qq{Module $do depends on module $module which is not activated.\n}; - } - } } else { if (defined($enabled{$do})) { print qq{Disabling $do\n}; my $target = sprintf("%s/conf-enabled/%s", $confdir,basename($enabled{$do})); + my $source = $available{$do}; + + + # scan for a reverse dependency line + foreach my $available_module (keys %available) { + if ($available_module eq $do) { + next; + } + local *MOD; + open(MOD, "< $available{$available_module}") || die("can't read $available{$available_module}: $!"); + while(my $i = <MOD>) { + if ($i =~ m/# -\*- depends: ([-\w, ]+) -\*-/) { + my @matches = split(/,\s+/, $1); + for my $module (@matches) { + if ($module eq $do && exists $enabled{$available_module}) { + print("Reverse dependency met: Disabling $available_module too\n"); + push(@todo, $available_module); + } + } + last; + } + } + } + close(MOD); unlink($target); } else { print qq{Already disabled $do\n};

