[Mono-dev] Error in UnixGroupInfo

Rolf Bjarne Kvinge rolflists at ya.com
Thu Jun 21 07:58:20 EDT 2007


> 
> So we have two proposed solutions:
> 
> 1. Skip invalid user names in UnixGroupInfo.GetMembers().
> 
> Pro: Allows use on mis-configured systems
> 
> Con: The only way to know that an error occurred is to compare
> UnixGroupInfo.GetMembers().Length to
> UnixGroupInfo.GetMemberNames().Length, and then to find which one was
> invalid you'd have to go through both arrays.
> 
> 2. Return the invalid user from UnixGroupInfo.GetMembers(), but make
> the UnixUserInfo instance returned provide invalid data; Rafael Teixeira
> mentioned two ways to do this (subclass UnixUserInfo or have a bool
> 'valid' flag on the UnixUserInfo instance).
> 
> Pro: Allows use on mis-configured systems.
> Pro: To find out which user is invalid you don't need to compare two
> different arrays.
> 
> Con: All but one property would now be able to throw an exception,
> while previously they wouldn't.  So currently-working "broken" code like
> this: 
> 	UnixGroupInfo g = ...
> 	foreach (UnixUserInfo u in g.GetMembers ()) {
> 		Console.WriteLine ("User: {0}; Home: {1}",
> 			u.UserName, u.HomeDirectory);
> 	}
> 

Maybe I missed something, but won't g.GetMembers () throw an 'invalid
username' exception now for this scenario?

In which case this code is already broken and will continue to be broken
with this solution...

More complex samples can of course be constructed, which would present the
working->broken pattern here, but anyways we'd be throwing an exception for
a user which it was not possible to get earlier on because we'd throw an
exception :) 
 
Rolf

> 
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 
> 
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.472 / Virus Database: 269.9.1/857 - Release Date:
> 20/06/2007 14:18





More information about the Mono-devel-list mailing list