Comment 16 for bug 14392

Revision history for this message
Sebastien Bacher (seb128) wrote :

Fixed with this upload:

 system-tools-backends (1.9.7-0ubuntu3) edgy; urgency=low
 .
   * debian/patches/01_chmod_network_interfaces_when_using_key.patch:
     - change network interfaces file mode to 640 and the group to "admin"
       when a key is set (Ubuntu: #14392)

The patch used:

diff -Nur system-tools-backends-1.9.7/Network/Ifaces.pm system-tools-backends-1.9.7.new/Network/Ifaces.pm
--- system-tools-backends-1.9.7/Network/Ifaces.pm 2006-10-06 00:16:51.000000000 +0200
+++ system-tools-backends-1.9.7.new/Network/Ifaces.pm 2006-10-11 12:28:42.000000000 +0200
@@ -693,6 +693,17 @@
   return (&get_debian_auto_by_stanza ($file, $iface) ne undef)? 1 : 0;
 }

+sub set_network_config_permission
+{
+ my ($key) = @_;
+
+ if ($key)
+ {
+ chmod 0640, "/etc/network/interfaces";
+ &Utils::File::run ("chgrp admin /etc/network/interfaces");
+ }
+}
+
 sub set_debian_auto
 {
   my ($file, $iface, $value) = @_;
@@ -3099,6 +3110,7 @@
       [ "gateway", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "gateway" ],
       [ "essid", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless-essid" ],
       [ "key", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless-key" ],
+ [ "key", \&set_network_config_permission, "%key%"],
       [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_interfaces_option_str, INTERFACES, IFACE, "wireless-key", "%key%" ]],
       # ugly hack for deleting undesired options (due to syntax duality)
       [ "essid", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless_essid", "" ],