Commit 12505e02 authored by Wayne Davison's avatar Wayne Davison

Allow --password-file=- for a stdin-supplied password.

parent d6df0739
...@@ -170,31 +170,38 @@ static const char *getpassf(const char *filename) ...@@ -170,31 +170,38 @@ static const char *getpassf(const char *filename)
{ {
STRUCT_STAT st; STRUCT_STAT st;
char buffer[512], *p; char buffer[512], *p;
int fd, n; int n;
if (!filename) if (!filename)
return NULL; return NULL;
if ((fd = open(filename,O_RDONLY)) < 0) { if (strcmp(filename, "-") == 0) {
rsyserr(FERROR, errno, "could not open password file %s", filename); n = fgets(buffer, sizeof buffer, stdin) == NULL ? -1 : (int)strlen(buffer);
exit_cleanup(RERR_SYNTAX); } else {
} int fd;
if (do_stat(filename, &st) == -1) { if ((fd = open(filename,O_RDONLY)) < 0) {
rsyserr(FERROR, errno, "stat(%s)", filename); rsyserr(FERROR, errno, "could not open password file %s", filename);
exit_cleanup(RERR_SYNTAX); exit_cleanup(RERR_SYNTAX);
} }
if ((st.st_mode & 06) != 0) {
rprintf(FERROR, "ERROR: password file must not be other-accessible\n"); if (do_stat(filename, &st) == -1) {
exit_cleanup(RERR_SYNTAX); rsyserr(FERROR, errno, "stat(%s)", filename);
} exit_cleanup(RERR_SYNTAX);
if (MY_UID() == 0 && st.st_uid != 0) { }
rprintf(FERROR, "ERROR: password file must be owned by root when running as root\n"); if ((st.st_mode & 06) != 0) {
exit_cleanup(RERR_SYNTAX); rprintf(FERROR, "ERROR: password file must not be other-accessible\n");
exit_cleanup(RERR_SYNTAX);
}
if (MY_UID() == 0 && st.st_uid != 0) {
rprintf(FERROR, "ERROR: password file must be owned by root when running as root\n");
exit_cleanup(RERR_SYNTAX);
}
n = read(fd, buffer, sizeof buffer - 1);
close(fd);
} }
n = read(fd, buffer, sizeof buffer - 1);
close(fd);
if (n > 0) { if (n > 0) {
buffer[n] = '\0'; buffer[n] = '\0';
if ((p = strtok(buffer, "\n\r")) != NULL) if ((p = strtok(buffer, "\n\r")) != NULL)
......
...@@ -2416,10 +2416,11 @@ want to see how the transfer is doing without scrolling the screen with a ...@@ -2416,10 +2416,11 @@ want to see how the transfer is doing without scrolling the screen with a
lot of names. (You don't need to specify the bf(--progress) option in lot of names. (You don't need to specify the bf(--progress) option in
order to use bf(--info=progress2).) order to use bf(--info=progress2).)
dit(bf(--password-file)) This option allows you to provide a password in a dit(bf(--password-file=FILE)) This option allows you to provide a password for
file for accessing an rsync daemon. The file must not be world readable. accessing an rsync daemon via a file or via standard input if bf(FILE) is
It should contain just the password as the first line of the file (all bf(-). The file should contain just the password on the first line (all other
other lines are ignored). lines are ignored). Rsync will exit with an error if bf(FILE) is world
readable or if a root-run rsync command finds a non-root-owned file.
This option does not supply a password to a remote shell transport such as This option does not supply a password to a remote shell transport such as
ssh; to learn how to do that, consult the remote shell's documentation. ssh; to learn how to do that, consult the remote shell's documentation.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment