public UnixUserInfo(string user) { passwd = new Native.Passwd(); Native.Passwd?pw; int r = Native.Syscall.getpwnam_r(user, passwd, out pw); if (r != 0 || pw == null) { throw new ArgumentException(Locale.GetText("invalid username"), "user"); } }
public UnixUserInfo(long user) { passwd = new Native.Passwd(); Native.Passwd pw; int r = Native.Syscall.getpwuid_r(Convert.ToUInt32(user), passwd, out pw); if (r != 0 || pw == null) { throw new ArgumentException(Locale.GetText("invalid user id"), "user"); } }
public void SetOwner(string owner) { Native.Passwd pw = Native.Syscall.getpwnam(owner); if (pw == null) { throw new ArgumentException(Locale.GetText("invalid username"), "owner"); } uint uid = pw.pw_uid; uint gid = pw.pw_gid; SetOwner((long)uid, (long)gid); }
private static Native.Passwd CopyPasswd(Native.Passwd pw) { Native.Passwd p = new Native.Passwd(); p.pw_name = pw.pw_name; p.pw_passwd = pw.pw_passwd; p.pw_uid = pw.pw_uid; p.pw_gid = pw.pw_gid; p.pw_gecos = pw.pw_gecos; p.pw_dir = pw.pw_dir; p.pw_shell = pw.pw_shell; return(p); }
public void SetOwner(string user) { AssertNotDisposed(); Native.Passwd pw = Native.Syscall.getpwnam(user); if (pw == null) { throw new ArgumentException(Locale.GetText("invalid username"), "user"); } long uid = pw.pw_uid; long gid = pw.pw_gid; SetOwner(uid, gid); }
public UnixUserInfo(Native.Passwd passwd) { this.passwd = CopyPasswd(passwd); }