The Samba-Bugzilla – Attachment 3116 Details for
Bug 5220
Syntax to access a daemon over a socket supplied on a fd
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
This patch implements the described feature
specify-fd.patch (text/plain), 3.70 KB, created by
Davy Durham
on 2008-01-21 22:35:44 UTC
(
hide
)
Description:
This patch implements the described feature
Filename:
MIME Type:
Creator:
Davy Durham
Created:
2008-01-21 22:35:44 UTC
Size:
3.70 KB
patch
obsolete
>diff -aur rsync-3.0.0pre8.orig/rsync.1 rsync-3.0.0pre8/rsync.1 >--- rsync-3.0.0pre8.orig/rsync.1 2008-01-21 19:34:20.000000000 -0600 >+++ rsync-3.0.0pre8/rsync.1 2008-01-21 22:20:56.000000000 -0600 >@@ -263,6 +263,37 @@ > WARNING: On some systems environment variables are visible to all > users. On those systems using \fB\-\-password\-file\fP is recommended. > .PP >+You may also specify a file descriptor number to use for the communications >+channel to the daemon. This is done by specifying a hostname of '&<integer>'. >+When doing this rsync does NOT make a TCP connection but rather uses the file >+descriptor number specified by the given integer and assumes this is an already >+connected socket (or other bi-directional handle) to the daemon. Values of >+1 and 2 may not be specified as these are used for rsync's logging. This >+feature is useful when some other application is going to make a connection on >+behalf of rsync (possibly pre-communicating with the other end) and then execute >+rsync letting it inherit the connected socket handle. >+ >+Be sure that when rsync is executed that stdout and stderr are not also >+referencing the same connection (as some programs using this model may do) since >+rsync will be logging to stdout and/or stderr. >+ >+Be sure to properly quote the '&' character on the command shell since it would >+otherwise be interpreted to use everything preceding it as a command to be >+executed in the background. >+ >+For example: >+.PP >+.nf >+ #!/bin/sh >+ # make sure stdout also goes to stderr in case it was also opened to stdin >+ rsync \-va '&0'::module/src/ /dest/ 1>&2 >+.fi >+ >+.PP >+The script above inherits file descriptor 0 as an already connected socket handle >+and runs rsync using that socket as the connection to the daemon >+ >+.PP > You may establish the connection via a web proxy by setting the > environment variable RSYNC_PROXY to a hostname:port pair pointing to > your web proxy. Note that your web proxy's configuration must support >diff -aur rsync-3.0.0pre8.orig/socket.c rsync-3.0.0pre8/socket.c >--- rsync-3.0.0pre8.orig/socket.c 2008-01-21 19:34:20.000000000 -0600 >+++ rsync-3.0.0pre8/socket.c 2008-01-21 21:39:25.000000000 -0600 >@@ -30,6 +30,9 @@ > #include <netinet/ip.h> > #include <netinet/tcp.h> > >+#include <sys/stat.h> >+#include <unistd.h> >+ > extern char *bind_address; > extern int default_af_hint; > extern int connect_timeout; >@@ -309,7 +312,9 @@ > /** > * Open an outgoing socket, but allow for it to be intercepted by > * $RSYNC_CONNECT_PROG, which will execute a program across a TCP >- * socketpair rather than really opening a socket. >+ * socketpair rather than really opening a socket. Also, allow a >+ * special hostname of "&<integer>" to specify a file descriptor >+ * number as an already connected socket to the daemon. > * > * We use this primarily in testing to detect TCP flow bugs, but not > * cause security problems by really opening remote connections. >@@ -366,6 +371,33 @@ > } > if (prog) > return sock_exec(prog); >+ >+ /* >+ * special "&<integer>" hostname means to use the specified integer as >+ * the file descriptor of an already connected socket handle to the >+ * daemon. (Though it be a handle to something other than an actual >+ * socket) >+ */ >+ if(host[0] == '&') { >+ int fd = atoi(host+1); >+ struct stat buf; >+ >+ if(fd == 1 || fd == 2) { >+ rsyserr(FERROR, errno, "%s specified the stdout or stderr which are used for logging", host); >+ return -1; >+ } >+ >+ /* test that fd is a valid file descriptor */ >+ if(fstat(fd,&buf)!=0) { >+ rsyserr(FERROR, errno, "%s specified an invalid file descriptor", host); >+ return -1; >+ } >+ >+ /* don't know of a way to check whether fd is open for read AND write */ >+ >+ return fd; >+ } >+ > return open_socket_out(host, port, bind_addr, af_hint); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 5220
: 3116