r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text
[tprouty/samba.git] / source / client / smbmount.c
index 6e8d9f5bca7e9710055d118ad331ef76b368d161..b68dbfe346299365c0541f4f8432587e90bbc528 100644 (file)
@@ -5,7 +5,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define NO_SYSLOG
-
 #include "includes.h"
 
 #include <mntent.h>
@@ -28,6 +25,8 @@
 
 extern BOOL in_client;
 extern pstring user_socket_options;
+extern char *optarg;
+extern int optind;
 
 static pstring credentials;
 static pstring my_netbios_name;
@@ -151,8 +150,8 @@ static struct cli_state *do_connection(char *the_service)
        if (have_ip) ip = dest_ip;
 
        /* have to open a new connection */
-       if (!(c=cli_initialise(NULL)) || (cli_set_port(c, smb_port) != smb_port) ||
-           !cli_connect(c, server_n, &ip)) {
+       if (!(c=cli_initialise()) || (cli_set_port(c, smb_port) != smb_port) ||
+           !NT_STATUS_IS_OK(cli_connect(c, server_n, &ip))) {
                DEBUG(0,("%d: Connection to %s failed\n", sys_getpid(), server_n));
                if (c) {
                        cli_shutdown(c);
@@ -213,14 +212,14 @@ static struct cli_state *do_connection(char *the_service)
                c->force_dos_errors = True;
        }
 
-       if (!cli_session_setup(c, username, 
-                              password, strlen(password),
-                              password, strlen(password),
-                              workgroup)) {
+       if (!NT_STATUS_IS_OK(cli_session_setup(c, username, 
+                                              password, strlen(password),
+                                              password, strlen(password),
+                                              workgroup))) {
                /* if a password was not supplied then try again with a
                        null username */
                if (password[0] || !username[0] ||
-                               !cli_session_setup(c, "", "", 0, "", 0, workgroup)) {
+                   !NT_STATUS_IS_OK(cli_session_setup(c, "", "", 0, "", 0, workgroup))) {
                        DEBUG(0,("%d: session setup failed: %s\n",
                                sys_getpid(), cli_errstr(c)));
                        cli_shutdown(c);
@@ -383,10 +382,14 @@ static void send_fs_socket(char *the_service, char *mount_point, struct cli_stat
 
                   If we don't do this we will "leak" sockets and memory on
                   each reconnection we have to make. */
+               c->smb_rw_error = DO_NOT_DO_TDIS;
                cli_shutdown(c);
                c = NULL;
 
                if (!closed) {
+                       /* close the name cache so that close_our_files() doesn't steal its FD */
+                       namecache_shutdown();
+
                        /* redirect stdout & stderr since we can't know that
                           the library functions we use are using DEBUG. */
                        if ( (fd = open("/dev/null", O_WRONLY)) < 0)
@@ -665,6 +668,9 @@ static void usage(void)
 
        printf("Version %s\n\n",SAMBA_VERSION_STRING);
 
+       printf("Please be aware that smbfs is deprecated in favor of "
+              "cifs\n\n");
+
        printf(
 "Options:\n\
       username=<arg>                  SMB username\n\
@@ -710,7 +716,6 @@ static void parse_mount_smb(int argc, char **argv)
        int opt;
        char *opts;
        char *opteq;
-       extern char *optarg;
        int val;
        char *p;
 
@@ -860,12 +865,12 @@ static void parse_mount_smb(int argc, char **argv)
 ****************************************************************************/
  int main(int argc,char *argv[])
 {
-       extern char *optarg;
-       extern int optind;
        char *p;
 
        DEBUGLEVEL = 1;
 
+       load_case_tables();
+
        /* here we are interactive, even if run from autofs */
        setup_logging("mount.smbfs",True);
 
@@ -908,7 +913,7 @@ static void parse_mount_smb(int argc, char **argv)
                pstrcpy(username,getenv("LOGNAME"));
        }
 
-       if (!lp_load(dyn_CONFIGFILE,True,False,False)) {
+       if (!lp_load(dyn_CONFIGFILE,True,False,False,True)) {
                fprintf(stderr, "Can't load %s - run testparm to debug it\n", 
                        dyn_CONFIGFILE);
        }