diff options
author | Gerco Dries <gerco@gdries.nl> | 2016-10-26 00:31:21 +0300 |
---|---|---|
committer | Gerco Dries <gerco@gdries.nl> | 2016-10-26 00:33:38 +0300 |
commit | d328847085562a3a6f1bcc4a28542e98c0da199f (patch) | |
tree | d06e12ac8f8ceb5c11cf99e250d9ed484aa02d64 /thirdparty | |
parent | ed87c6e93e5abf83d6fba83708cc948ee1e3652b (diff) |
Fix exceptions when users and groups are not defined on the local system (such as when a system is bound to Active Directory or a user or group has been deleted).
Diffstat (limited to 'thirdparty')
-rw-r--r-- | thirdparty/UnixSupport/File.cs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/thirdparty/UnixSupport/File.cs b/thirdparty/UnixSupport/File.cs index f96152201..18ace7fca 100644 --- a/thirdparty/UnixSupport/File.cs +++ b/thirdparty/UnixSupport/File.cs @@ -238,8 +238,26 @@ namespace UnixSupport UID = fse.OwnerUserId;
GID = fse.OwnerGroupId;
Permissions = (long)fse.FileAccessPermissions;
- OwnerName = fse.OwnerUser.UserName;
- GroupName = fse.OwnerGroup.GroupName;
+
+ try
+ {
+ OwnerName = fse.OwnerUser.UserName;
+ }
+ catch (ArgumentException)
+ {
+ // Could not retrieve user name, possibly the user is not defined on the local system
+ OwnerName = null;
+ }
+
+ try
+ {
+ GroupName = fse.OwnerGroup.GroupName;
+ }
+ catch (ArgumentException)
+ {
+ // Could not retrieve group name, possibly the group is not defined on the local system
+ GroupName = null;
+ }
}
}
|