コード例 #1
0
ファイル: UserAdd.auto.cs プロジェクト: isukces/SimpleLinux
        public static void CheckConflicts(this UserAddFlags value)
        {
            var flagsFilter = UserAddFlags.DoNotCreateHomeDirectory | UserAddFlags.CreateHome;

            if ((value & flagsFilter) == flagsFilter)
            {
                throw new Exception("options -M and --create-home can't be used together");
            }
        }
コード例 #2
0
ファイル: UserAdd.auto.cs プロジェクト: isukces/SimpleLinux
 public static UserAddFlags SetOrClear(this UserAddFlags current, UserAddFlags value, bool add)
 {
     if (add)
     {
         return(current | value);
     }
     else
     {
         return(current & ~value);
     }
 }
コード例 #3
0
ファイル: UserAdd.auto.cs プロジェクト: isukces/SimpleLinux
 public static IEnumerable <string> OptionsToString(this UserAddFlags value, OptionPreference preferLongNames = OptionPreference.Short)
 {
     // generator : SingleTaskEnumsGenerator
     CheckConflicts(value);
     // -l, --no-log-init: Do not add the user to the lastlog and faillog databases.
     if ((value & UserAddFlags.NoLogInit) != 0)
     {
         yield return(preferLongNames == OptionPreference.Long ? "--no-log-init" : "-l");
     }
     // -m, --create-home: Create the user's home directory if it does not exist.
     if ((value & UserAddFlags.CreateHome) != 0)
     {
         yield return(preferLongNames == OptionPreference.Long ? "--create-home" : "-m");
     }
     // -M: Do not create the user's home directory, even if the system wide setting from /etc/login.defs (CREATE_HOME) is set to yes.
     if ((value & UserAddFlags.DoNotCreateHomeDirectory) != 0)
     {
         yield return("-M");
     }
     // -N, --no-user-group: Do not create a group with the same name as the user, but add the user to the group specified by the -g option or by the GROUP variable in /etc/default/useradd.
     if ((value & UserAddFlags.NoUserGroup) != 0)
     {
         yield return(preferLongNames == OptionPreference.Long ? "--no-user-group" : "-N");
     }
     // -o, --non-unique: Allow the creation of a user account with a duplicate (non-unique) UID.
     if ((value & UserAddFlags.NonUnique) != 0)
     {
         yield return(preferLongNames == OptionPreference.Long ? "--non-unique" : "-o");
     }
     // -r, --system: Create a system account.
     if ((value & UserAddFlags.System) != 0)
     {
         yield return(preferLongNames == OptionPreference.Long ? "--system" : "-r");
     }
     // -U, --user-group: Create a group with the same name as the user, and add the user to this group. The default behavior (if the -g, -N, and -U options are not specified) is defined by the USERGROUPS_ENAB variable in /etc/login.defs.
     if ((value & UserAddFlags.UserGroup) != 0)
     {
         yield return(preferLongNames == OptionPreference.Long ? "--user-group" : "-U");
     }
 }