Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
first working version of challenge response authentication. needs
[rsync/rsync.git]
/
clientserver.c
diff --git
a/clientserver.c
b/clientserver.c
index
39e5b90
..
7fca65e
100644
(file)
--- a/
clientserver.c
+++ b/
clientserver.c
@@
-31,9
+31,19
@@
int start_socket_client(char *host, char *path, int argc, char *argv[])
char *sargs[MAX_ARGS];
int sargc=0;
char line[1024];
char *sargs[MAX_ARGS];
int sargc=0;
char line[1024];
- char *p;
+ char *p
, *user=NULL
;
extern int remote_version;
extern int remote_version;
+ p = strchr(host, '@');
+ if (p) {
+ user = host;
+ host = p+1;
+ *p = 0;
+ }
+
+ if (!user) user = getenv("USER");
+ if (!user) user = getenv("LOGNAME");
+
fd = open_socket_out(host, rsync_port);
if (fd == -1) {
exit_cleanup(1);
fd = open_socket_out(host, rsync_port);
if (fd == -1) {
exit_cleanup(1);
@@
-67,6
+77,12
@@
int start_socket_client(char *host, char *path, int argc, char *argv[])
if (!read_line(fd, line, sizeof(line)-1)) {
return -1;
}
if (!read_line(fd, line, sizeof(line)-1)) {
return -1;
}
+
+ if (strncmp(line,"@RSYNCD: AUTHREQD ",18) == 0) {
+ auth_client(fd, user, line+18);
+ continue;
+ }
+
if (strcmp(line,"@RSYNCD: OK") == 0) break;
rprintf(FINFO,"%s\n", line);
}
if (strcmp(line,"@RSYNCD: OK") == 0) break;
rprintf(FINFO,"%s\n", line);
}
@@
-76,15
+92,6
@@
int start_socket_client(char *host, char *path, int argc, char *argv[])
}
io_printf(fd,"\n");
}
io_printf(fd,"\n");
-#if 0
- while (1) {
- if (!read_line(fd, line, sizeof(line)-1)) {
- return -1;
- }
- rprintf(FINFO,"%s\n", line);
- }
-#endif
-
return client_run(fd, fd, -1, argc, argv);
}
return client_run(fd, fd, -1, argc, argv);
}
@@
-101,6
+108,7
@@
static int rsync_module(int fd, int i)
char *p;
char *addr = client_addr(fd);
char *host = client_name(fd);
char *p;
char *addr = client_addr(fd);
char *host = client_name(fd);
+ char *auth;
if (!allow_access(addr, host, lp_hosts_allow(i), lp_hosts_deny(i))) {
rprintf(FERROR,"rsync denied on module %s from %s (%s)\n",
if (!allow_access(addr, host, lp_hosts_allow(i), lp_hosts_deny(i))) {
rprintf(FERROR,"rsync denied on module %s from %s (%s)\n",
@@
-108,6
+116,12
@@
static int rsync_module(int fd, int i)
return -1;
}
return -1;
}
+ if (!auth_server(fd, i, addr, "@RSYNCD: AUTHREQD ")) {
+ rprintf(FERROR,"auth failed on module %s from %s (%s)\n",
+ lp_name(i), client_name(fd), client_addr(fd));
+ return -1;
+ }
+
if (!claim_connection(lp_lock_file(), lp_max_connections())) {
rprintf(FERROR,"ERROR: max connections reached\n");
return -1;
if (!claim_connection(lp_lock_file(), lp_max_connections())) {
rprintf(FERROR,"ERROR: max connections reached\n");
return -1;
@@
-115,7
+129,7
@@
static int rsync_module(int fd, int i)
rprintf(FINFO,"rsync on module %s from %s (%s)\n",
lp_name(i), host, addr);
rprintf(FINFO,"rsync on module %s from %s (%s)\n",
lp_name(i), host, addr);
-
+
module_id = i;
if (lp_read_only(i))
module_id = i;
if (lp_read_only(i))
@@
-249,7
+263,6
@@
static int start_daemon(int fd)
}
while (i == -1) {
}
while (i == -1) {
-
line[0] = 0;
if (!read_line(fd, line, sizeof(line)-1)) {
return -1;
line[0] = 0;
if (!read_line(fd, line, sizeof(line)-1)) {
return -1;