LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 04-24-2014, 02:01 PM   #1
zordrak
Member
 
Registered: Feb 2008
Distribution: Slackware
Posts: 595

Rep: Reputation: 116Reputation: 116
Exclamation httpd upgrade overwrote /srv/httpd directory with a symlink!


Part warning, part question.

I keep my web server content in /srv/httpd - I have previously asked Pat to consider this more proper location as a new default, but IIRC his opinion was that while /srv/httpd was technically better, /var/www 'aint broke so he wasn't fixing it.

Four days ago I patched up my server and with it upgraded httpd-2.2.17 to httpd-2.2.25. I have discovered to my abject horror that my web server directory was completely overwritten by the symlink back to /var/www (!!).

My warning is that if anyone else uses /srv/httpd or /srv/www for content, to duplicate that content before upgrading httpd.

My question is WHAT THE HELL?!?

Why should upgradepkg EVER be allowed to forcefully overwrite an existing directory with a symlink? Can anyone offer a suggestion of how this occurred so I can submit a patch to fix and stop it happening to anyone else?

Last edited by zordrak; 04-24-2014 at 02:01 PM. Reason: Readability.
 
Old 04-24-2014, 02:31 PM   #2
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
I don't have a 14.1 install handy so I don't know if it is the same but in 14.0's install script there is this:
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
It seems it is already trying not to clobber anything.
 
1 members found this post helpful.
Old 04-24-2014, 02:36 PM   #3
zordrak
Member
 
Registered: Feb 2008
Distribution: Slackware
Posts: 595

Original Poster
Rep: Reputation: 116Reputation: 116
Panic over :-D You're bob-on.

Because of the file dates I had assumed I created that backup ages ago. Now that I look more closely you're exactly right. It's all there. My bad
 
Old 04-26-2014, 02:05 PM   #4
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
It's good that the doinst.sh moves existing directories out of the way rather than just blindly stomping on them but IMO it'd be much better for it not to clobber existing directories at all. I think I'd favour removing those symlink creations from the httpd.Slackbuild, and putting then in the doinst.sh wrapped in a much safer 'test ! -e' :

if [ ! -e srv/httpd ]; then ; ln -Tsf /var/www srv/httpd ; fi


I'm not entirely sure what would happen under the existing scheme if /srv/httpd was the mountpoint of a separate filesystem but I get the feeling that it might get ugly under the right circumstances (e.g. the mv fails and then the rm -rf in the doinst.sh wipes out the existing contents anyway)

Last edited by GazL; 04-26-2014 at 02:07 PM.
 
1 members found this post helpful.
Old 04-27-2014, 12:23 AM   #5
wildwizard
Member
 
Registered: Apr 2009
Location: Oz
Distribution: slackware64-14.0
Posts: 875

Rep: Reputation: 282Reputation: 282Reputation: 282
It would be better to do the symlink the other way around.

Rational :-
http://www.pathname.com/fhs/pub/fhs-2.3.pdf

Gives /srv as the correct location for data served by the machine, /var/www is historical and only needs to exist for people who haven't caught up with current standards (which are pretty old btw).
 
Old 04-27-2014, 04:54 AM   #6
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
I disagree. Other UNIX/UNIX-likes still use /var/www so it's not merely "historical". The FHS doesn't say that anything in /srv has to be a directory rather than a symlink. What it does say however is:
Quote:
Distributions must take care not to remove locally placed files in these directories without administrator permission.
... and unfortunately that is what is happening here (though more accurately they're being moved rather than removed).

Actually, on reflection, rather than doing what I suggested above, I think the package should just leave the contents of /srv well alone and leave its management entirely in the hands of the sysadmin/user.
 
1 members found this post helpful.
Old 04-28-2014, 03:09 AM   #7
zordrak
Member
 
Registered: Feb 2008
Distribution: Slackware
Posts: 595

Original Poster
Rep: Reputation: 116Reputation: 116
Given that Slack is following the FHS recommendation to some extent already by allowing apache to reference /srv paths in the default config:

My preference: Pat sucks it up and just moves the default location to /srv/httpd, letting /var/www/ symlink to it.

Whether symlinks are in /srv or in /var: The symlink should be created conditionally IFF there is nothing already in place. A possible option would be to create "/srv/httpd.new -> /var/www" if /srv/httpd already exists (or the other way round if the default location were moved); but whether that's necessary is an exercise for the reader.
 
Old 04-28-2014, 03:21 AM   #8
Smokey_justme
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 534

Rep: Reputation: 203Reputation: 203Reputation: 203
I have to say, I'm a little surprised of this... I don't agree with updates that touch "working directories" like /srv/www and /srv/httpd are supposed to be .. It doesn't matter if backups are made or not (I like that they are).. The packages shouldn't touch them and links should only be created if nothing exists there..

P.S. Just think of what could happen if you upgrade under low disk space conditions..

LE: As for the location, I think /var/www is the best place since there are cases where /var might get mounted separately but it wouldn't make sense to mount /srv for a few MBs of data on a different partition/disk (and leaving them on under / is just careless)..

Last edited by Smokey_justme; 04-28-2014 at 03:35 AM.
 
1 members found this post helpful.
  


Reply

Tags
httpd, overwrite, symlink, upgradepkg



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
I overwrote /etc/httpd/conf/httpd.conf NotionCommotion Linux - Newbie 10 04-25-2014 11:58 AM
apache log: /srv/httpd/htdocs - I don't get it coldbeer Linux - Server 0 11-14-2013 03:44 PM
Can not restart httpd”File size limit exceeded(core dumped) $HTTPD -DSSL” sreejithedl Linux - Server 2 10-12-2009 11:24 AM
Starting httpd: httpd: Syntax error on line 209 of /etc/httpd/conf/httpd.conf: Syntax sethukpathi Linux - Networking 6 04-12-2008 11:26 AM
service httpd status, results in httpd dead but subsys locked squadja Red Hat 2 09-11-2004 10:31 PM

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

All times are GMT -5. The time now is 04:55 PM.

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
Open Source Consulting | Domain Registration