LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 12-25-2016, 10:06 AM   #1
Mig21
Member
 
Registered: Jan 2005
Posts: 221

Rep: Reputation: 33
WTF!!?? upgradepkg httpd deleted all my websites!


I thought I got hacked, but it happened immediately after I ran upgradepkg httpd-2.4.25-x86_64-1_slack14.2.txz

After running the command and trying to restart apache I got an error telling me that:

Code:
AH00112: Warning: DocumentRoot [/srv/httpd/htdocs] does not exist
AH00526: Syntax error on line 248 of /etc/httpd/httpd.conf:
DocumentRoot '/srv/httpd/htdocs' is not a directory, or is not readable
Which is weird because /srv/httpd is a logical volume dedicated to apache.

I checked the logs and confirmed that the error started happening only after I did the upgrade. I was confused as hell.

All my websites from /srv/httpd were gone, completely. I had in /drv/httpd/htdocs:

Code:
cgi-bin/  error/  htdocs/  htdocs-cot/  htdocs-dab/  htdocs-dab-redirect/  htdocs-vp/  icons/
And now all I have is:

Code:
root@littlesvr:/srv/httpd# ls -la /srv/httpd/
total 8
drwxr-xr-x 2 root root 4096 Dec 25 10:36 ./
drwxr-xr-x 5 root root 4096 Dec 25 10:36 ../
lrwxrwxrwx 1 root root    8 Dec 25 10:36 www -> /var/www/
root@littlesvr:/srv/httpd# ls -la /srv/httpd/www/
total 24
drwxr-xr-x  6 root root 4096 Dec 23 14:48 ./
drwxr-xr-x 17 root root 4096 Dec 23 14:35 ../
drwxr-xr-x  2 root root 4096 Dec 23 14:48 cgi-bin/
drwxr-xr-x  3 root root 4096 Dec 23 14:48 error/
drwxr-xr-x  3 root root 4096 Dec 25 10:36 htdocs/
drwxr-xr-x  3 root root 4096 Dec 23 14:48 icons/
root@littlesvr:/srv/httpd# ls -la /srv/httpd/www/htdocs/
total 20
drwxr-xr-x  3 root root 4096 Dec 25 10:36 ./
drwxr-xr-x  6 root root 4096 Dec 23 14:48 ../
-rw-r--r--  1 root root   45 Jun 11  2007 index.html
-rw-r--r--  1 root root   45 Jun 11  2007 index.html.bak.5381
drwxr-xr-x 14 root root 4096 Dec 23 14:49 manual/
Which is the default that comes with apache with slackware. All my files are gone!

After scratching my head for a while I looked at doinst.sh in the .txz file and found this in the end:

Code:
( cd srv ; rm -rf httpd )
( cd srv ; ln -sf /var/www httpd )
( cd srv ; rm -rf www )
( cd srv ; ln -sf /var/www www )
Really!? Just like that? It's not funny guys!

Luckily i just realized most of my content is in sql and I don't think I've made any major changes in htdocs since the last full backup. So I'll survive this. But man, this sucks so much.
 
Old 12-25-2016, 11:37 AM   #2
ponce
Senior Member
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 4,750

Rep: Reputation: Disabled
if you look above in the doinst.sh there's also this block
Code:
# Don't wipe out an existing document root:
if [ ! -L srv/www -a -d srv/www ]; then
  mv srv/www srv/www.bak.$$
fi
if [ ! -L srv/httpd -a -d srv/httpd ]; then
  mv srv/httpd srv/httpd.bak.$$
fi
 
Old 12-25-2016, 11:39 AM   #3
af7567
Member
 
Registered: Nov 2012
Posts: 204

Rep: Reputation: 68
A bit further up in the doinst.sh is

Code:
# Don't wipe out an existing document root:
if [ ! -L srv/www -a -d srv/www ]; then
  mv srv/www srv/www.bak.$$
fi
if [ ! -L srv/httpd -a -d srv/httpd ]; then
  mv srv/httpd srv/httpd.bak.$$
fi
So I guess doinst saw that /srv/httpd was a directory and tried moving it to /srv/httpd.bak.$$. But since your /srv/httpd is a mount point that mv failed and the script continued anyway.

edit:
Just tested mv'ing a mount point which was in use and get

Code:
# mv mp3/ mp3.bak
mv: cannot move 'mp3/' to 'mp3.bak': Device or resource busy
So doinst should check for that failure before continuing.

Last edited by af7567; 12-25-2016 at 11:42 AM. Reason: testing
 
Old 12-25-2016, 06:34 PM   #4
SCerovec
Senior Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware on x86 and arm
Posts: 1,541
Blog Entries: 2

Rep: Reputation: 358Reputation: 358Reputation: 358Reputation: 358
I would advise the OP to consider moving the mount-point "upwards" to /srv/ instead of /srv/httpd/ for various reasons this discovered [BUG] included?

not much will be lost, and some will be gained?
 
Old 12-25-2016, 06:35 PM   #5
Mig21
Member
 
Registered: Jan 2005
Posts: 221

Original Poster
Rep: Reputation: 33
I have other things in srv as well but I'll rename srv/httpd to something different.
 
Old 12-25-2016, 07:24 PM   #6
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 5,944

Rep: Reputation: 3643Reputation: 3643Reputation: 3643Reputation: 3643Reputation: 3643Reputation: 3643Reputation: 3643Reputation: 3643Reputation: 3643Reputation: 3643Reputation: 3643
What about switching the mount point to /var/www/? By default, /srv/httpd/ is just a symlink to /var/www/ anyway.
 
