Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 32938

Summary: (Vim + Vcron) != a functioning "crontab -e" (and some clue why)
Product: Gentoo Linux Reporter: Matt <matthew>
Component: Current packagesAssignee: Chris PeBenito (RETIRED) <pebenito>
Status: RESOLVED CANTFIX    
Severity: minor CC: agriffis, seemant
Priority: Normal    
Version: 1.4_rc4   
Hardware: x86   
OS: Linux   
URL: http://www.ussg.iu.edu/hypermail/linux/kernel/0110.3/0668.html
Whiteboard:
Package list:
Runtime testing required: ---

Description Matt 2003-11-07 04:08:48 UTC
This is a minor annoyance, perhaps someone has a better idea to fix it other than "use nano as your EDITOR"

Using:
*  sys-apps/vcron
      Latest version available: 3.0.1-r2
*  app-editors/vim
      Latest version available: 6.2-r3

REPRODUCING THE PROBLEM:
1. Put "vim" in your rc.conf as EDITOR.
2. As root try

crontab -e

3. Make your cron entry, save and quit.  (vim: i, wq)
4. Note that your crontab was not saved.

MORE INFO:
See the included URL for what seems to be a good technical description of this problem.
Comment 1 Aron Griffis (RETIRED) gentoo-dev 2003-11-07 09:49:28 UTC
This should be considered a vcron problem, not a vim problem.  There's no
reason to assume (on vcron's part) that the file will be overwritten instead
of replaced.
Comment 2 Ryan Phillips (RETIRED) gentoo-dev 2003-11-21 12:51:15 UTC
my EDITOR variable is set to vim, and I can save cronfiles perfectly fine within vim.
Comment 3 Ryan Phillips (RETIRED) gentoo-dev 2003-11-21 12:51:56 UTC
I'm using vcron 3.0.1-r1
Comment 4 Aron Griffis (RETIRED) gentoo-dev 2003-11-21 14:05:56 UTC
I've just tested as well, using EDITOR=vim and vcron-3.0.1-r3.  This seems
to work fine.
Comment 5 Matt 2003-11-21 15:03:41 UTC
I may have solved the mystery at least.

if /tmp is a symbolic link, vim isn't gonna work for your cron editing.

Maybe I'm spouting gibberish, but it seems to me the file vim edits and the file crontab has an open filehandle to are not the same, they'll have different inodes but the same name.  How is that possible?  Who knows.  I'm just repeating what I read in the included URL.  The file is replaced, but crontab still has an open handle to the previous file.
Comment 6 Chris PeBenito (RETIRED) gentoo-dev 2003-12-06 08:24:53 UTC
Using crontab and vim on a /tmp as regular directory and as a bind mount worked.  I can reproduce when /tmp was a symlink it didnt work, which doesn't make any sense to me.
Comment 7 Chris PeBenito (RETIRED) gentoo-dev 2003-12-09 13:36:39 UTC
This is the relevant comment in the crontab code:

/* we still have the file open.  editors will generally rewrite the
 * original file rather than renaming/unlinking it and starting a
 * new one; even backup files are supposed to be made by copying
 * rather than by renaming.  if some editor does not support this,
 * then don't use it.  the security problems are more severe if we
 * close and reopen the file around the edit.
 */

I agree with the decision, because of the security issue, so I won't modify it to close and reopen the temp file.
Comment 8 Chris PeBenito (RETIRED) gentoo-dev 2003-12-10 16:07:22 UTC
Well I don't see any obvious reason as to why this is happening, and vixie-cron hasn't been maintained upstream in a while.  Having /tmp as a symlink is odd; I suggest using a bind mount.