LSaddon::posix: Add deleteHomeDirectoryByFTP function

This commit is contained in:
Benjamin Renard 2023-10-13 19:05:42 +02:00
parent 5e8d625a34
commit 5998983315
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -24,16 +24,22 @@
// Support // Support
LSerror :: defineError('POSIX_SUPPORT_01', LSerror :: defineError('POSIX_SUPPORT_01',
___("POSIX Support : The constant %{const} is not defined.") ___("POSIX Support: The constant %{const} is not defined.")
); );
LSerror :: defineError('POSIX_SUPPORT_02', LSerror :: defineError('POSIX_SUPPORT_02',
___("POSIX Support : Unable to load LSaddon::FTP.") ___("POSIX support: Unable to load LSaddon::FTP.")
); );
// Autres erreurs // Autres erreurs
LSerror :: defineError('POSIX_01', LSerror :: defineError('POSIX_01',
___("POSIX : The attribute %{dependency} is missing. Unable to forge the attribute %{attr}.") ___("POSIX: The attribute %{dependency} is missing. Unable to forge the attribute %{attr}.")
);
LSerror :: defineError('POSIX_02',
___("POSIX: Fail to create user home directory.")
);
LSerror :: defineError('POSIX_03',
___("POSIX: Fail to delete user home directory.")
); );
/** /**
@ -189,6 +195,30 @@ function createHomeDirectoryByFTP($ldapObject) {
return true; return true;
} }
/**
* Delete home directory by FTP
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param LSldapObject $ldapObject L'objet ldap
*
* @return bool True on success, false otherwise
*/
function deleteHomeDirectoryByFTP($ldapObject) {
$dir = getFData(LS_POSIX_HOMEDIRECTORY_FTP_PATH, $ldapObject, 'getValue');
if (
!removeDirsByFTP(
LS_POSIX_HOMEDIRECTORY_FTP_HOST, LS_POSIX_HOMEDIRECTORY_FTP_PORT,
LS_POSIX_HOMEDIRECTORY_FTP_USER, LS_POSIX_HOMEDIRECTORY_FTP_PWD,
$dir
)
) {
LSerror :: addErrorCode('POSIX_03');
return false;
}
return true;
}
/** /**
* Generate member attribute value from memberUid * Generate member attribute value from memberUid
* *