[SCM] Samba Shared Repository - branch v3-3-stable updated - release-3-3-0rc1-131-g711e5d5

Karolin Seeger kseeger at samba.org
Fri Dec 12 14:05:57 GMT 2008


The branch, v3-3-stable has been updated
       via  711e5d5c727b5bf9d9d54c8b11c1bc3fd5ec96b1 (commit)
       via  56dcdf4575b86cf5055cdb1e6f875c491fd704d7 (commit)
       via  4b6986d5f0d9af172a48ae148a95f2c61d64cc9f (commit)
       via  6b9cc1b45ab7769a99b36725eccff8e7b1ea6853 (commit)
       via  f818ce5fc91d8ff29817c8a25f176cb6f3ea7dac (commit)
       via  dcbbc22d5a70b0b500ead079f83c0da7c3558a88 (commit)
       via  f424e621136580130014bb17cbf1015fa7c3d942 (commit)
       via  a457aadbcb9310bee50c69d82cfe058e684cb59b (commit)
       via  02ecd06500b5acf5a95641a8d775fa750a0e08d1 (commit)
       via  553cd4b184a3c0148996f0ad954dad2bae9eaa3d (commit)
       via  ecacbfc91922a5682878f05dfc907010f5e24a73 (commit)
       via  2901e96c5e6fd9883662bcde7753c295f1d1b649 (commit)
      from  7a5a3d3944ad7d9fa16f37cde2de43d2eceffd0f (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-stable


- Log -----------------------------------------------------------------
commit 711e5d5c727b5bf9d9d54c8b11c1bc3fd5ec96b1
Author: Karolin Seeger <kseeger at samba.org>
Date:   Fri Dec 12 14:30:01 2008 +0100

    docs: Add hint that "socket address" usually don't need to be set.
    
    This fixes bug #5950.
    Thanks to the Debian Samba package maintainers for reporting!
    
    Karolin
    (cherry picked from commit 19beef0dd9354296ae79d32077c58fbacf570c85)
    (cherry picked from commit 0d035d36bd3707ccb9f77f0b2730869dc78719d4)
    (cherry picked from commit 6be19f94802d545cc43286aa242b0ca2e5b79721)

commit 56dcdf4575b86cf5055cdb1e6f875c491fd704d7
Author: Jeff Layton <jlayton at redhat.com>
Date:   Fri Dec 12 07:06:07 2008 -0500

    mount.cifs: allow mounts to ipv6 capable servers
    
    The current name resolution scheme in mount.cifs is IPv4 only. Expand
    it to be protocol-independent. Also take advantage of the fact that
    getaddrinfo() returns a list of addresses and have mount.cifs try each
    in turn until it hits one that's reachable and allows the socket to
    connect.
    
    Signed-off-by: Jeff Layton <jlayton at redhat.com>
    (cherry picked from commit 4f19e0850bb457b41ea2953ca0d4e9aeaf3bc09a)

commit 4b6986d5f0d9af172a48ae148a95f2c61d64cc9f
Author: Michael Adam <obnox at samba.org>
Date:   Mon Dec 1 23:19:02 2008 +0100

    packaging(RHEL-CTDB): don't show failure messages in check for ccache
    
    by fixing the order of "> /dev/null 2>&1"
    
    Michael
    (cherry picked from commit 0e9d5638a7c375b3b18f19f83f97924ab45ad382)
    (cherry picked from commit 6e51f250c5d38e973948aa1d53222bcccdcca365)

commit 6b9cc1b45ab7769a99b36725eccff8e7b1ea6853
Author: Michael Adam <obnox at samba.org>
Date:   Mon Dec 1 23:03:38 2008 +0100

    packaging(RHEL-CTDB): fix the build when ccache is not found.
    
    Michael
    (cherry picked from commit c98fb34ef933944a96a286d2d276cf2adc99e25e)
    (cherry picked from commit 7d929d9fa363a1f1c67926678524f338e84b3535)

commit f818ce5fc91d8ff29817c8a25f176cb6f3ea7dac
Author: Michael Adam <obnox at samba.org>
Date:   Mon Dec 1 03:05:40 2008 +0100

    packaging(RHEL-CTDB): explicitly build the gpfs module
    
    to prevent potetential problems on PTF8 systems where there
    is no valid autodetecting configure check yet.
    
    Michael
    (cherry picked from commit 37039d345e9a25654bef038f2b8bb4b891cfa6f0)
    (cherry picked from commit b486890eb0883508c5ade3e1e4e99ac728b6bf71)

commit dcbbc22d5a70b0b500ead079f83c0da7c3558a88
Author: Michael Adam <obnox at samba.org>
Date:   Mon Dec 1 03:07:19 2008 +0100

    packaging(RHEL-CTDB): use ccache if available
    
    Michael
    (cherry picked from commit 36ca917a63f23126536e786bed845dee48fbf61c)
    (cherry picked from commit 05b51bc176f87e7dc1b65adf3d866e797159d953)

commit f424e621136580130014bb17cbf1015fa7c3d942
Author: Michael Adam <obnox at samba.org>
Date:   Thu Sep 18 05:02:14 2008 +0200

    packaging(RHEL-CTDB): adapt configure.rpm to changes to the spec file
    
    Michael
    (cherry picked from commit d249a9ca2a1761f20655cbcfe39fbc942547974d)
    (cherry picked from commit 402ac73f436e1b1b71199bbef44be775dc67801c)

commit a457aadbcb9310bee50c69d82cfe058e684cb59b
Author: Michael Adam <obnox at samba.org>
Date:   Tue Nov 11 13:47:37 2008 +0100

    packaging(RHEL-CTDB): move the cifs.upcall manpage to the client package
    
    Michael
    (cherry picked from commit 16f23eb27467ace9751ef2d1fbb6c4d3a5ae9550)
    (cherry picked from commit 9538e3130f33ffde1d68eaea303b2b2dd9ddd71d)

commit 02ecd06500b5acf5a95641a8d775fa750a0e08d1
Author: Michael Adam <obnox at samba.org>
Date:   Tue Nov 11 13:45:40 2008 +0100

    packaging(RHEL-CTDB): add the cifs.upcall binary to the client package.
    
    Michael
    (cherry picked from commit 1875b373a319ac9494fdc907793e59804c577a4d)
    (cherry picked from commit e1dca5f1870975b7d9a57869357c971d559afdfe)

commit 553cd4b184a3c0148996f0ad954dad2bae9eaa3d
Author: Michael Adam <obnox at samba.org>
Date:   Mon Sep 15 16:15:42 2008 +0200

    packaging(RHEL-CTDB): fix typo in makerpms.sh
    
    Michael
    (cherry picked from commit 5fc5e82d4c2c386894fde95f94992171620c7853)
    (cherry picked from commit 0e35ff0b46be2f9deab6e539c34970c85c3b58ce)

commit ecacbfc91922a5682878f05dfc907010f5e24a73
Author: Michael Adam <obnox at samba.org>
Date:   Fri Sep 12 15:50:33 2008 +0200

    packaging(RHEL-CTDB): refactor creation of spec file from template out
    
    into new script makespec.sh
    
    Michael
    (cherry picked from commit d49a9d1c67e4d98017ce5f7d1351bca1366e1a8d)
    (cherry picked from commit 086873f00de96ca48717b05dddb71e776c74ca7d)

commit 2901e96c5e6fd9883662bcde7753c295f1d1b649
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 10 23:06:28 2008 +0200

    packaging(RHEL-CTDB): fix installation of pam modules
    
    use configure parameter to specify the pam modules dir.
    
    Michael
    (cherry picked from commit 24282daa5e293ef9362a69f7f70a684587d6763a)

-----------------------------------------------------------------------

Summary of changes:
 docs-xml/smbdotconf/misc/socketaddress.xml |   12 +-
 packaging/RHEL-CTDB/configure.rpm          |   68 ++++++---
 packaging/RHEL-CTDB/makerpms.sh            |   25 +---
 packaging/RHEL-CTDB/makespec.sh            |   36 +++++
 packaging/RHEL-CTDB/samba.spec.tmpl        |   21 ++--
 source/client/mount.cifs.c                 |  221 +++++++++++++++-------------
 6 files changed, 224 insertions(+), 159 deletions(-)
 create mode 100755 packaging/RHEL-CTDB/makespec.sh


Changeset truncated at 500 lines:

diff --git a/docs-xml/smbdotconf/misc/socketaddress.xml b/docs-xml/smbdotconf/misc/socketaddress.xml
index 7566380..17018ef 100644
--- a/docs-xml/smbdotconf/misc/socketaddress.xml
+++ b/docs-xml/smbdotconf/misc/socketaddress.xml
@@ -4,12 +4,14 @@
 		 developer="1"
 		 xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
 <description>
-	<para>This option allows you to control what 
-	address Samba will listen for connections on. This is used to 
-	support multiple virtual interfaces on the one server, each 
+	<para>This option allows you to control what
+	address Samba will listen for connections on. This is used to
+	support multiple virtual interfaces on the one server, each
 	with a different configuration.</para>
-		
-	<para>By default Samba will accept connections on any 
+	<para>Setting this option should never be necessary on usual Samba
+	servers running only one nmbd.</para>
+
+	<para>By default Samba will accept connections on any
 		address.</para>
 </description>
 
diff --git a/packaging/RHEL-CTDB/configure.rpm b/packaging/RHEL-CTDB/configure.rpm
index 7596040..b9a1ee1 100755
--- a/packaging/RHEL-CTDB/configure.rpm
+++ b/packaging/RHEL-CTDB/configure.rpm
@@ -1,37 +1,56 @@
+#!/bin/sh
 
 case `uname -m` in
-     x86_64)
-	libdir=/usr/lib64/samba
-	;;
-     *)
-	libdir=/usr/lib/samba
-	;;
+	x86_64)
+		_libarch=lib64
+		;;
+	*)
+		_libarch=lib
+		;;
 esac
 
-CFLAGS="-Wall -g -D_GNU_SOURCE" ./configure \
-        --prefix=/usr \
-        --localstatedir=/var \
-        --with-configdir=/etc/samba \
-        --with-libdir=$libdir \
-        --with-lockdir=/var/lib/samba \
-        --with-logfilebase=/var/log/samba \
-        --with-mandir=/usr/man \
-        --with-piddir=/var/run \
-        --with-privatedir=/etc/samba \
-        --with-sambabook=/usr/share/swat/using_samba \
-        --with-swatdir=/usr/share/swat \
+_libarchdir=/usr/${_libarch}
+
+_prefix=/usr
+_sysconfdir=/etc
+_mandir=/usr/man
+_datadir=/usr/share
+
+# check for ccache
+ccache -h 2>&1 > /dev/null
+if [ $? -eq 0 ]; then
+	CC="ccache gcc"
+else
+	CC="gcc"
+fi
+
+./autogen.sh
+
+CC="$CC" CFLAGS="-Wall -g -D_GNU_SOURCE" ./configure -C \
+	--prefix=${_prefix} \
+	--localstatedir=/var \
+	--with-configdir=${_sysconfdir}/samba \
+	--with-libdir=${_libarchdir}/samba \
+	--with-pammodulesdir=/${_libarch}/security \
+	--with-lockdir=/var/lib/samba \
+	--with-logfilebase=/var/log/samba \
+	--with-mandir=${_mandir} \
+	--with-piddir=/var/run \
+	--with-privatedir=${_sysconfdir}/samba \
+	--with-sambabook=${_datadir}/swat/using_samba \
+	--with-swatdir=${_datadir}/swat \
 	--disable-cups \
-        --with-acl-support \
+	--with-acl-support \
 	--with-ads \
-        --with-automount \
-        --with-fhs \
+	--with-automount \
+	--with-fhs \
 	--with-pam_smbpass \
 	--with-libsmbclient \
 	--with-libsmbsharemodes \
-        --without-smbwrapper \
+	--without-smbwrapper \
 	--with-pam \
 	--with-quotas \
-	--with-shared-modules=idmap_rid,idmap_ad,idmap_tdb2 \
+	--with-shared-modules=idmap_rid,idmap_ad,idmap_tdb2,vfs_gpfs \
 	--with-syslog \
 	--with-utmp \
 	--with-cluster-support \
@@ -40,3 +59,6 @@ CFLAGS="-Wall -g -D_GNU_SOURCE" ./configure \
 	--without-dnsupdate \
 	--with-aio-support \
 	$*
+
+make showlayout
+
diff --git a/packaging/RHEL-CTDB/makerpms.sh b/packaging/RHEL-CTDB/makerpms.sh
index 219982f..50fa96c 100755
--- a/packaging/RHEL-CTDB/makerpms.sh
+++ b/packaging/RHEL-CTDB/makerpms.sh
@@ -25,8 +25,6 @@ RPMSRCDIR=`rpm --eval %_sourcedir`
 
 DIRNAME=$(dirname $0)
 TOPDIR=${DIRNAME}/../..