Old 12-25-2016, 07:36 PM   #7
Mig21
Member
 
Registered: Jan 2005
Posts: 221

Original Poster
Rep: Reputation: 33
After this experience I will do my best to avoid any standard directories for content. /var/www would have been deleted exactly the same way.

I moved it to /srv/httpd2. Unfortunately /srv/httpd was used in many places in several configuration files, some of which I've never touched before. But again - I'd rather risk breaking apache than risk losing my content.
 
Old 12-25-2016, 07:40 PM   #8
af7567
Member
 
Registered: Nov 2012
Posts: 204

Rep: Reputation: 68
Quote:
Originally Posted by bassmadrigal View Post
What about switching the mount point to /var/www/? By default, /srv/httpd/ is just a symlink to /var/www/ anyway.
That would be a good workaround, but the bug with trying to mv a mount point should still be fixed. The doinst script obviously attempts to be non-destructive, so that should work properly.
 
Old 12-25-2016, 07:42 PM   #9
af7567
Member
 
Registered: Nov 2012
Posts: 204

Rep: Reputation: 68
Quote:
Originally Posted by Mig21 View Post
After this experience I will do my best to avoid any standard directories for content. /var/www would have been deleted exactly the same way.
I don't think /var/www would have been deleted since upgradepkg should have detected "new" files in there, but any files in the httpd package would have been overwritten.
 
Old 12-26-2016, 02:32 AM   #10
SCerovec
Senior Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware on x86 and arm
Posts: 1,541
Blog Entries: 2

Rep: Reputation: 358Reputation: 358Reputation: 358Reputation: 358
Post

Quote:
Originally Posted by Mig21 View Post
After this experience I will do my best to avoid any standard directories for content. /var/www would have been deleted exactly the same way.

I moved it to /srv/httpd2. Unfortunately /srv/httpd was used in many places in several configuration files, some of which I've never touched before. But again - I'd rather risk breaking apache than risk losing my content.
This is the other way of solving this right IMO:
Avoid using default paths for data of value- default paths are targets for all sorts of malevolent software.
Or recent experience shows, of bugs also:
Preferably, use paths that, while make sense, cannot be assumed nor guessed?

I try hard to co-locate all my valuable data behind /home/ as ftp is doing, FWIW.
So I usually only backup /home and /etc .
 
Old 12-26-2016, 08:05 PM   #11
Mig21
Member
 
Registered: Jan 2005
Posts: 221

Original Poster
Rep: Reputation: 33
Quote:
I try hard to co-locate all my valuable data behind /home/ as ftp is doing, FWIW.
So I usually only backup /home and /etc .
I used to do exactly the same thing but after the recent Slackware upgrade I decided to use LVM so that I have more flexibility allocating disk space for various purposes.

Quote:
Avoid using default paths for data of value- default paths are targets for all sorts of malevolent software.
Or recent experience shows, of bugs also
I agree completely.
 
Old 12-27-2016, 01:44 AM   #12
SCerovec
Senior Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware on x86 and arm
Posts: 1,541
Blog Entries: 2

Rep: Reputation: 358Reputation: 358Reputation: 358Reputation: 358
An afterthought:
where You anticipating any harm to your data; You could just unmount it before the (any) upgrade?
That could be an strategy too, provided You run the upgrade offline.

The late developments (of events) however seem to encourage people to run servers "virtually":

One is to upgrades one "offline" copy and then just swaps what's running online.

The data (payload) and the server (towing-truck) are kept in opposing realms of "reality":

*- Servers are VMs (trivial to switch back and forth update wise)
*- Data is either (remote) service or partition/share (preferably off the VM host)

The technique is referred as "destiny separation" in some translations.

FWIW.
 
Old 12-27-2016, 11:16 AM   #13
Mig21
Member
 
Registered: Jan 2005
Posts: 221

Original Poster
Rep: Reputation: 33
Yep, all good points, except in this case if I had my remote data mounted on /srv/httpd - the apache security update would have deleted my remote data too.

Horrible!
 
Old 12-27-2016, 03:01 PM   #14
SCerovec
Senior Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware on x86 and arm
Posts: 1,541
Blog Entries: 2

Rep: Reputation: 358Reputation: 358Reputation: 358Reputation: 358
Well it is an unlucky bug, if there are any lucky bugs
 
Old 12-27-2016, 03:22 PM   #15
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 5,944

Rep: Reputation: 3643Reputation: 3643Reputation: 3643Reputation: 3643Reputation: 3643Reputation: 3643Reputation: 3643Reputation: 3643Reputation: 3643Reputation: 3643Reputation: 3643
Quote:
Originally Posted by Mig21 View Post
/var/www would have been deleted exactly the same way.
In looking at the script, I don't think this is the case. It is specifically doing things within the /srv/ folder, so any removals would only occur on that folder or symlink under /srv/. If the data exists in /var/www/, none of that should be touched (well, except for possibly replacing /var/www/htdocs/index.html if the conditions are met).

But, I agree with af7567, this is a bug that should be fixed. Have you considered emailing Pat in case he hasn't noticed this thread?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] httpd not showing index page: httpd.conf deleted zak100 Linux - Newbie 9 09-18-2014 11:37 PM
httpd multiple websites with physical and virtual hosting on apache with centos 6.4 jagdip Linux - Server 3 08-12-2013 07:22 PM
httpd running but websites offline SaveVM Linux - Server 5 05-07-2012 06:04 PM
Deleted /etc/httpd WizardLock Linux - General 3 06-11-2003 07:03 AM
HELP! I've deleted the /etc/httpd folder Neb Linux - Newbie 6 05-16-2003 07:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 07:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration