LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-06-2012, 10:54 AM   #1
clintonm9
LQ Newbie
 
Registered: Jun 2003
Posts: 20

Rep: Reputation: 0
Security limits.conf email/syslog notifications


I have setup /etc/security/limits.conf to limit all human users to just be able to run 50 process to help prevent fork bombs.

@users hard nproc 50

When testing this works great:
){ :|:& };:
I now see -bash: fork: Resource temporarily unavailable

same thing with perl
perl -e "while(1) {fork(); }"

the problem is I need to get alerts if these limits are reached.

I have search and can not find any way to get notified. I dont see any entries being logged to syslog either.

Any thoughts?
Thanks!
 
Old 05-06-2012, 09:42 PM   #2
clintonm9
LQ Newbie
 
Registered: Jun 2003
Posts: 20

Original Poster
Rep: Reputation: 0
Weird Apache/Security Limits.conf issue?

So I have setup a maximum number of processes a user can have in /etc/security/limits.conf

testuser hard nproc 16

When logging into the user I am limited to 16 processes (this is all bash base).

Then when I sudo -s into the root account the limit is now removed (This is what I want!)

When i start apache I now get this error:
[Sun May 06 21:34:39 2012] [alert] (11)Resource temporarily unavailable: setuid: unable to change to uid: 48

If I remove the testuser line from limits.conf it fixes the issues.

Any ideas why this limit is casing this when the root user is not inheriting the testuser limit on the shell? The apache user should also not be limited in any way.
 
Old 05-07-2012, 05:57 AM   #3
em31amit
Member
 
Registered: Apr 2012
Location: /root
Distribution: Ubuntu, Redhat, Fedora, CentOS
Posts: 190

Rep: Reputation: 55
alerts ?? are you talking about /var/log/messages file ? or any monitoring tool ?
 
Old 05-07-2012, 07:41 AM   #4
heinblöd
Member
 
Registered: May 2004
Location: France
Distribution: Slackware Gentoo
Posts: 186

Rep: Reputation: 31
very likely you limited the apache user (uid 48 = apache ? I guess ?) to fewer processes than apache needs to start up.
Or some error in the limits doesn't allow apache to drop it's root priviliges after startup

Why do you want to limit a service with pam ?

Last edited by heinblöd; 05-07-2012 at 07:42 AM.
 
Old 05-07-2012, 10:14 AM   #5
clintonm9
LQ Newbie
 
Registered: Jun 2003
Posts: 20

Original Poster
Rep: Reputation: 0
I am not limiting apache. Apache is not in the users group. That is what is weird about this.
 
Old 05-07-2012, 11:35 AM   #6
clintonm9
LQ Newbie
 
Registered: Jun 2003
Posts: 20

Original Poster
Rep: Reputation: 0
I would like an email when this limit is reached. But writing to /var/log/message would be fine as well, but it doesnt do that with the default setup
 
Old 05-07-2012, 03:21 PM   #7
heinblöd
Member
 
Registered: May 2004
Location: France
Distribution: Slackware Gentoo
Posts: 186

Rep: Reputation: 31
But if your limits file contains any errors it may affect all users.

For me it looks like apache can't drop it's root privileges and change to the apache user.

But without more details about your user ids and limits file, no-one can help ...
 
Old 05-07-2012, 11:25 PM   #8
clintonm9
LQ Newbie
 
Registered: Jun 2003
Posts: 20

Original Poster
Rep: Reputation: 0
I have had no issues recreating on other centos boxes:

the only entry in the limits.conf file are these two:
* hard core 0
@users hard nproc 50

/etc/group
users:x:100:testuser
apache:x:48:

Set httpd.conf to have more than 50 child and make sure the office/group is apache
<IfModule prefork.c>
StartServers 70
.....

Then login to testuser (make sure you re login after the changes to the limits file) and sudo -s to root.
now try and start apache. It might looks like it starts but check the error log or do status on the httpd service

It just seems like it is some how taking the limit from the testuser and applying it to starting apache as root?
 
Old 05-08-2012, 06:50 AM   #9
heinblöd
Member
 
Registered: May 2004
Location: France
Distribution: Slackware Gentoo
Posts: 186

Rep: Reputation: 31
I guess the problem is the
Quote:
* hard core 0
line which avoids file creation at all .

When I get it right, there are some issues with Pam and Apache
Maybe those two links can help you :

http://forums.gentoo.org/viewtopic-t...ex+apache.html
http://www.cyberciti.biz/faq/linux-disable-core-dumps/

Last edited by heinblöd; 05-08-2012 at 06:51 AM.
 
Old 05-12-2012, 09:05 AM   #10
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Moderator note: please keep discussion on the same topic in one place. Two strictly related threads have been merged here.
 
Old 10-08-2012, 10:11 PM   #11
techguru666
LQ Newbie
 
Registered: Jul 2012
Posts: 24

Rep: Reputation: Disabled
This link might be useful for fork bomb and limiting the number of processes by using limits:
http://www.expertslogin.com/tip-for-...-user-process/
 
  


Reply



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
Can't edit /etc/security/limits.conf mbk0asis Linux - Newbie 4 03-07-2012 02:54 AM
regardig /etc/security/limits.conf niaz_ph Linux - Newbie 1 10-20-2011 09:58 AM
ulimit and /etc/security/limits.conf chakkerz Linux - General 2 01-23-2011 01:42 AM
etc/security/limits.conf - what does it do? Ken_1969 Red Hat 5 03-14-2010 04:25 PM
/etc/security/limits.conf reverse Linux - Security 4 10-20-2007 03:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:35 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