„LnxUser::addUser” változatai közötti eltérés
Innen: IT documentation
Nincs szerkesztési összefoglaló |
|||
| (5 közbenső módosítás ugyanattól a szerkesztőtől nincs mutatva) | |||
| 8. sor: | 8. sor: | ||
== Parameters == | == Parameters == | ||
; | ; user | ||
: Associative array what contains the new user's parameters. | : Associative array what contains the new user's parameters. | ||
:; | : The structure of the the array: | ||
: [ | |||
:; 'name' => string | |||
:: Mantandory! Name of linux user. | :: Mantandory! Name of linux user. | ||
:; | :; 'password' => string | ||
:: Mantandory! Password of linux user. | :: Mantandory! Password of linux user. | ||
:; | :; 'hash' => string | ||
:: Optional. Password hash method. The method must be one of [[LnxUser PHP Class Reference|LNX_PH family of constants]]. If 'password' is not present this parameter will be ineffective. | |||
:; 'salt' => string | |||
:: Optional. Password hash salt. You can read about password hash, salt, round relationships and requirements [https://www.php.net/manual/en/function.crypt here]. If 'password' is not present this parameter will be ineffective. | |||
:; 'round' => string | int | |||
:: Optional. Password hash round. You can read about password hash, salt, round relationships and requirements [https://www.php.net/manual/en/function.crypt here]. If 'password' is not present this parameter will be ineffective. | |||
:; 'uid' => int | |||
:: Optional. User ID of linux user. The ID must not exist! | :: Optional. User ID of linux user. The ID must not exist! | ||
:; | :; 'gid' => int | string | ||
:: Optional. Primary group of the linux user. The group must exist! If this parameter is not present the Group name will be the User name and the Group ID will be the User ID or the first free ID. | :: Optional. Primary group of the linux user. The group must exist! If this parameter is not present the Group name will be the User name and the Group ID will be the User ID or the first free ID. | ||
:; | :; 'groups' => array | ||
:: Optional. Group membership of the linux user. It must be a simple indexed array what contains the groups in what the user will be member. The groups must exist. | :: Optional. Group membership of the linux user. It must be a simple indexed array what contains the groups in what the user will be member. The groups must exist. | ||
:; | :; 'nogroup' => bool | ||
:: Optional. If ''' | :: Optional. If '''true''' the Primary group will not be created. If 'gid' is present this parameter will be ineffective. | ||
:; | :; 'comment' => string | ||
:: Optional. Comment (display name) of linux user. | :: Optional. Comment (display name) of linux user. | ||
:; | :; 'home' => string | ||
:: Optional. Absolute path of Home directory of linux user. | :: Optional. Absolute path of Home directory of linux user. | ||
:; | :; 'createhome' => bool | ||
:: Optional. If ''' | :: Optional. If '''false''' the Home directory will not be created. | ||
:; | :; 'shell' => string | ||
:: Optional. Absolute path of shell for linux user. | :: Optional. Absolute path of shell for linux user. | ||
:; | :; 'inactive' => int | ||
:: Optional. The number of days after password expires that account is disabled. | :: Optional. The number of days after password expires that account is disabled. | ||
:; | :; 'expire' => int | ||
:: Optional. Date when account will be disabled. Format: | :: Optional. Date when account will be disabled. Format: timestamp. | ||
:; | :; 'system' => bool | ||
:: Optional. If ''' | :: Optional. If '''true''' create a system account. User ID will be under 1000. If 'uid' is present this parameter will be ineffective. | ||
:; | :; 'nonunique' => bool | ||
:: Optional. If ''' | :: Optional. If '''true''' allow to create users with duplicate (non-unique) User ID. | ||
: ] | |||
== Return Values == | == Return Values == | ||
| 46. sor: | 55. sor: | ||
!Version<br>(lnxUser) | !Version<br>(lnxUser) | ||
!Description | !Description | ||
|- | |||
|1.2 | |||
|add: password hash, salt, round | |||
|- | |- | ||
|1.00 | |1.00 | ||
A lap jelenlegi, 2021. szeptember 23., 20:13-kori változata
Description
Object-oriented style
public lnxUser::addUser ( array $user ): bool
Procedural style
lnxAddUser ( array $user ): bool
Create a linux user with user parameters.
Parameters
- user
- Associative array what contains the new user's parameters.
- The structure of the the array:
- [
- 'name' => string
- Mantandory! Name of linux user.
- 'password' => string
- Mantandory! Password of linux user.
- 'hash' => string
- Optional. Password hash method. The method must be one of LNX_PH family of constants. If 'password' is not present this parameter will be ineffective.
- 'salt' => string
- Optional. Password hash salt. You can read about password hash, salt, round relationships and requirements here. If 'password' is not present this parameter will be ineffective.
- 'round' => string | int
- Optional. Password hash round. You can read about password hash, salt, round relationships and requirements here. If 'password' is not present this parameter will be ineffective.
- 'uid' => int
- Optional. User ID of linux user. The ID must not exist!
- 'gid' => int | string
- Optional. Primary group of the linux user. The group must exist! If this parameter is not present the Group name will be the User name and the Group ID will be the User ID or the first free ID.
- 'groups' => array
- Optional. Group membership of the linux user. It must be a simple indexed array what contains the groups in what the user will be member. The groups must exist.
- 'nogroup' => bool
- Optional. If true the Primary group will not be created. If 'gid' is present this parameter will be ineffective.
- 'comment' => string
- Optional. Comment (display name) of linux user.
- 'home' => string
- Optional. Absolute path of Home directory of linux user.
- 'createhome' => bool
- Optional. If false the Home directory will not be created.
- 'shell' => string
- Optional. Absolute path of shell for linux user.
- 'inactive' => int
- Optional. The number of days after password expires that account is disabled.
- 'expire' => int
- Optional. Date when account will be disabled. Format: timestamp.
- 'system' => bool
- Optional. If true create a system account. User ID will be under 1000. If 'uid' is present this parameter will be ineffective.
- 'nonunique' => bool
- Optional. If true allow to create users with duplicate (non-unique) User ID.
- ]
Return Values
Returns true if user is created, false otherwise.
Changelog
| Version (lnxUser) |
Description |
|---|---|
| 1.2 | add: password hash, salt, round |
| 1.00 | available |
Examples
$user = 'testUser';
# Add linux user
if ( ! lnxAddUser( [
'name' => $user, // Mantandory! Name of linux user.
'password' => 'HelloNSA', // Mantandory! Password of linux user.
//'uid' => 1100, // Optional. User ID of linux user. The ID must not exist!
//'gid' => 1100, // Optional. Primary group of the linux user. The group must exist! If this parameter is not present the Group name will be the User name and the Group ID will be the User ID or the first free ID.
'groups' => [ 'users' ], // Optional. Group membership of the linux user. It must be a simple indexed array what contains the groups in what the user will be member. The groups must exist.
//'nogroup' => true, // Optional. If true the Primary group will not be created. If 'gid' is present this parameter will be ineffective.
'comment' => 'test user', // Optional. Comment (display name) of linux user.
//'home' => '/home/test',// Optional. Absolute path of Home directory of linux user.
//'createhome' => true, // Optional. If false the Home directory will not be created.
//'shell' => '/bin/bash', // Optional. Absolute path of shell for linux user.
//'inactive' => 90, // Optional. The number of days after password expires that account is disabled.
//'expire' => 1640995199, // Optional. Date when account will be disabled. Format: timestamp.
//'system' => true, // Optional. If true create a system account. User ID will be under 1000. If 'uid' is present this parameter will be ineffective.
//'nonunique' => true , // Optional. If true allow to create users with duplicate (non-unique) User ID.
] ) )
print( "Something went wrong during Add user!" . PHP_EOL );
else
print( "'$user' user is created." . PHP_EOL );