aboutsummaryrefslogtreecommitdiff
path: root/sysutils/kdeadmin4
diff options
context:
space:
mode:
authorMax Brazhnikov <makc@FreeBSD.org>2010-06-29 20:35:28 +0000
committerMax Brazhnikov <makc@FreeBSD.org>2010-06-29 20:35:28 +0000
commit31da485dc496058d37126c6e8f556e852a737f80 (patch)
treecd9d13f33e4233d44e1bfd0c1b6d7924f014323b /sysutils/kdeadmin4
parent56d1bf52d857305b1c5b9488a9b63efb7b45aa76 (diff)
downloadports-31da485dc496058d37126c6e8f556e852a737f80.tar.gz
ports-31da485dc496058d37126c6e8f556e852a737f80.zip
Notes
Diffstat (limited to 'sysutils/kdeadmin4')
-rw-r--r--sysutils/kdeadmin4/distinfo6
-rw-r--r--sysutils/kdeadmin4/files/patch-knetworkconf-knetworkconf-knetworkconfigparser.cpp121
2 files changed, 69 insertions, 58 deletions
diff --git a/sysutils/kdeadmin4/distinfo b/sysutils/kdeadmin4/distinfo
index 0a0cdb9accf3..a8137a93b956 100644
--- a/sysutils/kdeadmin4/distinfo
+++ b/sysutils/kdeadmin4/distinfo
@@ -1,3 +1,3 @@
-MD5 (KDE/kdeadmin-4.4.4.tar.bz2) = 26a1033026e300b70b297af61f5e1e1c
-SHA256 (KDE/kdeadmin-4.4.4.tar.bz2) = f09bfcb44d6a63f35944a52a9474ec0e64b8c86a42dbf737649f77b4b9dd5e12
-SIZE (KDE/kdeadmin-4.4.4.tar.bz2) = 1430798
+MD5 (KDE/kdeadmin-4.4.5.tar.bz2) = 695dfc8c22b34fa9914a8e6bec7ccafc
+SHA256 (KDE/kdeadmin-4.4.5.tar.bz2) = 9e87237f0d2af5bf58ecc71a90d5451e923be8f8c512d67d6f58b279a5dcb2ca
+SIZE (KDE/kdeadmin-4.4.5.tar.bz2) = 1430987
diff --git a/sysutils/kdeadmin4/files/patch-knetworkconf-knetworkconf-knetworkconfigparser.cpp b/sysutils/kdeadmin4/files/patch-knetworkconf-knetworkconf-knetworkconfigparser.cpp
index f6c96d9691d4..0977769bada6 100644
--- a/sysutils/kdeadmin4/files/patch-knetworkconf-knetworkconf-knetworkconfigparser.cpp
+++ b/sysutils/kdeadmin4/files/patch-knetworkconf-knetworkconf-knetworkconfigparser.cpp
@@ -1,84 +1,95 @@
--- knetworkconf/knetworkconf/knetworkconfigparser.cpp.orig 2009-07-28 21:43:49.000000000 +0200
-+++ knetworkconf/knetworkconf/knetworkconfigparser.cpp 2010-01-13 19:20:10.911935722 +0100
-@@ -21,6 +21,9 @@
++++ knetworkconf/knetworkconf/knetworkconfigparser.cpp 2010-06-15 07:23:42.039626265 +0200
+@@ -21,6 +21,10 @@
#include <QPixmap>
#include <QTextStream>
#include <Q3PtrList>
+#ifdef Q_OS_FREEBSD
-+#include <QProcess>
++#include <net/if_dl.h>
++#include <net/route.h>
+#endif
KNetworkConfigParser::KNetworkConfigParser(){
networkInfo = new KNetworkInfo();
-@@ -184,7 +187,8 @@
+@@ -184,7 +188,8 @@
}
/**
- Reads /proc/net/route looking for the default gateway.
-+ Reads /proc/net/route or parses the output of /sbin/route (FreeBSD)
++ Reads /proc/net/route or asks to a routing socket (FreeBSD)
+ looking for the default gateway.
NOTE:We should use the gateway reported by gst, but if there's a
gw in a config file and one of the network interfaces is
-@@ -193,22 +197,77 @@
+@@ -193,22 +198,87 @@
*/
void KNetworkConfigParser::loadRoutingInfo( KRoutingInfo *routingInfo){
// routingInfo = NULL;
- QFile f( "/proc/net/route");
+#ifdef Q_OS_FREEBSD
-+ QProcess *route = new QProcess(this);
-+ QString routeBin = "/sbin/route";
-+ bool success = false;
-+ QByteArray output;
-+ // Check for an IPv6 configuration.
-+ route->start(routeBin, QStringList() << "get" << "-inet6" << "default");
-+ if (route->waitForStarted(1000))
-+ {
-+ route->waitForFinished(1000);
-+ output = route->readAllStandardOutput();
-+ }
-+ if (output.isEmpty())
-+ {
-+ // IPv6 is not enabled, check for an IPv4 configuration.
-+ route = new QProcess(this);
-+ route->start(routeBin, QStringList() << "get" << "default");
-+ if (route->waitForStarted(1000))
-+ {
-+ route->waitForFinished(1000);
-+ output = route->readAllStandardOutput();
-+ }
++ int sfd = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC);
++ if (sfd < 0) {
++ KMessageBox::error(0,
++ i18n("Could not open the routing socket."),
++ i18n("Could Not Open Socket"));
++ return;
+ }
-+ if (!output.isEmpty())
-+ {
-+ QTextStream t(output);
-+ QString gw, interface;
-+ while (!t.atEnd())
-+ {
-+ QString s = t.readLine();
-+ QString row = s.section(' ', 0, 0, QString::SectionSkipEmpty);
-+ if (row == "gateway:")
-+ {
-+ gw = s.section(' ', 1, 1, QString::SectionSkipEmpty);
-+ }
-+ else if (row == "interface:")
-+ {
-+ interface = s.section(' ', 1, 1, QString::SectionSkipEmpty);
-+ }
-+ if (!gw.isEmpty() && !interface.isEmpty())
-+ {
-+ routingInfo->setGateway(gw);
-+ routingInfo->setGatewayDevice(interface);
-+ success = true;
-+ break;
-+ }
++ int pid = getpid();
++ const int buflen = sizeof(struct rt_msghdr) + 512;
++ int seq = 1138;
++ char *buf = (char *)calloc(1, buflen);
++ struct rt_msghdr *rtm = (struct rt_msghdr *)buf;
++ struct sockaddr *sin = (struct sockaddr *)(rtm + 1);
++ sin->sa_len = sizeof(struct sockaddr_in6);
++ sin->sa_family = AF_INET6;
++ struct sockaddr_dl *ifp = (struct sockaddr_dl *)((struct sockaddr_in6 *)sin + 1);
++ ifp->sdl_len = sizeof(struct sockaddr_dl);
++ ifp->sdl_family = AF_LINK;
++ rtm->rtm_msglen = sizeof(struct rt_msghdr) + sin->sa_len + ifp->sdl_len;
++ rtm->rtm_version = RTM_VERSION;
++ rtm->rtm_type = RTM_GET;
++ rtm->rtm_flags = RTF_UP | RTF_GATEWAY | RTF_HOST | RTF_STATIC;
++ rtm->rtm_addrs = RTA_DST | RTA_NETMASK | RTA_IFP;
++ rtm->rtm_pid = pid;
++ rtm->rtm_seq = seq;
++ if (write(sfd, buf, rtm->rtm_msglen) < 0) {
++ sin->sa_len = sizeof(struct sockaddr_in);
++ sin->sa_family = AF_INET;
++ ifp = (struct sockaddr_dl *)memmove((struct sockaddr_in *)sin + 1, ifp, ifp->sdl_len);
++ rtm->rtm_msglen = sizeof(struct rt_msghdr) + sin->sa_len + ifp->sdl_len;
++ rtm->rtm_seq = ++seq;
++ if (write(sfd, buf, rtm->rtm_msglen) < 0) {
++ KMessageBox::error(0,
++ i18n("Could not write to the routing socket: the connection may be down, or you don't have such a permission."),
++ i18n("Could Not Write to Socket"));
++ return;
+ }
+ }
-+ if (!success)
-+ {
++ int n;
++ do {
++ n = read(sfd, buf, buflen);
++ } while (n > 0 && (rtm->rtm_seq != seq || rtm->rtm_pid != pid));
++ if (n < 0) {
+ KMessageBox::error(0,
-+ i18n("Could not get information from %1.", routeBin),
-+ i18n("Could Not Get Information"));
++ i18n("Could not get information about the gateway."),
++ i18n("Could Not Read From Socket"));
++ return;
+ }
++ buf = (char *)(rtm + 1);
++ if (rtm->rtm_addrs & RTA_GATEWAY || rtm->rtm_addrs & RTA_IFP)
++ for (int i = 1; i; i <<= 1) {
++ if (i & rtm->rtm_addrs) {
++ struct sockaddr *sa = (struct sockaddr *)buf;
++ if (i == RTA_GATEWAY) {
++ if (sa->sa_family == AF_INET6)
++ routingInfo->setGateway(inet_ntop(AF_INET6, &(((struct sockaddr_in6 *)sa)->sin6_addr), (buf - INET6_ADDRSTRLEN), INET6_ADDRSTRLEN));
++ else if (sa->sa_family == AF_INET)
++ routingInfo->setGateway(inet_ntop(AF_INET, &(((struct sockaddr_in *)sa)->sin_addr), (buf - INET_ADDRSTRLEN), INET_ADDRSTRLEN));
++ } else if (i == RTA_IFP && sa->sa_family == AF_LINK && ((struct sockaddr_dl *)sa)->sdl_nlen)
++ routingInfo->setGatewayDevice(((struct sockaddr_dl *)sa)->sdl_data);
++ buf += SA_SIZE(sa);
++ }
++ }
+#else
+ QString fname = "/proc/net/route";
+ QFile f(fname);
@@ -102,7 +113,7 @@
QString interface = s.section('\t',0,0);
QString destination = s.section('\t',1,1);
QString gw = s.section('\t',2,2);
-@@ -222,6 +281,7 @@
+@@ -222,6 +292,7 @@
}
}
f.close();