Re: editing removes suid



Hello, Nerijus!

> When I edit suid perl script, after saving suid bit disappears:
> mc 4.5.55, didn't check with latest cvs, sorry.

Yes, I confirm the bug with the current version.

When restoring file permissions, chown should always be called before
chmod.  I almost knew that mcedit does it wrong as soon as I read your
message, before even checking the sources.

Thank you!  I'm applying this patch.

==========================
--- editcmd.c
+++ editcmd.c
@@ -229,8 +229,8 @@ int edit_save_file (WEdit * edit, const 
     } else
 	savename = g_strdup (filename);
 
-    mc_chmod (savename, edit->stat1.st_mode);
     mc_chown (savename, edit->stat1.st_uid, edit->stat1.st_gid);
+    mc_chmod (savename, edit->stat1.st_mode);
 
     if ((fd = mc_open (savename, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY ,
 		    edit->stat1.st_mode)) == -1)
==========================

-- 
Regards,
Pavel Roskin




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]