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
separated out the make_backup code in preparation for some patches
[rsync/rsync.git]
/
clientserver.c
diff --git
a/clientserver.c
b/clientserver.c
index
9e79538
..
8425243
100644
(file)
--- a/
clientserver.c
+++ b/
clientserver.c
@@
-25,6
+25,7
@@
extern int read_only;
extern int verbose;
extern int rsync_port;
char *auth_user;
extern int verbose;
extern int rsync_port;
char *auth_user;
+int sanitize_paths = 0;
int start_socket_client(char *host, char *path, int argc, char *argv[])
{
int start_socket_client(char *host, char *path, int argc, char *argv[])
{
@@
-221,6
+222,7
@@
static int rsync_module(int fd, int i)
io_printf(fd,"@ERROR: chdir failed\n");
return -1;
}
io_printf(fd,"@ERROR: chdir failed\n");
return -1;
}
+ sanitize_paths = 1;
}
if (am_root) {
}
if (am_root) {
@@
-262,7
+264,7
@@
static int rsync_module(int fd, int i)
request = strdup(p);
start_glob++;
}
request = strdup(p);
start_glob++;
}
- glob_expand(name, argv, &argc, MAX_ARGS
, !use_chroot
);
+ glob_expand(name, argv, &argc, MAX_ARGS);
} else {
argc++;
}
} else {
argc++;
}
@@
-276,7
+278,7
@@
static int rsync_module(int fd, int i)
}
}
}
}
- if (
!use_chroot
) {
+ if (
sanitize_paths
) {
/*
* Note that this is applied to all parameters, whether or not
* they are filenames, but no other legal parameters contain
/*
* Note that this is applied to all parameters, whether or not
* they are filenames, but no other legal parameters contain
@@
-285,7
+287,7
@@
static int rsync_module(int fd, int i)
* and which aren't.
*/
for (i = 1; i < argc; i++) {
* and which aren't.
*/
for (i = 1; i < argc; i++) {
- sanitize_path(argv[i]);
+ sanitize_path(argv[i]
, NULL
);
}
}
}
}
@@
-417,6
+419,7
@@
static int start_daemon(int fd)
int daemon_main(void)
{
extern char *config_file;
int daemon_main(void)
{
extern char *config_file;
+ extern int orig_umask;
char *pid_file;
if (is_a_socket(STDIN_FILENO)) {
char *pid_file;
if (is_a_socket(STDIN_FILENO)) {
@@
-447,16
+450,19
@@
int daemon_main(void)
rprintf(FINFO,"rsyncd version %s starting\n",VERSION);
if (((pid_file = lp_pid_file()) != NULL) && (*pid_file != '\0')) {
rprintf(FINFO,"rsyncd version %s starting\n",VERSION);
if (((pid_file = lp_pid_file()) != NULL) && (*pid_file != '\0')) {
- FILE *f;
+ char pidbuf[16];
+ int fd;
int pid = (int) getpid();
cleanup_set_pid(pid);
int pid = (int) getpid();
cleanup_set_pid(pid);
- if ((f = fopen(lp_pid_file(), "w")) == NULL) {
+ if ((fd = do_open(lp_pid_file(), O_WRONLY|O_CREAT|O_TRUNC,
+ 0666 & ~orig_umask)) == -1) {
cleanup_set_pid(0);
fprintf(stderr,"failed to create pid file %s\n", pid_file);
exit_cleanup(RERR_FILEIO);
}
cleanup_set_pid(0);
fprintf(stderr,"failed to create pid file %s\n", pid_file);
exit_cleanup(RERR_FILEIO);
}
- fprintf(f, "%d\n", pid);
- fclose(f);
+ slprintf(pidbuf, sizeof(pidbuf), "%d\n", pid);
+ write(fd, pidbuf, strlen(pidbuf));
+ close(fd);
}
start_accept_loop(rsync_port, start_daemon);
}
start_accept_loop(rsync_port, start_daemon);