-SRCDIR=${TOPDIR}/source
-VERSION_H=${SRCDIR}/include/version.h
 
 SPECFILE="samba.spec"
 DOCS="docs.tar.bz2"
@@ -49,25 +47,14 @@ esac
 ##
 ## determine the samba version and create the SPEC file
 ##
-pushd ${SRCDIR}
-./script/mkversion.sh
-popd
-if [ ! -f ${VERSION_H} ] ; then
-	echo "Error creating version.h"
-	exit 1
+${DIRNAME}/makespec.sh
+RC=$?
+if [ $RC -ne 0 ]; then
+	exit ${RC}
 fi
 
-VERSION=`grep SAMBA_VERSION_OFFICIAL_STRING ${VERSION_H} | awk '{print $3}'`
-vendor_version=`grep SAMBA_VERSION_VENDOR_SUFFIX ${VERSION_H} | awk '{print $3}'`
-if test "x${vendor_version}"  != "x" ; then
-	VERSION="${VERSION}-${vendor_version}"
-fi
-VERSION=`echo ${VERSION} | sed 's/-/_/g'`
-VERSION=`echo ${VERSION} | sed 's/\"//g'`
-echo "VERSION: ${VERSION}"
-sed -e s/PVERSION/${VERSION}/g \
-	< ${DIRNAME}/${SPECFILE}.tmpl \
-	> ${DIRNAME}/${SPECFILE}
+RELEASE=$(grep ^Release ${DIRNAME}/${SPECFILE} | sed -e 's/^Release:\ \+//')
+VERSION=$(grep ^Version ${DIRNAME}/${SPECFILE} | sed -e 's/^Version:\ \+//')
 
 ##
 ## create the tarball
diff --git a/packaging/RHEL-CTDB/makespec.sh b/packaging/RHEL-CTDB/makespec.sh
new file mode 100755
index 0000000..7d10d55
--- /dev/null
+++ b/packaging/RHEL-CTDB/makespec.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+# Copyright (C) Michael Adam 2008
+#
+# Script to determine the samba version and create the SPEC file from template
+
+DIRNAME=$(dirname $0)
+TOPDIR=${DIRNAME}/../..
+SRCDIR=${TOPDIR}/source
+VERSION_H=${SRCDIR}/include/version.h
+SPECFILE=${DIRNAME}/samba.spec
+
+##
+## determine the samba version and create the SPEC file
+##
+pushd ${SRCDIR}
+./script/mkversion.sh
+popd
+if [ ! -f ${VERSION_H} ] ; then
+	echo "Error creating version.h"
+	exit 1
+fi
+
+VERSION=`grep SAMBA_VERSION_OFFICIAL_STRING ${VERSION_H} | awk '{print $3}'`
+vendor_version=`grep SAMBA_VERSION_VENDOR_SUFFIX ${VERSION_H} | awk '{print
+$3}'`
+if test "x${vendor_version}"  != "x" ; then
+	VERSION="${VERSION}-${vendor_version}"
+fi
+VERSION=`echo ${VERSION} | sed 's/-/_/g'`
+VERSION=`echo ${VERSION} | sed 's/\"//g'`
+echo "VERSION: ${VERSION}"
+sed -e s/PVERSION/${VERSION}/g \
+	< ${SPECFILE}.tmpl \
+	> ${SPECFILE}
+
diff --git a/packaging/RHEL-CTDB/samba.spec.tmpl b/packaging/RHEL-CTDB/samba.spec.tmpl
index b34f01f..8a583a9 100644
--- a/packaging/RHEL-CTDB/samba.spec.tmpl
+++ b/packaging/RHEL-CTDB/samba.spec.tmpl
@@ -133,12 +133,11 @@ cd source
 # RPM_OPT_FLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64"
 
 ## check for ccache
