summaryrefslogtreecommitdiffstats
path: root/perl-install/any.pm
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2025-12-27 10:08:31 +0000
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2025-12-27 10:49:14 +0000
commit94f2881456fa0dcbacec31d7973cc5d9eb9514ce (patch)
treef8daed4376440bf7ffa51546e82572d788d625bb /perl-install/any.pm
parent07290675d392c2dc34de4cf1aa795501278b4c12 (diff)
downloaddrakx-94f2881456fa0dcbacec31d7973cc5d9eb9514ce.tar
drakx-94f2881456fa0dcbacec31d7973cc5d9eb9514ce.tar.gz
drakx-94f2881456fa0dcbacec31d7973cc5d9eb9514ce.tar.bz2
drakx-94f2881456fa0dcbacec31d7973cc5d9eb9514ce.tar.xz
drakx-94f2881456fa0dcbacec31d7973cc5d9eb9514ce.zip
Fix inconsistent use of any::sessions()
Some callers of any::sessions() expected it to return a list of session names, other callers expected it to return a list of base file names, leading to various bugs in the autologin handling. So provide two new subroutines, session_files(), to provide a map of names to files, and session_names() to return a sorted list of names. Remove sessions() to avoid confusion in future. Fix up the users accordingly.
Diffstat (limited to 'perl-install/any.pm')
-rw-r--r--perl-install/any.pm36
1 files changed, 26 insertions, 10 deletions
diff --git a/perl-install/any.pm b/perl-install/any.pm
index dcf028853..830ec7eb5 100644
--- a/perl-install/any.pm
+++ b/perl-install/any.pm
@@ -811,6 +811,30 @@ sub setupBootloader__grub2 {
}
}
+sub session_dirs() {
+ qw( /usr/share/xsessions /usr/share/wayland-sessions );
+}
+
+sub session_files() {
+ my %sessions;
+ foreach my $session_dir (session_dirs()) {
+ foreach my $session_file (glob("$::prefix$session_dir/*.desktop")) {
+ my $basename = $session_file;
+ $basename =~ s!\.[^.]+$!!;
+ $basename =~ s!.*/!!;
+ my %session = read_gnomekderc($session_file, 'Desktop Entry');
+ $session{Name} =~ s/\s+//g;
+ $sessions{$session{Name}} = { dir => $session_dir, basename => $basename };
+ }
+ }
+ %sessions;
+}
+
+sub session_names() {
+ my %session_files = session_files();
+ sort(keys %session_files);
+}
+
sub get_session_file {
my ($desktop) = @_;
my @dir_wm = qw(xsessions wayland-sessions);
@@ -864,7 +888,7 @@ sub get_autologin() {
my $lightdm_conffile = "$::prefix/etc/lightdm/lightdm.conf.d/50-mageia-autologin.conf";
my $lxdm_conffile = "$::prefix/etc/lxdm/lxdm.conf";
my $autologin_file = "$::prefix/etc/sysconfig/autologin";
- my $desktop = $desktop{DESKTOP} || first(sessions());
+ my $desktop = $desktop{DESKTOP} || first(session_names());
my $dm =
basename(readlink("$::prefix/etc/systemd/system/display-manager.service")) =~ s/(.*)\.service/$1/r ||
desktop_to_dm($desktop) ||
@@ -1164,14 +1188,6 @@ sub ask_user_and_root {
$ret && $u;
}
-sub sessions() {
- my @l;
- my @dir_wm = qw(xsessions wayland-sessions);
- foreach my $dwm (@dir_wm) {
- push @l, map { s/.desktop$//; basename($_) } glob("$::prefix/usr/share/$dwm/*.desktop");
- }
- @l;
-}
sub sessions_with_order() {
my %h = map { /(.*)=(.*)/ } split(' ', run_program::rooted_get_stdout($::prefix, '/usr/sbin/chksession', '-L'));
\%h;
@@ -1257,7 +1273,7 @@ sub format_wm {
sub autologin {
my ($o, $in) = @_;
- my @wm = sessions();
+ my @wm = session_names();
my @users = map { $_->{name} } @{$o->{users} || []};
my $kde_desktop = find { member($_, 'KDE', 'KDE4') } @wm;