couple of getpwnam() questions

okuyamak at dd.iij4u.or.jp okuyamak at dd.iij4u.or.jp
Sat Nov 25 21:16:26 GMT 2000


>>>>> "SL" == Steve Langasek <vorlon at netexpress.net> writes:
>> At least, getpwnam() will open(), close() and scan entire
>> /etc/passwd every time being called. This is large overhead, too
>> large. With 'getpwent() + case insensitive match', we only need
>> to scan once, though we might need more complex matching engine.
SL> This is true when getpwnam() uses a flatfile (/etc/passwd) for its backend,
SL> but this is not always the case, and therefore getpwent() is not always going
SL> to be much more efficient.  With some database backends (NIS+, LDAP, Berkeley
SL> DB, for example), you may find that calling getpwnam("user") is a *LOT* more
SL> efficient than iterating through getpwent().

! I didn't think about that case..... But wait.

Word "Administrator" have 2^13 patterns of upper and lower cases.
# What we are doing now is only not checking what we really should.

8192 ... is delicate number. Usually, we don't manage such a number
of users in single NIS server. But with multiple server, in case
like university, we do. If we think about single samba server's
number of users, we usually don't have such big numbers, but the
case we only need to think about single server, is when we manage
user with /etc/passwd file.


If we do have user name 'administrator' ( without thinking about
upper or lower cases ), we usually have them with name
"Administorator", the way NT server requires. So, within first three
checks ( "administrator", "ADMINISTRATOR", and "Administrator" )
we usually find him. But if we didn't, we have to check entire
8192 patterns to find out that we don't have such a user.


This problem seems lot harder to solve than what I first thought.
# .... Why is there no function getpwnum() ....?
# or .. why didn't Windows select words like ...
# "AdministrativeMemebers" :p or, other way around like
# "Bill" :(
---- 
Kenichi Okuyama at Tokyo Research Lab., IBM-Japan, Co.




More information about the samba-technical mailing list