/*****************************************************/
#include "includes.h"
+#include "libsmb/libsmb.h"
#include "../librpc/gen_ndr/rap.h"
#include "../librpc/gen_ndr/svcctl.h"
+#include "libsmb/clirap.h"
+#include "../libcli/smb/smbXcli_base.h"
#define WORDSIZE 2
#define DWORDSIZE 4
return 4;
}
-static char *make_header(char *param, uint16 apinum, const char *reqfmt, const char *datafmt)
+static char *make_header(char *param, uint16_t apinum, const char *reqfmt, const char *datafmt)
{
PUTWORD(param,apinum);
if (reqfmt)
if (cli_api(cli,
param, sizeof(param), 1024, /* Param, length, maxlen */
- data, soffset, sizeof(data), /* data, length, maxlen */
+ data, soffset, data_size, /* data, length, maxlen */
&rparam, &rprcnt, /* return params, length */
&rdata, &rdrcnt)) /* return data, length */
{
PUTWORD(p, 1); /* info level */
PUTWORD(p, 0); /* pwencrypt */
- if(userinfo->passwrd)
- PUTWORD(p,MIN(strlen((const char *)userinfo->passwrd), RAP_UPASSWD_LEN));
- else
- PUTWORD(p, 0); /* password length */
+ PUTWORD(p, MIN(strlen((const char *)userinfo->passwrd),
+ RAP_UPASSWD_LEN));
p = data;
memset(data, '\0', soffset);
Call a NetFileClose2 - close open file on another session to server.
****************************************************************************/
-int cli_NetFileClose(struct cli_state *cli, uint32 file_id )
+int cli_NetFileClose(struct cli_state *cli, uint32_t file_id )
{
char *rparam = NULL;
char *rdata = NULL;
if (res == 0) {
/* nothing to do */
} else if (res == 2314){
- DEBUG(1, ("NetFileClose2 - attempt to close non-existant file open instance\n"));
+ DEBUG(1, ("NetFileClose2 - attempt to close non-existent file open instance\n"));
} else {
DEBUG(4,("NetFileClose2 res=%d\n", res));
}
workstation.
****************************************************************************/
-int cli_NetFileGetInfo(struct cli_state *cli, uint32 file_id, void (*fn)(const char *, const char *, uint16, uint16, uint32))
+int cli_NetFileGetInfo(struct cli_state *cli, uint32_t file_id, void (*fn)(const char *, const char *, uint16_t, uint16_t, uint32_t))
{
char *rparam = NULL;
char *rdata = NULL;
int cli_NetFileEnum(struct cli_state *cli, const char * user,
const char * base_path,
- void (*fn)(const char *, const char *, uint16, uint16,
- uint32))
+ void (*fn)(const char *, const char *, uint16_t, uint16_t,
+ uint32_t))
{
char *rparam = NULL;
char *rdata = NULL;
TALLOC_FREE(frame);
}
} else {
- DEBUG(4,("cli_get_pdc_name: machine %s failed the NetServerEnum call. "
- "Error was : %s.\n", cli->desthost, cli_errstr(cli) ));
+ DEBUG(4, ("cli_get_pdc_name: machine %s failed the "
+ "NetServerEnum call. Error was : %s.\n",
+ smbXcli_conn_remote_name(cli->conn),
+ win_errstr(W_ERROR(cli->rap_error))));
}
}
return(count > 0);
}
-/*************************************************************************
-*
-* Function Name: cli_get_server_domain
-*
-* PURPOSE: Remotes a NetWkstaGetInfo API call to the current server
-* requesting wksta_info_10 level information to determine
-* the domain the server belongs to. On success, this
-* routine sets the server_domain field in the cli_state structure
-* to the server's domain name.
-*
-* Dependencies: none
-*
-* Parameters:
-* cli - pointer to cli_state structure
-*
-* Returns:
-* True - success
-* False - failure
-*
-* Origins: samba 2.0.6 source/libsmb/clientgen.c cli_NetServerEnum()
-*
-************************************************************************/
-
-bool cli_get_server_domain(struct cli_state *cli)
-{
- char *rparam = NULL;
- char *rdata = NULL;
- unsigned int rdrcnt,rprcnt;
- char *p;
- char param[WORDSIZE /* api number */
- +sizeof(RAP_WWkstaGetInfo_REQ) /* req string */
- +sizeof(RAP_WKSTA_INFO_L10) /* return string */
- +WORDSIZE /* info level */
- +WORDSIZE]; /* buffer size */
- int res = -1;
-
- /* send a SMBtrans command with api NetWkstaGetInfo */
- p = make_header(param, RAP_WWkstaGetInfo,
- RAP_WWkstaGetInfo_REQ, RAP_WKSTA_INFO_L10);
- PUTWORD(p, 10); /* info level */
- PUTWORD(p, CLI_BUFFER_SIZE);
-
- if (cli_api(cli, param, PTR_DIFF(p,param), 8, /* params, length, max */
- NULL, 0, CLI_BUFFER_SIZE, /* data, length, max */
- &rparam, &rprcnt, /* return params, return size */
- &rdata, &rdrcnt)) { /* return data, return size */
- char *endp = rparam + rprcnt;
- res = GETRES(rparam, endp);
-
- if (res == 0) {
- TALLOC_CTX *frame = talloc_stackframe();
- char *server_domain;
- int converter = 0;
-
- p = rparam + WORDSIZE;
- GETWORD(p, converter, endp);
-
- p = rdata + DWORDSIZE + DWORDSIZE; /* skip computer & user names */
- endp = rdata + rdrcnt;
- p += rap_getstringp(frame,
- p,
- &server_domain,
- rdata,
- converter,
- endp);
-
- if (server_domain) {
- fstrcpy(cli->server_domain, server_domain);
- }
- TALLOC_FREE(frame);
- }
- }
-
- SAFE_FREE(rparam);
- SAFE_FREE(rdata);
-
- return(res == 0);
-}
-
-/*************************************************************************
-*
-* Function Name: cli_get_server_type
-*
-* PURPOSE: Remotes a NetServerGetInfo API call to the current server
-* requesting server_info_1 level information to retrieve
-* the server type.
-*
-* Dependencies: none
-*
-* Parameters:
-* cli - pointer to cli_state structure
-* pstype - pointer to uint32 to contain returned server type
-*
-* Returns:
-* True - success
-* False - failure
-*
-* Origins: samba 2.0.6 source/libsmb/clientgen.c cli_NetServerEnum()
-*
-************************************************************************/
-
-bool cli_get_server_type(struct cli_state *cli, uint32 *pstype)
-{
- char *rparam = NULL;
- char *rdata = NULL;
- unsigned int rdrcnt,rprcnt;
- char *p;
- char param[WORDSIZE /* api number */
- +sizeof(RAP_WserverGetInfo_REQ) /* req string */
- +sizeof(RAP_SERVER_INFO_L1) /* return string */
- +WORDSIZE /* info level */
- +WORDSIZE]; /* buffer size */
- int res = -1;
-
- /* send a SMBtrans command with api NetServerGetInfo */
- p = make_header(param, RAP_WserverGetInfo,
- RAP_WserverGetInfo_REQ, RAP_SERVER_INFO_L1);
- PUTWORD(p, 1); /* info level */
- PUTWORD(p, CLI_BUFFER_SIZE);
-
- if (cli_api(cli,
- param, PTR_DIFF(p,param), 8, /* params, length, max */
- NULL, 0, CLI_BUFFER_SIZE, /* data, length, max */
- &rparam, &rprcnt, /* return params, return size */
- &rdata, &rdrcnt /* return data, return size */
- )) {
- char *endp = rparam + rprcnt;
- res = GETRES(rparam,endp);
-
- if (res == 0 || res == ERRmoredata) {
- p = rdata;
- endp = rparam + rprcnt;
- p += 18;
- GETDWORD(p,*pstype,endp);
- *pstype &= ~SV_TYPE_LOCAL_LIST_ONLY;
- }
- }
-
- SAFE_FREE(rparam);
- SAFE_FREE(rdata);
-
- return(res == 0 || res == ERRmoredata);
-}
-
bool cli_get_server_name(TALLOC_CTX *mem_ctx, struct cli_state *cli,
char **servername)
{
* PURPOSE: Remotes a NetServerEnum2 API call to the current server
* requesting server_info_0 level information of machines
* matching the given server type. If the returned server
-* list contains the machine name contained in cli->desthost
+* list contains the machine name contained in smbXcli_conn_remote_name(->conn)
* then we conclude the server type checks out. This routine
* is useful to retrieve list of server's of a certain
* type when all you have is a null session connection and
*
************************************************************************/
-bool cli_ns_check_server_type(struct cli_state *cli, char *workgroup, uint32 stype)
+bool cli_ns_check_server_type(struct cli_state *cli, char *workgroup, uint32_t stype)
{
char *rparam = NULL;
char *rdata = NULL;
+RAP_MACHNAME_LEN]; /* workgroup */
bool found_server = false;
int res = -1;
+ const char *remote_name = smbXcli_conn_remote_name(cli->conn);
/* send a SMBtrans command with api NetServerEnum */
p = make_header(param, RAP_NetServerEnum2,
RAP_MACHNAME_LEN,
RAP_MACHNAME_LEN,
endp);
- if (strequal(ret_server, cli->desthost)) {
+ if (strequal(ret_server, remote_name)) {
found_server = true;
break;
}
}
} else {
- DEBUG(4,("cli_ns_check_server_type: machine %s failed the NetServerEnum call. "
- "Error was : %s.\n", cli->desthost, cli_errstr(cli) ));
+ DEBUG(4, ("cli_ns_check_server_type: machine %s "
+ "failed the NetServerEnum call. Error was : "
+ "%s.\n", remote_name,
+ win_errstr(W_ERROR(cli->rap_error))));
}
}
PUTDWORD(p, 0); /* Null pointer */
PUTDWORD(p, 0); /* Null pointer */
strlcpy(upperbuf, user, sizeof(upperbuf));
- strupper_m(upperbuf);
+ if (!strupper_m(upperbuf)) {
+ return false;
+ }
tmp = upperbuf;
PUTSTRINGF(p, tmp, RAP_USERNAME_LEN);
p++; /* strange format, but ok */
strlcpy(upperbuf, workstation, sizeof(upperbuf));
- strupper_m(upperbuf);
+ if (!strupper_m(upperbuf)) {
+ return false;
+ }
tmp = upperbuf;
PUTSTRINGF(p, tmp, RAP_MACHNAME_LEN);
PUTWORD(p, CLI_BUFFER_SIZE);
}
int cli_NetPrintQEnum(struct cli_state *cli,
- void (*qfn)(const char*,uint16,uint16,uint16,const char*,const char*,const char*,const char*,const char*,uint16,uint16),
- void (*jfn)(uint16,const char*,const char*,const char*,const char*,uint16,uint16,const char*,unsigned int,unsigned int,const char*))
+ void (*qfn)(const char*,uint16_t,uint16_t,uint16_t,const char*,const char*,const char*,const char*,const char*,uint16_t,uint16_t),
+ void (*jfn)(uint16_t,const char*,const char*,const char*,const char*,uint16_t,uint16_t,const char*,unsigned int,unsigned int,const char*))
{
char param[WORDSIZE /* api number */
+sizeof(RAP_NetPrintQEnum_REQ) /* req string */
if (jobcount) {
int j;
for (j=0;j<jobcount;j++) {
- uint16 jid = 0, pos = 0, fsstatus = 0;
+ uint16_t jid = 0, pos = 0, fsstatus = 0;
char ownername[RAP_USERNAME_LEN];
char notifyname[RAP_MACHNAME_LEN];
char datatype[RAP_DATATYPE_LEN];
}
int cli_NetPrintQGetInfo(struct cli_state *cli, const char *printer,
- void (*qfn)(const char*,uint16,uint16,uint16,const char*,const char*,const char*,const char*,const char*,uint16,uint16),
- void (*jfn)(uint16,const char*,const char*,const char*,const char*,uint16,uint16,const char*,unsigned int,unsigned int,const char*))
+ void (*qfn)(const char*,uint16_t,uint16_t,uint16_t,const char*,const char*,const char*,const char*,const char*,uint16_t,uint16_t),
+ void (*jfn)(uint16_t,const char*,const char*,const char*,const char*,uint16_t,uint16_t,const char*,unsigned int,unsigned int,const char*))
{
char param[WORDSIZE /* api number */
+sizeof(RAP_NetPrintQGetInfo_REQ) /* req string */
Call a NetSessionEnum - list workstations with sessions to an SMB server.
****************************************************************************/
-int cli_NetSessionEnum(struct cli_state *cli, void (*fn)(char *, char *, uint16, uint16, uint16, unsigned int, unsigned int, unsigned int, char *))
+int cli_NetSessionEnum(struct cli_state *cli, void (*fn)(char *, char *, uint16_t, uint16_t, uint16_t, unsigned int, unsigned int, unsigned int, char *))
{
char param[WORDSIZE /* api number */
+sizeof(RAP_NetSessionEnum_REQ) /* parm string */
****************************************************************************/
int cli_NetSessionGetInfo(struct cli_state *cli, const char *workstation,
- void (*fn)(const char *, const char *, uint16, uint16, uint16, unsigned int, unsigned int, unsigned int, const char *))
+ void (*fn)(const char *, const char *, uint16_t, uint16_t, uint16_t, unsigned int, unsigned int, unsigned int, const char *))
{
char param[WORDSIZE /* api number */
+sizeof(RAP_NetSessionGetInfo_REQ) /* req string */