Also remove squirrelmail .sig files when deleting an account

This commit is contained in:
Daniel Winzen 2023-07-21 18:37:29 +02:00
parent 511eaff924
commit 56aa005a57
No known key found for this signature in database
GPG key ID: 222FCC3F35C41077

View file

@ -32,16 +32,17 @@ while ( $tmp = $stmt->fetch( PDO::FETCH_ASSOC ) ) {
if ( file_exists( $mail_files ) ) { if ( file_exists( $mail_files ) ) {
exec( 'rm -r ' . escapeshellarg( $mail_files ) ); exec( 'rm -r ' . escapeshellarg( $mail_files ) );
} }
@unlink( '/var/local/squirrelmail/data/' . $local_basename . '@' . $domain_basename . '.pref' ); $files = glob( '/var/local/squirrelmail/data/' . $local_basename . '@' . $domain_basename . '.{pref,abook,sig}', GLOB_BRACE );
@unlink( '/var/local/squirrelmail/data/' . $local_basename . '@' . $domain_basename . '.abook' );
if ( $tmp[ 'domain' ] === 'danwin1210.de' ) { if ( $tmp[ 'domain' ] === 'danwin1210.de' ) {
@unlink( '/var/local/squirrelmail/data/' . $local_basename . '.pref' ); $files = array_merge( $files, glob( '/var/local/squirrelmail/data/' . $local_basename . '{@danielas3rtn54uwmofdo3x2bsdifr47huasnmbgqzfrec5ubupvtpid.onion,}.{pref,abook,sig}', GLOB_BRACE ) );
@unlink( '/var/local/squirrelmail/data/' . $local_basename . '.abook' );
@unlink( '/var/local/squirrelmail/data/' . $local_basename . '@danielas3rtn54uwmofdo3x2bsdifr47huasnmbgqzfrec5ubupvtpid.onion.pref' );
@unlink( '/var/local/squirrelmail/data/' . $local_basename . '@danielas3rtn54uwmofdo3x2bsdifr47huasnmbgqzfrec5ubupvtpid.onion.abook' );
$delete_prosody->execute( [ $tmp[ 'local_part' ], $tmp[ 'domain' ] ] ); $delete_prosody->execute( [ $tmp[ 'local_part' ], $tmp[ 'domain' ] ] );
$delete_prosody_archive->execute( [ $tmp[ 'local_part' ], $tmp[ 'domain' ] ] ); $delete_prosody_archive->execute( [ $tmp[ 'local_part' ], $tmp[ 'domain' ] ] );
} }
if ( is_array( $files ) ) {
foreach ( $files as $file ) {
@unlink( $file );
}
}
} }
if ( $tmp[ 'active' ] === -2 ) { if ( $tmp[ 'active' ] === -2 ) {
$delete->execute( [ $tmp[ 'username' ] ] ); $delete->execute( [ $tmp[ 'username' ] ] );
@ -60,7 +61,7 @@ while ( $tmp = $stmt->fetch( PDO::FETCH_ASSOC ) ) {
if ( ! in_array( $domain_basename, [ '..', '.', '' ], true ) ) { if ( ! in_array( $domain_basename, [ '..', '.', '' ], true ) ) {
$del_alias->execute( [ $tmp[ 'domain' ] ] ); $del_alias->execute( [ $tmp[ 'domain' ] ] );
$del_mailbox->execute( [ $tmp[ 'domain' ] ] ); $del_mailbox->execute( [ $tmp[ 'domain' ] ] );
$files = glob( '/var/local/squirrelmail/data/*@' . $domain_basename . '.{pref,abook}', GLOB_BRACE ); $files = glob( '/var/local/squirrelmail/data/*@' . $domain_basename . '.{pref,abook,sig}', GLOB_BRACE );
$mail_files = '/var/mail/vmail/' . $domain_basename . '/'; $mail_files = '/var/mail/vmail/' . $domain_basename . '/';
if ( file_exists( $mail_files ) ) { if ( file_exists( $mail_files ) ) {
exec( 'rm -r ' . escapeshellarg( $mail_files ) ); exec( 'rm -r ' . escapeshellarg( $mail_files ) );