couple of getpwnam() questions
simo.sorce at polimi.it
Sun Nov 26 01:02:30 GMT 2000
On Sun, 26 Nov 2000 okuyamak at dd.iij4u.or.jp wrote:
> >>>>> "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.
Isn't it better to force samba user to have only lowercase names?
Or, at least have a switch in smb.conf to enable/disable the use of
lowercase names only?
I never make any username with any uppercase letters and such a switch
would make my samba more efficient while unix admin that have also
uppercase names in their passwd/nis/ldap... may still make samba try to
match the username.
as any getpw* functions maybe really slow on /etc/passwd only databases,
isn't it better to make an optimezed module to case-insesitive-read from
/etc/passwd ? (enabled as compile time option perhaps?)
Simo Sorce - Integrazione Sistemi Unix/Windows - Politecnico di Milano
E-mail: simo.sorce at polimi.it
Tel.int: 02 2399 2425 - Fax.int. 02 2399 2451
Be happy, use Linux!
More information about the samba-technical