Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Konsole
Commits
fa398f56
Commit
fa398f56
authored
Jul 11, 2020
by
Janet Blackquill
🌈
Committed by
Kurt Hindenburg
Nov 19, 2020
Browse files
Read shell from getpwuid when doing shell fallback
parent
923f8d14
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/session/Session.cpp
View file @
fa398f56
...
...
@@ -48,6 +48,12 @@
#include "terminalDisplay/TerminalDisplay.h"
#include "terminalDisplay/TerminalScrollBar.hpp"
// Linux
#ifdef Q_OS_LINUX
#include <sys/types.h>
#include <pwd.h>
#endif
using
namespace
Konsole
;
int
Session
::
lastSessionId
=
0
;
...
...
@@ -444,26 +450,30 @@ void Session::run()
_uniqueIdentifier
=
QUuid
::
createUuid
();
}
const
int
CHOICE_COUNT
=
3
;
// if '_program' is empty , fall back to default shell. If that is not set
// then fall back to /bin/sh
QString
programs
[
CHOICE_COUNT
]
=
{
_program
,
QString
::
fromUtf8
(
qgetenv
(
"SHELL"
)),
QStringLiteral
(
"/bin/sh"
)};
QStringList
programs
=
{
_program
,
QString
::
fromUtf8
(
qgetenv
(
"SHELL"
)),
QStringLiteral
(
"/bin/sh"
)};
#ifdef Q_OS_LINUX
auto
pw
=
getpwuid
(
getuid
());
// pw may be NULL
if
(
pw
!=
NULL
)
{
programs
.
insert
(
1
,
QString
::
fromLocal8Bit
(
pw
->
pw_shell
));
}
// we don't need to and shouldn't free pw
#endif
QString
exec
;
int
choice
=
0
;
while
(
choice
<
CHOICE_COUNT
)
{
exec
=
checkProgram
(
programs
[
choice
]);
if
(
exec
.
isEmpty
())
{
choice
++
;
}
else
{
for
(
auto
choice
:
programs
)
{
exec
=
checkProgram
(
choice
);
if
(
!
exec
.
isEmpty
())
{
break
;
}
}
// if a program was specified via setProgram(), but it couldn't be found, print a warning
if
(
choice
!=
0
&&
choice
<
CHOICE_COUNT
&&
!
_program
.
isEmpty
(
))
{
if
(
exec
!=
checkProgram
(
_program
))
{
terminalWarning
(
i18n
(
"Could not find '%1', starting '%2' instead. Please check your profile settings."
,
_program
,
exec
));
// if none of the choices are available, print a warning
}
else
if
(
choice
==
CHOICE_COUNT
)
{
}
else
if
(
programs
.
last
()
==
checkProgram
(
exec
)
)
{
terminalWarning
(
i18n
(
"Could not find an interactive shell to start."
));
return
;
}
...
...
Kurt Hindenburg
@hindenburg
mentioned in commit
98adc59f
·
Nov 21, 2020
mentioned in commit
98adc59f
mentioned in commit 98adc59f549ffbeedde8aff4d05d278cd0545961
Toggle commit list
Kurt Hindenburg
@hindenburg
mentioned in commit
34ad14c8
·
Jun 03, 2021
mentioned in commit
34ad14c8
mentioned in commit 34ad14c8cee4ab352481bf2ba190df9f8b744d29
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment