[OpenWrt-Devel] [PATCH] dropbear: use Openwrt default PATH also in dropbear

Hannu Nyman hannu.nyman at iki.fi
Fri Jan 15 08:02:56 EST 2016


Dropbear defines its own default PATH for new sessions.
When 500-set-default-path.patch was introduced by r32620,
the goal was to match /etc/profile.

Adjust 500-set-default-path.patch to match the current default PATH
as defined in https://dev.openwrt.org/changeset/47080/

   PATH=/usr/sbin:/usr/bin:/sbin:/bin

(In practice that PATH will be overridden by /etc/profile if that exists.)

Reference also to:
https://dev.openwrt.org/changeset/32620/
https://dev.openwrt.org/changeset/47590/
https://dev.openwrt.org/changeset/48235/  and
   http://git.openwrt.org/?p=project/procd.git;a=commit;h=45cb04fd85d788a37367a5385e5e90dd98a0a991

Signed-off-by: Hannu Nyman <hannu.nyman at iki.fi>
---

(I am not bumping the PKG_REVISION as dropbear version was bumped up today.)

After yesterday's fix to procd, I noticed that one process still had
a different PATH. It took a while to realize that it was coming
from hardcoded defaults in dropbear.

Process 23582 has different PATH than other processes:

 root at OpenWrt:~# grep -r PATH /proc/*/environ
 /proc/1/environ:PATH=/usr/sbin:/usr/bin:/sbin:/bin
 /proc/1299/environ:PATH=/usr/sbin:/usr/bin:/sbin:/bin
 ...
 /proc/23582/environ:PATH=/bin:/sbin:/usr/bin:/usr/sbin
 /proc/2401/environ:PATH=/usr/sbin:/usr/bin:/sbin:/bin
 /proc/2415/environ:PATH=/usr/sbin:/usr/bin:/sbin:/bin
 ...
 /proc/516/environ:PATH=/usr/sbin:/usr/bin:/sbin:/bin
 /proc/self/environ:PATH=/usr/sbin:/usr/bin:/sbin:/bin
 /proc/thread-self/environ:PATH=/usr/sbin:/usr/bin:/sbin:/bin

 root at OpenWrt:~# ps | grep ash
   516 root       896 S    /sbin/askfirst /bin/ash --login
 23582 root      1196 S    -ash
 23591 root      1192 S    grep ash

After this patch also the ash process has the same PATH as others:

 root at OpenWrt:~# grep -r PATH /proc/*/environ
 /proc/1/environ:PATH=/usr/sbin:/usr/bin:/sbin:/bin
 /proc/1288/environ:PATH=/usr/sbin:/usr/bin:/sbin:/bin
 ...
 /proc/4115/environ:PATH=/usr/sbin:/usr/bin:/sbin:/bin
 /proc/479/environ:PATH=/usr/sbin:/usr/bin:/sbin:/bin
 /proc/516/environ:PATH=/usr/sbin:/usr/bin:/sbin:/bin
 /proc/self/environ:PATH=/usr/sbin:/usr/bin:/sbin:/bin
 /proc/thread-self/environ:PATH=/usr/sbin:/usr/bin:/sbin:/bin

 root at OpenWrt:~# ps | grep ash
   516 root       896 S    /sbin/askfirst /bin/ash --login
  4115 root      1196 S    -ash
  4126 root      1192 S    grep ash

 package/network/services/dropbear/patches/500-set-default-path.patch | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/network/services/dropbear/patches/500-set-default-path.patch b/package/network/services/dropbear/patches/500-set-default-path.patch
index 648c391..7e8a4ff 100644
--- a/package/network/services/dropbear/patches/500-set-default-path.patch
+++ b/package/network/services/dropbear/patches/500-set-default-path.patch
@@ -5,7 +5,7 @@
  
  /* The default path. This will often get replaced by the shell */
 -#define DEFAULT_PATH "/usr/bin:/bin"
-+#define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin"
++#define DEFAULT_PATH "/usr/sbin:/usr/bin:/sbin:/bin"
  
  /* Some other defines (that mostly should be left alone) are defined
   * in sysoptions.h */
-- 
2.5.0
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list