You are not logged in.

#1 2023-06-25 13:02:31

Crion
Member
Registered: 2020-12-27
Posts: 11

[SOLVED] How to change user level core ulimit?

This should be a very basic issue, but for some reason I can't change the core ulimit for any user other than root. I have set the below in my /etc/security/limits.conf

* soft core unlimited
* hard core unlimited

I have no /etc/secuirty/limits.conf.d/ that could override the main file.

I have pam_limits.so in my login, system.d-user, polkit-1 and I added it to /etc/pam.d/su as a test (I normally login into a console and launch my compositor from there, so login should take care of this).

in my /etc/systemd/user.conf and /etc/systemd/system.conf, I have DefaultLimitCORE=1000000000 (i tried infinity as well). I don't have /etc/systemd/user.conf.d/ or /etc/systemd/system.conf.d/ so again there should be no obvious overrides.

When I login as root, ulimit -a shows unlimited, but if I login as a regular user, I get a limit of 0.
To test a bit more I added pam_limits.so to /etc/pam.d/su. If I login as regular user and su to root, my limit correctly goes from zero to unlimited, but if I then su to a regular user, the limit goes to zero again.

This is a hard limit. As a user I can override the soft limit, but not the hard now, so I'm stuck. Is there another place I'm missing where a hard ulimit may be set for a user?

Last edited by Crion (2023-06-25 21:28:26)

Offline

#2 2023-06-25 13:37:30

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,188

Re: [SOLVED] How to change user level core ulimit?

I have no /etc/secuirty/limits.conf.d/ that could override the main file.

And what does the main file look like?

This is a hard limit.

Just to be sure:

ulimit -a -H
ulimit -a -S

Offline

#3 2023-06-25 14:09:16

Crion
Member
Registered: 2020-12-27
Posts: 11

Re: [SOLVED] How to change user level core ulimit?

seth wrote:

And what does the main file look like?

There are only two lines that aren't comments:

* soft core unlimited
* hard core unlimited

seth wrote:

Just to be sure:

ulimit -a -H
ulimit -a -S

both are:
core file size  (blocks, -c) 0

Offline

#4 2023-06-25 14:28:54

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,188

Re: [SOLVED] How to change user level core ulimit?

Please don't paraphrase, https://bbs.archlinux.org/viewtopic.php?id=57855
You'd not be the first person ever to fuck themselves w/ a typo, ideally just  comment everything or restore the default file.

Also I'd like to see whether maybe some other limtis are off

Finally,

grep -ri limit /etc/pam*

Offline

#5 2023-06-25 16:21:56

Crion
Member
Registered: 2020-12-27
Posts: 11

Re: [SOLVED] How to change user level core ulimit?

Here you:

# /etc/security/limits.conf
#
#This file sets the resource limits for the users logged in via PAM.
#It does not affect resource limits of the system services.
#
#Also note that configuration files in /etc/security/limits.d directory,
#which are read in alphabetical order, override the settings in this
#file in case the domain is the same or more specific.
#That means, for example, that setting a limit for wildcard domain here
#can be overridden with a wildcard setting in a config file in the
#subdirectory, but a user specific setting here can be overridden only
#with a user specific setting in the subdirectory.
#
#Each line describes a limit for a user in the form:
#
#<domain>        <type>  <item>  <value>
#
#Where:
#<domain> can be:
#        - a user name
#        - a group name, with @group syntax
#        - the wildcard *, for default entry
#        - the wildcard %, can be also used with %group syntax,
#                 for maxlogin limit
#
#<type> can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
#<item> can be one of the following:
#        - core - limits the core file size (KB)
#        - data - max data size (KB)
#        - fsize - maximum filesize (KB)
#        - memlock - max locked-in-memory address space (KB)
#        - nofile - max number of open file descriptors
#        - rss - max resident set size (KB)
#        - stack - max stack size (KB)
#        - cpu - max CPU time (MIN)
#        - nproc - max number of processes
#        - as - address space limit (KB)
#        - maxlogins - max number of logins for this user
#        - maxsyslogins - max number of logins on the system
#        - priority - the priority to run user process with
#        - locks - max number of file locks the user can hold
#        - sigpending - max number of pending signals
#        - msgqueue - max memory used by POSIX message queues (bytes)
#        - nice - max nice priority allowed to raise to values: [-20, 19]
#        - rtprio - max realtime priority
#
#<domain>      <type>  <item>         <value>
#
*               soft    core            unlimited
*               hard    core            unlimited
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#@student        -       maxlogins       4

