0

I have some old code that needs the stack to not be limited to 8192kb in order for it to run. I am used to doing this in /etc/security/limits.conf

* stack   hard    unlimited
* stack   soft    unlimited

However in RHEL 7.9 having a local account with a bash shell when I do a ulimit -s it still responds with 8192. So my modification of limits.conf seems to have no affect?

In my terminal window having a bash shell if I do a ulimit -s unlimited first then run my code, my code runs fine.

What is the best way to set stack size to unlimited, globally for all users in RHEL 7.9 ?

Am I missing something, is ulimit and /etc/security/limits.conf not the same thing?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
ron
  • 6,575

1 Answers1

1

Using ulimit command to set limits will change the limits for the current spawned process (shell) and its children only.

For example if you do :

#With root
ulimit -s unlimited
#Switch to other user 
su - <user>
ulimit -s  ## unlimited ; because this still be a child process

But if you do :

  #With root
  ulimit -s unlimited
  #Logout
  logout
  #Login as the other user then execute the following
  ulimit -s ## 8192

Using /etc/security/limits.conf will set them permanently but you have to relogin ( New Session ) to they can be effective.

If even setting stack within /etc/security/limits.conf is not effective then check if it's been overridden under /etc/security/limits.d/ or look at your profile files ~/.bash_profile ~/.bashrc.

Also check if the above is available under /etc/pam.d/password-auth and /etc/pam.d/system-auth so you are sure that /etc/security/limits.conf is loaded :

session requires pam_limits.so
Reda Salih
  • 1,754
  • it's session required correct? – ron Dec 07 '20 at 19:40
  • yeah I have that under pam.d. A test pc running same exact rhel 7.9 setup, is fine with stack unlimited. But my server it seems like what I have in /etc/security/limit.conf is not being put into effect. I am stumped. – ron Dec 07 '20 at 19:44
  • I suppose I'll reboot the server when I can and see if that fixes it. I don't know what else to check at this point. – ron Dec 07 '20 at 19:45
  • Yes i don't see any other thing that can block this from working :) – Reda Salih Dec 07 '20 at 19:49
  • I think it might be systemd: https://unix.stackexchange.com/questions/345595/how-to-set-ulimits-on-service-with-systemd – ron Dec 07 '20 at 19:59
  • You can test and let me know. – Reda Salih Dec 07 '20 at 20:17
  • Is that a typo or mistake on your server? Should be /etc/security/limits.conf not limit.conf – ILMostro_7 Dec 07 '20 at 20:47