M
Michal Kwiatkowski
Hi,
Please look at the following code:
sub get_current_uids {
my(@uids, $uid);
setpwent;
push @uids, $uid while defined($uid = (getpwent)[2]);
endpwent;
return @uids;
}
&get_current_uids;
On systems with considerably large /etc/shadow and /etc/passwd files
(about 10.000 entries) it takes very long time to execute. Stracing it
shows really long loop of intructions quoted below:
open("/etc/shadow", O_RDONLY) = 4
fcntl64(4, F_GETFD) = 0
fcntl64(4, F_SETFD, FD_CLOEXEC) = 0
_llseek(4, 0, [0], SEEK_CUR) = 0
fstat64(4, {st_mode=S_IFREG|0640, st_size=1538953, ...}) = 0
fstat64(4, {st_mode=S_IFREG|0640, st_size=1538953, ...}) = 0
mmap2(NULL, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb7d09000
read(4, "root:$1$uUu3dni5$qztZJWVijz2SQGv"..., 131072) = 131072
close(4) = 0
munmap(0xb7d09000, 131072) = 0
open("/etc/shadow", O_RDONLY) = 4
fcntl64(4, F_GETFD) = 0
etc.....
It seems as getpwent opens "/etc/shadow" each time it is called. Is this
really needed? In fact, subroutine get_current_uids is part of adduser
script, so this bug affects lots of users.
mk
Please look at the following code:
sub get_current_uids {
my(@uids, $uid);
setpwent;
push @uids, $uid while defined($uid = (getpwent)[2]);
endpwent;
return @uids;
}
&get_current_uids;
On systems with considerably large /etc/shadow and /etc/passwd files
(about 10.000 entries) it takes very long time to execute. Stracing it
shows really long loop of intructions quoted below:
open("/etc/shadow", O_RDONLY) = 4
fcntl64(4, F_GETFD) = 0
fcntl64(4, F_SETFD, FD_CLOEXEC) = 0
_llseek(4, 0, [0], SEEK_CUR) = 0
fstat64(4, {st_mode=S_IFREG|0640, st_size=1538953, ...}) = 0
fstat64(4, {st_mode=S_IFREG|0640, st_size=1538953, ...}) = 0
mmap2(NULL, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb7d09000
read(4, "root:$1$uUu3dni5$qztZJWVijz2SQGv"..., 131072) = 131072
close(4) = 0
munmap(0xb7d09000, 131072) = 0
open("/etc/shadow", O_RDONLY) = 4
fcntl64(4, F_GETFD) = 0
etc.....
It seems as getpwent opens "/etc/shadow" each time it is called. Is this
really needed? In fact, subroutine get_current_uids is part of adduser
script, so this bug affects lots of users.
mk