On Wed, Jun 29, 2005 at 09:00:05AM +0100, Clayton, Nik wrote:
> > > homedir_ok() verifies that the home directory for the given
> > > user exists, is owned/group owned by that user, and has a given
> > > set of permissions.
> > >
> > > homedir_ok(name => nik, uid => 1000, gid => 1000, perm => 0755,
> > > 'Check nik\'s home directory');
> >
> > Is it necessary to tell homedir_ok() what the proper uid and
> > gid is? Can't it figure it out from the name? In fact, wouldn't that
> > be more robust since the uid/gid on the system might change but the name
> > will stay the same.
>
> homedir_ok() needs the option, as it's possible that a user's home directory
> might not be owned by the given owner or group (we have accounts like that
> here... yeah, I know).
>
> uid and gid could probably be made smart. If the value =~ /^\d+$/ then use
> that, otherwise do getpwnam()/getgrnam() to determine the correct value.
I'd have separate arguments. uid and gid for the ID numbers, user and group
for their names. Avoids any heuristical gotchas.
# equivalent
homedir_ok( name => 'nik', uid => getpwnam('nik') );
homedir_ok( name => 'nik', user => 'nik' );
Or perhaps "owner" would be getter than "user" to use the normal permissions
parlance and to not confuse it with "name".
What I was really thinking is that, uid should default to
getpwnam($args{name}) so that
# equivalent
homedir_ok( name => 'nik' );
homedir_ok( name => 'nik', uid => getpwnam('nik') );
are equivalent. But I realize now this is not a good idea because it leaves
the user unable to express "I don't care what the UID is".
> Any concerns about the namespace? I thought perhaps
>
> Test::Unix::User
> Test::Unix::Group
>
> might be better, but I'm open to suggestions.
Putting them in the Test::Unix namespace probably is a good idea.
--
Michael G Schwern [EMAIL PROTECTED] http://www.pobox.com/~schwern
'All anyone gets in a mirror is themselves,' she said. 'But what you
gets in a good gumbo is everything.'
-- "Witches Abroad" by Terry Prachett