Пример #1
0
        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");
            }
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
 public UnixUserInfo(Native.Passwd passwd)
 {
     this.passwd = CopyPasswd(passwd);
 }