diff options
author | Wayne Davison <wayned@samba.org> | 2008-03-15 11:25:01 -0700 |
---|---|---|
committer | Wayne Davison <wayned@samba.org> | 2008-03-15 11:56:18 -0700 |
commit | 53936ef935e97d2036ad09b61b7040979d175469 (patch) | |
tree | 640fc0feaebe1617cf33389a98fec2e32644d5ae /rsync.c | |
parent | 7f9bf6b710362860ff801855b8939bdd28fc838f (diff) | |
download | rsync-53936ef935e97d2036ad09b61b7040979d175469.tar.gz rsync-53936ef935e97d2036ad09b61b7040979d175469.tar.bz2 rsync-53936ef935e97d2036ad09b61b7040979d175469.zip |
Fixed the use of --protect-args (-s) with a daemon.
Diffstat (limited to 'rsync.c')
-rw-r--r-- | rsync.c | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -205,6 +205,41 @@ int iconvbufs(iconv_t ic, xbuf *in, xbuf *out, int flags) } #endif +void send_protected_args(int fd, char *args[]) +{ +#ifdef ICONV_OPTION + int i, convert = ic_send != (iconv_t)-1; + xbuf outbuf, inbuf; + + if (convert) + alloc_xbuf(&outbuf, 1024); +#endif + + for (i = 0; args[i]; i++) {} /* find first NULL */ + args[i] = "rsync"; /* set a new arg0 */ + if (verbose > 1) + print_child_argv("protected args:", args + i + 1); + do { +#ifdef ICONV_OPTION + if (convert) { + INIT_XBUF_STRLEN(inbuf, args[i]); + iconvbufs(ic_send, &inbuf, &outbuf, + ICB_EXPAND_OUT | ICB_INCLUDE_BAD | ICB_INCLUDE_INCOMPLETE); + outbuf.buf[outbuf.len] = '\0'; + write_buf(fd, outbuf.buf, outbuf.len + 1); + outbuf.len = 0; + } else +#endif + write_buf(fd, args[i], strlen(args[i]) + 1); + } while (args[++i]); + write_byte(fd, 0); + +#ifdef ICONV_OPTION + if (convert) + free(outbuf.buf); +#endif +} + int read_ndx_and_attrs(int f_in, int *iflag_ptr, uchar *type_ptr, char *buf, int *len_ptr) { |