I am very confused, and I tried a lot but I didn't get any way to overcome from a bug. I am posting the same. I am hoping that someone helps me.
My problem is,
When I run ulimit -n
it shows 12000
.
When I run rsh localhost ulimit -n
, it shows 12000
.
Till now, all is going well. But the actual problem arise here, I made some changes in rsh, by adding one feature and some more, it builds a new rsh, named modified-rsh
. Please don't ask for code because that is not public and don't say move to ssh , because rsh is insecure.
I know all these things.
When I run command, modified-rsh localhost ulimit -n
, it shows 1024. Why ??
Can you tell me what is the reason behind all these happenings.
I feel helpless. Help me in this situation. Thanks in advance. Looking for your kind reply.
Edit no 3
I think this edit will be helpful. This edit shows where and when ulimit is accessed during the trace of modified-rsh
Command :- strace -o log.txt modified-rsh localhost ulimit -n
writev(3, [{"service\0", 8}, {"service\0", 8}, {"ulimit -n\0", 10}], 3) = 26
read(3, "\0", 1) = 1
rt_sigprocmask(SIG_SETMASK, [], [URG], 8) = 0
setuid(500) = 0
rt_sigprocmask(SIG_BLOCK, [INT QUIT TERM], [], 8) = 0
rt_sigaction(SIGINT, {0x1, [INT], SA_RESTORER|SA_RESTART, 0x3454030330}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGINT, {0x401650, [INT], SA_RESTORER|SA_RESTART, 0x3454030330}, {0x1, [INT], SA_RESTORER|SA_RESTART, 0x3454030330}, 8) = 0
rt_sigaction(SIGQUIT, {0x1, [QUIT], SA_RESTORER|SA_RESTART, 0x3454030330}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGQUIT, {0x401650, [QUIT], SA_RESTORER|SA_RESTART, 0x3454030330}, {0x1, [QUIT], SA_RESTORER|SA_RESTART, 0x3454030330}, 8) = 0
rt_sigaction(SIGTERM, {0x1, [TERM], SA_RESTORER|SA_RESTART, 0x3454030330}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGTERM, {0x401650, [TERM], SA_RESTORER|SA_RESTART, 0x3454030330}, {0x1, [TERM], SA_RESTORER|SA_RESTART, 0x3454030330}, 8) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x2b749c27cd80) = 4583
ioctl(5, FIONBIO, [1]) = 0
ioctl(3, FIONBIO, [1]) = 0
rt_sigprocmask(SIG_SETMASK, [], [INT QUIT TERM], 8) = 0
select(6, [3 5], NULL, NULL, NULL) = 1 (in [3])
read(3, "1024\n", 8192) = 5
write(1, "1024\n", 5) = 5
select(6, [3 5], NULL, NULL, NULL) = 1 (in [3])
read(3, "", 8192) = 0
select(6, [5], NULL, NULL, NULL) = 1 (in [5])
read(5, "", 8192) = 0
kill(4583, SIGKILL) = 0
exit_group(0) = ?
See read system call
reads 1024. But it should have to read 12000, where is the problem, can you identify now?
Edit No. 4
strace -e open modified-rsh localhost ulimit -n
open("/etc/ld.so.cache", O_RDONLY) = 3
open("/lib64/libcrypt.so.1", O_RDONLY) = 3
open("/lib64/libutil.so.1", O_RDONLY) = 3
open("/lib64/libc.so.6", O_RDONLY) = 3
open("/etc/nsswitch.conf", O_RDONLY) = 3
open("/etc/ld.so.cache", O_RDONLY) = 3
open("/lib64/libnss_files.so.2", O_RDONLY) = 3
open("/etc/passwd", O_RDONLY) = 3
open("/etc/services", O_RDONLY) = 3
open("/etc/resolv.conf", O_RDONLY) = 3
open("/etc/host.conf", O_RDONLY) = 3
open("/etc/hosts", O_RDONLY) = 3
open("/etc/hosts", O_RDONLY) = 3
These open system calls is called sequentially, that having 3 in command. Out of above , only four are readable, i.e., /etc/nsswitch.conf, /etc/passwd, /etc/services, /etc/resolv.conf
strace -e open rsh localhost ulimit -n
1 open("/etc/ld.so.cache", O_RDONLY) = 3
2 open("/lib64/libcrypt.so.1", O_RDONLY) = 3
3 open("/lib64/libutil.so.1", O_RDONLY) = 3
4 open("/lib64/libc.so.6", O_RDONLY) = 3
5 open("/etc/nsswitch.conf", O_RDONLY) = 3
6 open("/etc/ld.so.cache", O_RDONLY) = 3
7 open("/lib64/libnss_files.so.2", O_RDONLY) = 3
8 open("/etc/passwd", O_RDONLY) = 3
9 open("/etc/services", O_RDONLY) = 3
10 open("/etc/host.conf", O_RDONLY) = 3
11 open("/etc/resolv.conf", O_RDONLY) = 3
12 open("/etc/hosts", O_RDONLY) = 3
13 open("/etc/hosts", O_RDONLY) = 3
14 open("/etc/hosts", O_RDONLY) = 3
cat /etc/services | grep rsh
kshell 544/tcp krcmd # Kerberized `rsh' (v5)
rsh-spx 222/tcp # Berkeley rshd with SPX auth
rsh-spx 222/udp # Berkeley rshd with SPX auth
carrius-rshell 1197/tcp # Carrius Remote Access
carrius-rshell 1197/udp # Carrius Remote Access
airshot 3975/tcp # Air Shot
airshot 3975/udp # Air Shot
watershed-lm 6143/tcp # Watershed License Manager
watershed-lm 6143/udp # Watershed License Manager
modified-rsh 2529/tcp
The below command I used is used by one question on this forum whose link is here
[root@jhamb ~]# sudo grep limits /etc/pam.d/*
/etc/pam.d/atd:# To enable PAM user limits for atd, please uncomment the
/etc/pam.d/atd:# following line and configure /etc/security/limits.conf:
/etc/pam.d/atd:# session required pam_limits.so
/etc/pam.d/runuser:session required pam_limits.so
/etc/pam.d/sudo:session required pam_limits.so
/etc/pam.d/sudo-i:session required pam_limits.so
/etc/pam.d/system-auth:session required pam_limits.so
/etc/pam.d/system-auth-ac:session required pam_limits.so