Package: fakeroot
Version: 1.7.1
Severity: normal
Tags: patch
The code that checks if the save-file is a named pipe causes a return
from save_database() if stat() on the save-file returns a negative
number. This happens also when the save-file does not exist. Thus,
save-files must exist beforehand. This restriction wasn't present in
versions before 1.7.1, and it's not mentioned in the man page.
Below is a patch that allows for non-existing save files. The patch
also changes the return behaviour of save_database() as follows:
. If the database was saved correctly, or save_file is NULL (no save
requested), return 0.
. If save_file is not NULL, and the database could not be saved,
return EOF (EOF == -1 and fclose returns it on error).
The patch also changes save() to emmit an error to stderr if the save
failed regardless of debug. I think this is important when fakeroot is
used for backups in conjunction with rsync.
8<-------------------------------------------------------------------------
--- fakeroot-1.7.1ubuntu1/faked.c 2007-05-10 16:55:56.000000000 +0200
+++ faked.c 2007-09-20 14:49:57.000000000 +0200
@@ -454,7 +454,7 @@
FILE *f;
if(!save_file)
- return 1;
+ return 0;
#ifdef FAKEROOT_DB_PATH
path[DB_PATH_LEN] = '\0';
@@ -468,7 +468,7 @@
int r,fd=0;
struct stat s;
r=stat(save_file,&s);
- if (r<0) return 0;
+ if (r<0 && errno != ENOENT) return EOF;
if (!(s.st_mode&S_IFIFO)) break;
fd=open(save_file,O_WRONLY|O_NONBLOCK);
if (fd<0) {
@@ -482,7 +482,7 @@
f=fopen(save_file, "w");
if(!f)
- return 0;
+ return EOF;
for (i = data_begin(); i != data_end(); i = data_node_next(i)) {
if (i->remote != remote)
@@ -878,12 +878,13 @@
/***********/
void save(int dummy){
- if(!save_database(0)) {
- if(debug)
+ int savedb_state;
+ savedb_state = save_database(0);
+ if(!savedb_state) {
+ if(debug && save_file)
fprintf(stderr, "fakeroot: saved database in %s\n", save_file);
} else
- if(debug)
- fprintf(stderr, "fakeroot: database save FAILED\n");
+ fprintf(stderr, "fakeroot: database save FAILED\n");
}
#ifdef FAKEROOT_FAKENET
8<-------------------------------------------------------------------------
-- System Information:
Debian Release: lenny/sid
APT prefers stable
APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-5-k7
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Versions of packages fakeroot depends on:
ii libc6 2.5-9+b1 GNU C Library: Shared libraries
fakeroot recommends no packages.
-- no debconf information
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]