bugGNU nano - Bugs: bug #29514, [nano 2.2.2] backup should ignore...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #29514: [nano 2.2.2] backup should ignore chown errors

Submitter:  None
Submitted:  Sat 10 Apr 2010 11:07:51 PM UTC
   
 
Severity:  4 - Important Status:  Fixed
Assigned to:  astyanax Open/Closed:  Closed

Sun 24 May 2020 03:12:19 PM UTC, comment #2: 

The point of always calling chown() is to change the group of the file (in case it is different from the user's default group).

Benno Schulenberg <bens>
Group administrator
Sun 23 May 2010 03:19:16 AM UTC, comment #1: 

Looking at this.

Thinking on it, in fact there should be not need to even chown() a file unless we're (effectively) root, since normal users can't chown() files unless they own them, and if they own them what's the point of chown()ing them since they cant change them to be owned by anyone else...

Chris Allegretta <astyanax>
Group administrator
Sat 10 Apr 2010 11:07:51 PM UTC, original submission:  

As of version 2.2.2, with 'set backup' enabled, nano will try to chown() the newly created backup file to the owner of the original file being edited.  The editing user is very likely not to be root, and it's not uncommon for a non-root user to be editing a file owned by a different user.  If the chown() fails, it should not cause the entire backup to fail (which thus prevents saving the original file).  The backup file is actually written successfully into the backupdir, the chmod() finishes successfully.  The only reason the backup fails is because a non-root user cannot chown() a file to be owned by a different user.

Currently, the only way to successfully save the file in this situation is to disable backups via M-B keyboard shortcut.

Here is a relevant excerpt from strace, showing the error and the subsequent abort of the save operation.

# Press F3
write(1, "\33[88d\33(B\33[0;7mFile Name to Write"..., 423) = 423
# Enter for default

getcwd("/home/otheruser/file.txt", 4097)
stat("file.txt", {st_mode=S_IFREG|0664, st_size=3226, ...}) = 0
getcwd("/home/otheruser/file.txt", 4097)
stat("file.txt", {st_mode=S_IFREG|0664, st_size=3226, ...}) = 0
stat("/home/otheruser/file.txt", {st_mode=S_IFREG|0664, st_size=3226, ...}) = 0
lstat("file.txt", {st_mode=S_IFREG|0664, st_size=3226, ...}) = 0
stat("file.txt", {st_mode=S_IFREG|0664, st_size=3226, ...}) = 0
open("file.txt", O_RDONLY) = 3
getcwd("/home/otheruser", 4097) = 65
stat("file.txt", {st_mode=S_IFREG|0664, st_size=3226, ...}) = 0
stat("/home/myuser/.nanobak/!home!otheruser!file.txt~", {st_mode=S_IFREG|0664, st_size=3226, ...}) = 0
stat("/home/myuser/.nanobak/!home!otheruser!file.txt~.1", 0x7cc82f818860) = -1 ENOENT (No such file or directory)
open("/home/myuser/.nanobak/!home!otheruser!file.txt~.1", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
chmod("/home/myuser/.nanobak/!home!otheruser!file.txt~.1", 0100664) = 0
fstat(3, {st_mode=S_IFREG|0664, st_size=3226, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x396a8ec91000
read(3, "contents of the file ..."..., 8192) = 3226
read(3, "", 4096)                       = 0
fstat(4, {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x396a8ec92000
read(3, "", 8192)                       = 0
close(3)                                = 0
munmap(0x396a8ec91000, 4096)            = 0
write(4, "contents of the file ..."..., 3226) = 3226
close(4)                                = 0

## At this point, the backup file was written successfully

munmap(0x396a8ec92000, 262144)          = 0
chown("/home/myuser/.nanobak/!home!otheruser!file.txt~.1", 2011, 2011) = -1 EPERM (Operation not permitted)

## I cannot change ownership of my new backup file to match "otheruser" (uid 2011)

rt_sigprocmask(SIG_UNBLOCK, [WINCH], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [WINCH], NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [WINCH], NULL, 8) = 0
rt_sigaction(SIGTSTP, {SIG_IGN}, {SIG_IGN}, 8) = 0
poll([{fd=0, events=POLLIN}], 1, 0)     = 0
poll([{fd=0, events=POLLIN}], 1, 0)     = 0
write(1, "\r\33(B\33[0;7m[ Error writing backup"..., 518) = 518

## Thus backup is deemed failed, and saving the file is aborted.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bens (Updated the item)
  • -email is unavailable- added by astyanax (Adding reporter for 29732 to this bug)
  • -email is unavailable- added by astyanax (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-02-24 bens StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2010-05-23 astyanax Carbon-Copy- Added skibrianski
    2010-05-23 astyanax Severity3 - Normal 4 - Important
        StatusNone In Progress
        Assigned toNone astyanax

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code