Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mkj/dropbear
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: akaros/dropbear-akaros
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: akaros
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.

Commits on Oct 30, 2015

  1. Get it to build under akaros

    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Oct 30, 2015
    Copy the full SHA
    646657b View commit details
  2. Update CONFIGURE_AKAROS to make it more generic

    As part of this, I moved the build itself into a 'build' subfolder to
    keep all the build files separate from the source and added a .gitgnore
    so that any generated files get ignored properly.
    klueska committed Oct 30, 2015
    Copy the full SHA
    2092c02 View commit details
  3. Copy the full SHA
    62573fa View commit details
  4. Copy the full SHA
    f00930b View commit details

Commits on Dec 18, 2015

  1. Slash and burn: remove select, hardwire to 1 socket, block on read.

    This actually starts now.
    
    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Dec 18, 2015
    Copy the full SHA
    258b9f9 View commit details

Commits on Jan 8, 2016

  1. Adding sort of tty support.

    It's done via a process since our kernel doesn't have all that tty crap.
    
    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Jan 8, 2016
    Copy the full SHA
    4a8cb55 View commit details
  2. Debug hack: echo means write to fd 1

    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Jan 8, 2016
    Copy the full SHA
    6e78d6c View commit details
  3. Reduce bring me another fucking rock behavior

    The prints from this code are useless, make them less so.
    
    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Jan 8, 2016
    Copy the full SHA
    0e2a7b7 View commit details

Commits on Jan 20, 2016

  1. TTY crap yanked; sort of working save for the child.

    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Jan 20, 2016
    Copy the full SHA
    2ffb85c View commit details

Commits on Feb 10, 2016

  1. Well, closer, we're getting to a failed startup of some sort.

    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Feb 10, 2016
    Copy the full SHA
    97fb3aa View commit details
  2. Just disable some more crap while we figure out what's not right.

    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Feb 10, 2016
    Copy the full SHA
    bce3932 View commit details

Commits on Feb 16, 2016

  1. Add some things back. We need to fix select in akaros now.

    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Feb 16, 2016
    Copy the full SHA
    2d1e9f3 View commit details

Commits on Feb 17, 2016

  1. Slightly closer.

    We get through the ident stuff.
    
    Hangs on reading the command.
    
    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Feb 17, 2016
    Copy the full SHA
    b8f7981 View commit details

Commits on Feb 19, 2016

  1. First command executed via ssh

    WIth this version, commands run.
    
    Not well, but they run.
    
    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Feb 19, 2016
    Copy the full SHA
    9992e2a View commit details

Commits on Mar 21, 2016

  1. Undo more debug prints

    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Mar 21, 2016
    Copy the full SHA
    d596d2d View commit details

Commits on Mar 22, 2016

  1. Get rid of stupid read of a line that we thought was a bug.

    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Mar 22, 2016
    Copy the full SHA
    175e30f View commit details
  2. add \n -> \n\r output conversion for stdout/stderr.

    No ttys in akaros but that does mean we do some processing in the
    ssh server (FOR NOW -- this will change later)
    
    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Mar 22, 2016
    Copy the full SHA
    c89d6f8 View commit details
  3. stdin character processing from harvey.

    Almost certainly wrong but this is a reasonable intermediate commit.Compiles.
    
    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Mar 22, 2016
    Copy the full SHA
    d7c0876 View commit details

Commits on Mar 23, 2016

  1. ECHO! FINALLY!

    input processing is next.
    
    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Mar 23, 2016
    Copy the full SHA
    2f9262f View commit details
  2. we have kind of working.

    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Mar 23, 2016
    Copy the full SHA
    a640187 View commit details
  3. Turn off more annoying debugging

    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Mar 23, 2016
    Copy the full SHA
    ccff8b4 View commit details
  4. Fix up the Akaros build/config

    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Mar 23, 2016
    Copy the full SHA
    96e70e6 View commit details
  5. Don't assume select won't be spurious

    They are assuming that their read will succeed, since select() said it
    would.  This allows an EGAIN.  Arguably they should be doing this
    already (see the notes at the end of man select).
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Mar 23, 2016
    Copy the full SHA
    0f6760d View commit details
  6. Turn off custom echoing and whatnot

    Build with the isatty() glibc change.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Mar 23, 2016
    Copy the full SHA
    82767eb View commit details

