r24698: Patch from Andrew Kroeger <andrew@sprocks.gotdns.com> to fix Bug
[jelmer/samba4-debian.git] / source / client / smbmount.c
index 795bd508122fb2cb5d66af1e15e8a8e809119131..f15b1f7030ec96fd26a4b09a995674070b2c79a5 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/>.
 */
 
 #include "includes.h"
+#include "system/passwd.h"
 
 #include <mntent.h>
 #include <asm/types.h>
 #include <linux/smb_fs.h>
 
-extern BOOL in_client;
-
 static pstring credentials;
 static pstring my_netbios_name;
 static pstring password;
@@ -35,7 +33,7 @@ static pstring mpoint;
 static pstring service;
 static pstring options;
 
-static struct in_addr dest_ip;
+static struct ipv4_addr dest_ip;
 static BOOL have_ip;
 static int smb_port = 0;
 static BOOL got_user;
@@ -118,7 +116,7 @@ static struct smbcli_state *do_connection(char *the_service)
        struct smbcli_state *c;
        struct nmb_name called, calling;
        char *server_n;
-       struct in_addr ip;
+       struct ipv4_addr ip;
        pstring server;
        char *share;
 
@@ -150,7 +148,7 @@ static struct smbcli_state *do_connection(char *the_service)
            !smbcli_connect(c, server_n, &ip)) {
                DEBUG(0,("%d: Connection to %s failed\n", sys_getpid(), server_n));
                if (c) {
-                       smbcli_shutdown(c);
+                       talloc_free(c);
                }
                return NULL;
        }
@@ -169,7 +167,7 @@ static struct smbcli_state *do_connection(char *the_service)
                char *p;
                DEBUG(0,("%d: session request to %s failed (%s)\n", 
                         sys_getpid(), called.name, smbcli_errstr(c)));
-               smbcli_shutdown(c);
+               talloc_free(c);
                if ((p=strchr_m(called.name, '.'))) {
                        *p = 0;
                        goto again;
@@ -185,7 +183,7 @@ static struct smbcli_state *do_connection(char *the_service)
 
        if (!smbcli_negprot(c)) {
                DEBUG(0,("%d: protocol negotiation failed\n", sys_getpid()));
-               smbcli_shutdown(c);
+               talloc_free(c);
                return NULL;
        }
 
@@ -219,7 +217,7 @@ static struct smbcli_state *do_connection(char *the_service)
                                !smbcli_session_setup(c, "", "", 0, "", 0, workgroup)) {
                        DEBUG(0,("%d: session setup failed: %s\n",
                                sys_getpid(), smbcli_errstr(c)));
-                       smbcli_shutdown(c);
+                       talloc_free(c);
                        return NULL;
                }
                DEBUG(0,("Anonymous login successful\n"));
@@ -227,11 +225,10 @@ static struct smbcli_state *do_connection(char *the_service)
 
        DEBUG(4,("%d: session setup ok\n", sys_getpid()));
 
-       if (!smbcli_send_tconX(c, share, "?????",
-                           password, strlen(password)+1)) {
+       if (!smbcli_tconX(c, share, "?????", password, strlen(password)+1)) {
                DEBUG(0,("%d: tree connect failed: %s\n",
                         sys_getpid(), smbcli_errstr(c)));
-               smbcli_shutdown(c);
+               talloc_free(c);
                return NULL;
        }
 
@@ -379,7 +376,7 @@ static void send_fs_socket(char *the_service, char *mount_point, struct smbcli_s
 
                   If we don't do this we will "leak" sockets and memory on
                   each reconnection we have to make. */
-               smbcli_shutdown(c);
+               talloc_free(c);
                c = NULL;
 
                if (!closed) {
@@ -495,7 +492,7 @@ static void init_mount(void)
 
                asprintf(&smbmnt_path, "%s/smbmnt", dyn_BINDIR);
                
-               if (file_exist(smbmnt_path, NULL)) {
+               if (file_exist(smbmnt_path)) {
                        execv(smbmnt_path, args);
                        fprintf(stderr,
                                "smbfs/init_mount: execv of %s failed. Error was %s.",
@@ -552,7 +549,7 @@ static void get_password_file(void)
                sscanf(p, "%d", &fd);
                close_it = False;
        } else if ((p = getenv("PASSWD_FILE")) != NULL) {
-               fd = sys_open(p, O_RDONLY, 0);
+               fd = open(p, O_RDONLY, 0);
                pstrcpy(spec, p);
                if (fd < 0) {
                        fprintf(stderr, "Error opening PASSWD_FILE %s: %s\n",
@@ -787,7 +784,7 @@ static void parse_mount_smb(int argc, char **argv)
                        } else if(!strcmp(opts, "debug")) {
                                DEBUGLEVEL = val;
                        } else if(!strcmp(opts, "ip")) {
-                               dest_ip = *interpret_addr2(opteq+1);
+                               dest_ip = interpret_addr2(opteq+1);
                                if (is_zero_ip(dest_ip)) {
                                        fprintf(stderr,"Can't resolve address %s\n", opteq+1);
                                        exit(1);
@@ -870,8 +867,6 @@ static void parse_mount_smb(int argc, char **argv)
                setenv("CLI_FORCE_ASCII", "true", 1);
 #endif
 
-       in_client = True;   /* Make sure that we tell lp_load we are */
-
        if (getenv("USER")) {
                pstrcpy(username,getenv("USER"));
 
@@ -898,9 +893,9 @@ static void parse_mount_smb(int argc, char **argv)
                pstrcpy(username,getenv("LOGNAME"));
        }
 
-       if (!lp_load(dyn_CONFIGFILE,True,False,False)) {
+       if (!lp_load()) {
                fprintf(stderr, "Can't load %s - run testparm to debug it\n", 
-                       dyn_CONFIGFILE);
+                       lp_config_file());
        }
 
        parse_mount_smb(argc, argv);
@@ -919,7 +914,6 @@ static void parse_mount_smb(int argc, char **argv)
                pstrcpy(workgroup,lp_workgroup());
        }
 
-       load_interfaces();
        if (!*my_netbios_name) {
                pstrcpy(my_netbios_name, myhostname());
        }