couple of getpwnam() questions
okuyamak at dd.iij4u.or.jp
okuyamak at dd.iij4u.or.jp
Sat Nov 25 15:28:45 GMT 2000
I don't really know what is the "right" cases about
'Administorator's. But if I were....
>>>>> "GC" == Gerald Carter <gcarter at valinux.com> writes:
GC> No one responded to this. Should I threaten making
GC> the change to issue #1 unless I hear differently?
GC> Does anyone depend on this behavior currently?
I don't even see the reason why current code uses this way.
Instead, I recommend using getpwent() function, take out each entry,
and do case insensitive match, or what ever match required.
# or, simply open the /etc/passwd file directly and look for
# entry.
I don't think
>> o getpwnam("Administrator")
>> o getpwnam("administrator")
>> o getpwnam("ADMINISTRATOR")
>> o getpwnam("administratoR")
>> o getpwnam("AdministratoR")
are the only entries we should look at. There are chances like
o getpwnam("aDministratOr")
o getpwnam("adMinistraTor")
o getpwnam("admInistrAtor")
o getpwnam("admiNistRator")
o getpwnam("adminIsTrator")
o getpwnam("adminiStrator")
etc.
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.
# We can always ask for regular express matching engine from GNU
# library. So even asking for regexp match is 'coding costy'.
best regards,
----
Kenichi Okuyama at Tokyo Research Lab. IBM-Japan, Co.
More information about the samba-technical
mailing list