nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

VI & PHP Security Remove swap and backup file

This is a discussion on VI & PHP Security Remove swap and backup file within the Linux software forums, part of the Linux Getting Started category; Hi I've discovered a large security risk on my apache server. I'm running a couple of PHP based websites and ...


Go Back   nixCraft Linux Forum > Linux Getting Started > Linux software

Linux answers from nixCraft.


Linux software General questions and discussion about Redhat/Fedora Core/Cent OS, Debian and Ubuntu Linux related to softwares should go here.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-02-2009, 03:34 PM
Junior Member
User
 
Join Date: Dec 2008
Location: Odense, Denmark
OS: openSUSE
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
GreyFollower is on a distinguished road
Default VI & PHP Security Remove swap and backup file

Hi

I've discovered a large security risk on my apache server. I'm running a couple of PHP based websites and often makes small changes in the config file or some of the other php files. I do this over SSH using VI. But I've discovered that sometimes VI makes a temporary file with the same name as the orginal file but with a ~ at the end. This means that if I have edited my config file config.php there is a temporary file called config.php~ and this file can also be accessed and will not be parsed as a php file, hence everyone can see usernames, passwords and other goodies.

So my questions are:
- Is there a way to avoid that VI makes these files?
- Or is there another command line editor I could use instead that does not make them
Reply With Quote
  #2 (permalink)  
Old 10-02-2009, 06:22 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 246 Times in 184 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Open your $HOME/.vimrc file and append following to disable backup option

Code:
set nobackup
set nowritebackup
You can also setup a backup dir to avoid problem in ~/.vimrc:
Code:
set backupdir=./.backup,.,/tmp 
set directory=.,./.backup,/tmp  " Automatically create .backup directory, writable by the group.
if filewritable(".") && ! filewritable(".backup")
 silent execute '!umask 002; mkdir .backup'
endif
This way, if you want your backups to be neatly grouped. It will create a directory called '.backup' in your working directory. Vim will stash backups there. The 'directory' option controls where swap files go. If your working directory is not writable, Vim will put the swap file in one of the specified places.



HTH
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply

Tags
.vimrc , vi stop backup files , vim


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
AIX /etc/security/user like file for Linux ftengcheng Getting started tutorials 4 25-03-2008 01:28 AM
Why Swap=2 x RAM diptanjan Getting started tutorials 5 25-03-2008 01:14 AM
Ext2 file system : Mechanism on number of backup Superblocks ? swapnil Getting started tutorials 1 03-09-2007 06:40 PM
Swap piggy Getting started tutorials 3 17-07-2007 09:44 AM
Difference between Linux Swap partition & Swap file hrishikesh Linux software 9 16-03-2007 02:08 AM


All times are GMT +5.5. The time now is 07:09 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38