first pass at merging rpcclient from TNG to HEAD. You can get a
authorGerald Carter <jerry@samba.org>
Mon, 3 Jul 2000 04:24:31 +0000 (04:24 +0000)
committerGerald Carter <jerry@samba.org>
Mon, 3 Jul 2000 04:24:31 +0000 (04:24 +0000)
semi-connection and a rpcclient prompt, but no functionality there yet.
Will be a few more days on that.

These files changed only with the addition of some support functions
from TNG

--jerry

source/libsmb/clientgen.c
source/libsmb/namequery.c
source/libsmb/nterr.c
source/libsmb/pwd_cache.c

index 32564aaf82524b2f9f7a4f53e1b8eb49d5bfd136..c6f24c5e80154270a9a2fae5713714fa5e173323 100644 (file)
@@ -150,6 +150,23 @@ static void cli_process_oplock(struct cli_state *cli)
        cli->outbuf = oldbuf;
 }
 
+/****************************************************************************
+initialise a client structure
+****************************************************************************/
+void cli_init_creds(struct cli_state *cli, const struct ntuser_creds *usr)
+{
+        /* copy_nt_creds(&cli->usr, usr); */
+       safe_strcpy(cli->domain   , usr->domain   , sizeof(usr->domain   )-1);
+       safe_strcpy(cli->user_name, usr->user_name, sizeof(usr->user_name)-1);
+       memcpy(&cli->pwd, &usr->pwd, sizeof(usr->pwd));
+        cli->ntlmssp_flags = usr->ntlmssp_flags;
+        cli->ntlmssp_cli_flgs = usr != NULL ? usr->ntlmssp_flags : 0;
+
+        DEBUG(10,("cli_init_creds: user %s domain %s flgs: %x\nntlmssp_cli_flgs:%x\n",
+               cli->user_name, cli->domain,
+               cli->ntlmssp_flags,cli->ntlmssp_cli_flgs));
+}
+
 
 /****************************************************************************
 initialise a client structure
index 5dadd4d474d00461fafa8627b394bd49a01b5075..8fb607bd8fcffe08401271538cb976d9eddc7c1d 100644 (file)
@@ -593,6 +593,23 @@ static BOOL resolve_hosts(const char *name,
        return False;
 }
 
+/********************************************************
+ Resolve a name into an IP address. Use this function if
+ the string is either an IP address, DNS or host name
+ or NetBIOS name. This uses the name switch in the
+ smb.conf to determine the order of name resolution.
+*********************************************************/
+BOOL is_ip_address(const char *name)
+{
+  int i;
+  for (i=0; name[i]; i++)
+    if (!(isdigit((int)name[i]) || name[i] == '.'))
+        return False;
+
+  return True;
+}
+
+
 /********************************************************
  Internal interface to resolve a name into an IP address.
  Use this function if the string is either an IP address, DNS
@@ -686,6 +703,52 @@ BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type)
        return False;
 }
 
+
+/********************************************************
+ resolve a name of format \\server_name or \\ipaddress
+ into a name.  also, cut the \\ from the front for us.
+*********************************************************/
+
+BOOL resolve_srv_name(const char* srv_name, fstring dest_host,
+                                struct in_addr *ip)
+{
+        BOOL ret;
+        const char *sv_name = srv_name;
+
+        DEBUG(10,("resolve_srv_name: %s\n", srv_name));
+
+        if (srv_name == NULL || strequal("\\\\.", srv_name))
+        {
+                extern pstring global_myname;
+                fstrcpy(dest_host, global_myname);
+                ip = interpret_addr2("127.0.0.1");
+                return True;
+        }
+
+        if (strnequal("\\\\", srv_name, 2))
+        {
+                sv_name = &srv_name[2];
+        }
+
+        fstrcpy(dest_host, sv_name);
+        /* treat the '*' name specially - it is a magic name for the PDC */
+        if (strcmp(dest_host,"*") == 0) {
+                extern pstring global_myname;
+                ret = resolve_name(lp_workgroup(), ip, 0x1B);
+                lookup_pdc_name(global_myname, lp_workgroup(), ip, dest_host);
+        } else {
+                ret = resolve_name(dest_host, ip, 0x20);
+        }
+        
+        if (is_ip_address(dest_host))
+        {
+                fstrcpy(dest_host, "*SMBSERVER");
+        }
+        
+        return ret;
+}
+
+
 /********************************************************
  Find the IP address of the master browser or DMB for a workgroup.
 *********************************************************/
index 3f19a669414d9e3f85101836628ee906c41f1a50..f9d717477a0b69fdd6022b586e9fa01caaa5a6f5 100644 (file)
@@ -519,22 +519,32 @@ nt_err_code_struct nt_errs[] =
 /*****************************************************************************
  returns an NT error message.  not amazingly helpful, but better than a number.
  *****************************************************************************/
-char *get_nt_error_msg(uint32 nt_code)
+BOOL get_safe_nt_error_msg(uint32 nt_code,char *msg, size_t len)
 {
-       static pstring msg;
        int idx = 0;
 
-       pstrcpy(msg, "Unknown NT error");
+       slprintf(msg, len-1, "NT code %08x", nt_code);
 
        while (nt_errs[idx].nt_errstr != NULL)
        {
                if ((nt_errs[idx].nt_errcode & 0xFFFFFF) == (nt_code & 0xFFFFFF))
                {
-                       pstrcpy(msg, nt_errs[idx].nt_errstr);
-                       return msg;
+                       safe_strcpy(msg, nt_errs[idx].nt_errstr, len);
+                       return True;
                }
                idx++;
        }
-       return msg;
+       return False;
 }
 
+/*****************************************************************************
+ returns an NT error message.  not amazingly helpful, but better than a number.
+ *****************************************************************************/
+const char *get_nt_error_msg(uint32 nt_code)
+{
+        static pstring msg;
+        get_safe_nt_error_msg(nt_code, msg, sizeof(msg));
+        return msg;
+}
+
+
index 1c5f8b51761aac3b69f753347dc9c681dc0b88db..26b1d192f09c1eaa09df484996b02f4948c1aaff 100644 (file)
@@ -40,6 +40,15 @@ void pwd_init(struct pwd_info *pwd)
        pwd->crypted   = False;
 }
 
+/****************************************************************************
+returns NULL password flag
+****************************************************************************/
+BOOL pwd_is_nullpwd(const struct pwd_info *pwd)
+{
+        return pwd->null_pwd;
+}
+
+
 /****************************************************************************
 compares two passwords.  hmm, not as trivial as expected.  hmm.
 ****************************************************************************/