I have on a Linux server with SuSE Linux Enterprise 15 SP5 the following situation:
I have two unpriv users “sisis” and “jenkins” which are both allowed (based on entries in /etc/security/limits.conf) to run the shell build-in command “ulimit -c unlimited”:
linux:~ # su - jenkins
jenkins@linux:~> id
uid=1003(jenkins) gid=100(users) Gruppen=100(users)
jenkins@linux:~> ulimit -c unlimited ; echo $?
0
exit
linux:~ # su - sisis
sisis@linux:~> id
uid=900118(sisis) gid=900118(sisis) Gruppen=900118(sisis),403(userdevl)
sisis@linux:~> ulimit -c unlimited ; echo $?
0
exit
But, when the user “jenkins” wants to do this in a shell script as user “sisis”, this gives an error:
linux:~ # su - jenkins
jenkins@linux:~> cat /tmp/ulimit.sh
#!/bin/sh
export LANG=C
ulimit -c unlimited
jenkins@linux:~> sudo -u sisis -g sisis /tmp/ulimit.sh
/tmp/ulimit.sh: line 3: ulimit: core file size: cannot modify limit: Operation not permitted
The background of this silly question is, that for test automation from another server (a Jenkins Continuous Integration server) jobs are started remotely as
ssh jenkins@linux bash CATserver_start.sh
+ sudo -u sisis /opt/lib/sisis/catserver/etc/S99catserver.testdb start
i.e. the “ulimit -c unlimited” command is issued in the above shellscript /opt/lib/sisis/catserver/etc/S99catserver.testdb which in production is started as user “sisis”, but in test automation from the Jenkins CI server via SSH as user “jenkins”.
Any ideas?