Zypp Commits
Threads by month
- ----- 2025 -----
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
October 2009
- 4 participants
- 179 discussions
ref: refs/heads/ma-misc
commit db1608aad7f8220bfa40f659d791266bae30119b
Author: Michael Andres <ma(a)suse.de>
Date: Sat Oct 31 23:08:26 2009 +0100
backup
---
devel/devel.ma/Main.cc | 60 ++++-----------
devel/devel.ma/NewPool.cc | 20 ++++-
tools/zypp-Orphans.cc | 146 +++++++++++++++++++++++++++++++++++++
zypp/CMakeLists.txt | 2 +
zypp/ResolverTransaction.cc | 109 +++++++++++++++++++++++++++
zypp/ResolverTransaction.h …
[View More] | 77 +++++++++++++++++++
zypp/sat/detail/PoolImpl.cc | 2 +-
zypp/solver/detail/SATResolver.cc | 5 +
8 files changed, 370 insertions(+), 51 deletions(-)
diff --git a/devel/devel.ma/Main.cc b/devel/devel.ma/Main.cc
index 7fe1c36..aa623ca 100644
--- a/devel/devel.ma/Main.cc
+++ b/devel/devel.ma/Main.cc
@@ -6,7 +6,7 @@
///////////////////////////////////////////////////////////////////
//static const Pathname sysRoot( getenv("SYSROOT") ? getenv("SYSROOT") : "/Local/ROOT" );
-static const Pathname sysRoot( "/tmp/ToolScanRepos" );
+static const Pathname sysRoot( "/" );
///////////////////////////////////////////////////////////////////
@@ -55,6 +55,18 @@ namespace zypp
}
}
+void changePriority( const std::string & alias_r, int prio_r )
+{
+ sat::Pool satpool( sat::Pool::instance() );
+ Repository r( satpool.reposFind( alias_r ) );
+ MIL << r << endl;
+ RepoInfo ri( r.info() );
+ ri.setPriority( prio_r );
+ r.setInfo( ri );
+ MIL << r << endl;
+}
+
+
int main( int argc, char * argv[] )
try {
--argc;
@@ -63,7 +75,7 @@ try {
INT << "===[START]==========================================" << endl;
::unsetenv( "ZYPP_CONF" );
ZConfig::instance();
- TestSetup::LoadSystemAt( sysRoot, Arch_i586 );
+ TestSetup::LoadSystemAt( sysRoot );
///////////////////////////////////////////////////////////////////
ResPool pool( ResPool::instance() );
sat::Pool satpool( sat::Pool::instance() );
@@ -71,49 +83,7 @@ try {
dumpRange( USR, satpool.reposBegin(), satpool.reposEnd() ) << endl;
USR << "pool: " << pool << endl;
- sat::AttrMatcher matches( "^aaa_base$", Match::REGEX );
-
- getZYpp()->resolver()->addRequire( Capability("aaa_base") );
-
- solve();
- for_( it, make_filter_begin<resfilter::ByTransact>(pool), make_filter_end<resfilter::ByTransact>(pool) )
- {
- USR << *it << " " << (*it)->repoInfo().name() << endl;
- if ( matches( (*it)->name() ) )
- {
- SEC << *it << " " << (*it)->repoInfo().name() << endl;
- }
- }
-
- std::vector<std::string> words;
- str::split( "3ddiag ConsoleKit-x11 FZFangSong FZKaiTiB IPAGothic ImageMagick MozillaFirefox MozillaFirefox-branding-Moblin MozillaFirefox-translations NetworkManager OpenOffice_org OpenOffice_org-LanguageTool OpenOffice_org-LanguageTool-de OpenOffice_org-LanguageTool-en OpenOffice_org-LanguageTool-es OpenOffice_org-LanguageTool-fr OpenOffice_org-LanguageTool-it OpenOffice_org-LanguageTool-nl OpenOffice_org-LanguageTool-pl OpenOffice_org-LanguageTool-sv OpenOffice_org-base OpenOffice_org-base-extensions OpenOffice_org-branding-SLED OpenOffice_org-calc OpenOffice_org-calc-extensions OpenOffice_org-components OpenOffice_org-draw OpenOffice_org-draw-extensions OpenOffice_org-filters OpenOffice_org-filters-optional OpenOffice_org-gnome OpenOffice_org-hyphen OpenOffice_org-icon-themes OpenOffice_org-impress OpenOffice_org-impress-extensions OpenOffice_org-l10n-de OpenOffice_org-l10n-el OpenOffice_org-l10n-en-GB OpenOffice_org-l10n-es OpenOffice_org-l10n-extras OpenOffice_org-l10
n-fi OpenOffice_org-l10n-fr OpenOffice_org-l10n-it OpenOffice_org-l10n-ja OpenOffice_org-l10n-ko OpenOffice_org-l10n-nl OpenOffice_org-l10n-pl OpenOffice_org-l10n-pt OpenOffice_org-l10n-pt-BR OpenOffice_org-l10n-ru OpenOffice_org-l10n-sv OpenOffice_org-l10n-zh-CN OpenOffice_org-l10n-zh-TW OpenOffice_org-libs-core OpenOffice_org-libs-extern OpenOffice_org-libs-gui OpenOffice_org-math OpenOffice_org-openclipart OpenOffice_org-templates-en OpenOffice_org-templates-labels-a4 OpenOffice_org-templates-labels-letter OpenOffice_org-templates-presentation-layouts OpenOffice_org-thesaurus-de OpenOffice_org-thesaurus-en OpenOffice_org-thesaurus-es OpenOffice_org-thesaurus-fr OpenOffice_org-thesaurus-pl OpenOffice_org-thesaurus-pt OpenOffice_org-thesaurus-ru OpenOffice_org-thesaurus-sk OpenOffice_org-thesaurus-sv OpenOffice_org-ure OpenOffice_org-writer OpenOffice_org-writer-extensions PackageKit PolicyKit PolicyKit-gnome SDL SDL_image SDL_mixer SDL_net SDL_ttf SuSEfirewall2 WorldOfGooD
emo a2ps aaa_base acct acl acpid acroread agfa-fonts alsa alsa-tools amavisd-new anerley anjal ash at atk attr audit-libs autoyast2-installation avahi backup-manager baekmuk-ttf banshee-1 banshee-1-backend-engine-gstreamer banshee-1-backend-platform-gnome banshee-1-backend-platform-unix banshee-1-extensions-default banshee-1-novell-aac bash bc bind-libs bind-utils binutils bisho bitstream-vera blt bluez bluez-alsa bluez-cups bluez-firmware bluez-gnome bluez-gstreamer bootchart bootsplash-branding-SLED branding-SLED brasero bzip2 cabextract cairo cdrkit-cdrtools-compat checkmedia cheese cifs-mount clutter-mozembed compat convmv coreutils cpio cpp cpufrequtils cracklib cracklib-dict-full cron cryptconfig csync cubano cups cups-autoconfig cups-backends cups-client cups-drivers cups-libs curl cyrus-sasl cyrus-sasl-crammd5 cyrus-sasl-digestmd5 cyrus-sasl-gssapi cyrus-sasl-plain dalston dates db-utils dbus-1 dbus-1-glib dbus-1-x11 dejavu deltarpm desktop-file-utils desktop-transla
tions device-mapper dhcpcd dialog diffutils dirmngr dmraid dos2unix dosfstools e2fsprogs ed eject elfutils empathy ethtool evince evolution evolution-pilot expat extreme-tuxracer f-spot fbset file file-roller filesystem fillup filters findutils finger flash-player fontconfig fonts-config foomatic-filters freeglut freetype freetype2 fribidi frozen-bubble gammu gawk gcalctool gconf2-branding-SLED gdb gdbm gdm gdm-branding-upstream gedit geoclue gettext-runtime gftp gfxboot-branding-SLED ghostscript-fonts-other ghostscript-fonts-std ghostscript-library ghostscript-x11 giflib gimp glib glib2 glib2-branding-Moblin glibc glibc-locale gnome-audio gnome-control-center gnome-desktop gnome-games gnome-icon-theme gnome-keyring gnome-keyring-pam gnome-media gnome-menus gnome-mime-data gnome-mount gnome-packagekit gnome-panel gnome-pilot gnome-session gnome-spell2 gnome-system-monitor gnome-terminal gnome-themes gnome-utils gnome-vfs2 gnome-web-photo gpart gpg2 gpgme gphoto gpm gpsd grep
groff grub gstreamer-0_10 gstreamer-0_10-plugins-base gstreamer-0_10-plugins-farsight gstreamer-0_10-plugins-good gstreamer-0_10-schroedinger gstreamer-0_10-utils gsynaptics gtk gtk2 gtk2-branding-SLED gtk2-engines gtk2-theme-SLED gtk2-themes gtkhtml2 gtkspell gutenprint gvfs-backends gypsy gzip hal hdparm hornsey hwinfo ifplugd imlib info initviocons inkscape insserv iproute2 iptables iputils ipw-firmware ispell ispell-american ispell_english_dictionary iw iwl3945-ucode iwl4965-ucode iwl5000-ucode jana java-1_6_0-sun java-1_6_0-sun-plugin json-glib kernel-default kernel-default-base kernel-default-extra kernel-firmware klogd krb5 ksymoops laptop-mode-tools lcms less libQtWebKit4 libacl libattr libblocxx6 libbluetooth3 libclutter-box2d-0_10-0 libclutter-glx-1_0-0 libclutter-gst-1_0-0 libclutter-gtk-1_0-0 libclutter-qt-1_0-0 libdb-4_5 libevent-1_4-2 libfakekey0 libfprint0 libgcc43 libgcrypt11 libgimpprint libgpg-error0 libgsf-gnome libjpeg libmikmod libmng libmoon0 libnetpbm
10 libnscd libopensync-plugin-file libpcap0 libpng12-0 libproxy-tools libproxy0 libproxy0-gnome libproxy0-mozjs libproxy0-networkmanager libreadline5 librpcsecgss libsmbios-bin libstdc++33 libstdc++43 libtiff3 libusbpp-0_1-4 libxcrypt libxml2 libxslt libzio libzypp lilo limal limal-perl linux-atm-lib login logrotate lsof lukemftp m4 mailx make man man-pages manufacturer-PPDs master-boot-code mdadm meerkat metacity metamail microcode_ctl mingetty mkinitrd moblin-branding-Samsung moblin-gtk-engine moblin-icon-theme moblin-menus moblin-registration moblin-release moblin-sound-theme moblin-ux-settings moblin-web-browser module-init-tools mojito monsoon moonlight-plugin moonshine moonshine-plugin mousetweaks mozilla-filesystem mozilla-xulrunner190 mtools mutter mutter-moblin myspell-american myspell-british myspell-dutch myspell-french myspell-german myspell-greek myspell-italian myspell-polish myspell-portuguese myspell-russian myspell-spanish myspell-swedish nautilus nautilus-c
d-burner nautilus-eiciel nautilus-open-terminal nautilus-sendto nautilus-share nbtk ncurses-utils net-tools netcat netcfg network-manager-netbook neverball nfsidmap notification-daemon novell-ipsec-tools novell-ldapext novell-nortelplugins nscd nspluginwrapper nss_ldap ntfs-3g ntfsprogs ntp numlockx openclipart-svg openldap2-client openmotif-libs openobex opensc openslp openssh openssh-askpass openssl padevchooser pam pam-config pam-modules pam_csync pam_krb5 pam_ldap pam_p11 pam_pkcs11 pam_radius pam_smb pam_ssh paman paprefs parted pavucontrol pavumeter pciutils pcmciautils pcre pcsc-lite perl perl-Bootloader perl-Config-Crontab perl-Crypt-SmbHash perl-Digest-MD4 perl-Digest-SHA1 perl-Parse-RecDescent perl-TermReadKey perl-X500-DN perl-XML-XPath perl-base perl-gettext perl-satsolver permissions pinentry-gtk2 planner plymouth-lite pmtools polkit-default-privs popt postfix ppp pptp preload procinfo procmail procps psmisc pulseaudio-esound-compat pulseaudio-module-bluetooth p
ulseaudio-module-gconf pulseaudio-module-lirc pulseaudio-module-x11 pulseaudio-module-zeroconf pulseaudio-utils pwdutils python python-gnome python-gtk python-numeric python-qt python-tk python-xml rdesktop recode reiserfs release-notes-sled rest rpm rsh rsync rsyslog rtc-tzset samba samba-client sample-media-images samsung-icon-theme samsung-manual sash sax2 sax2-gui sax2-ident sax2-libsax sax2-libsax-perl sax2-tools scim scim-bridge scim-bridge-clutter scim-bridge-gtk scim-bridge-qt scim-chewing scim-m17n scim-pinyin scim-tables scim-tables-zh screen seahorse sed setserial sg3_utils shared-mime-info sled-manuals_en sled-moblinquick_en sled-moblinquick_en-pdf splashy splashy-branding-SLED sqlite3 sreadahead star startup-notification strace sudo supportutils suse-build-key suse-sam suseRegister susehelp susehelp_en suspend syncevolution sysconfig sysfsutils syslinux system-config-printer sysvinit tango-icon-theme tar tcl-devel tcpd tcsh telnet terminfo tightvnc timezone tk-d
evel translation-update tsclient turnpike twitter-glib udev ulimit unrar unzip usbutils utempter util-linux uxlaunch vbetool vim vim-data vte w3m wdiff wget wimax-tools wireless-tools wol words wpa_supplicant wvdial wvstreams x11-input-synaptics x11-tools x86info xchat xdmbgrd xfsprogs xkeyboard-config xorg-x11 xorg-x11-Xvnc xorg-x11-driver-input xorg-x11-driver-video xorg-x11-fonts xorg-x11-libX11-ccache xorg-x11-libs xorg-x11-server xorg-x11-server-extra xorg-x11-xauth xpdf-tools xterm xtermset xulrunner yast2 yast2-bootloader yast2-branding-SLED yast2-control-center-gnome yast2-core yast2-country yast2-firewall yast2-firstboot yast2-gtk yast2-hardware-detection yast2-installation yast2-kerberos-client yast2-ldap yast2-ldap-client yast2-metapackage-handler yast2-mouse yast2-ncurses yast2-ncurses-pkg yast2-network yast2-ntp-client yast2-online-update yast2-online-update-frontend yast2-packager yast2-pam yast2-perl-bindings yast2-pkg-bindings yast2-qt yast2-qt-pkg yast2-rdp
yast2-registration yast2-registration-branding-SLE yast2-repair yast2-runlevel yast2-samba-client yast2-schema yast2-security yast2-slp yast2-sound yast2-storage yast2-storage-lib yast2-support yast2-sysconfig yast2-theme-SLE yast2-trans-en_GB yast2-trans-en_US yast2-trans-es yast2-trans-fi yast2-trans-fr yast2-trans-ja yast2-trans-ko yast2-trans-pt_BR yast2-trans-stats yast2-trans-sv yast2-trans-zh_CN yast2-trans-zh_TW yast2-transfer yast2-tune yast2-update yast2-users yast2-wagon yast2-x11 yast2-xml yelp youtube-player zenity zip zlib",
- std::back_inserter(words) );
- for_( it, words.begin(), words.end() )
- {
- getZYpp()->resolver()->addRequire( Capability(*it) );
- }
-
- getZYpp()->resolver()->addRequire( Capability("aaa_base > 11-6.2") );
-
- solve();
- for_( it, make_filter_begin<resfilter::ByTransact>(pool), make_filter_end<resfilter::ByTransact>(pool) )
- {
- USR << *it << " " << (*it)->repoInfo().name() << endl;
- if ( matches( (*it)->name() ) )
- {
- SEC << *it << " " << (*it)->repoInfo().name() << endl;
- }
- }
-
-
- if ( 0 )
- {
- getZYpp()->resolver()->addRequire( Capability("emacs") );
- solve();
- vdumpPoolStats( USR << "Transacting:"<< endl,
- make_filter_begin<resfilter::ByTransact>(pool),
- make_filter_end<resfilter::ByTransact>(pool) ) << endl;
- }
+ upgrade();
///////////////////////////////////////////////////////////////////
INT << "===[END]============================================" << endl << endl;
diff --git a/devel/devel.ma/NewPool.cc b/devel/devel.ma/NewPool.cc
index 1596cdc..f2606de 100644
--- a/devel/devel.ma/NewPool.cc
+++ b/devel/devel.ma/NewPool.cc
@@ -482,7 +482,7 @@ void cut( const Capability & cap )
}
else
{
- MIL << "---???---" << endl;
+ MIL << "--- ???? ---" << endl;
}
}
@@ -513,10 +513,18 @@ try {
INT << "===[START]==========================================" << endl;
ZConfig::instance();
+ Url u("http://user:pass@Host/path");
+ USR << u << endl;
+ USR << u.getHost() << endl;
+ USR << u.getUsername() << endl;
+ USR << u.getPassword() << endl;
+
+ return 0;
+
ResPool pool( ResPool::instance() );
sat::Pool satpool( sat::Pool::instance() );
- if ( 0 )
+ if ( 1 )
{
Measure x( "INIT TARGET" );
{
@@ -620,11 +628,13 @@ try {
///////////////////////////////////////////////////////////////////
+ for_( it, pool.proxy().byKindBegin<Package>(), pool.proxy().byKindEnd<Package>() )
+ {
+ ((*it)->identicalInstalledCandidate() ? MIL : WAR) << *it << endl;
+ }
-
-
-#if 1
+#if 0
getZYpp()->resolver()->addRequire( Capability("amarok") );
pool.byKindBegin<Package>()->status().setTransact( true, ResStatus::USER );
solve();
diff --git a/tools/zypp-Orphans.cc b/tools/zypp-Orphans.cc
new file mode 100644
index 0000000..4651614
--- /dev/null
+++ b/tools/zypp-Orphans.cc
@@ -0,0 +1,146 @@
+#define INCLUDE_TESTSETUP_WITHOUT_BOOST
+#include "zypp/../tests/lib/TestSetup.h"
+#undef INCLUDE_TESTSETUP_WITHOUT_BOOST
+
+#include <algorithm>
+#include <zypp/PoolQuery.h>
+#include <zypp/misc/DefaultLoadSystem.h>
+
+static std::string appname( "zypp-Orphans" );
+
+#define message cout
+using std::flush;
+
+int errexit( const std::string & msg_r = std::string(), int exit_r = 100 )
+{
+ if ( ! msg_r.empty() )
+ {
+ cerr << endl << msg_r << endl << endl;
+ }
+ return exit_r;
+}
+
+int usage( const std::string & msg_r = std::string(), int exit_r = 100 )
+{
+ if ( ! msg_r.empty() )
+ {
+ cerr << endl << msg_r << endl << endl;
+ }
+ cerr << "Usage: " << appname << " [--root ROOTDIR] [OPTIONS]" << endl;
+ cerr << " Load all enabled repositories (no refresh) and search for" << endl;
+ cerr << " orphaned packages. I.e packages wich are inatalled but not" << endl;
+ cerr << " available in any repository." << endl;
+ cerr << " --root Load repos from the system located below ROOTDIR. If ROOTDIR" << endl;
+ cerr << " denotes a sover testcase, the testcase is loaded." << endl;
+ cerr << "" << endl;
+ return exit_r;
+}
+
+void tableOut( const std::string & s1 = std::string(),
+ const std::string & s2 = std::string(),
+ const std::string & s3 = std::string(),
+ const std::string & s4 = std::string(),
+ const std::string & s5 = std::string() )
+{
+ message << " ";
+#define TABEL(N) static unsigned w##N = 0; if ( ! s##N.empty() ) w##N = std::max( w##N, unsigned(s##N.size()) ); message << str::form( " %-*s ", w##N, s##N.c_str() )
+#define TABER(N) static unsigned w##N = 0; if ( ! s##N.empty() ) w##N = std::max( w##N, unsigned(s##N.size()) ); message << str::form( " %*s ", w##N, s##N.c_str() )
+ TABER( 1 ); TABEL( 2 ); TABEL( 3 ); TABEL( 4 ); TABEL( 5 );
+#undef TABEL
+ message << endl;
+}
+
+bool solve()
+{
+ bool rres = false;
+ {
+ rres = getZYpp()->resolver()->resolvePool();
+ }
+ if ( ! rres )
+ {
+ ERR << "resolve " << rres << endl;
+ getZYpp()->resolver()->problems();
+ return false;
+ }
+ MIL << "resolve " << rres << endl;
+ return true;
+}
+
+/******************************************************************
+**
+** FUNCTION NAME : main
+** FUNCTION TYPE : int
+*/
+int main( int argc, char * argv[] )
+{
+ INT << "===[START]==========================================" << endl;
+ appname = Pathname::basename( argv[0] );
+ --argc,++argv;
+
+ ///////////////////////////////////////////////////////////////////
+
+ ZConfig::instance();
+ Pathname sysRoot("/");
+ sat::Pool satpool( sat::Pool::instance() );
+
+ while ( argc )
+ {
+ if ( (*argv) == std::string("--help") )
+ {
+ return usage();
+ }
+
+ if ( (*argv) == std::string("--root") )
+ {
+ --argc,++argv;
+ if ( ! argc )
+ return errexit("--root requires an argument.");
+
+ if ( ! PathInfo( *argv ).isDir() )
+ return errexit("--root requires a directory.");
+
+ sysRoot = *argv;
+ --argc,++argv;
+ }
+
+ }
+
+ if ( TestSetup::isTestcase( sysRoot ) )
+ {
+ message << str::form( "*** Load Testcase from '%s'", sysRoot.c_str() ) << endl;
+ TestSetup test;
+ test.loadTestcaseRepos( sysRoot );
+ }
+ else if ( TestSetup::isTestSetup( sysRoot ) )
+ {
+ message << str::form( "*** Load TestSetup from '%s'", sysRoot.c_str() ) << endl;
+ TestSetup test( sysRoot, Arch_x86_64 );
+ test.loadRepos();
+ }
+ else
+ {
+ // a system
+ message << str::form( "*** Load system at '%s'", sysRoot.c_str() ) << endl;
+ misc::defaultLoadSystem( sysRoot, misc::LS_READONLY | misc::LS_NOREFRESH );
+ }
+
+ ///////////////////////////////////////////////////////////////////
+
+ ResPool pool( ResPool::instance() );
+ solve();
+ unsigned cnt = 0;
+ message << "Orphaned packages:";
+ for_( it, pool.byStatusBegin(&ResStatus::isOrphaned), pool.byStatusEnd(&ResStatus::isOrphaned) )
+ {
+ ++cnt;
+ message << endl << " " << (*it).satSolvable().asString();
+ }
+
+ if ( ! cnt )
+ message << " none.";
+
+ message << endl;
+
+ INT << "===[END]============================================" << endl << endl;
+ return 0;
+}
diff --git a/zypp/CMakeLists.txt b/zypp/CMakeLists.txt
index bbceaa3..5f8048f 100644
--- a/zypp/CMakeLists.txt
+++ b/zypp/CMakeLists.txt
@@ -60,6 +60,7 @@ SET( zypp_SRCS
Resolvable.cc
Resolver.cc
ResolverProblem.cc
+ ResolverTransaction.cc
ResPool.cc
ResPoolProxy.cc
ResStatus.cc
@@ -157,6 +158,7 @@ SET( zypp_HEADERS
Resolvable.h
Resolver.h
ResolverProblem.h
+ ResolverTransaction.h
ResPool.h
ResPoolProxy.h
ResStatus.h
diff --git a/zypp/ResolverTransaction.cc b/zypp/ResolverTransaction.cc
new file mode 100644
index 0000000..cadf232
--- /dev/null
+++ b/zypp/ResolverTransaction.cc
@@ -0,0 +1,109 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/ResolverTransaction.cc
+ *
+*/
+extern "C"
+{
+#include <satsolver/transaction.h>
+}
+
+#include <iostream>
+
+#include "zypp/base/LogTools.h"
+#include "zypp/sat/detail/PoolMember.h"
+
+#include "zypp/ResolverTransaction.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ void remember_transaction( const _Transaction & trans_r )
+ {
+ ResolverTransaction trans( &trans_r );
+ USR << trans << endl;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ResolverTransaction::Impl
+ //
+ /** ResolverTransaction implementation. */
+ struct ResolverTransaction::Impl
+ {
+ public:
+ Impl( const ::_Transaction * sattrans_r = 0 )
+ {
+ if ( sattrans_r )
+ ::transaction_init_clone( &_trans, const_cast< ::_Transaction*>( sattrans_r ) );
+ else
+ ::transaction_init( &_trans, myPool().getPool() );
+ }
+
+ Impl( const Impl & rhs )
+ { ::transaction_init_clone( &_trans, const_cast< ::_Transaction*>( &rhs._trans ) ); }
+
+ ~Impl()
+ { ::transaction_free( &_trans ); }
+
+ public:
+
+ ::_Transaction _trans;
+
+ private:
+ friend Impl * rwcowClone<Impl>( const Impl * rhs );
+ /** clone for RWCOW_pointer */
+ Impl * clone() const
+ { return new Impl( *this ); }
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates ResolverTransaction::Impl Stream output */
+ inline std::ostream & operator<<( std::ostream & str, const ResolverTransaction::Impl & obj )
+ {
+ return str << "ResolverTransaction::Impl";
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ResolverTransaction
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ ResolverTransaction::ResolverTransaction()
+ : _pimpl( new Impl )
+ {}
+
+ ResolverTransaction::ResolverTransaction( const ::_Transaction * sattrans_r )
+ : _pimpl( new Impl( sattrans_r ) )
+ {}
+
+ ///////////////////////////////////////////////////////////////////
+
+ bool ResolverTransaction::empty() const
+ { return true; }
+
+ ::_Transaction * ResolverTransaction::get() const
+ { return const_cast< ::_Transaction*>( &_pimpl->_trans ); }
+
+ /******************************************************************
+ **
+ ** FUNCTION NAME : operator<<
+ ** FUNCTION TYPE : std::ostream &
+ */
+ std::ostream & operator<<( std::ostream & str, const ResolverTransaction & obj )
+ { return str << *obj._pimpl; }
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/ResolverTransaction.h b/zypp/ResolverTransaction.h
new file mode 100644
index 0000000..be64d35
--- /dev/null
+++ b/zypp/ResolverTransaction.h
@@ -0,0 +1,77 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/ResolverTransaction.h
+ *
+*/
+#ifndef ZYPP_RESOLVERTRANSACTION_H
+#define ZYPP_RESOLVERTRANSACTION_H
+
+#include <iosfwd>
+
+#include "zypp/base/SafeBool.h"
+#include "zypp/sat/detail/PoolImpl.h"
+
+#include "zypp/base/PtrTypes.h"
+
+extern "C"
+{
+struct _Transaction;
+}
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ void remember_transaction( const _Transaction & );
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ResolverTransaction
+ //
+ /** */
+ class ResolverTransaction: protected sat::detail::PoolMember,
+ private base::SafeBool<ResolverTransaction>
+ {
+ friend std::ostream & operator<<( std::ostream & str, const ResolverTransaction & obj );
+
+ public:
+ /** Default ctor */
+ ResolverTransaction();
+
+ /** Ctor taking satsolver data. */
+ ResolverTransaction( const ::_Transaction * sattrans_r );
+
+ public:
+ /** */
+ bool empty() const;
+
+ public:
+ /** Expert backdoor. */
+ ::_Transaction * get() const;
+ private:
+#ifndef SWIG // Swig treats it as syntax error
+ friend base::SafeBool<ResolverTransaction>::operator bool_type() const;
+#endif
+ bool boolTest() const { return ! empty(); }
+ public:
+ /** Implementation */
+ class Impl;
+ private:
+ /** Pointer to implementation */
+ RWCOW_pointer<Impl> _pimpl;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates ResolverTransaction Stream output */
+ std::ostream & operator<<( std::ostream & str, const ResolverTransaction & obj );
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_RESOLVERTRANSACTION_H
diff --git a/zypp/sat/detail/PoolImpl.cc b/zypp/sat/detail/PoolImpl.cc
index 9102074..73b9530 100644
--- a/zypp/sat/detail/PoolImpl.cc
+++ b/zypp/sat/detail/PoolImpl.cc
@@ -184,7 +184,7 @@ namespace zypp
if (verbose)
::pool_setdebuglevel( _pool, 2 );
else
- ::pool_setdebugmask(_pool, SAT_DEBUG_JOB|SAT_DEBUG_STATS);
+ ::pool_setdebugmask(_pool, SAT_DEBUG_JOB|SAT_DEBUG_STATS|SAT_DEBUG_RESULT);
::pool_setdebugcallback( _pool, logSat, NULL );
diff --git a/zypp/solver/detail/SATResolver.cc b/zypp/solver/detail/SATResolver.cc
index c76bad3..e38f92d 100644
--- a/zypp/solver/detail/SATResolver.cc
+++ b/zypp/solver/detail/SATResolver.cc
@@ -27,6 +27,7 @@ extern "C"
#include <satsolver/policy.h>
#include <satsolver/bitmap.h>
#include <satsolver/queue.h>
+#include <satsolver/solverdebug.h>
}
#include "zypp/solver/detail/Helper.h"
@@ -55,6 +56,7 @@ extern "C"
/////////////////////////////////////////////////////////////////////////
namespace zypp
{ ///////////////////////////////////////////////////////////////////////
+ void remember_transaction( const _Transaction & );
///////////////////////////////////////////////////////////////////////
namespace solver
{ /////////////////////////////////////////////////////////////////////
@@ -648,6 +650,9 @@ SATResolver::solverInit(const PoolItemList & weakItems)
void
SATResolver::solverEnd()
{
+ ::solver_printdecisions( _solv );
+ ::solver_printtransaction( _solv );
+ remember_transaction( _solv->trans );
// cleanup
solver_free(_solv);
_solv = NULL;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
[View Less]
1
0

[zypp-commit] <libzypp> master : MediaSMB and MediaCIFS are the same, so use CIFS everywhere and dop SMB
by Michael Andres 31 Oct '09
by Michael Andres 31 Oct '09
31 Oct '09
ref: refs/heads/master
commit a16adb004b0e20e84a5ab16a4d04d2e5fa48b8e8
Author: Michael Andres <ma(a)suse.de>
Date: Sat Oct 31 17:49:22 2009 +0100
MediaSMB and MediaCIFS are the same, so use CIFS everywhere and dop SMB
---
zypp/CMakeLists.txt | 2 -
zypp/media/MediaAccess.cc | 7 +-
zypp/media/MediaCIFS.cc | 461 +++++++++++++++++++++++++++++++++++++++++++-
zypp/media/MediaCIFS.h | 41 +++--
zypp/media/MediaSMB.cc | 470 ---------------------------------------…
[View More]------
zypp/media/MediaSMB.h | 78 --------
6 files changed, 487 insertions(+), 572 deletions(-)
diff --git a/zypp/CMakeLists.txt b/zypp/CMakeLists.txt
index 40973fc..bbceaa3 100644
--- a/zypp/CMakeLists.txt
+++ b/zypp/CMakeLists.txt
@@ -260,7 +260,6 @@ SET( zypp_media_SRCS
media/MediaCD.cc
media/MediaDIR.cc
media/MediaDISK.cc
- media/MediaSMB.cc
media/MediaCIFS.cc
media/ProxyInfo.cc
media/MediaCurl.cc
@@ -289,7 +288,6 @@ SET( zypp_media_HEADERS
media/MediaISO.h
media/MediaManager.h
media/MediaNFS.h
- media/MediaSMB.h
media/MediaSource.h
media/MediaUserAuth.h
media/Mount.h
diff --git a/zypp/media/MediaAccess.cc b/zypp/media/MediaAccess.cc
index cff2d01..7ed6af5 100644
--- a/zypp/media/MediaAccess.cc
+++ b/zypp/media/MediaAccess.cc
@@ -25,7 +25,6 @@
#include "zypp/media/MediaCD.h"
#include "zypp/media/MediaDIR.h"
#include "zypp/media/MediaDISK.h"
-#include "zypp/media/MediaSMB.h"
#include "zypp/media/MediaCIFS.h"
#include "zypp/media/MediaCurl.h"
#include "zypp/media/MediaAria2c.h"
@@ -123,10 +122,8 @@ MediaAccess::open (const Url& url, const Pathname & preferred_attach_point)
_handler = new MediaDIR (url,preferred_attach_point);
else if (scheme == "hd")
_handler = new MediaDISK (url,preferred_attach_point);
- else if (scheme == "smb")
- _handler = new MediaSMB (url,preferred_attach_point);
- else if (scheme == "cifs")
- _handler = new MediaCIFS (url,preferred_attach_point);
+ else if (scheme == "cifs" || scheme == "smb")
+ _handler = new MediaCIFS (url,preferred_attach_point);
else if (scheme == "ftp" || scheme == "http" || scheme == "https")
{
// Another good idea would be activate MediaAria2c handler via external var
diff --git a/zypp/media/MediaCIFS.cc b/zypp/media/MediaCIFS.cc
index f4f2133..7d5215e 100644
--- a/zypp/media/MediaCIFS.cc
+++ b/zypp/media/MediaCIFS.cc
@@ -10,7 +10,460 @@
*
*/
-//
-// NOTE: It's actually MediaSMB, but using "cifs"
-// as vfstype for mount.
-//
+#include <iostream>
+#include <fstream>
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Gettext.h"
+#include "zypp/TmpPath.h"
+#include "zypp/KVMap.h"
+#include "zypp/media/Mount.h"
+#include "zypp/media/MediaUserAuth.h"
+#include "zypp/media/CredentialManager.h"
+#include "zypp/ZYppCallbacks.h"
+
+#warning FIXME: get rid of this dependency on Target
+#include "zypp/ZYppFactory.h" // for target->root()
+#include "zypp/Target.h" // for zypp->target->root()
+
+#include "zypp/media/MediaCIFS.h"
+
+#include <sys/types.h>
+#include <sys/mount.h>
+#include <errno.h>
+#include <dirent.h>
+
+using namespace std;
+
+namespace zypp {
+ namespace media {
+
+ /******************************************************************
+ **
+ **
+ ** FUNCTION NAME : getShare
+ ** FUNCTION TYPE : inline Pathname
+ **
+ ** Get the 1st path component (CIFS share name).
+ */
+ inline string getShare( Pathname spath_r )
+ {
+ if ( spath_r.empty() )
+ return string();
+
+ string share( spath_r.absolutename().asString() );
+ string::size_type sep = share.find( "/", 1 );
+ if ( sep == string::npos )
+ share = share.erase( 0, 1 ); // nothing but the share name in spath_r
+ else
+ share = share.substr( 1, sep-1 );
+
+ // deescape %2f in sharename
+ while ( (sep = share.find( "%2f" )) != string::npos ) {
+ share.replace( sep, 3, "/" );
+ }
+
+ return share;
+ }
+
+ /******************************************************************
+ **
+ **
+ ** FUNCTION NAME : stripShare
+ ** FUNCTION TYPE : inline Pathname
+ **
+ ** Strip off the 1st path component (CIFS share name).
+ */
+ inline Pathname stripShare( Pathname spath_r )
+ {
+ if ( spath_r.empty() )
+ return Pathname();
+
+ string striped( spath_r.absolutename().asString() );
+ string::size_type sep = striped.find( "/", 1 );
+ if ( sep == string::npos )
+ return "/"; // nothing but the share name in spath_r
+
+ return striped.substr( sep );
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : MediaCIFS
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ //
+ // METHOD NAME : MediaCIFS::MediaCIFS
+ // METHOD TYPE : Constructor
+ //
+ // DESCRIPTION :
+ //
+ MediaCIFS::MediaCIFS( const Url & url_r,
+ const Pathname & attach_point_hint_r )
+ : MediaHandler( url_r, attach_point_hint_r,
+ stripShare( url_r.getPathName() ), // urlpath WITHOUT share name at attachpoint
+ false ) // does_download
+ {
+ MIL << "MediaCIFS::MediaCIFS(" << url_r << ", " << attach_point_hint_r << ")" << endl;
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ //
+ // METHOD NAME : MediaCIFS::attachTo
+ // METHOD TYPE : PMError
+ /**
+ * Asserted that not already attached, and attachPoint is a directory.
+ *
+ * Authentication: credentials can be specified in the following few ways
+ * (the first has the highest preference).
+ * - URL username:password
+ * - mountoptions URL query parameter (see man mount.cifs)
+ * - CredentialManager - either previously saved credentials will be used
+ * or the user will be promted for them via AuthenticationReport callback.
+ *
+ * \note The implementation currently serves both, "smb" and
+ * and "cifs" URL's, but passes "cifs" to the mount command
+ * in any case.
+ */
+ void MediaCIFS::attachTo(bool next)
+ {
+ if(_url.getHost().empty())
+ ZYPP_THROW(MediaBadUrlEmptyHostException(_url));
+ if(next)
+ ZYPP_THROW(MediaNotSupportedException(_url));
+
+ string path = "//";
+ path += _url.getHost() + "/" + getShare( _url.getPathName() );
+
+ MediaSourceRef media( new MediaSource( "cifs", path));
+ AttachedMedia ret( findAttachedMedia( media));
+
+ if( ret.mediaSource &&
+ ret.attachPoint &&
+ !ret.attachPoint->empty())
+ {
+ DBG << "Using a shared media "
+ << ret.mediaSource->name
+ << " attached on "
+ << ret.attachPoint->path
+ << endl;
+
+ removeAttachPoint();
+ setAttachPoint(ret.attachPoint);
+ setMediaSource(ret.mediaSource);
+ return;
+ }
+
+ std::string mountpoint = attachPoint().asString();
+ if( !isUseableAttachPoint(attachPoint()))
+ {
+ mountpoint = createAttachPoint().asString();
+ if( mountpoint.empty())
+ ZYPP_THROW( MediaBadAttachPointException(url()));
+ setAttachPoint( mountpoint, true);
+ }
+
+ Mount mount;
+ CredentialManager cm;
+
+ Mount::Options options( _url.getQueryParam("mountoptions") );
+ string username = _url.getUsername();
+ string password = _url.getPassword();
+
+ options["guest"]; // prevent smbmount from asking for password
+
+ if ( ! options.has( "rw" ) ) {
+ options["ro"];
+ }
+
+ // look for a workgroup
+ string workgroup = _url.getQueryParam("workgroup");
+ if ( workgroup.empty() )
+ workgroup = _url.getQueryParam("domain");
+ if ( !workgroup.empty() )
+ options["domain"] = workgroup;
+
+ // extract 'username', do not overwrite any _url.username
+
+ Mount::Options::iterator toEnv;
+ toEnv = options.find("username");
+ if ( toEnv != options.end() ) {
+ if ( username.empty() )
+ username = toEnv->second;
+ options.erase( toEnv );
+ }
+
+ toEnv = options.find("user"); // actually cifs specific
+ if ( toEnv != options.end() ) {
+ if ( username.empty() )
+ username = toEnv->second;
+ options.erase( toEnv );
+ }
+
+ // extract 'password', do not overwrite any _url.password
+
+ toEnv = options.find("password");
+ if ( toEnv != options.end() ) {
+ if ( password.empty() )
+ password = toEnv->second;
+ options.erase( toEnv );
+ }
+
+ toEnv = options.find("pass"); // actually cifs specific
+ if ( toEnv != options.end() ) {
+ if ( password.empty() )
+ password = toEnv->second;
+ options.erase( toEnv );
+ }
+
+ if ( username.empty() || password.empty() )
+ {
+ AuthData_Ptr c = cm.getCred(_url);
+ if (c)
+ {
+ username = c->username();
+ password = c->password();
+ }
+ }
+
+ bool firstTry = true;
+ bool authRequired = false;
+ AuthData authdata;
+ do // repeat this while the mount returns "Permission denied" error
+ {
+ // get credentials from authenicate()
+ if ( !firstTry )
+ {
+ username = authdata.username();
+ password = authdata.password();
+ }
+
+ // pass 'username' and 'password' via environment
+ Mount::Environment environment;
+ if ( !username.empty() )
+ environment["USER"] = username;
+ if ( !password.empty() )
+ environment["PASSWD"] = password;
+
+ //////////////////////////////////////////////////////
+ // In case we need a tmpfile, credentials will remove
+ // it in it's destructor after the mout call below.
+ filesystem::TmpPath credentials;
+ if ( !username.empty() || !password.empty() )
+ {
+ filesystem::TmpFile tmp;
+ ofstream outs( tmp.path().asString().c_str() );
+ outs << "username=" << username << endl;
+ outs << "password=" << password << endl;
+ outs.close();
+
+ credentials = tmp;
+ options["credentials"] = credentials.path().asString();
+ }
+ //
+ //////////////////////////////////////////////////////
+
+ try
+ {
+ mount.mount( path, mountpoint, "cifs",
+ options.asString(), environment );
+ setMediaSource(media);
+ break;
+ }
+ catch (const MediaMountException & e)
+ {
+ ZYPP_CAUGHT( e );
+
+ if ( e.mountError() == "Permission denied" )
+ authRequired = authenticate( authdata, firstTry );
+ else
+ ZYPP_RETHROW( e );
+ }
+
+ firstTry = false;
+ }
+ while ( authRequired );
+
+ // wait for /etc/mtab update ...
+ // (shouldn't be needed)
+ int limit = 3;
+ bool mountsucceeded;
+ while( !(mountsucceeded=isAttached()) && --limit)
+ sleep(1);
+
+ if ( !mountsucceeded )
+ {
+ setMediaSource(MediaSourceRef());
+ try
+ {
+ mount.umount(attachPoint().asString());
+ }
+ catch (const MediaException & excpt_r)
+ {
+ ZYPP_CAUGHT(excpt_r);
+ }
+ ZYPP_THROW(MediaMountException(
+ "Unable to verify that the media was mounted",
+ path, mountpoint
+ ));
+ }
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : MediaCIFS::isAttached
+ // METHOD TYPE : bool
+ //
+ // DESCRIPTION : Override check if media is attached.
+ //
+ bool
+ MediaCIFS::isAttached() const
+ {
+ return checkAttached(true);
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ //
+ // METHOD NAME : MediaCIFS::releaseFrom
+ // METHOD TYPE : PMError
+ //
+ // DESCRIPTION : Asserted that media is attached.
+ //
+ void MediaCIFS::releaseFrom( const std::string & ejectDev )
+ {
+ Mount mount;
+ mount.umount(attachPoint().asString());
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : MediaCIFS::getFile
+ // METHOD TYPE : PMError
+ //
+ // DESCRIPTION : Asserted that media is attached.
+ //
+ void MediaCIFS::getFile (const Pathname & filename) const
+ {
+ MediaHandler::getFile( filename );
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : MediaCIFS::getDir
+ // METHOD TYPE : PMError
+ //
+ // DESCRIPTION : Asserted that media is attached.
+ //
+ void MediaCIFS::getDir( const Pathname & dirname, bool recurse_r ) const
+ {
+ MediaHandler::getDir( dirname, recurse_r );
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ //
+ // METHOD NAME : MediaCIFS::getDirInfo
+ // METHOD TYPE : PMError
+ //
+ // DESCRIPTION : Asserted that media is attached and retlist is empty.
+ //
+ void MediaCIFS::getDirInfo( std::list<std::string> & retlist,
+ const Pathname & dirname, bool dots ) const
+ {
+ MediaHandler::getDirInfo( retlist, dirname, dots );
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ //
+ // METHOD NAME : MediaCIFS::getDirInfo
+ // METHOD TYPE : PMError
+ //
+ // DESCRIPTION : Asserted that media is attached and retlist is empty.
+ //
+ void MediaCIFS::getDirInfo( filesystem::DirContent & retlist,
+ const Pathname & dirname, bool dots ) const
+ {
+ MediaHandler::getDirInfo( retlist, dirname, dots );
+ }
+
+ bool MediaCIFS::getDoesFileExist( const Pathname & filename ) const
+ {
+ return MediaHandler::getDoesFileExist( filename );
+ }
+
+ bool MediaCIFS::authenticate(AuthData & authdata, bool firstTry) const
+ {
+ //! \todo need a way to pass different CredManagerOptions here
+ Target_Ptr target = zypp::getZYpp()->getTarget();
+ CredentialManager cm(CredManagerOptions(target ? target->root() : ""));
+
+ // get stored credentials
+ AuthData_Ptr cmcred = cm.getCred(_url);
+
+ AuthData_Ptr smbcred;
+ smbcred.reset(new AuthData());
+ callback::SendReport<AuthenticationReport> auth_report;
+
+ // preset the username if present in current url
+ if (!_url.getUsername().empty() && firstTry)
+ smbcred->setUsername(_url.getUsername());
+ // if CM has found some credentials, preset the username from there
+ else if (cmcred)
+ smbcred->setUsername(cmcred->username());
+
+ // indicate we have no good credentials from CM
+ cmcred.reset();
+
+ string prompt_msg = str::form(
+ //!\todo add comma to the message for the next release
+ _("Authentication required for '%s'"), _url.asString().c_str());
+
+ // ask user
+ if (auth_report->prompt(_url, prompt_msg, *smbcred))
+ {
+ DBG << "callback answer: retry" << endl
+ << "AuthData: " << *smbcred << endl;
+
+ if (smbcred->valid())
+ {
+ cmcred = smbcred;
+ // if (credentials->username() != _url.getUsername())
+ // _url.setUsername(credentials->username());
+ /**
+ * \todo find a way to save the url with changed username
+ * back to repoinfo or dont store urls with username
+ * (and either forbid more repos with the same url and different
+ * user, or return a set of credentials from CM and try them one
+ * by one)
+ */
+ }
+ }
+ else
+ DBG << "callback answer: cancel" << endl;
+
+ // set username and password
+ if (cmcred)
+ {
+ authdata.setUsername(cmcred->username());
+ authdata.setPassword(cmcred->password());
+
+ // save the credentials
+ cmcred->setUrl(_url);
+ cm.addCred(*cmcred);
+ cm.save();
+
+ return true;
+ }
+
+ return false;
+ }
+
+
+ } // namespace media
+} // namespace zypp
diff --git a/zypp/media/MediaCIFS.h b/zypp/media/MediaCIFS.h
index f05b912..73affb4 100644
--- a/zypp/media/MediaCIFS.h
+++ b/zypp/media/MediaCIFS.h
@@ -12,36 +12,51 @@
#ifndef ZYPP_MEDIA_MEDIACIFS_H
#define ZYPP_MEDIA_MEDIACIFS_H
-#include "zypp/media/MediaSMB.h"
+#include "zypp/media/MediaHandler.h"
namespace zypp {
namespace media {
+ class AuthData;
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : MediaCIFS
/**
* @short Implementation class for CIFS MediaHandler
*
- * NOTE: It's actually MediaSMB, but using "cifs"
- * as vfstype for mount.
+ * NOTE: The implementation serves both, "smb" and "cifs" URL's,
+ * but passes "cifs" to the mount command in any case.
* @see MediaHandler
**/
- class MediaCIFS : public MediaSMB {
-
+ class MediaCIFS : public MediaHandler {
+
+ protected:
+
+ virtual void attachTo (bool next = false);
+ virtual void releaseFrom( const std::string & ejectDev );
+ virtual void getFile( const Pathname & filename ) const;
+ virtual void getDir( const Pathname & dirname, bool recurse_r ) const;
+ virtual void getDirInfo( std::list<std::string> & retlist,
+ const Pathname & dirname, bool dots = true ) const;
+ virtual void getDirInfo( filesystem::DirContent & retlist,
+ const Pathname & dirname, bool dots = true ) const;
+ virtual bool getDoesFileExist( const Pathname & filename ) const;
+
public:
-
MediaCIFS( const Url& url_r,
- const Pathname & attach_point_hint_r )
- : MediaSMB( url_r, attach_point_hint_r )
- {
- mountAsCIFS();
- }
+ const Pathname & attach_point_hint_r );
+
+ virtual ~MediaCIFS() { try { release(); } catch(...) {} }
+
+ virtual bool isAttached() const;
+
+ private:
+ bool authenticate( AuthData & authdata, bool firstTry ) const;
};
+///////////////////////////////////////////////////////////////////A
} // namespace media
} // namespace zypp
-///////////////////////////////////////////////////////////////////
-
#endif // ZYPP_MEDIA_MEDIACIFS_H
diff --git a/zypp/media/MediaSMB.cc b/zypp/media/MediaSMB.cc
deleted file mode 100644
index 08e4f05..0000000
--- a/zypp/media/MediaSMB.cc
+++ /dev/null
@@ -1,470 +0,0 @@
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/MediaSMB.cc
- *
-*/
-
-#include <iostream>
-#include <fstream>
-
-#include "zypp/base/Logger.h"
-#include "zypp/base/Gettext.h"
-#include "zypp/TmpPath.h"
-#include "zypp/KVMap.h"
-#include "zypp/media/Mount.h"
-#include "zypp/media/MediaUserAuth.h"
-#include "zypp/media/CredentialManager.h"
-#include "zypp/ZYppCallbacks.h"
-
-#warning FIXME: get rid of this dependency on Target
-#include "zypp/ZYppFactory.h" // for target->root()
-#include "zypp/Target.h" // for zypp->target->root()
-
-#include "zypp/media/MediaSMB.h"
-
-#include <sys/types.h>
-#include <sys/mount.h>
-#include <errno.h>
-#include <dirent.h>
-
-using namespace std;
-
-namespace zypp {
- namespace media {
-
- /******************************************************************
- **
- **
- ** FUNCTION NAME : getShare
- ** FUNCTION TYPE : inline Pathname
- **
- ** Get the 1st path component (CIFS share name).
- */
- inline string getShare( Pathname spath_r )
- {
- if ( spath_r.empty() )
- return string();
-
- string share( spath_r.absolutename().asString() );
- string::size_type sep = share.find( "/", 1 );
- if ( sep == string::npos )
- share = share.erase( 0, 1 ); // nothing but the share name in spath_r
- else
- share = share.substr( 1, sep-1 );
-
- // deescape %2f in sharename
- while ( (sep = share.find( "%2f" )) != string::npos ) {
- share.replace( sep, 3, "/" );
- }
-
- return share;
- }
-
- /******************************************************************
- **
- **
- ** FUNCTION NAME : stripShare
- ** FUNCTION TYPE : inline Pathname
- **
- ** Strip off the 1st path component (CIFS share name).
- */
- inline Pathname stripShare( Pathname spath_r )
- {
- if ( spath_r.empty() )
- return Pathname();
-
- string striped( spath_r.absolutename().asString() );
- string::size_type sep = striped.find( "/", 1 );
- if ( sep == string::npos )
- return "/"; // nothing but the share name in spath_r
-
- return striped.substr( sep );
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : MediaSMB
- //
- ///////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- //
- // METHOD NAME : MediaSMB::MediaSMB
- // METHOD TYPE : Constructor
- //
- // DESCRIPTION :
- //
- MediaSMB::MediaSMB( const Url & url_r,
- const Pathname & attach_point_hint_r )
- : MediaHandler( url_r, attach_point_hint_r,
- stripShare( url_r.getPathName() ), // urlpath WITHOUT share name at attachpoint
- false ) // does_download
- , _vfstype( "cifs" )
- {
- MIL << "MediaSMB::MediaSMB(" << url_r << ", " << attach_point_hint_r << ")" << endl;
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- //
- // METHOD NAME : MediaSMB::attachTo
- // METHOD TYPE : PMError
- /**
- * Asserted that not already attached, and attachPoint is a directory.
- *
- * Authentication: credentials can be specified in the following few ways
- * (the first has the highest preference).
- * - URL username:password
- * - mountoptions URL query parameter (see man mount.cifs)
- * - CredentialManager - either previously saved credentials will be used
- * or the user will be promted for them via AuthenticationReport callback.
- *
- * \note The implementation currently serves both, "smb" and
- * and "cifs" URL's, but passes "cifs" to the mount command
- * in any case.
- */
- void MediaSMB::attachTo(bool next)
- {
- if(_url.getHost().empty())
- ZYPP_THROW(MediaBadUrlEmptyHostException(_url));
- if(next)
- ZYPP_THROW(MediaNotSupportedException(_url));
-
- string path = "//";
- path += _url.getHost() + "/" + getShare( _url.getPathName() );
-
- MediaSourceRef media( new MediaSource( _vfstype, path));
- AttachedMedia ret( findAttachedMedia( media));
-
- if( ret.mediaSource &&
- ret.attachPoint &&
- !ret.attachPoint->empty())
- {
- DBG << "Using a shared media "
- << ret.mediaSource->name
- << " attached on "
- << ret.attachPoint->path
- << endl;
-
- removeAttachPoint();
- setAttachPoint(ret.attachPoint);
- setMediaSource(ret.mediaSource);
- return;
- }
-
- std::string mountpoint = attachPoint().asString();
- if( !isUseableAttachPoint(attachPoint()))
- {
- mountpoint = createAttachPoint().asString();
- if( mountpoint.empty())
- ZYPP_THROW( MediaBadAttachPointException(url()));
- setAttachPoint( mountpoint, true);
- }
-
- Mount mount;
- CredentialManager cm;
-
- Mount::Options options( _url.getQueryParam("mountoptions") );
- string username = _url.getUsername();
- string password = _url.getPassword();
-
- options["guest"]; // prevent smbmount from asking for password
-
- if ( ! options.has( "rw" ) ) {
- options["ro"];
- }
-
- // look for a workgroup
- string workgroup = _url.getQueryParam("workgroup");
- if ( workgroup.empty() )
- workgroup = _url.getQueryParam("domain");
- if ( !workgroup.empty() )
- options["domain"] = workgroup;
-
- // extract 'username', do not overwrite any _url.username
-
- Mount::Options::iterator toEnv;
- toEnv = options.find("username");
- if ( toEnv != options.end() ) {
- if ( username.empty() )
- username = toEnv->second;
- options.erase( toEnv );
- }
-
- toEnv = options.find("user"); // actually cifs specific
- if ( toEnv != options.end() ) {
- if ( username.empty() )
- username = toEnv->second;
- options.erase( toEnv );
- }
-
- // extract 'password', do not overwrite any _url.password
-
- toEnv = options.find("password");
- if ( toEnv != options.end() ) {
- if ( password.empty() )
- password = toEnv->second;
- options.erase( toEnv );
- }
-
- toEnv = options.find("pass"); // actually cifs specific
- if ( toEnv != options.end() ) {
- if ( password.empty() )
- password = toEnv->second;
- options.erase( toEnv );
- }
-
- if ( username.empty() || password.empty() )
- {
- AuthData_Ptr c = cm.getCred(_url);
- if (c)
- {
- username = c->username();
- password = c->password();
- }
- }
-
- bool firstTry = true;
- bool authRequired = false;
- AuthData authdata;
- do // repeat this while the mount returns "Permission denied" error
- {
- // get credentials from authenicate()
- if ( !firstTry )
- {
- username = authdata.username();
- password = authdata.password();
- }
-
- // pass 'username' and 'password' via environment
- Mount::Environment environment;
- if ( !username.empty() )
- environment["USER"] = username;
- if ( !password.empty() )
- environment["PASSWD"] = password;
-
- //////////////////////////////////////////////////////
- // In case we need a tmpfile, credentials will remove
- // it in it's destructor after the mout call below.
- filesystem::TmpPath credentials;
- if ( !username.empty() || !password.empty() )
- {
- filesystem::TmpFile tmp;
- ofstream outs( tmp.path().asString().c_str() );
- outs << "username=" << username << endl;
- outs << "password=" << password << endl;
- outs.close();
-
- credentials = tmp;
- options["credentials"] = credentials.path().asString();
- }
- //
- //////////////////////////////////////////////////////
-
- try
- {
- mount.mount( path, mountpoint, _vfstype,
- options.asString(), environment );
- setMediaSource(media);
- break;
- }
- catch (const MediaMountException & e)
- {
- ZYPP_CAUGHT( e );
-
- if ( e.mountError() == "Permission denied" )
- authRequired = authenticate( authdata, firstTry );
- else
- ZYPP_RETHROW( e );
- }
-
- firstTry = false;
- }
- while ( authRequired );
-
- // wait for /etc/mtab update ...
- // (shouldn't be needed)
- int limit = 3;
- bool mountsucceeded;
- while( !(mountsucceeded=isAttached()) && --limit)
- sleep(1);
-
- if ( !mountsucceeded )
- {
- setMediaSource(MediaSourceRef());
- try
- {
- mount.umount(attachPoint().asString());
- }
- catch (const MediaException & excpt_r)
- {
- ZYPP_CAUGHT(excpt_r);
- }
- ZYPP_THROW(MediaMountException(
- "Unable to verify that the media was mounted",
- path, mountpoint
- ));
- }
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : MediaSMB::isAttached
- // METHOD TYPE : bool
- //
- // DESCRIPTION : Override check if media is attached.
- //
- bool
- MediaSMB::isAttached() const
- {
- return checkAttached(true);
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- //
- // METHOD NAME : MediaSMB::releaseFrom
- // METHOD TYPE : PMError
- //
- // DESCRIPTION : Asserted that media is attached.
- //
- void MediaSMB::releaseFrom( const std::string & ejectDev )
- {
- Mount mount;
- mount.umount(attachPoint().asString());
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : MediaSMB::getFile
- // METHOD TYPE : PMError
- //
- // DESCRIPTION : Asserted that media is attached.
- //
- void MediaSMB::getFile (const Pathname & filename) const
- {
- MediaHandler::getFile( filename );
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : MediaSMB::getDir
- // METHOD TYPE : PMError
- //
- // DESCRIPTION : Asserted that media is attached.
- //
- void MediaSMB::getDir( const Pathname & dirname, bool recurse_r ) const
- {
- MediaHandler::getDir( dirname, recurse_r );
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- //
- // METHOD NAME : MediaSMB::getDirInfo
- // METHOD TYPE : PMError
- //
- // DESCRIPTION : Asserted that media is attached and retlist is empty.
- //
- void MediaSMB::getDirInfo( std::list<std::string> & retlist,
- const Pathname & dirname, bool dots ) const
- {
- MediaHandler::getDirInfo( retlist, dirname, dots );
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- //
- // METHOD NAME : MediaSMB::getDirInfo
- // METHOD TYPE : PMError
- //
- // DESCRIPTION : Asserted that media is attached and retlist is empty.
- //
- void MediaSMB::getDirInfo( filesystem::DirContent & retlist,
- const Pathname & dirname, bool dots ) const
- {
- MediaHandler::getDirInfo( retlist, dirname, dots );
- }
-
- bool MediaSMB::getDoesFileExist( const Pathname & filename ) const
- {
- return MediaHandler::getDoesFileExist( filename );
- }
-
- bool MediaSMB::authenticate(AuthData & authdata, bool firstTry) const
- {
- //! \todo need a way to pass different CredManagerOptions here
- Target_Ptr target = zypp::getZYpp()->getTarget();
- CredentialManager cm(CredManagerOptions(target ? target->root() : ""));
-
- // get stored credentials
- AuthData_Ptr cmcred = cm.getCred(_url);
-
- AuthData_Ptr smbcred;
- smbcred.reset(new AuthData());
- callback::SendReport<AuthenticationReport> auth_report;
-
- // preset the username if present in current url
- if (!_url.getUsername().empty() && firstTry)
- smbcred->setUsername(_url.getUsername());
- // if CM has found some credentials, preset the username from there
- else if (cmcred)
- smbcred->setUsername(cmcred->username());
-
- // indicate we have no good credentials from CM
- cmcred.reset();
-
- string prompt_msg = str::form(
- //!\todo add comma to the message for the next release
- _("Authentication required for '%s'"), _url.asString().c_str());
-
- // ask user
- if (auth_report->prompt(_url, prompt_msg, *smbcred))
- {
- DBG << "callback answer: retry" << endl
- << "AuthData: " << *smbcred << endl;
-
- if (smbcred->valid())
- {
- cmcred = smbcred;
- // if (credentials->username() != _url.getUsername())
- // _url.setUsername(credentials->username());
- /**
- * \todo find a way to save the url with changed username
- * back to repoinfo or dont store urls with username
- * (and either forbid more repos with the same url and different
- * user, or return a set of credentials from CM and try them one
- * by one)
- */
- }
- }
- else
- DBG << "callback answer: cancel" << endl;
-
- // set username and password
- if (cmcred)
- {
- authdata.setUsername(cmcred->username());
- authdata.setPassword(cmcred->password());
-
- // save the credentials
- cmcred->setUrl(_url);
- cm.addCred(*cmcred);
- cm.save();
-
- return true;
- }
-
- return false;
- }
-
-
- } // namespace media
-} // namespace zypp
diff --git a/zypp/media/MediaSMB.h b/zypp/media/MediaSMB.h
deleted file mode 100644
index 41d3f11..0000000
--- a/zypp/media/MediaSMB.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/MediaSMB.h
- *
-*/
-#ifndef ZYPP_MEDIA_MEDIASMB_H
-#define ZYPP_MEDIA_MEDIASMB_H
-
-#include "zypp/media/MediaHandler.h"
-
-namespace zypp {
- namespace media {
-
- class AuthData;
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : MediaSMB
- /**
- * @short Implementation class for SMB MediaHandler
- *
- * NOTE: The implementation currently serves both, "smb"
- * and "cifs" URL's, but passes "cifs" to the mount command
- * in any case.
- * @see MediaHandler
- **/
- class MediaSMB : public MediaHandler {
-
- private:
-
- /**
- * vfstype for mount. This is either "smbfs"
- * or "cifs" (rewritten by MediaCIFS).
- * Obsolete: vfstype is allways "cifs".
- **/
- const char* _vfstype;
-
- protected:
-
- virtual void attachTo (bool next = false);
- virtual void releaseFrom( const std::string & ejectDev );
- virtual void getFile( const Pathname & filename ) const;
- virtual void getDir( const Pathname & dirname, bool recurse_r ) const;
- virtual void getDirInfo( std::list<std::string> & retlist,
- const Pathname & dirname, bool dots = true ) const;
- virtual void getDirInfo( filesystem::DirContent & retlist,
- const Pathname & dirname, bool dots = true ) const;
- virtual bool getDoesFileExist( const Pathname & filename ) const;
-
- /**
- * MediaCIFS rewrites the vfstype to "cifs"
- * within it's constructor.
- **/
- void mountAsCIFS() { _vfstype = "cifs"; }
-
- public:
- MediaSMB( const Url& url_r,
- const Pathname & attach_point_hint_r );
-
- virtual ~MediaSMB() { try { release(); } catch(...) {} }
-
- virtual bool isAttached() const;
-
- private:
- bool authenticate( AuthData & authdata, bool firstTry ) const;
- };
-
-///////////////////////////////////////////////////////////////////A
- } // namespace media
-} // namespace zypp
-
-#endif // ZYPP_MEDIA_MEDIASMB_H
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
[View Less]
1
0

[zypp-commit] <libzypp> ma-misc : MediaSMB and MediaCIFS are the same, so use CIFS everywhere and dop SMB
by Michael Andres 31 Oct '09
by Michael Andres 31 Oct '09
31 Oct '09
ref: refs/heads/ma-misc
commit a16adb004b0e20e84a5ab16a4d04d2e5fa48b8e8
Author: Michael Andres <ma(a)suse.de>
Date: Sat Oct 31 17:49:22 2009 +0100
MediaSMB and MediaCIFS are the same, so use CIFS everywhere and dop SMB
---
zypp/CMakeLists.txt | 2 -
zypp/media/MediaAccess.cc | 7 +-
zypp/media/MediaCIFS.cc | 461 +++++++++++++++++++++++++++++++++++++++++++-
zypp/media/MediaCIFS.h | 41 +++--
zypp/media/MediaSMB.cc | 470 --------------------------------------…
[View More]-------
zypp/media/MediaSMB.h | 78 --------
6 files changed, 487 insertions(+), 572 deletions(-)
diff --git a/zypp/CMakeLists.txt b/zypp/CMakeLists.txt
index 40973fc..bbceaa3 100644
--- a/zypp/CMakeLists.txt
+++ b/zypp/CMakeLists.txt
@@ -260,7 +260,6 @@ SET( zypp_media_SRCS
media/MediaCD.cc
media/MediaDIR.cc
media/MediaDISK.cc
- media/MediaSMB.cc
media/MediaCIFS.cc
media/ProxyInfo.cc
media/MediaCurl.cc
@@ -289,7 +288,6 @@ SET( zypp_media_HEADERS
media/MediaISO.h
media/MediaManager.h
media/MediaNFS.h
- media/MediaSMB.h
media/MediaSource.h
media/MediaUserAuth.h
media/Mount.h
diff --git a/zypp/media/MediaAccess.cc b/zypp/media/MediaAccess.cc
index cff2d01..7ed6af5 100644
--- a/zypp/media/MediaAccess.cc
+++ b/zypp/media/MediaAccess.cc
@@ -25,7 +25,6 @@
#include "zypp/media/MediaCD.h"
#include "zypp/media/MediaDIR.h"
#include "zypp/media/MediaDISK.h"
-#include "zypp/media/MediaSMB.h"
#include "zypp/media/MediaCIFS.h"
#include "zypp/media/MediaCurl.h"
#include "zypp/media/MediaAria2c.h"
@@ -123,10 +122,8 @@ MediaAccess::open (const Url& url, const Pathname & preferred_attach_point)
_handler = new MediaDIR (url,preferred_attach_point);
else if (scheme == "hd")
_handler = new MediaDISK (url,preferred_attach_point);
- else if (scheme == "smb")
- _handler = new MediaSMB (url,preferred_attach_point);
- else if (scheme == "cifs")
- _handler = new MediaCIFS (url,preferred_attach_point);
+ else if (scheme == "cifs" || scheme == "smb")
+ _handler = new MediaCIFS (url,preferred_attach_point);
else if (scheme == "ftp" || scheme == "http" || scheme == "https")
{
// Another good idea would be activate MediaAria2c handler via external var
diff --git a/zypp/media/MediaCIFS.cc b/zypp/media/MediaCIFS.cc
index f4f2133..7d5215e 100644
--- a/zypp/media/MediaCIFS.cc
+++ b/zypp/media/MediaCIFS.cc
@@ -10,7 +10,460 @@
*
*/
-//
-// NOTE: It's actually MediaSMB, but using "cifs"
-// as vfstype for mount.
-//
+#include <iostream>
+#include <fstream>
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Gettext.h"
+#include "zypp/TmpPath.h"
+#include "zypp/KVMap.h"
+#include "zypp/media/Mount.h"
+#include "zypp/media/MediaUserAuth.h"
+#include "zypp/media/CredentialManager.h"
+#include "zypp/ZYppCallbacks.h"
+
+#warning FIXME: get rid of this dependency on Target
+#include "zypp/ZYppFactory.h" // for target->root()
+#include "zypp/Target.h" // for zypp->target->root()
+
+#include "zypp/media/MediaCIFS.h"
+
+#include <sys/types.h>
+#include <sys/mount.h>
+#include <errno.h>
+#include <dirent.h>
+
+using namespace std;
+
+namespace zypp {
+ namespace media {
+
+ /******************************************************************
+ **
+ **
+ ** FUNCTION NAME : getShare
+ ** FUNCTION TYPE : inline Pathname
+ **
+ ** Get the 1st path component (CIFS share name).
+ */
+ inline string getShare( Pathname spath_r )
+ {
+ if ( spath_r.empty() )
+ return string();
+
+ string share( spath_r.absolutename().asString() );
+ string::size_type sep = share.find( "/", 1 );
+ if ( sep == string::npos )
+ share = share.erase( 0, 1 ); // nothing but the share name in spath_r
+ else
+ share = share.substr( 1, sep-1 );
+
+ // deescape %2f in sharename
+ while ( (sep = share.find( "%2f" )) != string::npos ) {
+ share.replace( sep, 3, "/" );
+ }
+
+ return share;
+ }
+
+ /******************************************************************
+ **
+ **
+ ** FUNCTION NAME : stripShare
+ ** FUNCTION TYPE : inline Pathname
+ **
+ ** Strip off the 1st path component (CIFS share name).
+ */
+ inline Pathname stripShare( Pathname spath_r )
+ {
+ if ( spath_r.empty() )
+ return Pathname();
+
+ string striped( spath_r.absolutename().asString() );
+ string::size_type sep = striped.find( "/", 1 );
+ if ( sep == string::npos )
+ return "/"; // nothing but the share name in spath_r
+
+ return striped.substr( sep );
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : MediaCIFS
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ //
+ // METHOD NAME : MediaCIFS::MediaCIFS
+ // METHOD TYPE : Constructor
+ //
+ // DESCRIPTION :
+ //
+ MediaCIFS::MediaCIFS( const Url & url_r,
+ const Pathname & attach_point_hint_r )
+ : MediaHandler( url_r, attach_point_hint_r,
+ stripShare( url_r.getPathName() ), // urlpath WITHOUT share name at attachpoint
+ false ) // does_download
+ {
+ MIL << "MediaCIFS::MediaCIFS(" << url_r << ", " << attach_point_hint_r << ")" << endl;
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ //
+ // METHOD NAME : MediaCIFS::attachTo
+ // METHOD TYPE : PMError
+ /**
+ * Asserted that not already attached, and attachPoint is a directory.
+ *
+ * Authentication: credentials can be specified in the following few ways
+ * (the first has the highest preference).
+ * - URL username:password
+ * - mountoptions URL query parameter (see man mount.cifs)
+ * - CredentialManager - either previously saved credentials will be used
+ * or the user will be promted for them via AuthenticationReport callback.
+ *
+ * \note The implementation currently serves both, "smb" and
+ * and "cifs" URL's, but passes "cifs" to the mount command
+ * in any case.
+ */
+ void MediaCIFS::attachTo(bool next)
+ {
+ if(_url.getHost().empty())
+ ZYPP_THROW(MediaBadUrlEmptyHostException(_url));
+ if(next)
+ ZYPP_THROW(MediaNotSupportedException(_url));
+
+ string path = "//";
+ path += _url.getHost() + "/" + getShare( _url.getPathName() );
+
+ MediaSourceRef media( new MediaSource( "cifs", path));
+ AttachedMedia ret( findAttachedMedia( media));
+
+ if( ret.mediaSource &&
+ ret.attachPoint &&
+ !ret.attachPoint->empty())
+ {
+ DBG << "Using a shared media "
+ << ret.mediaSource->name
+ << " attached on "
+ << ret.attachPoint->path
+ << endl;
+
+ removeAttachPoint();
+ setAttachPoint(ret.attachPoint);
+ setMediaSource(ret.mediaSource);
+ return;
+ }
+
+ std::string mountpoint = attachPoint().asString();
+ if( !isUseableAttachPoint(attachPoint()))
+ {
+ mountpoint = createAttachPoint().asString();
+ if( mountpoint.empty())
+ ZYPP_THROW( MediaBadAttachPointException(url()));
+ setAttachPoint( mountpoint, true);
+ }
+
+ Mount mount;
+ CredentialManager cm;
+
+ Mount::Options options( _url.getQueryParam("mountoptions") );
+ string username = _url.getUsername();
+ string password = _url.getPassword();
+
+ options["guest"]; // prevent smbmount from asking for password
+
+ if ( ! options.has( "rw" ) ) {
+ options["ro"];
+ }
+
+ // look for a workgroup
+ string workgroup = _url.getQueryParam("workgroup");
+ if ( workgroup.empty() )
+ workgroup = _url.getQueryParam("domain");
+ if ( !workgroup.empty() )
+ options["domain"] = workgroup;
+
+ // extract 'username', do not overwrite any _url.username
+
+ Mount::Options::iterator toEnv;
+ toEnv = options.find("username");
+ if ( toEnv != options.end() ) {
+ if ( username.empty() )
+ username = toEnv->second;
+ options.erase( toEnv );
+ }
+
+ toEnv = options.find("user"); // actually cifs specific
+ if ( toEnv != options.end() ) {
+ if ( username.empty() )
+ username = toEnv->second;
+ options.erase( toEnv );
+ }
+
+ // extract 'password', do not overwrite any _url.password
+
+ toEnv = options.find("password");
+ if ( toEnv != options.end() ) {
+ if ( password.empty() )
+ password = toEnv->second;
+ options.erase( toEnv );
+ }
+
+ toEnv = options.find("pass"); // actually cifs specific
+ if ( toEnv != options.end() ) {
+ if ( password.empty() )
+ password = toEnv->second;
+ options.erase( toEnv );
+ }
+
+ if ( username.empty() || password.empty() )
+ {
+ AuthData_Ptr c = cm.getCred(_url);
+ if (c)
+ {
+ username = c->username();
+ password = c->password();
+ }
+ }
+
+ bool firstTry = true;
+ bool authRequired = false;
+ AuthData authdata;
+ do // repeat this while the mount returns "Permission denied" error
+ {
+ // get credentials from authenicate()
+ if ( !firstTry )
+ {
+ username = authdata.username();
+ password = authdata.password();
+ }
+
+ // pass 'username' and 'password' via environment
+ Mount::Environment environment;
+ if ( !username.empty() )
+ environment["USER"] = username;
+ if ( !password.empty() )
+ environment["PASSWD"] = password;
+
+ //////////////////////////////////////////////////////
+ // In case we need a tmpfile, credentials will remove
+ // it in it's destructor after the mout call below.
+ filesystem::TmpPath credentials;
+ if ( !username.empty() || !password.empty() )
+ {
+ filesystem::TmpFile tmp;
+ ofstream outs( tmp.path().asString().c_str() );
+ outs << "username=" << username << endl;
+ outs << "password=" << password << endl;
+ outs.close();
+
+ credentials = tmp;
+ options["credentials"] = credentials.path().asString();
+ }
+ //
+ //////////////////////////////////////////////////////
+
+ try
+ {
+ mount.mount( path, mountpoint, "cifs",
+ options.asString(), environment );
+ setMediaSource(media);
+ break;
+ }
+ catch (const MediaMountException & e)
+ {
+ ZYPP_CAUGHT( e );
+
+ if ( e.mountError() == "Permission denied" )
+ authRequired = authenticate( authdata, firstTry );
+ else
+ ZYPP_RETHROW( e );
+ }
+
+ firstTry = false;
+ }
+ while ( authRequired );
+
+ // wait for /etc/mtab update ...
+ // (shouldn't be needed)
+ int limit = 3;
+ bool mountsucceeded;
+ while( !(mountsucceeded=isAttached()) && --limit)
+ sleep(1);
+
+ if ( !mountsucceeded )
+ {
+ setMediaSource(MediaSourceRef());
+ try
+ {
+ mount.umount(attachPoint().asString());
+ }
+ catch (const MediaException & excpt_r)
+ {
+ ZYPP_CAUGHT(excpt_r);
+ }
+ ZYPP_THROW(MediaMountException(
+ "Unable to verify that the media was mounted",
+ path, mountpoint
+ ));
+ }
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : MediaCIFS::isAttached
+ // METHOD TYPE : bool
+ //
+ // DESCRIPTION : Override check if media is attached.
+ //
+ bool
+ MediaCIFS::isAttached() const
+ {
+ return checkAttached(true);
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ //
+ // METHOD NAME : MediaCIFS::releaseFrom
+ // METHOD TYPE : PMError
+ //
+ // DESCRIPTION : Asserted that media is attached.
+ //
+ void MediaCIFS::releaseFrom( const std::string & ejectDev )
+ {
+ Mount mount;
+ mount.umount(attachPoint().asString());
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : MediaCIFS::getFile
+ // METHOD TYPE : PMError
+ //
+ // DESCRIPTION : Asserted that media is attached.
+ //
+ void MediaCIFS::getFile (const Pathname & filename) const
+ {
+ MediaHandler::getFile( filename );
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : MediaCIFS::getDir
+ // METHOD TYPE : PMError
+ //
+ // DESCRIPTION : Asserted that media is attached.
+ //
+ void MediaCIFS::getDir( const Pathname & dirname, bool recurse_r ) const
+ {
+ MediaHandler::getDir( dirname, recurse_r );
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ //
+ // METHOD NAME : MediaCIFS::getDirInfo
+ // METHOD TYPE : PMError
+ //
+ // DESCRIPTION : Asserted that media is attached and retlist is empty.
+ //
+ void MediaCIFS::getDirInfo( std::list<std::string> & retlist,
+ const Pathname & dirname, bool dots ) const
+ {
+ MediaHandler::getDirInfo( retlist, dirname, dots );
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ //
+ // METHOD NAME : MediaCIFS::getDirInfo
+ // METHOD TYPE : PMError
+ //
+ // DESCRIPTION : Asserted that media is attached and retlist is empty.
+ //
+ void MediaCIFS::getDirInfo( filesystem::DirContent & retlist,
+ const Pathname & dirname, bool dots ) const
+ {
+ MediaHandler::getDirInfo( retlist, dirname, dots );
+ }
+
+ bool MediaCIFS::getDoesFileExist( const Pathname & filename ) const
+ {
+ return MediaHandler::getDoesFileExist( filename );
+ }
+
+ bool MediaCIFS::authenticate(AuthData & authdata, bool firstTry) const
+ {
+ //! \todo need a way to pass different CredManagerOptions here
+ Target_Ptr target = zypp::getZYpp()->getTarget();
+ CredentialManager cm(CredManagerOptions(target ? target->root() : ""));
+
+ // get stored credentials
+ AuthData_Ptr cmcred = cm.getCred(_url);
+
+ AuthData_Ptr smbcred;
+ smbcred.reset(new AuthData());
+ callback::SendReport<AuthenticationReport> auth_report;
+
+ // preset the username if present in current url
+ if (!_url.getUsername().empty() && firstTry)
+ smbcred->setUsername(_url.getUsername());
+ // if CM has found some credentials, preset the username from there
+ else if (cmcred)
+ smbcred->setUsername(cmcred->username());
+
+ // indicate we have no good credentials from CM
+ cmcred.reset();
+
+ string prompt_msg = str::form(
+ //!\todo add comma to the message for the next release
+ _("Authentication required for '%s'"), _url.asString().c_str());
+
+ // ask user
+ if (auth_report->prompt(_url, prompt_msg, *smbcred))
+ {
+ DBG << "callback answer: retry" << endl
+ << "AuthData: " << *smbcred << endl;
+
+ if (smbcred->valid())
+ {
+ cmcred = smbcred;
+ // if (credentials->username() != _url.getUsername())
+ // _url.setUsername(credentials->username());
+ /**
+ * \todo find a way to save the url with changed username
+ * back to repoinfo or dont store urls with username
+ * (and either forbid more repos with the same url and different
+ * user, or return a set of credentials from CM and try them one
+ * by one)
+ */
+ }
+ }
+ else
+ DBG << "callback answer: cancel" << endl;
+
+ // set username and password
+ if (cmcred)
+ {
+ authdata.setUsername(cmcred->username());
+ authdata.setPassword(cmcred->password());
+
+ // save the credentials
+ cmcred->setUrl(_url);
+ cm.addCred(*cmcred);
+ cm.save();
+
+ return true;
+ }
+
+ return false;
+ }
+
+
+ } // namespace media
+} // namespace zypp
diff --git a/zypp/media/MediaCIFS.h b/zypp/media/MediaCIFS.h
index f05b912..73affb4 100644
--- a/zypp/media/MediaCIFS.h
+++ b/zypp/media/MediaCIFS.h
@@ -12,36 +12,51 @@
#ifndef ZYPP_MEDIA_MEDIACIFS_H
#define ZYPP_MEDIA_MEDIACIFS_H
-#include "zypp/media/MediaSMB.h"
+#include "zypp/media/MediaHandler.h"
namespace zypp {
namespace media {
+ class AuthData;
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : MediaCIFS
/**
* @short Implementation class for CIFS MediaHandler
*
- * NOTE: It's actually MediaSMB, but using "cifs"
- * as vfstype for mount.
+ * NOTE: The implementation serves both, "smb" and "cifs" URL's,
+ * but passes "cifs" to the mount command in any case.
* @see MediaHandler
**/
- class MediaCIFS : public MediaSMB {
-
+ class MediaCIFS : public MediaHandler {
+
+ protected:
+
+ virtual void attachTo (bool next = false);
+ virtual void releaseFrom( const std::string & ejectDev );
+ virtual void getFile( const Pathname & filename ) const;
+ virtual void getDir( const Pathname & dirname, bool recurse_r ) const;
+ virtual void getDirInfo( std::list<std::string> & retlist,
+ const Pathname & dirname, bool dots = true ) const;
+ virtual void getDirInfo( filesystem::DirContent & retlist,
+ const Pathname & dirname, bool dots = true ) const;
+ virtual bool getDoesFileExist( const Pathname & filename ) const;
+
public:
-
MediaCIFS( const Url& url_r,
- const Pathname & attach_point_hint_r )
- : MediaSMB( url_r, attach_point_hint_r )
- {
- mountAsCIFS();
- }
+ const Pathname & attach_point_hint_r );
+
+ virtual ~MediaCIFS() { try { release(); } catch(...) {} }
+
+ virtual bool isAttached() const;
+
+ private:
+ bool authenticate( AuthData & authdata, bool firstTry ) const;
};
+///////////////////////////////////////////////////////////////////A
} // namespace media
} // namespace zypp
-///////////////////////////////////////////////////////////////////
-
#endif // ZYPP_MEDIA_MEDIACIFS_H
diff --git a/zypp/media/MediaSMB.cc b/zypp/media/MediaSMB.cc
deleted file mode 100644
index 08e4f05..0000000
--- a/zypp/media/MediaSMB.cc
+++ /dev/null
@@ -1,470 +0,0 @@
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/MediaSMB.cc
- *
-*/
-
-#include <iostream>
-#include <fstream>
-
-#include "zypp/base/Logger.h"
-#include "zypp/base/Gettext.h"
-#include "zypp/TmpPath.h"
-#include "zypp/KVMap.h"
-#include "zypp/media/Mount.h"
-#include "zypp/media/MediaUserAuth.h"
-#include "zypp/media/CredentialManager.h"
-#include "zypp/ZYppCallbacks.h"
-
-#warning FIXME: get rid of this dependency on Target
-#include "zypp/ZYppFactory.h" // for target->root()
-#include "zypp/Target.h" // for zypp->target->root()
-
-#include "zypp/media/MediaSMB.h"
-
-#include <sys/types.h>
-#include <sys/mount.h>
-#include <errno.h>
-#include <dirent.h>
-
-using namespace std;
-
-namespace zypp {
- namespace media {
-
- /******************************************************************
- **
- **
- ** FUNCTION NAME : getShare
- ** FUNCTION TYPE : inline Pathname
- **
- ** Get the 1st path component (CIFS share name).
- */
- inline string getShare( Pathname spath_r )
- {
- if ( spath_r.empty() )
- return string();
-
- string share( spath_r.absolutename().asString() );
- string::size_type sep = share.find( "/", 1 );
- if ( sep == string::npos )
- share = share.erase( 0, 1 ); // nothing but the share name in spath_r
- else
- share = share.substr( 1, sep-1 );
-
- // deescape %2f in sharename
- while ( (sep = share.find( "%2f" )) != string::npos ) {
- share.replace( sep, 3, "/" );
- }
-
- return share;
- }
-
- /******************************************************************
- **
- **
- ** FUNCTION NAME : stripShare
- ** FUNCTION TYPE : inline Pathname
- **
- ** Strip off the 1st path component (CIFS share name).
- */
- inline Pathname stripShare( Pathname spath_r )
- {
- if ( spath_r.empty() )
- return Pathname();
-
- string striped( spath_r.absolutename().asString() );
- string::size_type sep = striped.find( "/", 1 );
- if ( sep == string::npos )
- return "/"; // nothing but the share name in spath_r
-
- return striped.substr( sep );
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : MediaSMB
- //
- ///////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- //
- // METHOD NAME : MediaSMB::MediaSMB
- // METHOD TYPE : Constructor
- //
- // DESCRIPTION :
- //
- MediaSMB::MediaSMB( const Url & url_r,
- const Pathname & attach_point_hint_r )
- : MediaHandler( url_r, attach_point_hint_r,
- stripShare( url_r.getPathName() ), // urlpath WITHOUT share name at attachpoint
- false ) // does_download
- , _vfstype( "cifs" )
- {
- MIL << "MediaSMB::MediaSMB(" << url_r << ", " << attach_point_hint_r << ")" << endl;
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- //
- // METHOD NAME : MediaSMB::attachTo
- // METHOD TYPE : PMError
- /**
- * Asserted that not already attached, and attachPoint is a directory.
- *
- * Authentication: credentials can be specified in the following few ways
- * (the first has the highest preference).
- * - URL username:password
- * - mountoptions URL query parameter (see man mount.cifs)
- * - CredentialManager - either previously saved credentials will be used
- * or the user will be promted for them via AuthenticationReport callback.
- *
- * \note The implementation currently serves both, "smb" and
- * and "cifs" URL's, but passes "cifs" to the mount command
- * in any case.
- */
- void MediaSMB::attachTo(bool next)
- {
- if(_url.getHost().empty())
- ZYPP_THROW(MediaBadUrlEmptyHostException(_url));
- if(next)
- ZYPP_THROW(MediaNotSupportedException(_url));
-
- string path = "//";
- path += _url.getHost() + "/" + getShare( _url.getPathName() );
-
- MediaSourceRef media( new MediaSource( _vfstype, path));
- AttachedMedia ret( findAttachedMedia( media));
-
- if( ret.mediaSource &&
- ret.attachPoint &&
- !ret.attachPoint->empty())
- {
- DBG << "Using a shared media "
- << ret.mediaSource->name
- << " attached on "
- << ret.attachPoint->path
- << endl;
-
- removeAttachPoint();
- setAttachPoint(ret.attachPoint);
- setMediaSource(ret.mediaSource);
- return;
- }
-
- std::string mountpoint = attachPoint().asString();
- if( !isUseableAttachPoint(attachPoint()))
- {
- mountpoint = createAttachPoint().asString();
- if( mountpoint.empty())
- ZYPP_THROW( MediaBadAttachPointException(url()));
- setAttachPoint( mountpoint, true);
- }
-
- Mount mount;
- CredentialManager cm;
-
- Mount::Options options( _url.getQueryParam("mountoptions") );
- string username = _url.getUsername();
- string password = _url.getPassword();
-
- options["guest"]; // prevent smbmount from asking for password
-
- if ( ! options.has( "rw" ) ) {
- options["ro"];
- }
-
- // look for a workgroup
- string workgroup = _url.getQueryParam("workgroup");
- if ( workgroup.empty() )
- workgroup = _url.getQueryParam("domain");
- if ( !workgroup.empty() )
- options["domain"] = workgroup;
-
- // extract 'username', do not overwrite any _url.username
-
- Mount::Options::iterator toEnv;
- toEnv = options.find("username");
- if ( toEnv != options.end() ) {
- if ( username.empty() )
- username = toEnv->second;
- options.erase( toEnv );
- }
-
- toEnv = options.find("user"); // actually cifs specific
- if ( toEnv != options.end() ) {
- if ( username.empty() )
- username = toEnv->second;
- options.erase( toEnv );
- }
-
- // extract 'password', do not overwrite any _url.password
-
- toEnv = options.find("password");
- if ( toEnv != options.end() ) {
- if ( password.empty() )
- password = toEnv->second;
- options.erase( toEnv );
- }
-
- toEnv = options.find("pass"); // actually cifs specific
- if ( toEnv != options.end() ) {
- if ( password.empty() )
- password = toEnv->second;
- options.erase( toEnv );
- }
-
- if ( username.empty() || password.empty() )
- {
- AuthData_Ptr c = cm.getCred(_url);
- if (c)
- {
- username = c->username();
- password = c->password();
- }
- }
-
- bool firstTry = true;
- bool authRequired = false;
- AuthData authdata;
- do // repeat this while the mount returns "Permission denied" error
- {
- // get credentials from authenicate()
- if ( !firstTry )
- {
- username = authdata.username();
- password = authdata.password();
- }
-
- // pass 'username' and 'password' via environment
- Mount::Environment environment;
- if ( !username.empty() )
- environment["USER"] = username;
- if ( !password.empty() )
- environment["PASSWD"] = password;
-
- //////////////////////////////////////////////////////
- // In case we need a tmpfile, credentials will remove
- // it in it's destructor after the mout call below.
- filesystem::TmpPath credentials;
- if ( !username.empty() || !password.empty() )
- {
- filesystem::TmpFile tmp;
- ofstream outs( tmp.path().asString().c_str() );
- outs << "username=" << username << endl;
- outs << "password=" << password << endl;
- outs.close();
-
- credentials = tmp;
- options["credentials"] = credentials.path().asString();
- }
- //
- //////////////////////////////////////////////////////
-
- try
- {
- mount.mount( path, mountpoint, _vfstype,
- options.asString(), environment );
- setMediaSource(media);
- break;
- }
- catch (const MediaMountException & e)
- {
- ZYPP_CAUGHT( e );
-
- if ( e.mountError() == "Permission denied" )
- authRequired = authenticate( authdata, firstTry );
- else
- ZYPP_RETHROW( e );
- }
-
- firstTry = false;
- }
- while ( authRequired );
-
- // wait for /etc/mtab update ...
- // (shouldn't be needed)
- int limit = 3;
- bool mountsucceeded;
- while( !(mountsucceeded=isAttached()) && --limit)
- sleep(1);
-
- if ( !mountsucceeded )
- {
- setMediaSource(MediaSourceRef());
- try
- {
- mount.umount(attachPoint().asString());
- }
- catch (const MediaException & excpt_r)
- {
- ZYPP_CAUGHT(excpt_r);
- }
- ZYPP_THROW(MediaMountException(
- "Unable to verify that the media was mounted",
- path, mountpoint
- ));
- }
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : MediaSMB::isAttached
- // METHOD TYPE : bool
- //
- // DESCRIPTION : Override check if media is attached.
- //
- bool
- MediaSMB::isAttached() const
- {
- return checkAttached(true);
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- //
- // METHOD NAME : MediaSMB::releaseFrom
- // METHOD TYPE : PMError
- //
- // DESCRIPTION : Asserted that media is attached.
- //
- void MediaSMB::releaseFrom( const std::string & ejectDev )
- {
- Mount mount;
- mount.umount(attachPoint().asString());
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : MediaSMB::getFile
- // METHOD TYPE : PMError
- //
- // DESCRIPTION : Asserted that media is attached.
- //
- void MediaSMB::getFile (const Pathname & filename) const
- {
- MediaHandler::getFile( filename );
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : MediaSMB::getDir
- // METHOD TYPE : PMError
- //
- // DESCRIPTION : Asserted that media is attached.
- //
- void MediaSMB::getDir( const Pathname & dirname, bool recurse_r ) const
- {
- MediaHandler::getDir( dirname, recurse_r );
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- //
- // METHOD NAME : MediaSMB::getDirInfo
- // METHOD TYPE : PMError
- //
- // DESCRIPTION : Asserted that media is attached and retlist is empty.
- //
- void MediaSMB::getDirInfo( std::list<std::string> & retlist,
- const Pathname & dirname, bool dots ) const
- {
- MediaHandler::getDirInfo( retlist, dirname, dots );
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- //
- // METHOD NAME : MediaSMB::getDirInfo
- // METHOD TYPE : PMError
- //
- // DESCRIPTION : Asserted that media is attached and retlist is empty.
- //
- void MediaSMB::getDirInfo( filesystem::DirContent & retlist,
- const Pathname & dirname, bool dots ) const
- {
- MediaHandler::getDirInfo( retlist, dirname, dots );
- }
-
- bool MediaSMB::getDoesFileExist( const Pathname & filename ) const
- {
- return MediaHandler::getDoesFileExist( filename );
- }
-
- bool MediaSMB::authenticate(AuthData & authdata, bool firstTry) const
- {
- //! \todo need a way to pass different CredManagerOptions here
- Target_Ptr target = zypp::getZYpp()->getTarget();
- CredentialManager cm(CredManagerOptions(target ? target->root() : ""));
-
- // get stored credentials
- AuthData_Ptr cmcred = cm.getCred(_url);
-
- AuthData_Ptr smbcred;
- smbcred.reset(new AuthData());
- callback::SendReport<AuthenticationReport> auth_report;
-
- // preset the username if present in current url
- if (!_url.getUsername().empty() && firstTry)
- smbcred->setUsername(_url.getUsername());
- // if CM has found some credentials, preset the username from there
- else if (cmcred)
- smbcred->setUsername(cmcred->username());
-
- // indicate we have no good credentials from CM
- cmcred.reset();
-
- string prompt_msg = str::form(
- //!\todo add comma to the message for the next release
- _("Authentication required for '%s'"), _url.asString().c_str());
-
- // ask user
- if (auth_report->prompt(_url, prompt_msg, *smbcred))
- {
- DBG << "callback answer: retry" << endl
- << "AuthData: " << *smbcred << endl;
-
- if (smbcred->valid())
- {
- cmcred = smbcred;
- // if (credentials->username() != _url.getUsername())
- // _url.setUsername(credentials->username());
- /**
- * \todo find a way to save the url with changed username
- * back to repoinfo or dont store urls with username
- * (and either forbid more repos with the same url and different
- * user, or return a set of credentials from CM and try them one
- * by one)
- */
- }
- }
- else
- DBG << "callback answer: cancel" << endl;
-
- // set username and password
- if (cmcred)
- {
- authdata.setUsername(cmcred->username());
- authdata.setPassword(cmcred->password());
-
- // save the credentials
- cmcred->setUrl(_url);
- cm.addCred(*cmcred);
- cm.save();
-
- return true;
- }
-
- return false;
- }
-
-
- } // namespace media
-} // namespace zypp
diff --git a/zypp/media/MediaSMB.h b/zypp/media/MediaSMB.h
deleted file mode 100644
index 41d3f11..0000000
--- a/zypp/media/MediaSMB.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/MediaSMB.h
- *
-*/
-#ifndef ZYPP_MEDIA_MEDIASMB_H
-#define ZYPP_MEDIA_MEDIASMB_H
-
-#include "zypp/media/MediaHandler.h"
-
-namespace zypp {
- namespace media {
-
- class AuthData;
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : MediaSMB
- /**
- * @short Implementation class for SMB MediaHandler
- *
- * NOTE: The implementation currently serves both, "smb"
- * and "cifs" URL's, but passes "cifs" to the mount command
- * in any case.
- * @see MediaHandler
- **/
- class MediaSMB : public MediaHandler {
-
- private:
-
- /**
- * vfstype for mount. This is either "smbfs"
- * or "cifs" (rewritten by MediaCIFS).
- * Obsolete: vfstype is allways "cifs".
- **/
- const char* _vfstype;
-
- protected:
-
- virtual void attachTo (bool next = false);
- virtual void releaseFrom( const std::string & ejectDev );
- virtual void getFile( const Pathname & filename ) const;
- virtual void getDir( const Pathname & dirname, bool recurse_r ) const;
- virtual void getDirInfo( std::list<std::string> & retlist,
- const Pathname & dirname, bool dots = true ) const;
- virtual void getDirInfo( filesystem::DirContent & retlist,
- const Pathname & dirname, bool dots = true ) const;
- virtual bool getDoesFileExist( const Pathname & filename ) const;
-
- /**
- * MediaCIFS rewrites the vfstype to "cifs"
- * within it's constructor.
- **/
- void mountAsCIFS() { _vfstype = "cifs"; }
-
- public:
- MediaSMB( const Url& url_r,
- const Pathname & attach_point_hint_r );
-
- virtual ~MediaSMB() { try { release(); } catch(...) {} }
-
- virtual bool isAttached() const;
-
- private:
- bool authenticate( AuthData & authdata, bool firstTry ) const;
- };
-
-///////////////////////////////////////////////////////////////////A
- } // namespace media
-} // namespace zypp
-
-#endif // ZYPP_MEDIA_MEDIASMB_H
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
[View Less]
1
0

[zypp-commit] <libzypp> master : MediaSMB: fix optionname for workgroup; it's 'domain'.
by Michael Andres 31 Oct '09
by Michael Andres 31 Oct '09
31 Oct '09
ref: refs/heads/master
commit 1f46b966ec29450439d58bca22105c8209242a8b
Author: Michael Andres <ma(a)suse.de>
Date: Sat Oct 31 16:22:48 2009 +0100
MediaSMB: fix optionname for workgroup; it's 'domain'.
---
zypp/media/MediaManager.h | 6 +++---
zypp/media/MediaSMB.cc | 4 +++-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/zypp/media/MediaManager.h b/zypp/media/MediaManager.h
index 5142428..dbadab9 100644
--- a/zypp/media/MediaManager.h
+++ b/zypp/media/…
[View More]MediaManager.h
@@ -322,16 +322,16 @@ namespace zypp
* - <tt>mountoptions</tt>:
* The mount options separated by a comma ','. Default are the
* "ro" and "guest" options.
- * - <tt>workgroup</tt>:
+ * - <tt>workgroup</tt> or <tt>domain</tt>:
* The name of the workgroup.
* - <tt>username</tt>:
* Alternative username to username in URL authority.
* - <tt>password</tt>:
* Alternative password to password in URL authority.
* - <tt>user</tt>:
- * Alternative username (cifs specific variant?)
+ * Alternative username (cifs specific variant)
* - <tt>pass</tt>:
- * Alternative password (cifs specific variant?)
+ * Alternative password (cifs specific variant)
* - Authority:
* The authority component has to provide a hostname. Optionally
* also a username and password.
diff --git a/zypp/media/MediaSMB.cc b/zypp/media/MediaSMB.cc
index c6577f6..08e4f05 100644
--- a/zypp/media/MediaSMB.cc
+++ b/zypp/media/MediaSMB.cc
@@ -183,8 +183,10 @@ namespace zypp {
// look for a workgroup
string workgroup = _url.getQueryParam("workgroup");
+ if ( workgroup.empty() )
+ workgroup = _url.getQueryParam("domain");
if ( !workgroup.empty() )
- options["workgroup"] = workgroup;
+ options["domain"] = workgroup;
// extract 'username', do not overwrite any _url.username
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
[View Less]
1
0

[zypp-commit] <libzypp> ma-misc : MediaSMB: fix optionname for workgroup; it's 'domain'.
by Michael Andres 31 Oct '09
by Michael Andres 31 Oct '09
31 Oct '09
ref: refs/heads/ma-misc
commit 1f46b966ec29450439d58bca22105c8209242a8b
Author: Michael Andres <ma(a)suse.de>
Date: Sat Oct 31 16:22:48 2009 +0100
MediaSMB: fix optionname for workgroup; it's 'domain'.
---
zypp/media/MediaManager.h | 6 +++---
zypp/media/MediaSMB.cc | 4 +++-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/zypp/media/MediaManager.h b/zypp/media/MediaManager.h
index 5142428..dbadab9 100644
--- a/zypp/media/MediaManager.h
+++ b/zypp/media/…
[View More]MediaManager.h
@@ -322,16 +322,16 @@ namespace zypp
* - <tt>mountoptions</tt>:
* The mount options separated by a comma ','. Default are the
* "ro" and "guest" options.
- * - <tt>workgroup</tt>:
+ * - <tt>workgroup</tt> or <tt>domain</tt>:
* The name of the workgroup.
* - <tt>username</tt>:
* Alternative username to username in URL authority.
* - <tt>password</tt>:
* Alternative password to password in URL authority.
* - <tt>user</tt>:
- * Alternative username (cifs specific variant?)
+ * Alternative username (cifs specific variant)
* - <tt>pass</tt>:
- * Alternative password (cifs specific variant?)
+ * Alternative password (cifs specific variant)
* - Authority:
* The authority component has to provide a hostname. Optionally
* also a username and password.
diff --git a/zypp/media/MediaSMB.cc b/zypp/media/MediaSMB.cc
index c6577f6..08e4f05 100644
--- a/zypp/media/MediaSMB.cc
+++ b/zypp/media/MediaSMB.cc
@@ -183,8 +183,10 @@ namespace zypp {
// look for a workgroup
string workgroup = _url.getQueryParam("workgroup");
+ if ( workgroup.empty() )
+ workgroup = _url.getQueryParam("domain");
if ( !workgroup.empty() )
- options["workgroup"] = workgroup;
+ options["domain"] = workgroup;
// extract 'username', do not overwrite any _url.username
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
[View Less]
1
0

31 Oct '09
ref: refs/heads/SuSE-Linux-10_3-Branch
commit 13b58b7011e54d0916a6c03a66d070e9d682c54b
Author: Michael Andres <ma(a)suse.de>
Date: Sat Oct 31 12:00:35 2009 +0100
changes 3.27.4
---
VERSION.cmake | 2 +-
package/libzypp.changes | 6 ++++++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/VERSION.cmake b/VERSION.cmake
index 4d64684..900e772 100644
--- a/VERSION.cmake
+++ b/VERSION.cmake
@@ -47,4 +47,4 @@
SET(LIBZYPP_MAJOR "3")
SET(LIBZYPP_MINOR "27")
…
[View More]SET(LIBZYPP_COMPATMINOR "24")
-SET(LIBZYPP_PATCH "3")
+SET(LIBZYPP_PATCH "4")
diff --git a/package/libzypp.changes b/package/libzypp.changes
index 009ad53..3065b4e 100644
--- a/package/libzypp.changes
+++ b/package/libzypp.changes
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Sat Oct 31 11:56:21 CET 2009 - ma(a)suse.de
+
+- Fixed password handling in URLs (bnc #347273, bnc #551646)
+- 3.27.4
+
+-------------------------------------------------------------------
Wed Oct 15 14:33:01 CEST 2008 - ma(a)suse.de
- Fix package-manager script to properly quote arguments.
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
[View Less]
1
0

[zypp-commit] <libzypp> SuSE-Linux-10_3-Branch : Fixed password handling in URLs (bnc #347273, bnc #551646)
by Michael Andres 31 Oct '09
by Michael Andres 31 Oct '09
31 Oct '09
ref: refs/heads/SuSE-Linux-10_3-Branch
commit 6f18482beb24d68662ca8f7f227bfae6bc27fb5c
Author: Michael Andres <ma(a)suse.de>
Date: Sat Oct 31 12:00:20 2009 +0100
Fixed password handling in URLs (bnc #347273, bnc #551646)
---
zypp/repo/RepoVariables.cc | 23 ++++++++---------------
1 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/zypp/repo/RepoVariables.cc b/zypp/repo/RepoVariables.cc
index 8bf617f..41c5d04 100644
--- a/zypp/repo/RepoVariables.cc
+++ b/zypp/repo/…
[View More]RepoVariables.cc
@@ -21,7 +21,7 @@ namespace zypp
{
namespace repo
{
-
+
RepoVariablesStringReplacer::RepoVariablesStringReplacer()
{}
@@ -31,19 +31,19 @@ RepoVariablesStringReplacer::~RepoVariablesStringReplacer()
std::string RepoVariablesStringReplacer::operator()( const std::string &value ) const
{
string newvalue(value);
-
+
// $arch
newvalue = str::gsub( newvalue,
"$arch",
ZConfig::instance().systemArchitecture().asString() );
// $basearch
-
+
Arch::CompatSet cset( Arch::compatSet( ZConfig::instance().systemArchitecture() ) );
Arch::CompatSet::const_iterator it = cset.end();
--it;
// now at noarch
--it;
-
+
Arch basearch = *it;
if ( basearch == Arch_noarch )
{
@@ -67,18 +67,11 @@ RepoVariablesUrlReplacer::~RepoVariablesUrlReplacer()
Url RepoVariablesUrlReplacer::operator()( const Url &value ) const
{
+ Url newurl( value );
RepoVariablesStringReplacer replacer;
- string transformed = replacer(value.asString());
- Url newurl;
- try {
- newurl = Url(transformed);
- }
- catch ( const Exception &e )
- {
- ZYPP_CAUGHT(e);
- // just return what we got
- return value;
- }
+ newurl.setPathData(replacer(value.getPathData()));
+ newurl.setQueryString(replacer(value.getQueryString()));
+
return newurl;
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
[View Less]
1
0
ref: refs/heads/master
commit e9601c1be29887d40ee499f508f0c9085bbad672
Author: Michael Andres <ma(a)suse.de>
Date: Fri Oct 30 12:38:41 2009 +0100
changes
---
package/libzypp.changes | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/package/libzypp.changes b/package/libzypp.changes
index 9d4a04f..96239b1 100644
--- a/package/libzypp.changes
+++ b/package/libzypp.changes
@@ -1,7 +1,8 @@
-------------------------------------------------------------------
…
[View More]Fri Oct 30 12:30:48 CET 2009 - ma(a)suse.de
-- Don't try to use an empty proxy string (bnc #551314)
+- Don't try to use an empty proxy string. (bnc #551314)
+- MediaSMB failed to pass the --workgroup option to mount. (bnc #547354)
- version 6.21.1 (19)
-------------------------------------------------------------------
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
[View Less]
1
0
ref: refs/heads/ma-misc
commit e9601c1be29887d40ee499f508f0c9085bbad672
Author: Michael Andres <ma(a)suse.de>
Date: Fri Oct 30 12:38:41 2009 +0100
changes
---
package/libzypp.changes | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/package/libzypp.changes b/package/libzypp.changes
index 9d4a04f..96239b1 100644
--- a/package/libzypp.changes
+++ b/package/libzypp.changes
@@ -1,7 +1,8 @@
-------------------------------------------------------------------
…
[View More]Fri Oct 30 12:30:48 CET 2009 - ma(a)suse.de
-- Don't try to use an empty proxy string (bnc #551314)
+- Don't try to use an empty proxy string. (bnc #551314)
+- MediaSMB failed to pass the --workgroup option to mount. (bnc #547354)
- version 6.21.1 (19)
-------------------------------------------------------------------
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
[View Less]
1
0

[zypp-commit] <libzypp> master : MediaSMB failed to pass the --workgroup option to mount. (bnc #547354)
by Michael Andres 30 Oct '09
by Michael Andres 30 Oct '09
30 Oct '09
ref: refs/heads/master
commit d5545f5bb4a997f742034285303dc751accc5345
Author: Michael Andres <ma(a)suse.de>
Date: Fri Oct 30 12:38:33 2009 +0100
MediaSMB failed to pass the --workgroup option to mount. (bnc #547354)
---
zypp/media/MediaSMB.cc | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/zypp/media/MediaSMB.cc b/zypp/media/MediaSMB.cc
index 84b4fd5..c6577f6 100644
--- a/zypp/media/MediaSMB.cc
+++ b/zypp/media/MediaSMB.cc
@@ -182,11 +182,9 @@ namespace …
[View More]zypp {
}
// look for a workgroup
- /*
string workgroup = _url.getQueryParam("workgroup");
if ( !workgroup.empty() )
options["workgroup"] = workgroup;
- */
// extract 'username', do not overwrite any _url.username
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
[View Less]
1
0