id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	blockedby	blocking	branch_state	votes
3689	mc doesn't recognize shell (e.g., /bin/sh) as bash when it is a link to bash binary	alllexx88		"Currently mc identifies shell as bash only if this statement is true (in lib/shell.c):

 (strstr (mc_shell->path, ""/bash"") != NULL || getenv (""BASH"") != NULL)

However, this won't work if shell, e.g., is /bin/sh pointing to bash. Let's see why:

1. (strstr (mc_shell->path, ""/bash"") != NULL) is obviously false, since shell path doesn't end with ""/bash""

2. (getenv (""BASH"") != NULL) is false too, unless BASH env variable was somewhere intentionally set, since BASH is actually internal bash variable -- not environmental variable, and so by default getenv (""BASH"") is NULL

Here's a log that illustrates the second point:

{{{
#!div style=""background: #ffd; border: 3px ridge""
  {{{#!default
root@DiskStation:/opt# cat test.c
#include <stdio.h>      /* printf */
#include <stdlib.h>     /* getenv */

int main ()
{
  char* bash;
  bash = getenv (""BASH"");
  if (bash!=NULL)
    printf (""$BASH=%s\n"",bash);
  return 0;
}
root@DiskStation:/opt# gcc test.c -o test
root@DiskStation:/opt# echo $BASH
/bin/ash
root@DiskStation:/opt# env
SHELL=/bin/ash
TERM=xterm
SSH_CLIENT=192.168.133.169 63110 22
SSH_TTY=/dev/pts/5
LC_ALL=en_US.utf8
USER=root
PAGER=more
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin:/opt/bin:/opt/sbin
MAIL=/var/mail/root
PWD=/opt
EDITOR=/opt/bin/nano
LANG=en_US.utf8
PS1=\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$
HOME=/root
SHLVL=2
TERMINFO=/usr/share/terminfo
LOGNAME=root
SSH_CONNECTION=192.168.133.169 63110 192.168.133.15 22
PGDATA=/var/services/pgsql
_=/bin/env
root@DiskStation:/opt# ./test
root@DiskStation:/opt# export BASH=$BASH
root@DiskStation:/opt# ./test
$BASH=/bin/ash
root@DiskStation:/opt# /bin/ash --version
GNU bash, version 4.3.39(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
  }}}
}}}

This is a log from Synology DSM 6.0. It uses /bin/ash as login shell for root user, and /bin/sh -- for admin user. Both /bin/ash and /bin/sh are links to bash. Starting mc as root leads to identifying shell as busybox ash, and as admin -- leads to 'common.c: unimplemented subshell type 1' error and no subshell as the result.

The suggested fix (attaching patch next) is to test whether mc_shell->real_path ends with ""/bash"". Tested to work fine on Synology DSM 6.0."	enhancement	closed	major		mc-core	master	duplicate	shell bash	egmont			no branch	