Commits on Mar 24, 2016

  1. Hack scp to work without /etc/passwd

    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Mar 24, 2016
    Copy the full SHA
    0a2958f View commit details

Commits on Mar 25, 2016

  1. Clean up and add ^C support

    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed Mar 25, 2016
    Copy the full SHA
    6c7afd7 View commit details

Commits on Mar 31, 2016

  1. Remove the non-blocking read function

    Akaros now supports non-blocking pipes.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Mar 31, 2016
    Copy the full SHA
    f850068 View commit details
  2. Fix Ctrl-C

    Instead of !, we inject a \n.  Not ideal for when we want to abort a
    line in progress, but whatever. =)
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Mar 31, 2016
    Copy the full SHA
    6a5d5ca View commit details
  3. Add scp to the default programs

    There might be a better way to do this that just involves our CONFIGURE
    script.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Mar 31, 2016
    Copy the full SHA
    1ec8c7f View commit details

Commits on Apr 1, 2016

  1. Remove the select timeout hack

    Upstream now works without this.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Apr 1, 2016
    Copy the full SHA
    edb348a View commit details

Commits on Apr 4, 2016

  1. Restore sshpty.c

    We don't build it, and we don't want to muck with the original DB
    unnecessarily.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Apr 4, 2016
    Copy the full SHA
    081f4c8 View commit details
  2. Remove 9tty.c

    We don't build it, and we're using tty.c instead.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Apr 4, 2016
    Copy the full SHA
    10dd0f9 View commit details
  3. Update CONFIGURE

    Reconfig.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Apr 4, 2016
    Copy the full SHA
    938baf7 View commit details
  4. Rewrite tty.c, remove hacks from common-channel.c

    Not perfect yet - the ctlr seems to hang around and concurrent sessions
    have issues.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Apr 4, 2016
    Copy the full SHA
    e3c38ee View commit details

Commits on Apr 5, 2016

  1. Fix up the EAGAINS

    One was a straight-up bug on my part.  The others are proactive changes.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Apr 5, 2016
    Copy the full SHA
    006a083 View commit details
  2. Undo a lot of debugging

    git checkout -p origin/main --
    
    pick and choose what to remove.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Apr 5, 2016
    Copy the full SHA
    79c3289 View commit details
  3. Have dropbear_exit report its callsite

    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Apr 5, 2016
    Copy the full SHA
    5d22f68 View commit details
  4. Send the ctrl-c to the shell

    Actually clearing the line was pretty easy - the shell reads the ctrl-c
    directly.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Apr 5, 2016
    Copy the full SHA
    f62cf43 View commit details

Commits on Apr 6, 2016

  1. Extract hacks into akaros.c

    Stuff like getpwnam can be done.  I'll probably move some of that into
    glibc soon.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Apr 6, 2016
    Copy the full SHA
    3016860 View commit details
  2. Undo some changes, make the rest OS-independent

    Aiming for a small delta, and the code base works for linux or akaros.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Apr 6, 2016
    Copy the full SHA
    f8bba5f View commit details
  3. Daemonize support

    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Apr 6, 2016
    Copy the full SHA
    00717f8 View commit details
  4. Take timestamps during tracing again

    We have such a large number of syscalls that this doesn't help anymore.
    We can always turn it off in the future.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Apr 6, 2016
    Copy the full SHA
    2baa28f View commit details
  5. Add a warning for printf from the signal handler

    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Apr 6, 2016
    Copy the full SHA
    493b6c2 View commit details

Commits on Apr 7, 2016

  1. Add README.akaros

    Instructions for setup.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Apr 7, 2016
    Copy the full SHA
    4b116f9 View commit details

Commits on May 12, 2016

  1. If the script gets an error, then DON'T SAY IT WORKED.

    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed May 12, 2016
    Copy the full SHA
    f948fb3 View commit details
  2. Just name the CC binary. Paths are how you find things, not obscure v…

    …ariables.
    
    Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
    rminnich committed May 12, 2016
    Copy the full SHA
    e63a1a9 View commit details

Commits on Aug 30, 2016

  1. Invert daemon()'s closefd parameter.

    daemon() expects "noclose".  We were passing closefd.  I'm not sure of
    the intent, but this seems backwards.
    
    With this change, child processes of dropbear, such as the intermediate
    controller process, can output TRACE messages to the parent dropbear
    process's stderr.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Aug 30, 2016
    Copy the full SHA
    c2147b7 View commit details

