summaryrefslogtreecommitdiffstats
path: root/lib/exec_shell.c
diff options
context:
space:
mode:
authorRuediger Meier2016-02-11 03:45:11 +0100
committerRuediger Meier2016-02-11 13:40:28 +0100
commit7f79adb3429efe130ceb1b32032a1925abe66d76 (patch)
treec3983bc83403f6e7549759e248caac2ae11d92aa /lib/exec_shell.c
parentlib/path: ifdef path_set_prefix() like in path.h (diff)
downloadkernel-qcow2-util-linux-7f79adb3429efe130ceb1b32032a1925abe66d76.tar.gz
kernel-qcow2-util-linux-7f79adb3429efe130ceb1b32032a1925abe66d76.tar.xz
kernel-qcow2-util-linux-7f79adb3429efe130ceb1b32032a1925abe66d76.zip
exec_shell: prevent basename from modifying env
Fix warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Diffstat (limited to 'lib/exec_shell.c')
-rw-r--r--lib/exec_shell.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/exec_shell.c b/lib/exec_shell.c
index 2b723acb4..a7374bd33 100644
--- a/lib/exec_shell.c
+++ b/lib/exec_shell.c
@@ -32,12 +32,15 @@
void exec_shell(void)
{
- const char *shell = getenv("SHELL"), *shell_basename;
+ const char *shell = getenv("SHELL");
+ char *shellc = xstrdup(shell);
+ const char *shell_basename;
char *arg0;
+
if (!shell)
shell = DEFAULT_SHELL;
- shell_basename = basename(shell);
+ shell_basename = basename(shellc);
arg0 = xmalloc(strlen(shell_basename) + 2);
arg0[0] = '-';
strcpy(arg0 + 1, shell_basename);