# End of file

and

/etc/pam.d/system-login:#session    required     pam_limits.so
/etc/pam.d/polkit-1:session    required     pam_limits.so
/etc/pam.d/systemd-user:session    required     pam_limits.so
/etc/pam.d/system-auth:#session    required                    pam_limits.so
/etc/pam.d/login:session    required     pam_limits.so
/etc/pam.d/system-services:#session   required    pam_limits.so
/etc/pam.d/su:session    required     pam_limits.so

Offline

#6 2023-06-25 18:56:25

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,188

Re: [SOLVED] How to change user level core ulimit?

seth wrote:

restore the default file … Also I'd like to see whether maybe some other limits are off

(Latter implying the full ulimit outputs)

From the provided data there's little chance that pam_limits restricts this.

Likewise

in my /etc/systemd/user.conf and /etc/systemd/system.conf, I have DefaultLimitCORE=1000000000 (i tried infinity as well)

restore the defaults there.
Speaking of which: what starts your user session? How do you log in?

loginctl session-status

Offline

#7 2023-06-25 20:51:37

Crion
Member
Registered: 2020-12-27
Posts: 11

Re: [SOLVED] How to change user level core ulimit?

With default /etc/security/limits.conf, /etc/systemd/user.conf and /etc/systemd/system.conf

ulimit -H -a

real-time non-blocking time  (microseconds, -R) unlimited
core file size              (blocks, -c) 0
data seg size               (kbytes, -d) unlimited
scheduling priority                 (-e) 0
file size                   (blocks, -f) unlimited
pending signals                     (-i) 30683
max locked memory           (kbytes, -l) 8192
max memory size             (kbytes, -m) unlimited
open files                          (-n) 524288
pipe size                (512 bytes, -p) 8
POSIX message queues         (bytes, -q) 819200
real-time priority                  (-r) 0
stack size                  (kbytes, -s) unlimited
cpu time                   (seconds, -t) unlimited
max user processes                  (-u) 30683
virtual memory              (kbytes, -v) unlimited
file locks                          (-x) unlimited

ulimit -S -a

real-time non-blocking time  (microseconds, -R) unlimited
core file size              (blocks, -c) 0
data seg size               (kbytes, -d) unlimited
scheduling priority                 (-e) 0
file size                   (blocks, -f) unlimited
pending signals                     (-i) 30683
max locked memory           (kbytes, -l) 8192
max memory size             (kbytes, -m) unlimited
open files                          (-n) 1024
pipe size                (512 bytes, -p) 8
POSIX message queues         (bytes, -q) 819200
real-time priority                  (-r) 0
stack size                  (kbytes, -s) 8192
cpu time                   (seconds, -t) unlimited
max user processes                  (-u) 30683
virtual memory              (kbytes, -v) unlimited
file locks                          (-x) unlimited

I login into console and launch sway, although the core ulimit is set to zero by the time I logged into console.

loginctl session-status

