[SCM] Samba Shared Repository - branch master updated
Volker Lendecke
vlendec at samba.org
Sun Oct 24 15:29:01 MDT 2010
The branch, master has been updated
via caf77f7 s3: Use cli_setpathinfo in cli_posix_unlink_internal
via 2d51a24 s3: Avoid passing down a boolean to cli_posix_unlink_internal_send
via 28e243f s3: Use cli_setpathinfo in cli_posix_chown_chmod_internal
via dedda3e s3: Use cli_setpathinfo in cli_posix_link_internal
via c0a6b74 s3: Use tevent_req_simple_recv_ntstatus where appropriate
via 64275eb s3: Pass down a level instead of a flag to cli_posix_link_internal
via 7b3fccd s3: Add async cli_setpathinfo
via 40cc1a3 s3: Add "setea" to smbclient
via 86cb0ad s3: Add "geteas" to smbclient
via 0831807 Add dump_data_cb()
via 611bcfc Add print_asc_cb()
from 9e7bcaa s4-test: Print correct partition DN in msDSIntId test
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit caf77f7c73419064b3a4cea68d0b8591a4ec486a
Author: Volker Lendecke <vl at samba.org>
Date: Sun Oct 24 18:32:29 2010 +0200
s3: Use cli_setpathinfo in cli_posix_unlink_internal
Autobuild-User: Volker Lendecke <vlendec at samba.org>
Autobuild-Date: Sun Oct 24 21:28:08 UTC 2010 on sn-devel-104
commit 2d51a24ba51934e1a9264ced1d52648a5c4c2cfc
Author: Volker Lendecke <vl at samba.org>
Date: Sun Oct 24 18:27:25 2010 +0200
s3: Avoid passing down a boolean to cli_posix_unlink_internal_send
commit 28e243f7ad1a0b645a00bb92b43638af5bfe8b8d
Author: Volker Lendecke <vl at samba.org>
Date: Sun Oct 24 18:05:03 2010 +0200
s3: Use cli_setpathinfo in cli_posix_chown_chmod_internal
commit dedda3e245d9ee2a875494d0f3c42c44e749f4f6
Author: Volker Lendecke <vl at samba.org>
Date: Sun Oct 24 17:06:47 2010 +0200
s3: Use cli_setpathinfo in cli_posix_link_internal
commit c0a6b74aa4cb1c3833353b28b22b83df59955cfd
Author: Volker Lendecke <vl at samba.org>
Date: Sun Oct 24 16:59:56 2010 +0200
s3: Use tevent_req_simple_recv_ntstatus where appropriate
commit 64275ebe898e4ac47ec00e49d24e37b914527734
Author: Volker Lendecke <vl at samba.org>
Date: Sun Oct 24 16:56:34 2010 +0200
s3: Pass down a level instead of a flag to cli_posix_link_internal
commit 7b3fccd5b4342494a33081f88b5069b2af9749de
Author: Volker Lendecke <vl at samba.org>
Date: Sun Oct 24 16:45:54 2010 +0200
s3: Add async cli_setpathinfo
commit 40cc1a3d2e4d63153730a03d89cca8c936a2e06c
Author: Volker Lendecke <vl at samba.org>
Date: Sun Oct 24 15:43:34 2010 +0200
s3: Add "setea" to smbclient
commit 86cb0ad242002014a4bfcdd9d0b40a3d3d172b81
Author: Volker Lendecke <vl at samba.org>
Date: Sun Oct 24 13:32:30 2010 +0200
s3: Add "geteas" to smbclient
commit 0831807782e01d8fb6e4e5ebcd46c014dc3ab599
Author: Volker Lendecke <vl at samba.org>
Date: Sun Oct 24 15:42:45 2010 +0200
Add dump_data_cb()
commit 611bcfcb49f3a17ac7a1b866b2ea04806c7c1b40
Author: Volker Lendecke <vl at samba.org>
Date: Sun Oct 24 15:23:41 2010 +0200
Add print_asc_cb()
-----------------------------------------------------------------------
Summary of changes:
lib/util/util.c | 85 ++++++++---
lib/util/util.h | 11 ++
source3/client/client.c | 106 +++++++++++++
source3/include/proto.h | 9 +
source3/libsmb/clifile.c | 368 ++++++++++++++++++----------------------------
5 files changed, 332 insertions(+), 247 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/util/util.c b/lib/util/util.c
index 11bb315..42beed4 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -300,29 +300,46 @@ _PUBLIC_ bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type)
return true;
}
-void print_asc(int level, const uint8_t *buf,int len)
+static void debugadd_cb(const char *buf, void *private_data)
+{
+ int *plevel = (int *)private_data;
+ DEBUGADD(*plevel, ("%s", buf));
+}
+
+void print_asc_cb(const uint8_t *buf, int len,
+ void (*cb)(const char *buf, void *private_data),
+ void *private_data)
{
int i;
- for (i=0;i<len;i++)
- DEBUGADD(level,("%c", isprint(buf[i])?buf[i]:'.'));
+ char s[2];
+ s[1] = 0;
+
+ for (i=0; i<len; i++) {
+ s[0] = isprint(buf[i]) ? buf[i] : '.';
+ cb(s, private_data);
+ }
+}
+
+void print_asc(int level, const uint8_t *buf,int len)
+{
+ print_asc_cb(buf, len, debugadd_cb, &level);
}
/**
- * Write dump of binary data to the log file.
- *
- * The data is only written if the log level is at least level.
+ * Write dump of binary data to a callback
*/
-static void _dump_data(int level, const uint8_t *buf, int len,
- bool omit_zero_bytes)
+void dump_data_cb(const uint8_t *buf, int len,
+ bool omit_zero_bytes,
+ void (*cb)(const char *buf, void *private_data),
+ void *private_data)
{
int i=0;
static const uint8_t empty[16] = { 0, };
bool skipped = false;
+ char tmp[16];
if (len<=0) return;
- if (!DEBUGLVL(level)) return;
-
for (i=0;i<len;) {
if (i%16 == 0) {
@@ -336,23 +353,30 @@ static void _dump_data(int level, const uint8_t *buf, int len,
}
if (i<len) {
- DEBUGADD(level,("[%04X] ",i));
+ snprintf(tmp, sizeof(tmp), "[%04X] ", i);
+ cb(tmp, private_data);
}
}
- DEBUGADD(level,("%02X ",(int)buf[i]));
+ snprintf(tmp, sizeof(tmp), "%02X ", (int)buf[i]);
+ cb(tmp, private_data);
i++;
- if (i%8 == 0) DEBUGADD(level,(" "));
+ if (i%8 == 0) {
+ cb(" ", private_data);
+ }
if (i%16 == 0) {
- print_asc(level,&buf[i-16],8); DEBUGADD(level,(" "));
- print_asc(level,&buf[i-8],8); DEBUGADD(level,("\n"));
+ print_asc_cb(&buf[i-16], 8, cb, private_data);
+ cb(" ", private_data);
+ print_asc_cb(&buf[i-8], 8, cb, private_data);
+ cb("\n", private_data);
if ((omit_zero_bytes == true) &&
(len > i+16) &&
(memcmp(&buf[i], &empty, 16) == 0)) {
if (!skipped) {
- DEBUGADD(level,("skipping zero buffer bytes\n"));
+ cb("skipping zero buffer bytes\n",
+ private_data);
skipped = true;
}
}
@@ -362,14 +386,21 @@ static void _dump_data(int level, const uint8_t *buf, int len,
if (i%16) {
int n;
n = 16 - (i%16);
- DEBUGADD(level,(" "));
- if (n>8) DEBUGADD(level,(" "));
- while (n--) DEBUGADD(level,(" "));
+ cb(" ", private_data);
+ if (n>8) {
+ cb(" ", private_data);
+ }
+ while (n--) {
+ cb(" ", private_data);
+ }
n = MIN(8,i%16);
- print_asc(level,&buf[i-(i%16)],n); DEBUGADD(level,( " " ));
+ print_asc_cb(&buf[i-(i%16)], n, cb, private_data);
+ cb(" ", private_data);
n = (i%16) - n;
- if (n>0) print_asc(level,&buf[i-n],n);
- DEBUGADD(level,("\n"));
+ if (n>0) {
+ print_asc_cb(&buf[i-n], n, cb, private_data);
+ }
+ cb("\n", private_data);
}
}
@@ -381,7 +412,10 @@ static void _dump_data(int level, const uint8_t *buf, int len,
*/
_PUBLIC_ void dump_data(int level, const uint8_t *buf, int len)
{
- _dump_data(level, buf, len, false);
+ if (!DEBUGLVL(level)) {
+ return;
+ }
+ dump_data_cb(buf, len, false, debugadd_cb, &level);
}
/**
@@ -392,7 +426,10 @@ _PUBLIC_ void dump_data(int level, const uint8_t *buf, int len)
*/
_PUBLIC_ void dump_data_skip_zeros(int level, const uint8_t *buf, int len)
{
- _dump_data(level, buf, len, true);
+ if (!DEBUGLVL(level)) {
+ return;
+ }
+ dump_data_cb(buf, len, true, debugadd_cb, &level);
}
diff --git a/lib/util/util.h b/lib/util/util.h
index c613e65..c407d60 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -674,6 +674,14 @@ _PUBLIC_ bool process_exists_by_pid(pid_t pid);
_PUBLIC_ bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type);
/**
+ * Write dump of binary data to a callback
+ */
+void dump_data_cb(const uint8_t *buf, int len,
+ bool omit_zero_bytes,
+ void (*cb)(const char *buf, void *private_data),
+ void *private_data);
+
+/**
* Write dump of binary data to the log file.
*
* The data is only written if the log level is at least level.
@@ -840,6 +848,9 @@ bool pm_process( const char *fileName,
bool unmap_file(void *start, size_t size);
void print_asc(int level, const uint8_t *buf,int len);
+void print_asc_cb(const uint8_t *buf, int len,
+ void (*cb)(const char *buf, void *private_data),
+ void *private_data);
/**
* Add an id to an array of ids.
diff --git a/source3/client/client.c b/source3/client/client.c
index 761d8d3..d69e55c 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -3231,6 +3231,108 @@ static int cmd_getfacl(void)
return 0;
}
+static void printf_cb(const char *buf, void *private_data)
+{
+ printf("%s", buf);
+}
+
+/****************************************************************************
+ Get the EA list of a file
+****************************************************************************/
+
+static int cmd_geteas(void)
+{
+ TALLOC_CTX *ctx = talloc_tos();
+ char *src = NULL;
+ char *name = NULL;
+ char *targetname = NULL;
+ struct cli_state *targetcli;
+ NTSTATUS status;
+ size_t i, num_eas;
+ struct ea_struct *eas;
+
+ if (!next_token_talloc(ctx, &cmd_ptr,&name,NULL)) {
+ d_printf("geteas filename\n");
+ return 1;
+ }
+ src = talloc_asprintf(ctx,
+ "%s%s",
+ client_get_cur_dir(),
+ name);
+ if (!src) {
+ return 1;
+ }
+
+ if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetname)) {
+ d_printf("stat %s: %s\n", src, cli_errstr(cli));
+ return 1;
+ }
+
+ status = cli_get_ea_list_path(targetcli, targetname, talloc_tos(),
+ &num_eas, &eas);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("cli_get_ea_list_path: %s\n", nt_errstr(status));
+ return 1;
+ }
+
+ for (i=0; i<num_eas; i++) {
+ d_printf("%s (%d) =\n", eas[i].name, (int)eas[i].flags);
+ dump_data_cb(eas[i].value.data, eas[i].value.length, false,
+ printf_cb, NULL);
+ d_printf("\n");
+ }
+
+ TALLOC_FREE(eas);
+
+ return 0;
+}
+
+/****************************************************************************
+ Set an EA of a file
+****************************************************************************/
+
+static int cmd_setea(void)
+{
+ TALLOC_CTX *ctx = talloc_tos();
+ char *src = NULL;
+ char *name = NULL;
+ char *eaname = NULL;
+ char *eavalue = NULL;
+ char *targetname = NULL;
+ struct cli_state *targetcli;
+
+ if (!next_token_talloc(ctx, &cmd_ptr, &name, NULL)
+ || !next_token_talloc(ctx, &cmd_ptr, &eaname, NULL)) {
+ d_printf("setea filename eaname value\n");
+ return 1;
+ }
+ if (!next_token_talloc(ctx, &cmd_ptr, &eavalue, NULL)) {
+ eavalue = talloc_strdup(ctx, "");
+ }
+ src = talloc_asprintf(ctx,
+ "%s%s",
+ client_get_cur_dir(),
+ name);
+ if (!src) {
+ return 1;
+ }
+
+ if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetname)) {
+ d_printf("stat %s: %s\n", src, cli_errstr(cli));
+ return 1;
+ }
+
+ if (!cli_set_ea_path(targetcli, targetname, eaname, eavalue,
+ strlen(eavalue))) {
+ d_printf("set_ea %s: %s\n", src, cli_errstr(cli));
+ return 1;
+ }
+
+ return 0;
+}
+
/****************************************************************************
UNIX stat.
****************************************************************************/
@@ -4070,6 +4172,8 @@ static struct {
{"exit",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}},
{"get",cmd_get,"<remote name> [local name] get a file",{COMPL_REMOTE,COMPL_LOCAL}},
{"getfacl",cmd_getfacl,"<file name> get the POSIX ACL on a file (UNIX extensions only)",{COMPL_REMOTE,COMPL_LOCAL}},
+ {"geteas", cmd_geteas, "<file name> get the EA list of a file",
+ {COMPL_REMOTE, COMPL_LOCAL}},
{"hardlink",cmd_hardlink,"<src> <dest> create a Windows hard link",{COMPL_REMOTE,COMPL_REMOTE}},
{"help",cmd_help,"[command] give help on a command",{COMPL_NONE,COMPL_NONE}},
{"history",cmd_history,"displays the command history",{COMPL_NONE,COMPL_NONE}},
@@ -4110,6 +4214,8 @@ static struct {
{"rm",cmd_del,"<mask> delete all matching files",{COMPL_REMOTE,COMPL_NONE}},
{"rmdir",cmd_rmdir,"<directory> remove a directory",{COMPL_NONE,COMPL_NONE}},
{"showacls",cmd_showacls,"toggle if ACLs are shown or not",{COMPL_NONE,COMPL_NONE}},
+ {"setea", cmd_setea, "<file name> <eaname> <eaval> Set an EA of a file",
+ {COMPL_REMOTE, COMPL_LOCAL}},
{"setmode",cmd_setmode,"filename <setmode string> change modes of file",{COMPL_REMOTE,COMPL_NONE}},
{"stat",cmd_stat,"filename Do a UNIX extensions stat call on a file",{COMPL_REMOTE,COMPL_REMOTE}},
{"symlink",cmd_symlink,"<oldname> <newname> create a UNIX symlink",{COMPL_REMOTE,COMPL_REMOTE}},
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 0c05e6e..97e1923 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1768,6 +1768,15 @@ bool cli_state_is_connected(struct cli_state *cli);
/* The following definitions come from libsmb/clifile.c */
+struct tevent_req *cli_setpathinfo_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli,
+ uint16_t level,
+ const char *path,
+ uint8_t *data,
+ size_t data_len);
+NTSTATUS cli_setpathinfo_recv(struct tevent_req *req);
+
struct tevent_req *cli_posix_symlink_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct cli_state *cli,
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 6ce884a..2ebe7e7 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -127,35 +127,26 @@ static uint8_t *trans2_bytes_push_str(uint8_t *buf, bool ucs2,
false, pconverted_size);
}
-/****************************************************************************
- Hard/Symlink a file (UNIX extensions).
- Creates new name (sym)linked to oldname.
-****************************************************************************/
-
-struct link_state {
+struct cli_setpathinfo_state {
uint16_t setup;
uint8_t *param;
- uint8_t *data;
};
-static void cli_posix_link_internal_done(struct tevent_req *subreq)
-{
- NTSTATUS status = cli_trans_recv(subreq, NULL, NULL, NULL, 0, NULL,
- NULL, 0, NULL, NULL, 0, NULL);
- tevent_req_simple_finish_ntstatus(subreq, status);
-}
+static void cli_setpathinfo_done(struct tevent_req *subreq);
-static struct tevent_req *cli_posix_link_internal_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
+struct tevent_req *cli_setpathinfo_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
struct cli_state *cli,
- const char *oldname,
- const char *newname,
- bool hardlink)
+ uint16_t level,
+ const char *path,
+ uint8_t *data,
+ size_t data_len)
{
- struct tevent_req *req = NULL, *subreq = NULL;
- struct link_state *state = NULL;
+ struct tevent_req *req, *subreq;
+ struct cli_setpathinfo_state *state;
- req = tevent_req_create(mem_ctx, &state, struct link_state);
+ req = tevent_req_create(mem_ctx, &state,
+ struct cli_setpathinfo_state);
if (req == NULL) {
return NULL;
}
@@ -164,46 +155,94 @@ static struct tevent_req *cli_posix_link_internal_send(TALLOC_CTX *mem_ctx,
SSVAL(&state->setup, 0, TRANSACT2_SETPATHINFO);
/* Setup param array. */
- state->param = talloc_array(state, uint8_t, 6);
+ state->param = TALLOC_ZERO_ARRAY(state, uint8_t, 6);
if (tevent_req_nomem(state->param, req)) {
return tevent_req_post(req, ev);
}
- memset(state->param, '\0', 6);
- SSVAL(state->param,0,hardlink ? SMB_SET_FILE_UNIX_HLINK : SMB_SET_FILE_UNIX_LINK);
-
- state->param = trans2_bytes_push_str(state->param, cli_ucs2(cli), newname,
- strlen(newname)+1, NULL);
+ SSVAL(state->param, 0, level);
+ state->param = trans2_bytes_push_str(
+ state->param, cli_ucs2(cli), path, strlen(path)+1, NULL);
if (tevent_req_nomem(state->param, req)) {
return tevent_req_post(req, ev);
}
+ subreq = cli_trans_send(
+ state, /* mem ctx. */
+ ev, /* event ctx. */
+ cli, /* cli_state. */
+ SMBtrans2, /* cmd. */
+ NULL, /* pipe name. */
+ -1, /* fid. */
+ 0, /* function. */
+ 0, /* flags. */
+ &state->setup, /* setup. */
+ 1, /* num setup uint16_t words. */
+ 0, /* max returned setup. */
+ state->param, /* param. */
+ talloc_get_size(state->param), /* num param. */
+ 2, /* max returned param. */
+ data, /* data. */
+ data_len, /* num data. */
+ 0); /* max returned data. */
+
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, cli_setpathinfo_done, req);
+ return req;
+}
+
+static void cli_setpathinfo_done(struct tevent_req *subreq)
+{
+ NTSTATUS status = cli_trans_recv(subreq, NULL, NULL, NULL, 0, NULL,
+ NULL, 0, NULL, NULL, 0, NULL);
+ tevent_req_simple_finish_ntstatus(subreq, status);
+}
+
+NTSTATUS cli_setpathinfo_recv(struct tevent_req *req)
+{
+ return tevent_req_simple_recv_ntstatus(req);
+}
+
+/****************************************************************************
+ Hard/Symlink a file (UNIX extensions).
+ Creates new name (sym)linked to oldname.
+****************************************************************************/
+
+struct cli_posix_link_internal_state {
+ uint8_t *data;
+};
+
+static void cli_posix_link_internal_done(struct tevent_req *subreq);
+
+static struct tevent_req *cli_posix_link_internal_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ uint16_t level,
+ const char *oldname,
+ const char *newname)
+{
+ struct tevent_req *req = NULL, *subreq = NULL;
+ struct cli_posix_link_internal_state *state = NULL;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct cli_posix_link_internal_state);
+ if (req == NULL) {
+ return NULL;
+ }
+
/* Setup data array. */
state->data = talloc_array(state, uint8_t, 0);
if (tevent_req_nomem(state->data, req)) {
return tevent_req_post(req, ev);
}
- state->data = trans2_bytes_push_str(state->data, cli_ucs2(cli), oldname,
- strlen(oldname)+1, NULL);
-
- subreq = cli_trans_send(state, /* mem ctx. */
- ev, /* event ctx. */
- cli, /* cli_state. */
- SMBtrans2, /* cmd. */
- NULL, /* pipe name. */
- -1, /* fid. */
- 0, /* function. */
- 0, /* flags. */
- &state->setup, /* setup. */
- 1, /* num setup uint16_t words. */
- 0, /* max returned setup. */
- state->param, /* param. */
- talloc_get_size(state->param), /* num param. */
- 2, /* max returned param. */
- state->data, /* data. */
- talloc_get_size(state->data), /* num data. */
- 0); /* max returned data. */
+ state->data = trans2_bytes_push_str(
+ state->data, cli_ucs2(cli), oldname, strlen(oldname)+1, NULL);
+ subreq = cli_setpathinfo_send(
+ state, ev, cli, level, newname,
+ state->data, talloc_get_size(state->data));
--
Samba Shared Repository
More information about the samba-cvs
mailing list