UK WEB HOSTING FORUM FOR DISCUSSION ON WEB HOSTING SERVICE AND SUPPORT
LINUX HOSTING WINDOWS HOSTING PACKAGES SHOPPING CART OSCOMMERCE ZEN CART AGORA
ECOMMERCE HOSTING ASP MSSQL FRONTPAGE HOSTING PHP MYSQL HOSTING DISCUSSION FORUM
CPANEL RESELLER HOSTING DEDICATED SERVER VPS HOSTING PLESK VIRTUOZZO
Quick Search
Your forum announcement here!

  UK Web Hosting | Dedicated Server Windows and Linux VPS Forum > Technical Support > VPS Hosting - Virtual Private Servers

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-12-2006, 11:10
eUK-Scott's Avatar
System Administrator
 
Join Date: Oct 2006
Posts: 210
Wink How do I mount /tmp on VPSes with noexec,nosuid options?

The idea is to create a separate file which will contain a filesystem for /tmp directories for all VPS Hostinges and mount that file as a loop device using noexec,nosuid options.

It can be done thusly:

1) Create a special file, and create a filesystem inside that file and mount it:

# dd if=/dev/zero of=/vz/tmpVE bs=1k count=2000000
# losetup /dev/loop0 /vz/tmpVE
# mkfs.ext2 /dev/loop0
# mkdir /vz/tmpVEs
# mount /dev/loop0 /vz/tmpVEs -o noexec,nosuid,nodev,rw

2) Add the following lines into /etc/sysconfig/vz-scripts/dists/scripts/postcreate.sh:

