[Category ("AndroidNotWorking")] // API 21 conditionally has setgrent in the NDK headers, but bionic doesn't export it public void NonReentrantSyscalls () { var seen = new Dictionary<string, object> (); foreach (UnixGroupInfo group in UnixGroupInfo.GetLocalGroups ()) { if (seen.ContainsKey (group.GroupName)) continue; seen.Add (group.GroupName, null); try { Group byName = Syscall.getgrnam (group.GroupName); Group byId = Syscall.getgrgid ((uint) group.GroupId); Assert.IsNotNull (byName, "#TNRS: access by name"); Assert.IsNotNull (byId, "#TNRS: access by gid"); UnixGroupInfo n = new UnixGroupInfo (byName); UnixGroupInfo u = new UnixGroupInfo (byId); Assert.AreEqual (group, n, "#TNRS: construct by name"); Assert.AreEqual (group, u, "#TNRS: construct by gid"); Assert.AreEqual (n, u, "#TNRS: name == gid?"); } catch (Exception e) { Assert.Fail ( string.Format ("#TRC: Exception constructing UnixGroupInfo: {0}", e.ToString())); } } }
public void SetOwner(string user, string group) { AssertNotDisposed(); long uid = new UnixUserInfo(user).UserId; long gid = new UnixGroupInfo(group).GroupId; SetOwner(uid, gid); }
public static UnixGroupInfo[] GetSupplementaryGroups() { uint[] ids = _GetSupplementaryGroupIds(); UnixGroupInfo[] groups = new UnixGroupInfo [ids.Length]; for (int i = 0; i < groups.Length; ++i) { groups [i] = new UnixGroupInfo(ids [i]); } return(groups); }
public static UnixGroupInfo[] GetSupplementaryGroups() { uint[] numArray = UnixEnvironment._GetSupplementaryGroupIds(); UnixGroupInfo[] unixGroupInfo = new UnixGroupInfo[(int)numArray.Length]; for (int i = 0; i < (int)unixGroupInfo.Length; i++) { unixGroupInfo[i] = new UnixGroupInfo((long)numArray[i]); } return(unixGroupInfo); }
public void SetOwner(UnixUserInfo owner, UnixGroupInfo group) { long uid, gid; uid = gid = -1; if (owner != null) { uid = owner.UserId; } if (group != null) { gid = owner.GroupId; } SetOwner(uid, gid); }
public void SetOwner(UnixUserInfo owner, UnixGroupInfo group) { long num = (long)-1; long groupId = num; long userId = num; if (owner != null) { userId = owner.UserId; } if (group != null) { groupId = owner.GroupId; } this.SetOwner(userId, groupId); }
public void SetOwner(string owner, string group) { long uid = -1; if (owner != null) { uid = new UnixUserInfo(owner).UserId; } long gid = -1; if (group != null) { gid = new UnixGroupInfo(group).GroupId; } SetOwner(uid, gid); }
public void ReentrantConstructors () { foreach (UnixGroupInfo group in UnixGroupInfo.GetLocalGroups ()) { try { UnixGroupInfo byName = new UnixGroupInfo (group.GroupName); UnixGroupInfo byId = new UnixGroupInfo (group.GroupId); Assert.AreEqual (group, byName, "#TRC: construct by name"); Assert.AreEqual (group, byId, "#TRC: construct by gid"); Assert.AreEqual (byName, byId, "#TRC: name == gid?"); } catch (Exception e) { Assert.Fail ( string.Format ("#TRC: Exception constructing UnixGroupInfo: {0}", e.ToString())); } } }
[Category ("AndroidNotWorking")] // API 21 conditionally has setgrent in the NDK headers, but bionic doesn't export it public void ReentrantConstructors () { var seen = new Dictionary<string, object> (); foreach (UnixGroupInfo group in UnixGroupInfo.GetLocalGroups ()) { if (seen.ContainsKey (group.GroupName)) continue; seen.Add (group.GroupName, null); try { UnixGroupInfo byName = new UnixGroupInfo (group.GroupName); UnixGroupInfo byId = new UnixGroupInfo (group.GroupId); Assert.AreEqual (group, byName, "#TRC: construct by name"); Assert.AreEqual (group, byId, "#TRC: construct by gid"); Assert.AreEqual (byName, byId, "#TRC: name == gid?"); } catch (Exception e) { Assert.Fail ( string.Format ("#TRC: Exception constructing UnixGroupInfo: {0}", e.ToString())); } } }
public void NonReentrantSyscalls () { foreach (UnixGroupInfo group in UnixGroupInfo.GetLocalGroups ()) { try { Group byName = Syscall.getgrnam (group.GroupName); Group byId = Syscall.getgrgid ((uint) group.GroupId); Assert.IsNotNull (byName, "#TNRS: access by name"); Assert.IsNotNull (byId, "#TNRS: access by gid"); UnixGroupInfo n = new UnixGroupInfo (byName); UnixGroupInfo u = new UnixGroupInfo (byId); Assert.AreEqual (group, n, "#TNRS: construct by name"); Assert.AreEqual (group, u, "#TNRS: construct by gid"); Assert.AreEqual (n, u, "#TNRS: name == gid?"); } catch (Exception e) { Assert.Fail ( string.Format ("#TRC: Exception constructing UnixGroupInfo: {0}", e.ToString())); } } }
public void SetOwner(UnixUserInfo owner, UnixGroupInfo group) { long uid, gid; uid = gid = -1; if (owner != null) uid = owner.UserId; if (group != null) gid = owner.GroupId; SetOwner (uid, gid); }
public void SetOwner(string owner, string group) { long uid = -1; if (owner != null) uid = new UnixUserInfo (owner).UserId; long gid = -1; if (group != null) gid = new UnixGroupInfo (group).GroupId; SetOwner (uid, gid); }
public static void SetSupplementaryGroups (UnixGroupInfo[] groups) { uint[] list = new uint [groups.Length]; for (int i = 0; i < list.Length; ++i) { list [i] = Convert.ToUInt32 (groups [i].GroupId); } int r = Native.Syscall.setgroups (list); UnixMarshal.ThrowExceptionForLastErrorIf (r); }
public static UnixGroupInfo[] GetSupplementaryGroups () { uint[] ids = _GetSupplementaryGroupIds (); UnixGroupInfo[] groups = new UnixGroupInfo [ids.Length]; for (int i = 0; i < groups.Length; ++i) groups [i] = new UnixGroupInfo (ids [i]); return groups; }
static uint GetGid (string group) { var info = new UnixGroupInfo (group); var gid = info.GroupId; if (gid > UInt32.MaxValue || gid <= 0) throw new ArgumentOutOfRangeException ("group", String.Format ("Gid for {0} ({1}) not in range for sgid", group, gid)); return (uint)gid; }
static void CreateWithPerm (string path, string permissions, string groupName = null) { Directory.CreateDirectory (path); uint perm = Convert.ToUInt32(permissions, 8); Syscall.chmod (path, NativeConvert.ToFilePermissions (perm)); if (groupName == null) return; var group = new UnixGroupInfo (groupName); Syscall.chown (path, 0, (uint)group.GroupId); }
public void SetOwner(string user, string group) { AssertNotDisposed (); long uid = new UnixUserInfo (user).UserId; long gid = new UnixGroupInfo (group).GroupId; SetOwner (uid, gid); }
public Group ToGroup() { return(UnixGroupInfo.CopyGroup(this.@group)); }
public UnixGroupInfo(Group group) { this.@group = UnixGroupInfo.CopyGroup(group); }