Commits on Mar 21, 2017

  1. Merge branch 'upstream' into akaros

    Conflicts:
          debug.h
          options.h
    
    Added localoptions.h.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Mar 21, 2017
    Copy the full SHA
    73996e8 View commit details
  2. Assert AKAROS_ROOT is set for CONFIGURE_AKAROS

    Previously, we'd use Kevin's old path.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Mar 21, 2017
    Copy the full SHA
    cae85c2 View commit details
  3. Allow select() on /dev/urandom

    The kernel doesn't have support for FD taps on #random, but we actually
    don't need it.  select() will stat the FD first, and (currently) reading
     #random never blocks, so stat will always see the FD as readable.
    
    If we ever want to epoll, then we'll need tap support.
    
    Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
    brho committed Mar 21, 2017
    Copy the full SHA
    6771c7d View commit details
Showing with 569 additions and 19 deletions.
  1. +6 −0 .gitignore
  2. +58 −0 CONFIGURE_AKAROS
  3. +17 −4 Makefile.in
  4. +54 −0 README.akaros
  5. +152 −0 akaros.c
  6. +1 −1 common-channel.c
  7. +2 −2 common-session.c
  8. +10 −0 config.sub
  9. +1 −1 dbutil.c
  10. +4 −1 dbutil.h
  11. +1 −1 gensignkey.c
  12. +1 −1 includes.h
  13. +2 −1 libtomcrypt/src/prngs/rng_get_bytes.c
  14. +2 −1 libtommath/mtest/mtest.c
  15. +6 −0 localoptions.h
  16. +3 −3 netio.c
  17. +1 −1 packet.c
  18. +4 −0 svr-authpubkey.c
  19. +2 −0 svr-chansession.c
  20. +10 −1 svr-main.c
  21. +1 −1 sysoptions.h
  22. +231 −0 tty.c
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
autom4te.cache/
config.h.in
configure
build/
*.o
*.swp
58 changes: 58 additions & 0 deletions CONFIGURE_AKAROS
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash
set -e

if [ "x${AKAROS_ROOT}" == "x" ]
then
echo AKAROS_ROOT is empty! You must set it!
exit
fi

KFS=${AKAROS_ROOT}/kern/kfs/
XCC=x86_64-ucb-akaros-gcc
AKAROS_CFLAGS="-fno-omit-frame-pointer -g -std=gnu99"
AKAROS_LDFLAGS=""
AKAROS_LIBS="-liplib -lpthread"

function bootstrap()
{
autoreconf --install
}

function configure()
{
rm -rf build; mkdir build; cd build
CC=${XCC} CFLAGS=${AKAROS_CFLAGS} LDFLAGS=${AKAROS_LDFLAGS} \
LIBS=$AKAROS_LIBS ../configure \
--prefix=${KFS} \
--sbindir=${KFS}/bin \
--host=$(basename ${XCC%-gcc}) \
--disable-zlib \
--disable-openpty \
--disable-syslog \
--disable-shadow \
--enable-bundled-libtom \
--disable-lastlog \
--disable-utmp \
--disable-utmpx \
--disable-wtmp \
--disable-wtmpx \
--disable-loginfunc \
--disable-pututline \
--disable-pututxline
cd -
}

bootstrap
configure

cat << EndOfMessage
Dropbear has now been configured for Akaros!
Please cd into the 'build' directory and run the following
commands to install it into the KFS of your Akaros tree.
$ cd build
$ make
$ make install
EndOfMessage
21 changes: 17 additions & 4 deletions Makefile.in
Original file line number Diff line number Diff line change
@@ -10,9 +10,11 @@
# Hopefully that seems intuitive.

ifndef PROGRAMS
PROGRAMS=dropbear dbclient dropbearkey dropbearconvert
PROGRAMS=dropbear dbclient dropbearkey dropbearconvert scp
endif

akaros-detect=$(findstring akaros,$(notdir @CC@))

STATIC_LTC=libtomcrypt/libtomcrypt.a
STATIC_LTM=libtommath/libtommath.a

@@ -24,7 +26,7 @@ CFLAGS+=-I$(srcdir)/libtomcrypt/src/headers/
LIBTOM_LIBS=$(STATIC_LTC) $(STATIC_LTM)
endif

ifneq ($(wildcard localoptions.h),)
ifneq ($(wildcard ../localoptions.h),)
CFLAGS+=-DLOCALOPTIONS_H_EXISTS
endif

