From f9e34675c8ce147c07161ad695696e760d084a6f31943e373f62808313d44e2c Mon Sep 17 00:00:00 2001 From: Dominique Leuenberger Date: Tue, 14 Dec 2010 13:43:56 +0000 Subject: [PATCH] Accepting request 54906 from home:vuntz:branches:GNOME:Factory Looks good. We probably want to extend this at least to wpad and pac support though :) OBS-URL: https://build.opensuse.org/request/show/54906 OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/libproxy?expand=0&rev=56 --- libproxy-plugins.changes | 7 ++ libproxy-plugins.spec | 5 +- libproxy-sysconfig-support.patch | 201 +++++++++++++++++++++++++++++++ libproxy.changes | 7 ++ libproxy.spec | 3 + 5 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 libproxy-sysconfig-support.patch diff --git a/libproxy-plugins.changes b/libproxy-plugins.changes index 68e7474..7c2420e 100644 --- a/libproxy-plugins.changes +++ b/libproxy-plugins.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Dec 6 16:32:28 CET 2010 - vuntz@opensuse.org + +- Add libproxy-sysconfig-support.patch, to support the proxy + configuration from sysconfig. Part of bnc#655483. + Patch written by Duncan Mac-Vicar . + ------------------------------------------------------------------- Thu Sep 2 09:38:47 CEST 2010 - dimstar@opensuse.org diff --git a/libproxy-plugins.spec b/libproxy-plugins.spec index ebee3d0..6f7fbb5 100644 --- a/libproxy-plugins.spec +++ b/libproxy-plugins.spec @@ -1,5 +1,5 @@ # -# spec file for package libproxy-plugins (Version 0.4.6) +# spec file for package libproxy (Version 0.4.6) # # Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany. # @@ -49,6 +49,8 @@ Source: http://libproxy.googlecode.com/files/%{_sourcename}.tar.bz2 # Script used for automatic snapshot updates Source98: update-from-svn.sh Source99: baselibs.conf +# PATCH-FEATURE-UPSTREAM libproxy-sysconfig-support.patch bnc#655483 dmacvicar@novell.com -- Add /etc/sysconfig support. Also tracked at http://code.google.com/p/libproxy/issues/detail?id=150 +Patch0: libproxy-sysconfig-support.patch License: GPLv2+ ; LGPLv2.1+ BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: cmake @@ -289,6 +291,7 @@ about network configuration changes. %prep %setup -q -n %{_sourcename} mkdir build +%patch0 -p0 %build cd build diff --git a/libproxy-sysconfig-support.patch b/libproxy-sysconfig-support.patch new file mode 100644 index 0000000..08608b0 --- /dev/null +++ b/libproxy-sysconfig-support.patch @@ -0,0 +1,201 @@ +Index: libproxy/cmake/modules.cmk +=================================================================== +--- libproxy/cmake/modules.cmk (revision 775) ++++ libproxy/cmake/modules.cmk (working copy) +@@ -9,6 +9,7 @@ + include(cmake/pxmodule.cmk) + include(cmake/pkgconfig.cmk) + include(cmake/modules/config_envvar.cmk) ++include(cmake/modules/config_sysconfig.cmk) + include(cmake/modules/config_gnome.cmk) + include(cmake/modules/config_kde4.cmk) + include(cmake/modules/config_macosx.cmk) +@@ -27,6 +28,7 @@ + # + message("MODULES TO BUILD:") + px_module(config_envvar "${ENVVAR_FOUND}" 1) ++px_module(config_sysconfig "${SYSCONFIG_FOUND}" 1) + px_module(config_gnome "${GNOME_FOUND}" 0) + px_module(config_kde4 "${KDE4_FOUND}" 0 ${KDE4_LIBRARIES}) + px_module(config_macosx "${SC_FOUND}" 1 ${SC_LIBRARIES} ${CF_LIBRARIES}) +Index: libproxy/cmake/modules/config_sysconfig.cmk +=================================================================== +--- libproxy/cmake/modules/config_sysconfig.cmk (revision 0) ++++ libproxy/cmake/modules/config_sysconfig.cmk (revision 0) +@@ -0,0 +1,5 @@ ++if (NOT WIN32 AND NOT APPLE) ++ if (EXISTS "/etc/sysconfig" AND IS_DIRECTORY "/etc/sysconfig") ++ set(SYSCONFIG_FOUND 1) ++ endif() ++endif() +\ No newline at end of file +Index: libproxy/modules/config_sysconfig.cpp +=================================================================== +--- libproxy/modules/config_sysconfig.cpp (revision 0) ++++ libproxy/modules/config_sysconfig.cpp (revision 0) +@@ -0,0 +1,165 @@ ++/******************************************************************************* ++ * libproxy sysconfig module ++ * Copyright (C) 2010 Novell Inc. ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library 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 ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ ******************************************************************************/ ++ ++#include ++#include ++#include ++#include ++ ++#include "../extension_config.hpp" ++using namespace libproxy; ++using std::map; ++ ++enum Trim { ++ NO_TRIM = 0x00, ++ L_TRIM = 0x01, ++ R_TRIM = 0x02, ++ TRIM = (L_TRIM|R_TRIM) ++}; ++ ++static std::string trim( const std::string & s, const Trim trim_r = TRIM ) { ++ ++ if (s.empty() || trim_r == NO_TRIM) ++ return s; ++ ++ std::string ret(s); ++ ++ if (trim_r & L_TRIM) { ++ std::string::size_type p = ret.find_first_not_of(" \t\n"); ++ if (p == std::string::npos) ++ return std::string(); ++ ++ ret = ret.substr(p); ++ } ++ ++ if (trim_r & R_TRIM) { ++ std::string::size_type p = ret.find_last_not_of(" \t\n"); ++ if (p == std::string::npos) ++ return std::string(); ++ ++ ret = ret.substr(0, p+1); ++ } ++ ++ return ret; ++} ++ ++static map sysconfig_read(const string &_path) { ++ ++ map ret; ++ string line; ++ ++ ifstream in(_path.c_str()); ++ if (in.fail()) { ++ return ret; ++ } ++ ++ while(getline( in, line)) { ++ ++ if (*line.begin() != '#') { ++ ++ string::size_type pos = line.find('=', 0); ++ ++ if (pos != string::npos) { ++ ++ string key = trim(line.substr(0, pos)); ++ string value = trim(line.substr(pos + 1, line.length() - pos - 1)); ++ ++ if (value.length() >= 2 ++ && *(value.begin()) == '"' ++ && *(value.rbegin()) == '"') { ++ value = value.substr( 1, value.length() - 2 ); ++ } ++ ++ if (value.length() >= 2 ++ && *(value.begin()) == '\'' ++ && *(value.rbegin()) == '\'' ) { ++ value = value.substr( 1, value.length() - 2 ); ++ } ++ ret[key] = value; ++ } // '=' found ++ ++ } // not comment ++ ++ } // while getline ++ return ret; ++} ++ ++static bool should_use_sysconfig() ++{ ++ struct stat st; ++ if (stat("/etc/sysconfig", &st) == 0) ++ return (getuid() == 0); ++ return false; ++} ++ ++class sysconfig_config_extension : public config_extension { ++ ++ map _data; ++ ++public: ++ sysconfig_config_extension() ++ : _data(sysconfig_read("/etc/sysconfig/proxy")) { ++ ++ } ++ ++ ~sysconfig_config_extension() { ++ } ++ ++ url get_config(url url) throw (runtime_error) { ++ map::const_iterator it = _data.find("PROXY_ENABLED"); ++ if (it != _data.end() && it->second == "no") ++ return libproxy::url("direct://"); ++ ++ string key; ++ string proxy; ++ ++ // If the URL is an ftp url, try to read the ftp proxy ++ if (url.get_scheme() == "ftp") ++ key = "FTP_PROXY"; ++ else if (url.get_scheme() == "http") ++ key = "HTTP_PROXY"; ++ else if (url.get_scheme() == "https") ++ key = "HTTPS_PROXY"; ++ ++ it = _data.find(key); ++ if (it != _data.end()) ++ proxy = it->second; ++ ++ if (proxy.empty()) ++ throw runtime_error("Unable to read configuration"); ++ ++ return libproxy::url(proxy); ++ } ++ ++ string get_ignore(url) { ++ map::const_iterator it = _data.find("NO_PROXY"); ++ if (it != _data.end()) ++ return it->second; ++ return ""; ++ } ++ ++ // if we are running as root, and the module is used, then ++ // make sure this is the first method tried ++ virtual bool operator<(const base_extension&) const { ++ return true; ++ } ++}; ++ ++MM_MODULE_INIT_EZ(sysconfig_config_extension, should_use_sysconfig(), NULL, NULL); ++ diff --git a/libproxy.changes b/libproxy.changes index 68e7474..7c2420e 100644 --- a/libproxy.changes +++ b/libproxy.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Dec 6 16:32:28 CET 2010 - vuntz@opensuse.org + +- Add libproxy-sysconfig-support.patch, to support the proxy + configuration from sysconfig. Part of bnc#655483. + Patch written by Duncan Mac-Vicar . + ------------------------------------------------------------------- Thu Sep 2 09:38:47 CEST 2010 - dimstar@opensuse.org diff --git a/libproxy.spec b/libproxy.spec index 1ebe2eb..09f280a 100644 --- a/libproxy.spec +++ b/libproxy.spec @@ -49,6 +49,8 @@ Source: http://libproxy.googlecode.com/files/%{_sourcename}.tar.bz2 # Script used for automatic snapshot updates Source98: update-from-svn.sh Source99: baselibs.conf +# PATCH-FEATURE-UPSTREAM libproxy-sysconfig-support.patch bnc#655483 dmacvicar@novell.com -- Add /etc/sysconfig support. Also tracked at http://code.google.com/p/libproxy/issues/detail?id=150 +Patch0: libproxy-sysconfig-support.patch License: GPLv2+ ; LGPLv2.1+ BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: cmake @@ -289,6 +291,7 @@ about network configuration changes. %prep %setup -q -n %{_sourcename} mkdir build +%patch0 -p0 %build cd build