-# ccache -h 2>&1 > /dev/null
-#if [ $? -eq 0 ]; then
-#	CC="ccache gcc"
-#else
+if ccache -h >/dev/null 2>&1 ; then
+	CC="ccache gcc"
+else
 	CC="gcc"
-#fi 
+fi
 
 ## always run autogen.sh
 ./autogen.sh
@@ -149,6 +148,7 @@ CFLAGS="$RPM_OPT_FLAGS $EXTRA -D_GNU_SOURCE" ./configure \
         --with-configdir=%{_sysconfdir}/samba \
         --libdir=%{_libarchdir} \
 	--with-modulesdir=%{_libarchdir}/samba \
+	--with-pammodulesdir=%{_libarch}/security \
         --with-lockdir=/var/lib/samba \
         --with-logfilebase=/var/log/samba \
         --with-mandir=%{_mandir} \
@@ -167,7 +167,7 @@ CFLAGS="$RPM_OPT_FLAGS $EXTRA -D_GNU_SOURCE" ./configure \
         --without-smbwrapper \
 	--with-pam \
 	--with-quotas \
-	--with-shared-modules=idmap_rid,idmap_ad,idmap_tdb2 \
+	--with-shared-modules=idmap_rid,idmap_ad,idmap_tdb2,vfs_gpfs \
 	--with-syslog \
 	--with-utmp \
 	--with-cluster-support \
@@ -230,8 +230,7 @@ make DESTDIR=$RPM_BUILD_ROOT \
         install
 cd ..
 
-# NSS & PAM winbind support
-install -m 755 source/bin/pam_winbind.so $RPM_BUILD_ROOT/%{_libarch}/security/pam_winbind.so
+# NSS winbind support
 install -m 755 source/nsswitch/libnss_winbind.so $RPM_BUILD_ROOT/%{_libarch}/libnss_winbind.so.2
 ( cd $RPM_BUILD_ROOT/%{_libarch};
   ln -sf libnss_winbind.so.2  libnss_winbind.so )
@@ -242,8 +241,6 @@ install -m 755 source/nsswitch/libnss_winbind.so $RPM_BUILD_ROOT/%{_libarch}/lib
 #install -m 755 source/nsswitch/libnss_wins.so $RPM_BUILD_ROOT/%{_libarch}/libnss_wins.so
 # ( cd $RPM_BUILD_ROOT/%{_libarch}; ln -sf libnss_wins.so  libnss_wins.so.2 )
 
-# Install pam_smbpass.so
-install -m755 source/bin/pam_smbpass.so $RPM_BUILD_ROOT/%{_libarch}/security/pam_smbpass.so
 
 ## cleanup
 /bin/rm -rf $RPM_BUILD_ROOT/usr/lib*/samba/security
@@ -419,6 +416,8 @@ exit 0
 /sbin/mount.cifs
 /sbin/umount.cifs
 
+%{_sbindir}/cifs.upcall
+
 %{_bindir}/rpcclient
 %{_bindir}/smbcacls
 %{_bindir}/findsmb
@@ -432,6 +431,7 @@ exit 0
 
 %{_mandir}/man8/mount.cifs.8.*
 %{_mandir}/man8/umount.cifs.8.*
+%{_mandir}/man8/cifs.upcall.8*
 %{_mandir}/man8/smbspool.8*
 %{_mandir}/man1/smbget.1*
 %{_mandir}/man5/smbgetrc.5*
@@ -512,7 +512,6 @@ exit 0
 %{_mandir}/man1/ldbedit.1*
 %{_mandir}/man1/ldbmodify.1*
 %{_mandir}/man1/ldbsearch.1*
-%{_mandir}/man8/cifs.upcall.8*
 
 %ifarch i386 i486 i586 i686 ppc s390
 %files winbind-32bit
diff --git a/source/client/mount.cifs.c b/source/client/mount.cifs.c
index 0bc61ae..9f4d1d3 100644
--- a/source/client/mount.cifs.c
+++ b/source/client/mount.cifs.c
@@ -80,6 +80,9 @@
 #define MOUNT_PASSWD_SIZE 64
 #define DOMAIN_SIZE 64
 
