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

 
 

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

Submitted by:  None
Submitted on:  Sat 10 Apr 2010 11:07:51 PM UTC  
 
Category: NoneSeverity: 4 - Important
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Chris Allegretta <astyanax>
Open/Closed: ClosedRelease: None

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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>
Project AdministratorIn charge of this item.
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.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 24 Feb 2014 08:08:39 PM UTCbensStatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
    Sun 23 May 2010 03:24:11 AM UTCastyanaxCarbon-Copy-=>Added skibrianski
    Sun 23 May 2010 03:19:16 AM UTCastyanaxSeverity3 - Normal=>4 - Important
      StatusNone=>In Progress
      Assigned toNone=>astyanax

    Back to the top


    Powered by Savane 3.1-cleanup