From patchwork Thu Sep 27 03:22:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 1944 Return-Path: Received: from mail01.ipfire.org (mail01.i.ipfire.org [172.28.1.200]) by web02.i.ipfire.org (Postfix) with ESMTP id 184BD6031E for ; Wed, 26 Sep 2018 19:21:08 +0200 (CEST) Received: from mail01.i.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 60EF010A33D5; Wed, 26 Sep 2018 18:21:07 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201801; t=1537982467; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references:list-id: list-unsubscribe:list-subscribe:list-post; bh=6rmhtlAnQkLYh89CyhLxucO9xhp6u7mFWhe4h7tc4Ak=; b=vJYpG+pftbnTMQ3tkWxZqADY1EAEkHaMkSjdRTCYH3JSkHn/hz1W05z4h8mKq8Gv1WIWK4 kl5R4hfmwuqZAljbYszrxPkd4yx2KJ/6Vr6jnxWvNciGU1o4rSystgeIAXeg57caLYPF8W qGIPbozGRq+r/b+RFupur3YKZY2B4vylvgbUZJX1B4rcllMG9VSQ+ECvRqekJEAX+Z8ds2 miVFJJi5/1LLMD70s7reKUU1E86712L4/sxEDD/JeQehW2tjF4KuB1g+esj7dKWpfyAqCh hkJ4SXQvUgdwLN3ejxISMzgxTXaUJP1T0Dcw8Mkkx1cxDmE0b1dRqpPp6Iu2yA== Received: from jonatan.builders.ipfire.org (fw01.ipfire.org [172.28.1.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id CB9CA109D64B; Wed, 26 Sep 2018 18:21:04 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201801; t=1537982464; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=6rmhtlAnQkLYh89CyhLxucO9xhp6u7mFWhe4h7tc4Ak=; b=amOMkoOBxLw+Lgl1wr0bsTnse7LlG7nBOZqqZDjueJdpZASqEbjmeGHPort4fuxw7H1/9P UEhqGpmpzQhxqv0n+A5zhtZHY78cPa+v43cuACp0L0QL9Ua2ny44j5IDlVZ4m2bWEYtFC2 G953uQf8YfuKnE0/N1bLdXsr4GbsNF6qgwg3eolRzno5f+ZDKJIp+HiEJOtXlqszbZ1fbY 3Ky54htt5JL4lXEnzJKEH9fLsyNhmHNZC93rX/aXATpQ23e4hUhI6Sp4IRUNf5uNqXPn3/ P0OQdLklzWcjK4ObbvkUt7++Nv9ggGdIBqzIf4bActit2bg5SPrEk2CEUJb67Q== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH] Avoid calling a perl script for getting DNS-Servers from DHCP Date: Wed, 26 Sep 2018 18:22:42 +0100 Message-Id: <1537982562-18609-1-git-send-email-jonatan.schlag@ipfire.org> X-Mailer: git-send-email 1.8.3.1 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" This codes does the same as before but we do everythin in Bash now. Signed-off-by: Jonatan Schlag --- config/rootfiles/common/aarch64/initscripts | 1 - config/rootfiles/common/armv5tel/initscripts | 1 - config/rootfiles/common/i586/initscripts | 1 - config/rootfiles/common/x86_64/initscripts | 1 - src/initscripts/helper/getdnsfromdhcpc.pl | 47 ---------------------------- src/initscripts/networking/dhcpcd.exe | 16 ++++++++-- 6 files changed, 14 insertions(+), 53 deletions(-) delete mode 100644 src/initscripts/helper/getdnsfromdhcpc.pl diff --git a/config/rootfiles/common/aarch64/initscripts b/config/rootfiles/common/aarch64/initscripts index bce6d0f..081e6d4 100644 --- a/config/rootfiles/common/aarch64/initscripts +++ b/config/rootfiles/common/aarch64/initscripts @@ -2,7 +2,6 @@ etc/init.d #etc/rc.d #etc/rc.d/helper etc/rc.d/helper/aws-setup -etc/rc.d/helper/getdnsfromdhcpc.pl #etc/rc.d/init.d etc/rc.d/init.d/acpid etc/rc.d/init.d/apache diff --git a/config/rootfiles/common/armv5tel/initscripts b/config/rootfiles/common/armv5tel/initscripts index bce6d0f..081e6d4 100644 --- a/config/rootfiles/common/armv5tel/initscripts +++ b/config/rootfiles/common/armv5tel/initscripts @@ -2,7 +2,6 @@ etc/init.d #etc/rc.d #etc/rc.d/helper etc/rc.d/helper/aws-setup -etc/rc.d/helper/getdnsfromdhcpc.pl #etc/rc.d/init.d etc/rc.d/init.d/acpid etc/rc.d/init.d/apache diff --git a/config/rootfiles/common/i586/initscripts b/config/rootfiles/common/i586/initscripts index f793952..134d9ca 100644 --- a/config/rootfiles/common/i586/initscripts +++ b/config/rootfiles/common/i586/initscripts @@ -2,7 +2,6 @@ etc/init.d #etc/rc.d #etc/rc.d/helper etc/rc.d/helper/aws-setup -etc/rc.d/helper/getdnsfromdhcpc.pl #etc/rc.d/init.d etc/rc.d/init.d/acpid etc/rc.d/init.d/apache diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts index f793952..134d9ca 100644 --- a/config/rootfiles/common/x86_64/initscripts +++ b/config/rootfiles/common/x86_64/initscripts @@ -2,7 +2,6 @@ etc/init.d #etc/rc.d #etc/rc.d/helper etc/rc.d/helper/aws-setup -etc/rc.d/helper/getdnsfromdhcpc.pl #etc/rc.d/init.d etc/rc.d/init.d/acpid etc/rc.d/init.d/apache diff --git a/src/initscripts/helper/getdnsfromdhcpc.pl b/src/initscripts/helper/getdnsfromdhcpc.pl deleted file mode 100644 index e4d461d..0000000 --- a/src/initscripts/helper/getdnsfromdhcpc.pl +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/perl -############################################################################### -# # -# IPFire.org - A linux based firewall # -# Copyright (C) 2007 Michael Tremer & Christian Schmidt # -# # -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation, either version 3 of the License, or # -# (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with this program. If not, see . # -# # -############################################################################### - -use strict; -require '/var/ipfire/general-functions.pl'; - -my $count = $ARGV[0]; -my ($dhcp, $dns, @alldns, %dhcpc); - -if ($count eq "" || $count < 1) { - die "Bad DNS number given"; } - -if (open(FILE, "${General::swroot}/red/iface")) { - my $iface = ; - close FILE; - chomp ($iface); - if (!&General::readhash("${General::swroot}/dhcpc/dhcpcd-$iface.info", \%dhcpc)) { - die "Could not open dhcpc info file"; - } -} else { - die "Could not open interface file"; -} - - -$dns = $dhcpc{'domain_name_servers'}; - -@alldns = split(' ', $dns); - -print "$alldns[$count - 1]\n"; diff --git a/src/initscripts/networking/dhcpcd.exe b/src/initscripts/networking/dhcpcd.exe index a2cdc66..227481e 100644 --- a/src/initscripts/networking/dhcpcd.exe +++ b/src/initscripts/networking/dhcpcd.exe @@ -49,8 +49,20 @@ dhcpcd_up() echo -n ${DNS0} > /var/ipfire/red/dns1 echo -n ${DNS1} > /var/ipfire/red/dns2 else - echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 1` > /var/ipfire/red/dns1 - echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 2` > /var/ipfire/red/dns2 + # Check that we get DNS-Servers from our DHCP Server + if [ -n "${new_domain_name_servers}" ]; then + # Convert the string into an arry + dhcp_dns_servers=(${new_domain_name_servers}) + # We need 2 DNS-Servers + if [ ${#dhcp_dns_servers[@]} -lt 2 ]; then + logger -p local0.error -t dhcpcd.exe[$$] "DHCP Server does provides less then two DNS-Servers" + else + echo -n "${dhcp_dns_servers[0]}" > /var/ipfire/red/dns1 + echo -n "${dhcp_dns_servers[1]}" > /var/ipfire/red/dns2 + fi + else + logger -p local0.error -t dhcpcd.exe[$$] "DHCP Servers does not provide any DNS-Servers." + fi fi #Get IP Address