fix: workaround a deluser bug in Debian 13

pull/570/head
Stéphane Lesimple 6 months ago committed by Stéphane Lesimple
parent c4112994f4
commit 686b56619d

@ -158,7 +158,7 @@ my %_autoload_files = (
qw{ enable_mocking is_mocking set_mock_data mock_get_account_entry mock_get_account_accesses mock_get_account_personal_accesses mock_get_account_legacy_accesses mock_get_group_accesses mock_get_account_guest_accesses }
],
os => [
qw{ sysinfo is_linux is_debian is_redhat is_bsd is_freebsd is_openbsd is_netbsd has_acls sys_useradd sys_groupadd sys_userdel sys_groupdel sys_addmembertogroup sys_delmemberfromgroup sys_changepassword sys_neutralizepassword sys_setpasswordpolicy sys_getpasswordinfo sys_getsudoersfolder sys_setfacl is_in_path sys_getpw_all sys_getpw_all_cached sys_getpw_name sys_getgr_all sys_getgr_all_cached sys_getgr_name sys_list_processes }
qw{ sysinfo is_linux is_debian is_debian_trixie is_redhat is_bsd is_freebsd is_openbsd is_netbsd has_acls sys_useradd sys_groupadd sys_userdel sys_groupdel sys_addmembertogroup sys_delmemberfromgroup sys_changepassword sys_neutralizepassword sys_setpasswordpolicy sys_getpasswordinfo sys_getsudoersfolder sys_setfacl is_in_path sys_getpw_all sys_getpw_all_cached sys_getpw_name sys_getgr_all sys_getgr_all_cached sys_getgr_name sys_list_processes }
],
password => [qw{ get_hashes_from_password get_password_file get_hashes_list is_valid_hash }],
ssh => [

@ -11,7 +11,7 @@ sub sysinfo {
while (my $line = <$fh>) {
chomp $line;
# man 5 os-release
foreach my $key (qw{ NAME VERSION ID ID_LIKE PRETTY_NAME }) {
foreach my $key (qw{ NAME VERSION ID VERSION_ID ID_LIKE PRETTY_NAME }) {
$data{lc($key)} = $1 if $line =~ m{^${key}="?([^"]+)};
}
}
@ -42,8 +42,9 @@ sub _is_distro {
}
return R('KO');
}
sub is_debian { return _is_distro('debian'); }
sub is_redhat { return _is_distro('rhel'); }
sub is_debian { return _is_distro('debian'); }
sub is_debian_trixie { return R(_is_distro('debian') && sysinfo()->value->{'version_id'} eq "13" ? 'OK' : 'KO'); }
sub is_redhat { return _is_distro('rhel'); }
sub is_bsd { return R($^O =~ /bsd$/ ? 'OK' : 'KO'); }
sub is_freebsd { return R($^O eq 'freebsd' ? 'OK' : 'KO'); }
@ -296,7 +297,8 @@ sub sys_delmemberfromgroup {
if (is_freebsd()) {
@cmd = ('pw', 'groupmod', '-n', $group, '-d', $user);
}
elsif (is_debian()) {
# remove the Trixie if when this is fixed https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1109329
elsif (is_debian() && !is_debian_trixie()) {
@cmd = ('deluser', $user, $group);
}
elsif (is_openbsd() || is_linux()) {

Loading…
Cancel
Save