1 - crion (1000)
           Since: Sun 2023-06-25 21:30:01 BST; 18min ago
          Leader: 396 (login)
            Seat: seat0; vc1
             TTY: tty1
         Service: login; type wayland; class user
           State: active
            Unit: session-1.scope
                  ├─ 396 "login -- crion"
                  ├─ 445 -bash
                  ├─ 480 sway
                  ├─ 484 /usr/bin/dbus-daemon --syslog --fork --print-pid 4 --print-address 6 --session
                  ├─ 498 swaybg -o "*" -i /home/crion/.config/sway/drops.jpg -m tile
                  ├─ 506 /home/crion/dev/sfw/sfwbar/build/sfwbar -b bar-0
                  ├─ 513 /usr/lib/at-spi-bus-launcher
                  ├─ 519 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-add>
                  ├─ 524 /usr/lib/at-spi2-registryd --use-gnome-session
                  ├─ 537 alacritty
                  ├─ 553 /bin/bash
                  ├─ 561 /usr/lib/firefox/firefox
                  ├─ 622 /usr/lib/firefox/firefox -contentproc -parentBuildID 20230605155639 -prefsLen 27114 -prefMapSize 23555>
                  ├─ 642 /usr/lib/firefox/firefox -contentproc -childID 1 -isForBrowser -prefsLen 27255 -prefMapSize 235551 -js>
                  ├─ 682 /usr/lib/firefox/firefox -contentproc -childID 2 -isForBrowser -prefsLen 32576 -prefMapSize 235551 -js>
                  ├─ 737 /usr/lib/firefox/firefox -contentproc -childID 3 -isForBrowser -prefsLen 29307 -prefMapSize 235551 -js>
                  ├─ 740 /usr/lib/firefox/firefox -contentproc -childID 4 -isForBrowser -prefsLen 29307 -prefMapSize 235551 -js>
                  ├─ 744 /usr/lib/firefox/firefox -contentproc -childID 5 -isForBrowser -prefsLen 29307 -prefMapSize 235551 -js>
                  ├─ 817 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -prefsLen 32576 -prefMapSize 235551 -js>
                  ├─ 846 /usr/lib/firefox/firefox -contentproc -childID 7 -isForBrowser -prefsLen 29307 -prefMapSize 235551 -js>
                  ├─ 879 /usr/lib/firefox/firefox -contentproc -childID 8 -isForBrowser -prefsLen 29307 -prefMapSize 235551 -js>
                  ├─ 935 /usr/lib/firefox/firefox -contentproc -parentBuildID 20230605155639 -prefsLen 32576 -prefMapSize 23555>
                  ├─ 936 /usr/lib/firefox/firefox -contentproc -parentBuildID 20230605155639 -sandboxingKind 0 -prefsLen 32576 >
                  ├─ 953 alacritty
                  ├─ 970 /bin/bash
                  ├─1005 alacritty
                  ├─1021 /bin/bash
                  ├─1034 loginctl session-status
                  └─1035 less

Jun 25 21:30:17 rover dbus-daemon[484]: [session uid=1000 pid=482] Activating service name='org.a11y.Bus' requested by ':1.1' (>
Jun 25 21:30:17 rover dbus-daemon[484]: [session uid=1000 pid=482] Successfully activated service 'org.a11y.Bus'
Jun 25 21:30:17 rover org.a11y.Bus[519]: dbus-daemon[519]: Activating service name='org.a11y.atspi.Registry' requested by ':1.0>
Jun 25 21:30:17 rover org.a11y.Bus[519]: dbus-daemon[519]: Successfully activated service 'org.a11y.atspi.Registry'
Jun 25 21:30:17 rover org.a11y.Bus[524]: SpiRegistry daemon is running with well-known name - org.a11y.atspi.Registry

Offline

#8 2023-06-25 21:07:15

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,188

Re: [SOLVED] How to change user level core ulimit?

So you're not starting any shell as user service anyway.

uname -a
cat /proc/cmdline
pstree -sp

Check every PID in there

grep core /proc/$PID/limits

to see where the limit is first applied.

Offline

#9 2023-06-25 21:28:01

Crion
Member
Registered: 2020-12-27
Posts: 11

Re: [SOLVED] How to change user level core ulimit?

seth wrote:

Check every PID in there

grep core /proc/$PID/limits

Ouch. This is certainly a facepalm moment. This led me straight to bash and an old bashrc file I copied from my older system where I set the core ulimit to... zero.

Solved as a PEBCAC.

Offline

Board footer

Powered by FluxBB