gnc-backend-file.c: ERR_BACKEND_PERM too unspecific

Derek Atkins warlord at MIT.EDU
Tue Nov 29 10:37:23 EST 2005


I think you misread what he (and I) wrote..  ;)

Gnucash does a "rename and create" when saving the data file.
It renames the existing data file to the backup file, then creates
a new file and saves the new data into it.  Then it tries to
fix up the permissions on the new data file (chmod).

What I don't understand is why we're trying to chown() the
file:

[warlord at cliodev src]$ find . -name \*.c | xargs grep chown
./src/backend/file/gnc-backend-file.c:            if(chown(tmp_name, statbuf.st_uid, statbuf.st_gid) != 0)
./src/backend/file/gnc-backend-file.c:                PWARN("unable to chown filename %s: %s",
./src/backend/file/gnc-backend-file.c:#if VFAT_DOESNT_SUCK /* chown always fails on vfat fs */

I think we're trying to retain the original owner/group, but that
can't work because only the superuser can change the owner.  I think
we should change this chown() call to:

  chown(tmp_name, -1, statbuf.st_gid)

This would retain the original group setting on the file, which should
work provided the user is in the group.  Or we can just forego the
group setting completely and assume the user has a proper setgid
setting on the directory.

-derek

Tim Wunder <tim at thewunders.org> writes:

> I don't see where Christian is talking about chmoding a backup file here. I 
> read this as him getting a warning when saving the data file. A warning that 
> caused the app to fail, and really wasn't the warning it thought it was (the 
> file was saved regardless of the warning). Regardless, an app should not try 
> to chmod *any* pre-existing data file. Sys admins assign file permissions for 
> a reason. Apps shouldn't attempt to change that willy-nilly...
>
> Of course, I reserve the right to have misread what he wrote ;)
>
> Tim
>
> On Monday 28 November 2005 6:48 pm, someone claiming to be Derek Atkins wrote:
>> I'm wondering why we even try to chown the old backup file at all?
>> I can understand why we want to chmod the NEW data file, but I
>> don't understand why we'd want to do anything but "rename" the
>> old backup file?
>>
>> -derek
>>
>> Christian Stimming <stimming at tuhh.de> writes:
>> > I just recently got a new error message from the gnucash-HEAD that didn't
>> > show up with 1.8. Here's the deal: I have two linux users accessing the
>> > gnucash file alternating. The directory of that file has 775 permissions
>> > and both of them are in the same group, so both are able to write the
>> > file in that directory.  However, on file saving in 1.8 I always got the
>> > PWARN message on the cmdline saying that the new user is "unable to chown
>> > filename", which was quite understandable because the new user cannot
>> > chown the previous file that was written by the old user. In 1.8 this was
>> > a not-too-noisy warning on the cmdline.
>> >
>> > However, with SVN-HEAD on "save file" this "unable to chown filename"
>> > warning in  src/backend/file/gnc-backend-file.c:556 results in a
>> > ERR_BACKEND_PERM error code being passed to gnucash, which will then show
>> > a big red error window saying "You do not have permission to access 
>> > %s\n"! Uh oh! Very frightening.
>> >
>> > As it turns out, the file saving went just fine. Only the old backup file
>> > couldn't be chown'd to the new user, because it is still being owned by
>> > that other user.
>> >
>> > Conclusion: This ERR_BACKEND_PERM either needs to be removed from these
>> > two particular warnings, or these particular warnings need to have (new,
>> > additional) error codes. That ERR_BACKEND_PERM error message is really
>> > meant for the case when the actual data file cannot be accessed because
>> > of permissions, isn't it? This user feedback needs to be crystal clear in
>> > such respect. Any ideas?
>> >
>> > Christian
>> > _______________________________________________
>> > gnucash-devel mailing list
>> > gnucash-devel at gnucash.org
>> > https://lists.gnucash.org/mailman/listinfo/gnucash-devel
>
> -- 
> Fedora Core release 4 (Stentz), Linux 2.6.14-1.1637_FC4
> KDE: 3.4.3-1.1.fc4.kde, xorg-x11-6.8.2-37.FC4.49.2
>  19:30:06 up 8 days, 11:48,  4 users,  load average: 1.58, 1.32, 0.67
> MP3/OGG archive Total playlength : 7 days, 10 hours, 31 mins 30 seconds
> "It's what you learn after you know it all that counts" John Wooden
> _______________________________________________
> gnucash-devel mailing list
> gnucash-devel at gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-devel

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list