@@ -35,11 +37,19 @@ COMMONOBJS=dbutil.o buffer.o dbhelpers.o \
atomicio.o compat.o fake-rfc2553.o \
ltc_prng.o ecc.o ecdsa.o crypto_desc.o \
gensignkey.o gendss.o genrsa.o
ifeq ($(akaros-detect), akaros)
COMMONOBJS += akaros.o
endif

SVROBJS=svr-kex.o svr-auth.o sshpty.o \
SVROBJS=svr-kex.o svr-auth.o \
svr-authpasswd.o svr-authpubkey.o svr-authpubkeyoptions.o svr-session.o svr-service.o \
svr-chansession.o svr-runopts.o svr-agentfwd.o svr-main.o svr-x11fwd.o\
svr-tcpfwd.o svr-authpam.o
ifeq ($(akaros-detect), akaros)
SVROBJS += tty.o
else
SVROBJS += sshpty.o
endif

CLIOBJS=cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o \
cli-session.o cli-runopts.o cli-chansession.o \
@@ -56,6 +66,9 @@ KEYOBJS=dropbearkey.o
CONVERTOBJS=dropbearconvert.o keyimport.o

SCPOBJS=scp.o progressmeter.o atomicio.o scpmisc.o compat.o
ifeq ($(akaros-detect), akaros)
SCPOBJS += akaros.o
endif

HEADERS=options.h dbutil.h session.h packet.h algo.h ssh.h buffer.h kex.h \
dss.h bignum.h signkey.h rsa.h dbrandom.h service.h auth.h \
@@ -174,7 +187,7 @@ dbclient: $(HEADERS) $(LIBTOM_DEPS) Makefile
$(CC) $(LDFLAGS) -o $@$(EXEEXT) $($@objs) $(LIBTOM_LIBS) $(LIBS)

dropbearkey dropbearconvert: $(HEADERS) $(LIBTOM_DEPS) Makefile
$(CC) $(LDFLAGS) -o $@$(EXEEXT) $($@objs) $(LIBTOM_LIBS)
$(CC) $(LDFLAGS) -o $@$(EXEEXT) $($@objs) $(LIBTOM_LIBS) $(LIBS)

# scp doesn't use the libs so is special.
scp: $(SCPOBJS) $(HEADERS) Makefile
54 changes: 54 additions & 0 deletions README.akaros
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
README.akaros


Environment prep:
-----------------------
Set and export AKAROS_ROOT. AKAROS_ROOT is the path to the Akaros git repo.


Put a server key in KFS:
-----------------------
A default one is in KFS already, but everyone in the world has that key. If
you want your own to avoid MITM attacks, you'll need to make the Linux version
of Dropbear and use its key generator.

$ rm -r build/ && mkdir build && cd build && ../configure && make
$ ./dropbearkey -t rsa -f $AKAROS_ROOT/kern/kfs/etc/dropbear/dropbear_rsa_host_key
$ cd -


Build Dropbear for Akaros:
-----------------------
./CONFIGURE_AKAROS
cd build ; make clean ; make install ; cd -


Put an authorized key in KFS:
-----------------------
If you don't want to use an existing key, you can build a new one:

$ ssh-keygen -t rsa -b 4096 -C "your@email.com" -f $HOME/.ssh/id_db_akaros_rsa

Either way, put a key in KFS:
$ cat $HOME/.ssh/id_db_akaros_rsa.pub >> $AKAROS_ROOT/kern/kfs/.ssh/authorized_keys


Set up your SSH config:
-----------------------
You might want entries in .ssh/config, especially if you have a lot of keys or
are using qemu. The entry for qemu assumes you're using usermode networking
with port forwarding.

~/.ssh/config
Host qemu
Hostname 127.0.0.1
User root
Port 5555
IdentityFile ~/.ssh/id_db_akaros_rsa
IdentitiesOnly yes

Host some-machine-name
Hostname SOME-IP
User root
IdentityFile ~/.ssh/id_db_akaros_rsa
IdentitiesOnly yes
152 changes: 152 additions & 0 deletions akaros.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/* Copyright (c) 2016 Google, Inc.
* Barret Rhoden <brho@cs.berkeley.edu>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. */

#include <sys/types.h>
#include <unistd.h>
#include <pwd.h>
#include <string.h>
#include <sys/time.h>
#include <sys/resource.h>

