#include "../libcli/smbreadline/smbreadline.h"
#include "../libcli/security/security.h"
#include "system/select.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
#include "trans2.h"
+#include "libsmb/nmblib.h"
+#include "include/ntioctl.h"
#ifndef REGISTER
#define REGISTER 0
static int port = 0;
static char *service;
static char *desthost;
-static char *calling_name;
static bool grepable = false;
static char *cmdstr = NULL;
const char *cmd_ptr = NULL;
TALLOC_CTX *ctx = talloc_tos();
NTSTATUS status;
- if ( !cli_resolve_path(ctx, "", auth_info, cli, client_get_cur_dir(), &targetcli, &targetpath)) {
- d_printf("Error in dskattr: %s\n", cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli,
+ client_get_cur_dir(), &targetcli,
+ &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("Error in dskattr: %s\n", nt_errstr(status));
return 1;
}
uint32 attributes;
int ret = 1;
TALLOC_CTX *ctx = talloc_stackframe();
+ NTSTATUS status;
newdir = talloc_strdup(ctx, new_dir);
if (!newdir) {
new_cd = clean_name(ctx, new_cd);
client_set_cur_dir(new_cd);
- if ( !cli_resolve_path(ctx, "", auth_info, cli, new_cd, &targetcli, &targetpath)) {
- d_printf("cd %s: %s\n", new_cd, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, new_cd,
+ &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("cd %s: %s\n", new_cd, nt_errstr(status));
client_set_cur_dir(saved_dir);
goto out;
}
Except Win9x doesn't support the qpathinfo_basic() call..... */
if (targetcli->protocol > PROTOCOL_LANMAN2 && !targetcli->win95) {
- NTSTATUS status;
status = cli_qpathinfo_basic(targetcli, targetpath, &sbuf,
&attributes);
goto out;
}
} else {
- NTSTATUS status;
targetpath = talloc_asprintf(ctx,
"%s%s",
return false;
}
- if (finfo->mode & aDIR) {
+ if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
return true;
}
return false;
}
- if ((archive_level==1 || archive_level==2) && !(finfo->mode & aARCH)) {
+ if ((archive_level==1 || archive_level==2) && !(finfo->mode & FILE_ATTRIBUTE_ARCHIVE)) {
DEBUG(3,("archive %s failed\n", finfo->name));
return false;
}
if (!showacls) {
d_printf(" %-30s%7.7s %8.0f %s",
finfo->name,
- attrib_string(finfo->mode),
+ attrib_string(talloc_tos(), finfo->mode),
(double)finfo->size,
time_to_asc(t));
dir_total += finfo->size;
}
/* print file meta date header */
d_printf( "FILENAME:%s\n", finfo->name);
- d_printf( "MODE:%s\n", attrib_string(finfo->mode));
+ d_printf( "MODE:%s\n", attrib_string(talloc_tos(), finfo->mode));
d_printf( "SIZE:%.0f\n", (double)finfo->size);
d_printf( "MTIME:%s", time_to_asc(t));
status = cli_ntcreate(cli_state, afname, 0,
}
}
if (do_list_queue) {
- safe_strcpy_base(do_list_queue + do_list_queue_end,
+ strlcpy_base(do_list_queue + do_list_queue_end,
entry, do_list_queue, do_list_queue_size);
do_list_queue_end = new_end;
DEBUG(4,("added %s to do_list_queue (start=%d, end=%d)\n",
*dir_end = '\0';
}
- if (f->mode & aDIR) {
+ if (f->mode & FILE_ATTRIBUTE_DIRECTORY) {
if (do_list_dirs && do_this_one(f)) {
status = do_list_fn(cli_state, f, dir);
if (!NT_STATUS_IS_OK(status)) {
/* check for dfs */
- if ( !cli_resolve_path(ctx, "", auth_info, cli, head, &targetcli, &targetpath ) ) {
- d_printf("do_list: [%s] %s\n", head, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli,
+ head, &targetcli,
+ &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("do_list: [%s] %s\n", head,
+ nt_errstr(status));
remove_do_list_queue_head();
continue;
}
}
} else {
/* check for dfs */
- if (cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetpath)) {
-
+ status = cli_resolve_path(ctx, "", auth_info, cli, mask,
+ &targetcli, &targetpath);
+ if (NT_STATUS_IS_OK(status)) {
status = cli_list(targetcli, targetpath, attribute,
do_list_helper, targetcli);
if (!NT_STATUS_IS_OK(status)) {
}
TALLOC_FREE(targetpath);
} else {
- d_printf("do_list: [%s] %s\n", mask, cli_errstr(cli));
- ret_status = cli_nt_error(cli);
+ d_printf("do_list: [%s] %s\n", mask, nt_errstr(status));
+ ret_status = status;
}
}
static int cmd_dir(void)
{
TALLOC_CTX *ctx = talloc_tos();
- uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
+ uint16 attribute = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
char *mask = NULL;
char *buf = NULL;
int rc = 1;
static int cmd_du(void)
{
TALLOC_CTX *ctx = talloc_tos();
- uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
+ uint16 attribute = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
char *mask = NULL;
char *buf = NULL;
NTSTATUS status;
strlower_m(lname);
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, rname, &targetcli, &targetname ) ) {
- d_printf("Failed to open %s: %s\n", rname, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, rname, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("Failed to open %s: %s\n", rname, nt_errstr(status));
return 1;
}
close(handle);
}
- if (archive_level >= 2 && (attr & aARCH)) {
- cli_setatr(cli, rname, attr & ~(uint16)aARCH, 0);
+ if (archive_level >= 2 && (attr & FILE_ATTRIBUTE_ARCHIVE)) {
+ cli_setatr(cli, rname, attr & ~(uint16)FILE_ATTRIBUTE_ARCHIVE, 0);
}
{
return NT_STATUS_UNSUCCESSFUL;
}
- if (finfo->mode & aDIR) {
+ if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
if (asprintf(&quest,
"Get directory %s? ",finfo->name) < 0) {
return NT_STATUS_NO_MEMORY;
}
SAFE_FREE(quest);
- if (!(finfo->mode & aDIR)) {
+ if (!(finfo->mode & FILE_ATTRIBUTE_DIRECTORY)) {
rname = talloc_asprintf(ctx,
"%s%s",
client_get_cur_dir(),
return NT_STATUS_NO_MEMORY;
}
- status = do_list(mget_mask, aSYSTEM | aHIDDEN | aDIR,do_mget,false, true);
+ status = do_list(mget_mask, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,do_mget,false, true);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
static int cmd_mget(void)
{
TALLOC_CTX *ctx = talloc_tos();
- uint16 attribute = aSYSTEM | aHIDDEN;
+ uint16 attribute = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
char *mget_mask = NULL;
char *buf = NULL;
NTSTATUS status = NT_STATUS_OK;
if (recurse) {
- attribute |= aDIR;
+ attribute |= FILE_ATTRIBUTE_DIRECTORY;
}
abort_mget = false;
char *targetname = NULL;
NTSTATUS status;
- if (!cli_resolve_path(ctx, "", auth_info, cli, name, &targetcli, &targetname)) {
- d_printf("mkdir %s: %s\n", name, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, name, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("mkdir %s: %s\n", name, nt_errstr(status));
return false;
}
TALLOC_CTX *ctx = talloc_tos();
char *mask = NULL;
char *buf = NULL;
+ NTSTATUS status;
mask = talloc_strdup(ctx, client_get_cur_dir());
if (!mask) {
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
+ status = cli_resolve_path(ctx, "", auth_info, cli, mask,
+ &targetcli, &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
return 1;
}
static char *attr_str(TALLOC_CTX *mem_ctx, uint16_t mode)
{
- char *attrs = TALLOC_ZERO_ARRAY(mem_ctx, char, 17);
+ char *attrs = talloc_zero_array(mem_ctx, char, 17);
int i = 0;
if (!(mode & FILE_ATTRIBUTE_NORMAL)) {
(unsigned long long)streams[i].size);
}
- status = cli_open(cli, name, O_RDONLY, DENY_NONE, &fnum);
+ if (mode & FILE_ATTRIBUTE_REPARSE_POINT) {
+ char *subst, *print;
+ uint32_t flags;
+
+ status = cli_readlink(cli, name, talloc_tos(), &subst, &print,
+ &flags);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, "cli_readlink returned %s\n",
+ nt_errstr(status));
+ } else {
+ d_printf("symlink: subst=[%s], print=[%s], flags=%x\n",
+ subst, print, flags);
+ TALLOC_FREE(subst);
+ TALLOC_FREE(print);
+ }
+ }
+
+ status = cli_ntcreate(cli, name, 0,
+ CREATE_ACCESS_READ, 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE
+ |FILE_SHARE_DELETE,
+ FILE_OPEN, 0x0, 0x0, &fnum);
if (!NT_STATUS_IS_OK(status)) {
/*
* Ignore failure, it does not hurt if we can't list
struct push_state state;
NTSTATUS status;
- if (!cli_resolve_path(ctx, "", auth_info, cli, rname, &targetcli, &targetname)) {
- d_printf("Failed to open %s: %s\n", rname, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, rname,
+ &targetcli, &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("Failed to open %s: %s\n", rname, nt_errstr(status));
return 1;
}
return NT_STATUS_NO_MEMORY;
}
- if (finfo->mode & aDIR) {
+ if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
TALLOC_FREE(mask);
return NT_STATUS_OK;
}
- status = cli_unlink(cli_state, mask, aSYSTEM | aHIDDEN);
+ status = cli_unlink(cli_state, mask, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
if (!NT_STATUS_IS_OK(status)) {
d_printf("%s deleting remote file %s\n",
nt_errstr(status), mask);
char *mask = NULL;
char *buf = NULL;
NTSTATUS status = NT_STATUS_OK;
- uint16 attribute = aSYSTEM | aHIDDEN;
+ uint16 attribute = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
if (recurse) {
- attribute |= aDIR;
+ attribute |= FILE_ATTRIBUTE_DIRECTORY;
}
mask = talloc_strdup(ctx, client_get_cur_dir());
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
- d_printf("cmd_wdel %s: %s\n", mask, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("cmd_wdel %s: %s\n", mask, nt_errstr(status));
return 1;
}
char *targetname = NULL;
struct cli_state *targetcli;
uint16_t fnum = (uint16_t)-1;
+ NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
d_printf("open <filename>\n");
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
- d_printf("open %s: %s\n", mask, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("open %s: %s\n", mask, nt_errstr(status));
return 1;
}
struct cli_state *targetcli;
mode_t mode;
uint16_t fnum;
+ NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
d_printf("posix_open <filename> 0<mode>\n");
}
mode = (mode_t)strtol(buf, (char **)NULL, 8);
- if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
- d_printf("posix_open %s: %s\n", mask, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("posix_open %s: %s\n", mask, nt_errstr(status));
return 1;
}
- if (!NT_STATUS_IS_OK(cli_posix_open(targetcli, targetname, O_CREAT|O_RDWR, mode, &fnum))) {
- if (!NT_STATUS_IS_OK(cli_posix_open(targetcli, targetname, O_CREAT|O_RDONLY, mode, &fnum))) {
- d_printf("posix_open file %s: for read/write fnum %d\n", targetname, fnum);
+ status = cli_posix_open(targetcli, targetname, O_CREAT|O_RDWR, mode,
+ &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ status = cli_posix_open(targetcli, targetname,
+ O_CREAT|O_RDONLY, mode, &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("Failed to open file %s. %s\n", targetname,
+ nt_errstr(status));
} else {
- d_printf("Failed to open file %s. %s\n", targetname, cli_errstr(cli));
+ d_printf("posix_open file %s: for readonly fnum %d\n",
+ targetname, fnum);
}
} else {
- d_printf("posix_open file %s: for read/write fnum %d\n", targetname, fnum);
+ d_printf("posix_open file %s: for read/write fnum %d\n",
+ targetname, fnum);
}
return 0;
char *targetname = NULL;
struct cli_state *targetcli;
mode_t mode;
+ NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
d_printf("posix_mkdir <filename> 0<mode>\n");
}
mode = (mode_t)strtol(buf, (char **)NULL, 8);
- if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
- d_printf("posix_mkdir %s: %s\n", mask, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("posix_mkdir %s: %s\n", mask, nt_errstr(status));
return 1;
}
char *buf = NULL;
char *targetname = NULL;
struct cli_state *targetcli;
+ NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
d_printf("posix_unlink <filename>\n");
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
- d_printf("posix_unlink %s: %s\n", mask, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("posix_unlink %s: %s\n", mask, nt_errstr(status));
return 1;
}
char *buf = NULL;
char *targetname = NULL;
struct cli_state *targetcli;
+ NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
d_printf("posix_rmdir <filename>\n");
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
- d_printf("posix_rmdir %s: %s\n", mask, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("posix_rmdir %s: %s\n", mask, nt_errstr(status));
return 1;
}
char *buf = NULL;
char *targetname = NULL;
struct cli_state *targetcli;
+ NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
d_printf("rmdir <dirname>\n");
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
- d_printf("rmdir %s: %s\n", mask, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("rmdir %s: %s\n", mask, nt_errstr(status));
return 1;
}
char *buf2 = NULL;
char *targetname = NULL;
struct cli_state *targetcli;
+ NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
!next_token_talloc(ctx, &cmd_ptr,&buf2,NULL)) {
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, oldname, &targetcli, &targetname)) {
- d_printf("link %s: %s\n", oldname, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, oldname, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("link %s: %s\n", oldname, nt_errstr(status));
return 1;
}
char *targetname = NULL;
char linkname[PATH_MAX+1];
struct cli_state *targetcli;
+ NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
d_printf("readlink <name>\n");
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, name, &targetcli, &targetname)) {
- d_printf("readlink %s: %s\n", name, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, name, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("readlink %s: %s\n", name, nt_errstr(status));
return 1;
}
char *buf = NULL;
char *buf2 = NULL;
struct cli_state *newcli;
+ NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
!next_token_talloc(ctx, &cmd_ptr,&buf2,NULL)) {
/* Oldname (link target) must be an untouched blob. */
oldname = buf;
- newname = talloc_asprintf(ctx,
- "%s%s",
- client_get_cur_dir(),
- buf2);
- if (!newname) {
- return 1;
- }
-
- /* New name must be present in share namespace. */
- if (!cli_resolve_path(ctx, "", auth_info, cli, newname, &newcli, &newname)) {
- d_printf("link %s: %s\n", oldname, cli_errstr(cli));
- return 1;
- }
-
- if (!SERVER_HAS_UNIX_CIFS(newcli)) {
- d_printf("Server doesn't support UNIX CIFS calls.\n");
- return 1;
+ if (SERVER_HAS_UNIX_CIFS(cli)) {
+ newname = talloc_asprintf(ctx, "%s%s", client_get_cur_dir(),
+ buf2);
+ if (!newname) {
+ return 1;
+ }
+ /* New name must be present in share namespace. */
+ status = cli_resolve_path(ctx, "", auth_info, cli, newname,
+ &newcli, &newname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("link %s: %s\n", oldname, nt_errstr(status));
+ return 1;
+ }
+ status = cli_posix_symlink(newcli, oldname, newname);
+ } else {
+ status = cli_symlink(
+ cli, oldname, buf2,
+ buf2[0] == '\\' ? 0 : SYMLINK_FLAG_RELATIVE);
}
- if (!NT_STATUS_IS_OK(cli_posix_symlink(newcli, oldname, newname))) {
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("%s symlinking files (%s -> %s)\n",
- cli_errstr(newcli), newname, newname);
+ nt_errstr(status), oldname, newname);
return 1;
}
char *targetname = NULL;
struct cli_state *targetcli;
mode_t mode;
+ NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
!next_token_talloc(ctx, &cmd_ptr,&buf2,NULL)) {
mode = (mode_t)strtol(buf, NULL, 8);
- if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname)) {
- d_printf("chmod %s: %s\n", src, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("chmod %s: %s\n", src, nt_errstr(status));
return 1;
}
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname)) {
- d_printf("stat %s: %s\n", src, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("stat %s: %s\n", src, nt_errstr(status));
return 1;
}
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
- &targetname)) {
- d_printf("stat %s: %s\n", src, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("stat %s: %s\n", src, nt_errstr(status));
return 1;
}
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
- &targetname)) {
- d_printf("stat %s: %s\n", src, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("stat %s: %s\n", src, nt_errstr(status));
return 1;
}
SMB_STRUCT_STAT sbuf;
struct tm *lt;
time_t tmp_time;
+ NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&name,NULL)) {
d_printf("stat file\n");
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname)) {
- d_printf("stat %s: %s\n", src, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("stat %s: %s\n", src, nt_errstr(status));
return 1;
}
char *buf, *buf2, *buf3;
struct cli_state *targetcli;
char *targetname = NULL;
+ NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
!next_token_talloc(ctx, &cmd_ptr,&buf2,NULL) ||
if (!src) {
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname) ) {
- d_printf("chown %s: %s\n", src, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("chown %s: %s\n", src, nt_errstr(status));
return 1;
}
struct cli_state *targetcli;
char *targetsrc;
char *targetdest;
+ NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
!next_token_talloc(ctx, &cmd_ptr,&buf2,NULL)) {
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetsrc)) {
- d_printf("rename %s: %s\n", src, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetsrc);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("rename %s: %s\n", src, nt_errstr(status));
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, dest, &targetcli, &targetdest)) {
- d_printf("rename %s: %s\n", dest, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, dest, &targetcli,
+ &targetdest);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("rename %s: %s\n", dest, nt_errstr(status));
return 1;
}
static int cmd_volume(void)
{
- fstring volname;
- uint32 serial_num;
+ char *volname;
+ uint32_t serial_num;
time_t create_date;
NTSTATUS status;
- status = cli_get_fs_volume_info(cli, volname, &serial_num,
+ status = cli_get_fs_volume_info(cli, talloc_tos(),
+ &volname, &serial_num,
&create_date);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Error %s getting volume info\n", nt_errstr(status));
char *buf, *buf2;
struct cli_state *targetcli;
char *targetname;
+ NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
!next_token_talloc(ctx, &cmd_ptr,&buf2,NULL)) {
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname)) {
- d_printf("hardlink %s: %s\n", src, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("hardlink %s: %s\n", src, nt_errstr(status));
return 1;
}
buf, strerror(errno));
}
}
- d = TALLOC_ARRAY(ctx, char, PATH_MAX+1);
+ d = sys_getwd();
if (!d) {
return 1;
}
- DEBUG(2,("the local directory is now %s\n",sys_getwd(d)));
+ DEBUG(2,("the local directory is now %s\n",d));
+ SAFE_FREE(d);
return 0;
}
TALLOC_CTX *ctx = talloc_tos();
struct cli_state *targetcli;
char *targetpath;
+ NTSTATUS status;
- if (!cli_resolve_path(ctx, "", auth_info, cli, client_get_cur_dir(),
- &targetcli, &targetpath ) ) {
- d_printf("showconnect %s: %s\n", cur_dir, cli_errstr(cli));
+ status = cli_resolve_path(ctx, "", auth_info, cli,
+ client_get_cur_dir(), &targetcli,
+ &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("showconnect %s: %s\n", cur_dir, nt_errstr(status));
return 1;
}
/* establish the connection if not already */
if (!cli) {
- cli = cli_cm_open(talloc_tos(), NULL,
- have_ip ? dest_ss_str : desthost,
- service, auth_info,
- true, smb_encrypt,
- max_protocol, port, name_type);
- if (!cli) {
+ NTSTATUS status;
+
+ status = cli_cm_open(talloc_tos(), NULL,
+ have_ip ? dest_ss_str : desthost,
+ service, auth_info,
+ true, smb_encrypt,
+ max_protocol, port, name_type,
+ &cli);
+ if (!NT_STATUS_IS_OK(status)) {
return 1;
}
}
return NT_STATUS_OK;
}
- if ((info->dirmask[0] == 0) && !(f->mode & aDIR))
+ if ((info->dirmask[0] == 0) && !(f->mode & FILE_ATTRIBUTE_DIRECTORY))
info->matches[info->count] = SMB_STRDUP(f->name);
else {
TALLOC_CTX *ctx = talloc_stackframe();
TALLOC_FREE(ctx);
return NT_STATUS_NO_MEMORY;
}
- if (f->mode & aDIR) {
+ if (f->mode & FILE_ATTRIBUTE_DIRECTORY) {
tmp = talloc_asprintf_append(tmp, "%s",
CLI_DIRSEP_STR);
}
if (info->matches[info->count] == NULL) {
return NT_STATUS_OK;
}
- if (f->mode & aDIR) {
+ if (f->mode & FILE_ATTRIBUTE_DIRECTORY) {
smb_readline_ca_char(0);
}
if (info->count == 1) {
goto cleanup;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, dirmask, &targetcli, &targetpath)) {
+ status = cli_resolve_path(ctx, "", auth_info, cli, dirmask, &targetcli,
+ &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
goto cleanup;
}
- status = cli_list(targetcli, targetpath, aDIR | aSYSTEM | aHIDDEN,
+ status = cli_list(targetcli, targetpath, FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN,
completion_remote_filter, (void *)&info);
if (!NT_STATUS_IS_OK(status)) {
goto cleanup;
static int process(const char *base_directory)
{
int rc = 0;
+ NTSTATUS status;
- cli = cli_cm_open(talloc_tos(), NULL,
- have_ip ? dest_ss_str : desthost,
- service, auth_info, true, smb_encrypt,
- max_protocol, port, name_type);
- if (!cli) {
+ status = cli_cm_open(talloc_tos(), NULL,
+ have_ip ? dest_ss_str : desthost,
+ service, auth_info, true, smb_encrypt,
+ max_protocol, port, name_type, &cli);
+ if (!NT_STATUS_IS_OK(status)) {
return 1;
}
static int do_host_query(const char *query_host)
{
- cli = cli_cm_open(talloc_tos(), NULL,
- have_ip ? dest_ss_str : query_host, "IPC$", auth_info, true, smb_encrypt,
- max_protocol, port, name_type);
- if (!cli)
+ NTSTATUS status;
+
+ status = cli_cm_open(talloc_tos(), NULL,
+ have_ip ? dest_ss_str : query_host,
+ "IPC$", auth_info, true, smb_encrypt,
+ max_protocol, port, name_type, &cli);
+ if (!NT_STATUS_IS_OK(status)) {
return 1;
+ }
browse_host(true);
else but port 139... */
cli_shutdown(cli);
- cli = cli_cm_open(talloc_tos(), NULL,
- have_ip ? dest_ss_str : query_host, "IPC$",
- auth_info, true, smb_encrypt,
- max_protocol, 139, name_type);
+ status = cli_cm_open(talloc_tos(), NULL,
+ have_ip ? dest_ss_str : query_host,
+ "IPC$", auth_info, true, smb_encrypt,
+ max_protocol, 139, name_type, &cli);
+ if (!NT_STATUS_IS_OK(status)) {
+ cli = NULL;
+ }
}
if (cli == NULL) {
/* do we already have a connection? */
if (!cli) {
- cli = cli_cm_open(talloc_tos(), NULL,
- have_ip ? dest_ss_str : desthost,
- service, auth_info, true, smb_encrypt,
- max_protocol, port, name_type);
- if (!cli)
+ NTSTATUS status;
+
+ status = cli_cm_open(talloc_tos(), NULL,
+ have_ip ? dest_ss_str : desthost,
+ service, auth_info, true, smb_encrypt,
+ max_protocol, port, name_type, &cli);
+ if (!NT_STATUS_IS_OK(status)) {
return 1;
+ }
}
recurse=true;
static int do_message_op(struct user_auth_info *a_info)
{
- struct sockaddr_storage ss;
- struct nmb_name called, calling;
- fstring server_name;
- char name_type_hex[10];
- int msg_port;
NTSTATUS status;
- make_nmb_name(&calling, calling_name, 0x0);
- make_nmb_name(&called , desthost, name_type);
-
- fstrcpy(server_name, desthost);
- snprintf(name_type_hex, sizeof(name_type_hex), "#%X", name_type);
- fstrcat(server_name, name_type_hex);
-
- zero_sockaddr(&ss);
- if (have_ip)
- ss = dest_ss;
-
- /* we can only do messages over port 139 (to windows clients at least) */
-
- msg_port = port ? port : 139;
-
- if (!(cli=cli_initialise())) {
- d_printf("Connection to %s failed\n", desthost);
- return 1;
- }
- cli_set_port(cli, msg_port);
-
- status = cli_connect(cli, server_name, &ss);
+ status = cli_connect_nb(desthost, have_ip ? &dest_ss : NULL,
+ port ? port : 139, name_type,
+ lp_netbios_name(), Undefined, &cli);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Connection to %s failed. Error %s\n", desthost, nt_errstr(status));
return 1;
}
- if (!cli_session_request(cli, &calling, &called)) {
- d_printf("session request failed\n");
- cli_shutdown(cli);
- return 1;
- }
-
send_message(get_cmdline_auth_info_username(a_info));
cli_shutdown(cli);
poptContext pc;
char *p;
int rc = 0;
- fstring new_workgroup;
bool tar_opt = false;
bool service_opt = false;
struct poptOption long_options[] = {
exit(ENOMEM);
}
- /* initialize the workgroup name so we can determine whether or
- not it was set by a command line option */
-
- set_global_myworkgroup( "" );
- set_global_myname( "" );
-
/* set default debug level to 1 regardless of what smb.conf sets */
setup_logging( "smbclient", DEBUG_DEFAULT_STDERR );
load_case_tables();
poptGetArg(pc));
}
- /* save the workgroup...
-
- FIXME!! do we need to do this for other options as well
- (or maybe a generic way to keep lp_load() from overwriting
- everything)? */
-
- fstrcpy( new_workgroup, lp_workgroup() );
- calling_name = talloc_strdup(frame, global_myname() );
- if (!calling_name) {
- exit(ENOMEM);
- }
-
if ( override_logfile )
setup_logging( lp_logfile(), DEBUG_FILE );
}
}
- if ( strlen(new_workgroup) != 0 ) {
- set_global_myworkgroup( new_workgroup );
- }
-
- if ( strlen(calling_name) != 0 ) {
- set_global_myname( calling_name );
- } else {
- TALLOC_FREE(calling_name);
- calling_name = talloc_strdup(frame, global_myname() );
- }
-
smb_encrypt = get_cmdline_auth_info_smb_encrypt(auth_info);
if (!init_names()) {
fprintf(stderr, "init_names() failed\n");