Commit Graph

131 Commits

Author SHA1 Message Date
MaxMougg
1622c80be4
Fix indentations 2022-05-30 11:28:17 -04:00
MaxMougg
c77d02bb11
Update svr-chansession for build issue
Following issue "Compilation error when disabling pubkey authentication (DROPBEAR_SVR_PUBKEY_AUTH)" from davidbernard04, code is modified to take in account that requesting information from method "ses.authstate.pubkey_info" isn't possible since the method is disabled when DROPBEAR_SVR_PUBKEY_OPTIONS_BUILT value is 0.
2022-05-30 11:01:16 -04:00
Raphael Hertzog
0e042476a0 Add /usr/sbin and /sbin to default root PATH
When dropbear is used in a very restricted environment (such as in a
initrd), the default user shell is often also very restricted
and doesn't take care of setting the PATH so the user ends up
with the PATH set by dropbear. Unfortunately, dropbear always
sets "/usr/bin:/bin" as default PATH even for the root user
which should have /usr/sbin and /sbin too.

For a concrete instance of this problem, see the "Remote Unlocking"
section in this tutorial: https://paxswill.com/blog/2013/11/04/encrypted-raspberry-pi/

It speaks of a bug in the initramfs script because it's written "blkid"
instead of "/sbin/blkid"... this is just because the scripts from the
initramfs do not expect to have a PATH without the sbin directories and
because dropbear is not setting the PATH appropriately for the root user.

I'm thus suggesting to use the attached patch to fix this misbehaviour (I
did not test it, but it's easy enough). It might seem anecdotic but
multiple Kali users have been bitten by this.

From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=903403
2022-03-30 23:13:34 +08:00
Begley Brothers Inc
0de8d44297 Expand home path for MOTD file
Patch modified by Matt Johnston

Signed-off-by: Begley Brothers Inc <begleybrothers@gmail.com>
2022-03-30 13:52:09 +08:00
Begley Brothers Inc
f4be5a3c8b Allow user space file locations (rootless support)
Why:
Running dropbear as a user (rootless) is aided if
files and programs can be saved/removed without
needing sudo.

What:
Use the same convention as DROPBEAR_DEFAULT_CLI_AUTHKEY;
if not starting with '/', then is relative to hedge's /home/hedge:
*_PRIV_FILENAME
DROPBEAR_PIDFILE
SFTPSERVER_PATH

default_options.h commentary added.

Changes kept to a minimum, so log entry in svr_kex.c#163
is refactored.
From:
    Generated hostkey is <path> ... <finger-print>
to:
    Generated hostkey path is <path>
    Generated hostkey fingerprint is <fp>
Otherwise the unexpanded path was reported.

Patch modified by Matt Johnston

Signed-off-by: Begley Brothers Inc <begleybrothers@gmail.com>
2022-03-30 13:51:57 +08:00
HansH111
35631a21a2 set envvar SSH_PUBKEYINFO if authstate.pubkey_info contains information 2022-03-13 17:38:38 +00:00
Matt Johnston
8d11116dcb Make missing homedir non-fatal, instead use /
Fixes github #146
2022-02-24 11:51:51 +08:00
Matt Johnston
c7b7c9a99d Add re-exec for server
This allows ASLR to re-randomize the address
space for every connection, preventing some
vulnerabilities from being exploitable by
repeated probing.

Overhead (memory and time) is yet to be confirmed.

At present this is only enabled on Linux. Other BSD platforms
with fexecve() would probably also work though have not been tested.
2022-01-30 10:14:56 +08:00
Matt Johnston
1c8f00bd59 Leave non-interactive at default QoS class
Lower class levels are less well defined, and non-interactive
SSH can carry various different types of applications.

