mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-05-14 09:55:51 -04:00
Open config files in text mode when O_TEXT is defined. This helps on
Cygwin when the config files are on a filesystem that is mounted in binary mode. Patch from Ville Herva.
This commit is contained in:
4
NEWS
4
NEWS
@@ -34,6 +34,10 @@ rsync changes since last release
|
||||
* Set the default value of --modify-window to 1 on Cygwin. (Lapo
|
||||
Luchini)
|
||||
|
||||
* Open config files in text mode when O_TEXT is defined. This helps
|
||||
on Cygwin when the config files are on a filesystem that are mounted
|
||||
in binary mode. (Ville Herva)
|
||||
|
||||
* Ignore errors from chmod when -p/-a/--preserve-perms is not set.
|
||||
(Dave Dykstra)
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ static int get_secret(int module, char *user, char *secret, int len)
|
||||
|
||||
if (!fname || !*fname) return 0;
|
||||
|
||||
fd = open(fname,O_RDONLY);
|
||||
fd = open(fname,O_RDONLY | O_TEXT);
|
||||
if (fd == -1) return 0;
|
||||
|
||||
if (do_stat(fname, &st) == -1) {
|
||||
@@ -144,7 +144,7 @@ static char *getpassf(char *filename)
|
||||
|
||||
if (!filename) return NULL;
|
||||
|
||||
if ( (fd=open(filename,O_RDONLY)) == -1) {
|
||||
if ( (fd=open(filename,O_RDONLY | O_TEXT)) == -1) {
|
||||
rsyserr(FERROR, errno, "could not open password file \"%s\"",filename);
|
||||
if (envpw) rprintf(FERROR,"falling back to RSYNC_PASSWORD environment variable.\n");
|
||||
return NULL;
|
||||
|
||||
@@ -514,7 +514,7 @@ int start_daemon(int f_in, int f_out)
|
||||
|
||||
motd = lp_motd_file();
|
||||
if (motd && *motd) {
|
||||
FILE *f = fopen(motd,"r");
|
||||
FILE *f = fopen(motd,"r" O_TEXT_STR);
|
||||
while (f && !feof(f)) {
|
||||
int len = fread(line, 1, sizeof(line)-1, f);
|
||||
if (len > 0) {
|
||||
|
||||
@@ -224,9 +224,9 @@ struct exclude_struct **make_exclude_list(const char *fname,
|
||||
char line[MAXPATHLEN];
|
||||
|
||||
if (strcmp(fname, "-")) {
|
||||
f = fopen(fname,"r");
|
||||
f = fopen(fname,"r" O_TEXT_STR);
|
||||
} else {
|
||||
f = fdopen(0, "r");
|
||||
f = fdopen(0, "r" O_TEXT_STR);
|
||||
}
|
||||
if (!f) {
|
||||
if (fatal) {
|
||||
|
||||
2
params.c
2
params.c
@@ -488,7 +488,7 @@ static FILE *OpenConfFile( char *FileName )
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
OpenedFile = fopen( FileName, "r" );
|
||||
OpenedFile = fopen( FileName, "r" O_TEXT_STR );
|
||||
if( NULL == OpenedFile )
|
||||
{
|
||||
rprintf(FERROR,"rsync: unable to open configuration file \"%s\": %s\n",
|
||||
|
||||
14
rsync.h
14
rsync.h
@@ -595,6 +595,20 @@ void rsyserr(enum logcode, int, const char *, ...)
|
||||
#define inet_ntoa rep_inet_ntoa
|
||||
#endif
|
||||
|
||||
/* Compatibility defines so that platforms that don't distinguish between
|
||||
* text and binary files (like Cygwin does) can use the same code. */
|
||||
#ifndef O_TEXT
|
||||
#define O_TEXT 0
|
||||
#define O_TEXT_STR ""
|
||||
#else
|
||||
#define O_TEXT_STR "t"
|
||||
#endif
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#define O_BINARY_STR ""
|
||||
#else
|
||||
#define O_BINARY_STR "b"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
size_t strlcpy(char *d, const char *s, size_t bufsize);
|
||||
|
||||
Reference in New Issue
Block a user