/* TODO: we can move most of these into glibc. */

struct passwd default_user = {
.pw_name = "root",
.pw_passwd = "x",
.pw_uid = 0,
.pw_gid = 0,
.pw_gecos = "",
.pw_dir = "/",
.pw_shell = "/bin/sh",
};

static int getpwd_r_foobar(struct passwd *pwd, char *buf, size_t buflen,
struct passwd **result)
{
memcpy(pwd, &default_user, sizeof(struct passwd));
*result = pwd;
return 0;
}

struct passwd *getpwnam(const char *name)
{
return &default_user;
}

struct passwd *getpwuid(uid_t uid)
{
return &default_user;
}

int getpwnam_r(const char *name, struct passwd *pwd,
char *buf, size_t buflen, struct passwd **result)
{
return getpwd_r_foobar(pwd, buf, buflen, result);
}

int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf, size_t buflen,
struct passwd **result)
{
return getpwd_r_foobar(pwd, buf, buflen, result);
}

uid_t getuid(void)
{
return 0;
}

uid_t geteuid(void)
{
return 0;
}

gid_t getgid(void)
{
return 0;
}

gid_t getegid(void)
{
return 0;
}

int seteuid(uid_t euid)
{
return 0;
}

int setegid(gid_t egid)
{
return 0;
}

int setrlimit(int resource, const struct rlimit *rlim)
{
return 0;
}

/* TODO: probably need session support or something */
pid_t setsid(void)
{
return 0x1337;
}

/* The daemon func is from compat.c.
*
* Once we do setsid in glibc, we don't need to do this anymore and can use
* glibc's version. */
#include "includes.h"
int daemon(int nochdir, int noclose) {

int fd;

switch (fork()) {
case -1:
return (-1);
case 0:
break;
default:
_exit(0);
}

if (setsid() == -1)
return -1;

if (!nochdir)
(void)chdir("/");

if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
(void)dup2(fd, STDIN_FILENO);
(void)dup2(fd, STDOUT_FILENO);
(void)dup2(fd, STDERR_FILENO);
if (fd > STDERR_FILENO)
(void)close(fd);
}
return 0;
}
2 changes: 1 addition & 1 deletion common-channel.c
Original file line number Diff line number Diff line change
@@ -760,7 +760,7 @@ static void send_msg_channel_data(struct Channel *channel, int isextended) {
len = read(fd, buf_getwriteptr(ses.writepayload, maxlen), maxlen);

if (len <= 0) {
if (len == 0 || errno != EINTR) {
if (len == 0 || (errno != EINTR && errno != EAGAIN)) {
/* This will also get hit in the case of EAGAIN. The only
time we expect to receive EAGAIN is when we're flushing a FD,
in which case it can be treated the same as EOF */
4 changes: 2 additions & 2 deletions common-session.c
Original file line number Diff line number Diff line change
@@ -348,7 +348,7 @@ static void read_session_identification() {
for (i = 0; i < 50; i++) {
len = ident_readln(ses.sock_in, linebuf, sizeof(linebuf));

if (len < 0 && errno != EINTR) {
if (len < 0 && (errno != EINTR && errno != EAGAIN)) {
/* It failed */
break;
}
@@ -425,7 +425,7 @@ static int ident_readln(int fd, char* buf, int count) {
* so that it won't be read as part of the next line */
if (num < 0) {
/* error */
if (errno == EINTR) {
if ((errno == EINTR) || (errno == EAGAIN)) {
continue; /* not a real error */
}
TRACE(("leave ident_readln: read error"))
10 changes: 10 additions & 0 deletions config.sub
Original file line number Diff line number Diff line change
@@ -140,6 +140,10 @@ esac
### recognize some manufacturers as not being operating systems, so we
### can provide default operating systems below.
case $os in
-akaros*)
os=-akaros
basic_machine=x86_64
;;
-sun*os*)
# Prevent following clause from handling this invalid input.
;;
@@ -1329,6 +1333,9 @@ case $os in
# First match some system type aliases
# that might get confused with valid system types.
# -solaris* is a basic system type, with this one exception.
-akaros*)
os=-akaros
;;
-auroraux)
os=-auroraux
;;
@@ -1714,6 +1721,9 @@ vendor=unknown
case $basic_machine in
*-unknown)
case $os in
-akaros*)
vendor=ucb
;;
-riscix*)
vendor=acorn
;;
Loading