This change also sets lowdelay class (AF21) earlier in an an outbound
dbclient session
2022-01-27 14:34:10 +08:00
Matt Johnston
18be2a6509 Fix accidentally committed debug message
Was added Oct 18 2021
"Only redirect stderr after the session login."
2022-01-22 12:46:08 +08:00
Matt Johnston
3e640acd17 Only redirect stderr after the session login. That lets errors
get recorded on the server parent side, rather than being sent
over a SSH connection.
2021-10-18 23:20:08 +08:00
Matt Johnston
a7ef149463 Bring back recently removed channel->flushing
This resolves the "sleep 10&echo hello" case which should
return immediately
2021-10-14 20:55:15 +08:00
Matt Johnston
f3b72bfd18 Merge 2021-10-11 15:46:49 +08:00
Matt Johnston
f17400e738 Replace ChanType.sepfds with Channel.bidir_fd
This handles the case where a svrchansess has separate FDs
for nopty, but a single FD for pty mode.

The use of sepfds was also previously incorrect for X11 and
agent forwarding
2021-10-11 15:42:14 +08:00
Matt Johnston
8e6f73e879 - Remove "flushing" handling for exited processes, it should be
handled by normal file descriptor reads.

- Fix sesscheckclose() handling if a channel was closed before a
  process was ever launched
