diff options
author | Jeremy Allison <jra@samba.org> | 2019-05-18 11:18:19 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-05-24 19:00:05 +0000 |
commit | 61054e53f53e5884902b566b1f9b454a3ff4741f (patch) | |
tree | 6d174fbb31d3320631cca3b52f6e63228ab47f54 /source3 | |
parent | c5729ae44219ec81008040d4d50f0f5fdf254201 (diff) | |
download | samba-61054e53f53e5884902b566b1f9b454a3ff4741f.tar.gz |
s3: lib: Add file_ploadv_send().
Not yet used. Preparing to remove file_pload_send()
with this safer alternative.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13964
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/util_file.c | 29 | ||||
-rw-r--r-- | source3/lib/util_file.h | 3 |
2 files changed, 32 insertions, 0 deletions
diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c index 8f91f7d00fb..6ee2d58b532 100644 --- a/source3/lib/util_file.c +++ b/source3/lib/util_file.c @@ -65,6 +65,35 @@ struct tevent_req *file_pload_send(TALLOC_CTX *mem_ctx, return req; } +struct tevent_req *file_ploadv_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + char * const argl[], size_t maxsize) +{ + struct tevent_req *req = NULL, *subreq = NULL; + struct file_pload_state *state = NULL; + + req = tevent_req_create(mem_ctx, &state, struct file_pload_state); + if (req == NULL) { + return NULL; + } + state->ev = ev; + state->maxsize = maxsize; + + state->fd = sys_popenv(argl); + if (state->fd == -1) { + tevent_req_error(req, errno); + return tevent_req_post(req, ev); + } + talloc_set_destructor(state, file_pload_state_destructor); + + subreq = wait_for_read_send(state, state->ev, state->fd, false); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, file_pload_readable, req); + return req; +} + static int file_pload_state_destructor(struct file_pload_state *s) { if (s->fd != -1) { diff --git a/source3/lib/util_file.h b/source3/lib/util_file.h index 9cf00aae893..fe2782fd349 100644 --- a/source3/lib/util_file.h +++ b/source3/lib/util_file.h @@ -26,6 +26,9 @@ struct tevent_req *file_pload_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, const char *syscmd, size_t maxsize); +struct tevent_req *file_ploadv_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + char * const argl[], size_t maxsize); int file_pload_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, uint8_t **buf); char **file_lines_ploadv(TALLOC_CTX *mem_ctx, |