function vztmpsetup()
{

VEID=`basename $VE_ROOT`

cp /etc/sysconfig/vz-scripts/new.mount /etc/sysconfig/vz-scripts/$VEID.mount
cp /etc/sysconfig/vz-scripts/new.umount /etc/sysconfig/vz-scripts/$VEID.umount

if [ "$" != "" ]; then
[ -d /vz/tmpVEs/$ ] && rm -rf /vz/tmpVEs/$VEID/*
fi

chmod 755 /etc/sysconfig/vz-scripts/$VEID.mount
/etc/sysconfig/vz-scripts/$VEID.umount

}

vztmpsetup

exit 0

3) Create "/etc/sysconfig/vz-scripts/new.mount":

#!/bin/bash
#
# if one of these files does not exist then something is really broken
[ -f /etc/sysconfig/vz ] || exit 1
[ -f $VE_CONFFILE ] || exit 1
[ -f /etc/sysconfig/vz-scripts/$VEID.conf ] || exit 1
# Source configuration files to access $VE_ROOT
. /etc/sysconfig/vz
. $VE_CONFFILE
[ -e /vz/tmpVEs/$VEID ] || mkdir /vz/tmpVEs/$VEID
mount --bind /vz/tmpVEs/$VEID $VE_ROOT/tmp

4) Create "/etc/sysconfig/vz-scripts/new.umount":

#!/bin/bash
# if one of these files does not exist then something is really broken
[ -f /etc/sysconfig/vz ] || exit 1
[ -f $VE_CONFFILE ] || exit 1
# Source configuration files to access $VE_ROOT
. /etc/sysconfig/vz
. $VE_CONFFILE
# Unmount shared directory
if grep "/vz/root/$VEID/tmp" /proc/mounts >/dev/null; then
umount $VE_ROOT/tmp
fi

5) Add the following lines into "/etc/rc.sysinit":

losetup /dev/loop0 /vz/tmpVE
mount /dev/loop0 /vz/tmpVEs -o noexec,nosuid,nodev,rw
__________________


--------------
Best Regards,
eUKScott
Business Hosting || VPS Hosting || eUKhost Knowledgebase
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 23-01-2007, 23:32
Member
 
Join Date: Dec 2006
Location: UK
Posts: 92
Default

Wow, what an excellent guide.

This looks like it is for those with vzpp, could you also provide a guide for those of us who don't have it?

Last edited by Fidget; 20-06-2007 at 06:59.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 20-06-2007, 07:00
Member
 
Join Date: Dec 2006
Location: UK
Posts: 92
Default

I might get shot for bumping this, but hopefully you guys can advise when you have a moment
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 20-06-2007, 12:15
DPS Computing's Avatar
Premium Member
 
Join Date: Apr 2007
Location: Manchester, United Kingdom
Posts: 5,701
Send a message via ICQ to DPS Computing Send a message via AIM to DPS Computing Send a message via MSN to DPS Computing Send a message via Yahoo to DPS Computing Send a message via Skype™ to DPS Computing
Default

Quote:
Originally Posted by Fidget View Post
I might get shot for bumping this, but hopefully you guys can advise when you have a moment
I'm sure you won't get shot lol . Your question just probably wasn't seen at the original time .
__________________
David Smith
DPS Computing
http://www.dpscomputing.com (Computing, Reviews, News) - New site / new polls / new stories! With many more to follow!
http://djdavid.dpscomputing.com (My DJ Website) - Updated for Christmas 08!
NEW LAUNCH! http://davidsmith.dpscomputing.com (My Personal Website) - Temporarily Unavailable .
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 20-06-2007, 15:38
eUKhost.com's Avatar
Chief Marketing Officer
 
Join Date: Sep 2005
Posts: 4,812
Send a message via AIM to eUKhost.com Send a message via MSN to eUKhost.com Send a message via Skype™ to eUKhost.com
Default

Alex is not available right now so I will ask him to reply tomorrow morning.
__________________
UK Web Hosting || Business Hosting || eUKhost Knowledgebase
Toll Free : 0808 262 0255 || MSN : mark @ eukhost.com || AIM : eukmark
A bunch of Sheep led by a Lion is better than a bunch of Lions led by a Sheep.
__________________________________________________

Great Opportunity :: Join our Affiliate Program for FREE and earn 20% commission on each referral.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 20-06-2007, 17:35
DPS Computing's Avatar
Premium Member
 
Join Date: Apr 2007
Location: Manchester, United Kingdom
Posts: 5,701
Send a message via ICQ to DPS Computing Send a message via AIM to DPS Computing Send a message via MSN to DPS Computing Send a message via Yahoo to DPS Computing Send a message via Skype™ to DPS Computing
Default

Quote:
Originally Posted by eukhost.com View Post
Alex is not available right now so I will ask him to reply tomorrow morning.
There you go Fidget - an answer will be on its way to you soon (hopefully tommorow if Alex has the time!)
__________________
David Smith
DPS Computing
http://www.dpscomputing.com (Computing, Reviews, News) - New site / new polls / new stories! With many more to follow!
http://djdavid.dpscomputing.com (My DJ Website) - Updated for Christmas 08!
NEW LAUNCH! http://davidsmith.dpscomputing.com (My Personal Website) - Temporarily Unavailable .
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 21-06-2007, 03:54
eUK-Scott's Avatar
System Administrator
 
Join Date: Oct 2006
Posts: 210
Wink

Fidget,

We have not tried this with OpenVZ. Also Swsoft has provided /tmp security option with the Linux Virtuozzo SP1 itself now. If you want, you can secure /tmp for individual VPS Hosting using following steps :

* Login to VPS Hosting.

* Edit /etc/fstab

- Under the existing line (there should only be one line)
- add >> none /tmp tmpfs nodev,nosuid,noexec 0 0
- Reboot the VPS Hosting to make the changes take effect.
- Log back in and enter "df -h" to see whether the changes have taken effect.

IMPORTANT NOTE 1: You should see a separated /tmp partition now). Note that unlike with a dedicated server, this /tmp partition isn't a real partition. What it basically does is to create a ramdisk on the hardware node for the VPS Hosting, of which the diskusage isn't accounted towards the quota of the rest of the VPS Hosting. The usage is accounted against the "shmpages" of the VPS Hosting, which can only be set from the hardware node. Usually this is set to either 32mb or 64mb. Also note that the /tmp ramdisk isn't the only thing that consumes the shmpages, there are also several other things that use up the space.

NOTE 2: because it's a ramdisk, all data on the /tmp 'partition' will be lost after a reboot. That's not a problem because all data on the /tmp partition' is temporary data anyway. However, when you install eaccelerator for instance, it needs its own directory on the /tmp partition (it needs /tmp/eaccelerator and needs to be chmod to 777). So after a reboot, that directory would be lost and eaccelerator wouldn't function properly. So if you install eaccelerator (or anything else that requires something like this), then make sure that after a reboot the required directory and chmod are automatically created. You could do this with /etc/rc.local for instance (at the end of that file just add "mkdir /tmp/eaccelerator" "chmod 777 /tmp/eaccelerator").
__________________


--------------
Best Regards,
eUKScott
Business Hosting || VPS Hosting || eUKhost Knowledgebase
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 22-06-2007, 08:11
Member
 
Join Date: Dec 2006
Location: UK
Posts: 92
Default

Thanks Alex! What a cracking guide.

I happened to ask support to do it for us after our last move, and they handled it very effectively, but this is excellent advice for those who want to do it themselves.

Thanks very much indeed

.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 22-06-2007, 12:04
DPS Computing's Avatar
Premium Member
 
Join Date: Apr 2007
Location: Manchester, United Kingdom
Posts: 5,701
Send a message via ICQ to DPS Computing Send a message via AIM to DPS Computing Send a message via MSN to DPS Computing Send a message via Yahoo to DPS Computing Send a message via Skype™ to DPS Computing
Default

Quote:
Originally Posted by Fidget View Post
Thanks Alex! What a cracking guide.

I happened to ask support to do it for us after our last move, and they handled it very effectively, but this is excellent advice for those who want to do it themselves.

Thanks very much indeed

.
At least you got your answer that you were waiting for in the end!
__________________
David Smith
DPS Computing
http://www.dpscomputing.com (Computing, Reviews, News) - New site / new polls / new stories! With many more to follow!
http://djdavid.dpscomputing.com (My DJ Website) - Updated for Christmas 08!
NEW LAUNCH! http://davidsmith.dpscomputing.com (My Personal Website) - Temporarily Unavailable .
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 08-07-2007, 03:55
System Administrator
 
Join Date: Dec 2006
Location: localhost
Posts: 723
Lightbulb

Since Virtuozzo 3.0 SP1 it is very easy to mount /tmp (and /var/tmp if needed) dir on VEs with noexec, nosuid, nodev options using introduced 'bindmount' technology. You can follow the steps below to mount /tmp and /var/tmp directories on all VEs with noexec,nosuid options.

1. Update Virtuozzo installation to Virtuozzo 3 SP1 using 'vzup2date' utility.

2. If you want to mount /tmp and /var/tmp on all VEs with noexec,nosuid,nodev options then do the following:
Insert the following line into the main Virtuozzo configuration file /etc/sysconfig/vz:
Quote:
BINDMOUNT="/tmp,nosuid,noexec,nodev /var/tmp,nosuid,noexec,nodev "
and restart all VEs.

3. If you want to mount /tmp and /var/tmp in this way on a particular VE only, you should insert the line above into the VE configuration file /etc/sysconfig/vz-scripts/VEID.conf manually or do it using 'vzctl' utility:
Quote:
# vzctl set VEID --bindmount_add /tmp,nosuid,noexec,nodev --bindmount_add /var/tmp,nosuid,noexec,nodev --save
where VEID is an ID of VE you want to apply changes to. VE must be restarted for the changes to take effect.

I hope this will make your task a bit easier in securing the VPS Hosting's /tmp with noexec,nosuid options...
__________________

Rock _a.k.a._ Jack L.

http://www.eUKhost.com
Windows Hosting || Windows Reseller Hosting
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



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

Advanced Search
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 On
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 16:11.

 

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by Web Hosting 3.1.0
Copyright © 2001-2008, eUKhost.com. All rights reserved.

 
Site Map

VPS Hosting
VPS Hosting plans

Dedicated Server Hosting
Dedicated Server plans

Business Web Hosting
100% uptime Hosting

Cpanel Hosting
cPanel Shared Hosting

Reseller Hosting
Reseller Web Hosting

Windows Hosting
Windows Shared Hosting

Windows VPS

Windows VPS Hosting

Semi Dedicated Servers
Semi-Dedicated Hosting

Dedicated Server Mirroring
Dedicated Server Mirroring

Webhosting Knowledgebase
Frequently asked Questions

Web Hosting Blog
eUKhost Blog

Web Hosting Support
Support Helpdesk

UK Data Center
eUKhost Datacenter

Web Hosting Forum
eUKhost Forum

Support Tutorials
Online Flash Tutorials

Offsite Back-up Plans
Remote Backup Service

Customer Testimonials
eUK Customer Testimonials


knowledgebase articles

eUKhost.com Services

Pre-Sales Questions
Pre-sales FAQ's

Domain Names
Domain registration FAQ's

cPanel Hosting
cPanel Hosting FAQ's

Windows Web Hosting
Plesk Control Panel

Reseller Hosting
Reseller Hosting FAQ's

VPS Hosting
Virtual Private Server

Semi-Dedicated Servers
Semi-Dedicated FAQ's

Dedicated Servers
Dedicated Server Hosting


popular blog categories


Web Hosting
Website Hosting articles

UK Web Hosting
UK Hosting articles

Dedicated Server Hosting
Dedicated Server guidelines

VPS Hosting
VPS hosting articles

cPanel Hosting
cPanel Hosting articles

Linux Operating System
Linux Operating techniques

Windows Web Hosting
Windows plesk articles

Web Hosting
Web Hosting Service