2021-10-11 15:16:54 +08:00
Matt Johnston
cc59c08605 Move comment to svr_chansess_checksignal() where it belongs 2021-10-11 15:13:42 +08:00
fidomax
41d4b4e7f7
keep LANG env variable for child process (#111) 2021-08-19 23:49:52 +08:00
Roland Vollgraf
2157d52352
pass on sever process environment to child processes (option -e) (#118) 2021-08-19 23:13:41 +08:00
Matt Johnston
67a8de30b7 Prevent multiple shells being spawned
Existing shells would be leaked.
The old check only caught multiple commands, not shells.
2021-03-06 23:06:43 +08:00
Matt Johnston
6c571c54e5 small tidy of "signal" while loop 2021-03-06 23:05:17 +08:00
Matt Johnston
e8640bdca3 fuzz: wrap kill() 2021-01-29 21:47:56 +08:00
Matt Johnston
17873e8c92 Avoid gnu extension conditional operator 2020-10-08 11:00:04 +08:00
Matt Johnston
e35d0784a8 Set SSH_ORIGINAL_COMMAND for "dropbear -c" too, fix build without
DROPBEAR_SVR_PUBKEY_OPTIONS
2020-03-14 23:28:18 +08:00
Patrick Stewart
0af22aa8e4 Support servers without multiple user support (#76) 2019-03-20 22:44:49 +08:00
Matt Johnston
fe992bf4ea Split ChanType closehandler() and cleanup() so that dbclient doesn't
lose exit status messages
2018-11-14 22:57:56 +08:00
François Perrad
f042eb41ab more linting (#55)
* dropbear_exit: remove priority parameter

confusion with dropbear_log()

* const parameter
2018-02-17 11:27:37 +08:00
Michael Witten
3ee685ad1c options: Complete the transition to numeric toggles (`#if')
For the sake of review, this commit alters only the code; the affiliated
comments within the source files also need to be updated, but doing so
now would obscure the operational changes that have been made here.

* All on/off options have been switched to the numeric `#if' variant;
  that is the only way to make this `default_options.h.in' thing work
  in a reasonable manner.

* There is now some very minor compile-time checking of the user's
  choice of options.

* NO_FAST_EXPTMOD doesn't seem to be used, so it has been removed.

* ENABLE_USER_ALGO_LIST was supposed to be renamed DROPBEAR_USER_ALGO_LIST,
  and this commit completes that work.

* DROPBEAR_FUZZ seems to be a relatively new, as-yet undocumented option,
  which was added by the following commit:

    commit 6e0b539e9c
    Author: Matt Johnston <matt@ucc.asn.au>
    Date:   Tue May 23 22:29:21 2017 +0800

        split out checkpubkey_line() separately

  It has now been added to `sysoptions.h' and defined as `0' by default.

* The configuration option `DROPBEAR_PASSWORD_ENV' is no longer listed in
  `default_options.h.in'; it is no longer meant to be set by the user, and
  is instead left to be defined in `sysoptions.h' (where it was already being
  defined) as merely the name of the environment variable in question:

    DROPBEAR_PASSWORD

  To enable or disable use of that environment variable, the user must now
  toggle `DROPBEAR_USE_DROPBEAR_PASSWORD'.

* The sFTP support is now toggled by setting `DROPBEAR_SFTPSERVER', and the
  path of the sFTP server program is set independently through the usual
  SFTPSERVER_PATH.
2018-02-16 23:13:47 +08:00
Matt Johnston
1700987bfc fix compile warnings 2018-02-14 23:09:28 +08:00
Matt Johnston
a1aa161527 make signal flags volatile, simplify handling 2018-02-14 23:06:01 +08:00
Francois Perrad
598056d168 Pointer parameter could be declared as pointing to const (callback) 2017-08-19 22:39:53 +02:00
Francois Perrad
89e64c631e Pointer parameter could be declared as pointing to const 2017-08-19 17:16:13 +02:00
Francois Perrad
2e38ac7504 initialize variable 2016-11-15 15:33:27 +01:00
Matt Johnston
32a28d0d9c Convert #ifdef to #if, other build changes 2016-05-04 15:33:40 +02:00
Jeremy Kerr
ac9a4c839f Add -c <command> option to force a specific command
This change adds a -c option to dropbear, to force the session to use a
specific command, in a similar fashion to OpenSSH's ForceCommand
configuration option.

This is useful to provide a simple fixed service over ssh, without
requiring an authorized key file for the per-key forced_command option.

This setting takes precedence over the channel session's provided
command, and the per-key forced_command setting.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
2016-04-12 21:01:08 +08:00
Guilhem Moulin
dc01a8edd4 Don't display the MOTD when an explicit command is run.
(possibly via authorized_keys(5) restrictions), even when a
pseudo-terminal has been allocated for the session.  In other words,
only display the MOTD when the server starts the user's default shell.
2015-10-21 22:08:47 +08:00
Matt Johnston
1a4db21fe4 buf_getstring and buf_putstring now use non-unsigned char* 2015-06-04 23:08:50 +08:00
Gaël PORTAY
292656d899 Turn signame local variable into char * 2015-05-05 20:39:14 +02:00
Gaël PORTAY
05b36b484e Turn ChanSess's cmd attribute into char * 2015-05-05 20:39:14 +02:00
Gaël PORTAY
e5ce3fc51b Turn type local variable into char * 2015-05-05 20:39:14 +02:00
Gaël PORTAY
9f97511356 Turn ChanSess's tty and term attributes into char * 2015-05-05 20:39:14 +02:00
Gaël PORTAY
224b16b247 Fix pointer differ in signess warnings [-Werror=pointer-sign] 2015-05-05 20:39:13 +02:00
Gaël PORTAY
ef0aac432c Fix unused make_connection_string() warning [-Werror=unused-function]
This function is used when USE_VFORK is unset.
2015-05-05 20:39:13 +02:00
Matt Johnston
9adfff5c1a Revert accidental commented out signal handlers 2015-02-24 22:23:32 +08:00
Matt Johnston
21bed0d21a Free memory before exiting. Based on patch from Thorsten Horstmann.
Client side is not complete.
2015-02-24 22:01:33 +08:00
Thorsten Horstmann
ab9439519a Fix for old compilers, variable declarations at beginning of functions
and /**/ comments
2015-02-24 20:51:18 +08:00
Matt Johnston
776d908703 Combine code for SSH_CONNECTION and SSH_CLIENT 2014-10-21 22:33:49 +08:00
Ryan Cleere
957450582f Add SSH_CLIENT environment variable 2014-10-20 12:59:47 -05:00
Matt Johnston
6d2d3669f3 Make keepalive handling more robust, this should now match what OpenSSH does 2014-08-19 23:08:56 +08:00
Matt Johnston
0e7409c7ff Make sure the check_close() handler runs when a server child process exits 2014-07-28 23:23:49 +08:00
Matt Johnston
da57dd13c5 Set tcp priority as follows:
if (connecting || ptys || x11) tos = LOWDELAY;
else if (tcp_forwards) tos = 0;
else tos = BULK;

TCP forwards could be either lowdelay or bulk, hence the default priority.
2014-07-16 22:53:32 +08:00