+/* currently maximum length of IPv6 address string */
+#define MAX_ADDRESS_LEN INET6_ADDRSTRLEN
+
 const char *thisprogram;
 int verboseflag = 0;
 static int got_password = 0;
@@ -189,12 +192,6 @@ static char * getusername(void) {
 	return username;
 }
 
-static char * parse_cifs_url(char * unc_name)
-{
-	printf("\nMounting cifs URL not implemented yet. Attempt to mount %s\n",unc_name);
-	return NULL;
-}
-
 static int open_cred_file(char * file_name)
 {
 	char * line_buf;
@@ -494,7 +491,7 @@ static int parse_options(char ** optionsp, int * filesys_flags)
 		} else if (strncmp(data, "ip", 2) == 0) {
 			if (!value || !*value) {
 				printf("target ip address argument missing");
-			} else if (strnlen(value, 35) < 35) {
+			} else if (strnlen(value, MAX_ADDRESS_LEN) <= MAX_ADDRESS_LEN) {
 				if(verboseflag)
 					printf("ip address %s override specified\n",value);
 				got_ip = 1;
@@ -882,23 +879,23 @@ static void replace_char(char *string, char from, char to, int maxlen)
 }
 
 /* Note that caller frees the returned buffer if necessary */
-static char * parse_server(char ** punc_name)
+static struct addrinfo *
+parse_server(char ** punc_name)
 {
 	char * unc_name = *punc_name;
 	int length = strnlen(unc_name, MAX_UNC_LEN);
 	char * share;
-	char * ipaddress_string = NULL;
-	struct hostent * host_entry = NULL;
-	struct in_addr server_ipaddr;
+	struct addrinfo *addrlist;
+	int rc;
 
 	if(length > (MAX_UNC_LEN - 1)) {
 		printf("mount error: UNC name too long");
 		return NULL;
 	}
-	if (strncasecmp("cifs://",unc_name,7) == 0)
-		return parse_cifs_url(unc_name+7);
-	if (strncasecmp("smb://",unc_name,6) == 0) {
-		return parse_cifs_url(unc_name+6);
+	if ((strncasecmp("cifs://", unc_name, 7) == 0) ||
+	    (strncasecmp("smb://", unc_name, 6) == 0)) {
+		printf("\nMounting cifs URL not implemented yet. Attempt to mount %s\n", unc_name);
+		return NULL;
 	}
 
 	if(length < 3) {
@@ -939,7 +936,12 @@ continue_unc_parsing:
 				*share = 0;  /* temporarily terminate the string */
 				share += 1;
 				if(got_ip == 0) {
-					host_entry = gethostbyname(unc_name);
+					rc = getaddrinfo(unc_name, NULL, NULL, &addrlist);
+					if (rc != 0) {
+						printf("mount error: could not resolve address for %s: %s\n",
+							unc_name, gai_strerror(rc));
+						addrlist = NULL;
+					}
 				}
 				*(share - 1) = '/'; /* put delimiter back */
 
@@ -954,23 +956,9 @@ continue_unc_parsing:
 						printf("ip address specified explicitly\n");
 					return NULL;
 				}
-				if(host_entry == NULL) {
-					printf("mount error: could not find target server. TCP name %s not found\n", unc_name);
-					return NULL;
-				} else {
-					/* BB should we pass an alternate version of the share name as Unicode */
-					/* BB what about ipv6? BB */
-					/* BB add retries with alternate servers in list */
+				/* BB should we pass an alternate version of the share name as Unicode */
 
-					memcpy(&server_ipaddr.s_addr, host_entry->h_addr, 4);
-
-					ipaddress_string = inet_ntoa(server_ipaddr);                                                                                     
-					if(ipaddress_string == NULL) {
-						printf("mount error: could not get valid ip address for target server\n");
-						return NULL;
-					}
-					return ipaddress_string; 
-				}
+				return addrlist; 
 			} else {
 				/* BB add code to find DFS root (send null path on get DFS Referral to specified server here */
 				printf("Mounting the DFS root for a particular server not implemented yet\n");
@@ -1034,10 +1022,11 @@ int main(int argc, char ** argv)
 	int flags = MS_MANDLOCK; /* no need to set legacy MS_MGC_VAL */
 	char * orgoptions = NULL;
 	char * share_name = NULL;
-	char * ipaddr = NULL;
+	const char * ipaddr = NULL;
 	char * uuid = NULL;
 	char * mountpoint = NULL;
 	char * options = NULL;
+	char * optionstail;
 	char * resolved_path = NULL;
 	char * temp;
 	char * dev_name;
@@ -1050,10 +1039,14 @@ int main(int argc, char ** argv)
 	int optlen = 0;
 	int orgoptlen = 0;
 	size_t options_size = 0;
+	size_t current_len;
 	int retry = 0; /* set when we have to retry mount with uppercase */
+	struct addrinfo *addrhead = NULL, *addr;
 	struct stat statbuf;
 	struct utsname sysinfo;
 	struct mntent mountent;
+	struct sockaddr_in *addr4;
+	struct sockaddr_in6 *addr6;
 	FILE * pmntfile;
 
 	/* setlocale(LC_ALL, "");
@@ -1245,8 +1238,8 @@ int main(int argc, char ** argv)
                 rc = EX_USAGE;
 		goto mount_exit;
 	}
-	ipaddr = parse_server(&share_name);
-	if((ipaddr == NULL) && (got_ip == 0)) {
+	addrhead = addr = parse_server(&share_name);
+	if((addrhead == NULL) && (got_ip == 0)) {
 		printf("No ip address specified and hostname not found\n");
 		rc = EX_USAGE;
 		goto mount_exit;
@@ -1316,7 +1309,6 @@ int main(int argc, char ** argv)
 	}
 	/* FIXME launch daemon (handles dfs name resolution and credential change) 
 	   remember to clear parms and overwrite password field before launching */
-mount_retry:
 	if(orgoptions) {
 		optlen = strlen(orgoptions);
 		orgoptlen = optlen;
@@ -1331,10 +1323,10 @@ mount_retry:
 	}
 	if(user_name)
 		optlen += strlen(user_name) + 6;
-	if(ipaddr)
-		optlen += strlen(ipaddr) + 4;
+	optlen += MAX_ADDRESS_LEN + 4;
 	if(mountpassword)
 		optlen += strlen(mountpassword) + 6;
+mount_retry:
 	SAFE_FREE(options);
 	options_size = optlen + 10 + DOMAIN_SIZE;
 	options = (char *)malloc(options_size /* space for commas in password */ + 8 /* space for domain=  , domain name itself was counted as part of the length username string above */);
@@ -1344,18 +1336,12 @@ mount_retry:
 		exit(EX_SYSERR);
 	}
 
-	options[0] = 0;
-	strlcpy(options,"unc=",options_size);
+	strlcpy(options, "unc=", options_size);
 	strlcat(options,share_name,options_size);
 	/* scan backwards and reverse direction of slash */
 	temp = strrchr(options, '/');
 	if(temp > options + 6)
 		*temp = '\\';
-	if(ipaddr) {
-		strlcat(options,",ip=",options_size);
-		strlcat(options,ipaddr,options_size);
-	}
-
 	if(user_name) {
 		/* check for syntax like user=domain\user */
 		if(got_domain == 0)
@@ -1397,11 +1383,42 @@ mount_retry:
 	/* convert all '\\' to '/' in share portion so that /proc/mounts looks pretty */
 	replace_char(dev_name, '\\', '/', strlen(share_name));
 
-	if(mount(dev_name, mountpoint, "cifs", flags, options)) {
-	/* remember to kill daemon on error */
+	if (!got_ip && addr) {
+		strlcat(options, ",ip=", options_size);
+		current_len = strnlen(options, options_size);
+		optionstail = options + current_len;
+		switch (addr->ai_addr->sa_family) {
+		case AF_INET6:
+			addr6 = (struct sockaddr_in6 *) addr->ai_addr;
+			ipaddr = inet_ntop(AF_INET6, &addr6->sin6_addr, optionstail,
+					   options_size - current_len);
+			break;
+		case AF_INET:
+			addr4 = (struct sockaddr_in *) addr->ai_addr;
+			ipaddr = inet_ntop(AF_INET, &addr4->sin_addr, optionstail,
+					   options_size - current_len);
+			break;
+		}
+
+		/* if the address looks bogus, try the next one */
+		if (!ipaddr) {
+			addr = addr->ai_next;
+			if (addr)
+				goto mount_retry;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list