Пример #1
0
        public EtcUser[] GetAllUsers()
        {
            List <EtcUser> result = new List <EtcUser>();

            string[] passwdFile = File.ReadAllLines(passwdPath);

            foreach (string line in passwdFile)
            {
                string[] passwdProperties = line.Split(':');
                if (passwdProperties.Length > 1)
                {
                    EtcUser etcUser = new EtcUser()
                    {
                        Name   = passwdProperties[0],
                        Passwd = passwdProperties[1],
                        Uid    = int.Parse(passwdProperties[2]),
                        Gid    = int.Parse(passwdProperties[3]),
                        Gecos  = passwdProperties[4],
                        Dir    = passwdProperties[5],
                        Shell  = passwdProperties[6],
                    };

                    result.Add(etcUser);
                }
            }

            return(result.ToArray());
        }
Пример #2
0
        public EtcUser[] GetAllUsers()
        {
            List<EtcUser> result = new List<EtcUser>();

            string[] passwdFile = File.ReadAllLines(passwdPath);

            foreach (string line in passwdFile)
            {
                string[] passwdProperties = line.Split(':');
                if (passwdProperties.Length > 1)
                {
                    EtcUser etcUser = new EtcUser()
                    {
                        Name = passwdProperties[0],
                        Passwd = passwdProperties[1],
                        Uid = int.Parse(passwdProperties[2]),
                        Gid = int.Parse(passwdProperties[3]),
                        Gecos = passwdProperties[4],
                        Dir = passwdProperties[5],
                        Shell = passwdProperties[6],
                    };

                    result.Add(etcUser);
                }
            }

            return result.ToArray();
        }
Пример #3
0
        /// <summary>
        /// Gets the user information with the specified login name.
        /// </summary>
        /// <param name="name">The name of the user.</param>
        /// <returns>EtcUser</returns>
        public EtcUser GetPwanam(string name)
        {
            EtcUser etcUser = new EtcUser();

            string[] passwdFile = File.ReadAllLines(passwdPath);

            int    uid    = 0;
            int    gid    = 0;
            string passwd = string.Empty;
            string gecos  = string.Empty;
            string dir    = string.Empty;
            string shell  = string.Empty;

            foreach (string line in passwdFile)
            {
                string[] passwdProperties = line.Split(':');
                if (passwdProperties.Length > 1)
                {
                    if (passwdProperties[0] == name)
                    {
                        uid    = int.Parse(passwdProperties[2]);
                        gid    = int.Parse(passwdProperties[3]);
                        passwd = passwdProperties[1];
                        gecos  = passwdProperties[4];
                        dir    = passwdProperties[5];
                        shell  = passwdProperties[6];
                    }
                }
            }

            if (uid == 0)
            {
                throw new Exception(string.Format("User {0} does not exist", name));
            }

            etcUser.Name   = name;
            etcUser.Uid    = uid;
            etcUser.Gid    = gid;
            etcUser.Passwd = passwd;
            etcUser.Gecos  = gecos;
            etcUser.Dir    = dir;
            etcUser.Shell  = shell;

            return(etcUser);
        }
Пример #4
0
        /// <summary>
        /// Gets the user information with the specified login name.
        /// </summary>
        /// <param name="name">The name of the user.</param>
        /// <returns>EtcUser</returns>
        public EtcUser GetPwanam(string name)
        {
            EtcUser etcUser = new EtcUser();
            string[] passwdFile = File.ReadAllLines(passwdPath);

            int uid = 0;
            int gid = 0;
            string passwd = string.Empty;
            string gecos = string.Empty;
            string dir = string.Empty;
            string shell = string.Empty;

            foreach (string line in passwdFile)
            {
                string[] passwdProperties = line.Split(':');
                if (passwdProperties.Length > 1)
                {
                    if (passwdProperties[0] == name)
                    {
                        uid = int.Parse(passwdProperties[2]);
                        gid = int.Parse(passwdProperties[3]);
                        passwd = passwdProperties[1];
                        gecos = passwdProperties[4];
                        dir = passwdProperties[5];
                        shell = passwdProperties[6];
                    }
                }
            }

            if (uid == 0)
            {
                throw new Exception(string.Format("User {0} does not exist", name));
            }

            etcUser.Name = name;
            etcUser.Uid = uid;
            etcUser.Gid = gid;
            etcUser.Passwd = passwd;
            etcUser.Gecos = gecos;
            etcUser.Dir = dir;
            etcUser.Shell = shell;

            return etcUser;
        }
 public ApplicationContainer(string applicationUuid, string containerUuid, EtcUser userId, string applicationName,
     string containerName, string namespaceName, object quotaBlocks, object quotaFiles, Hourglass hourglass,int applicationUid=0)
 {
     this.config = NodeConfig.Values;
     this.Uuid = containerUuid;
     this.ApplicationUuid = applicationUuid;
     this.ApplicationName = applicationName;
     this.ContainerName = containerName;
     this.Namespace = namespaceName;
     this.QuotaBlocks = quotaBlocks;
     this.QuotaFiles = quotaFiles;
     this.State = new ApplicationState(this);            
     this.hourglass = hourglass ?? new Hourglass(3600);
     this.BaseDir = this.config["GEAR_BASE_DIR"];
     this.containerPlugin = new ContainerPlugin(this);
     this.Cartridge = new CartridgeModel(this, this.State, this.hourglass);            
     if (userId != null)
     {
         this.uid = userId.Uid;
         this.gid = userId.Gid;
         this.gecos = userId.Gecos;
     }
     if (applicationUid > 0)
     {
         this.uid = applicationUid;
     }
 }