← all packages

ssh

native: 44 functions analysed · 20 typed · 9 untypeable · 0 timed out · 13 entry points (4 typed) · R: 22 definitions, 2 typed strict, 17 gradual, prelude debt 7 · fuzzing: 6 definitions, 0 unsound, 0 accept calls outside their domain · tyr dc7f1a7 · Rsem 7bcb45f · NativeSem 770a1eb · rstt 2b2696f unpinned

Native functions

C functions reachable from an entry point
44 / 44 (100.0%)
typed
20 / 44 (45.5%)
15 more bound at their declared C signature after inference failed.

Native → R

entry points
13 / 13 (100.0%)
defined in src/
13 / 13 (100.0%)
typed
4 / 13 (30.8%)
bound in R
4 / 13 (30.8%)

R definitions

named top-level definitions
22 / 22 (100.0%)
not blocked by an unbound native symbol
19 / 22 (86.4%)
3 definitions report unbound variable on a native symbol tyr could not bind — the native panel’s loss, arriving here.
typed, gradual
17 / 22 (77.3%)
typed, strict
2 / 22 (9.1%)
7 of the strict failures are a name missing from the prelude.
side
mode
71 / 71

Native functions 44

assert_channel typed

[c_false, c_string, *struct ssh_channel_struct] -> ()
timing: 0.017 s
source
void assert_channel(int rc, const char * what, ssh_channel channel){
  if (rc != SSH_OK){
    char buf[1024];
    strncpy(buf, ssh_get_error(ssh_channel_get_session(channel)), 1023);
    ssh_channel_close (channel);
    ssh_channel_free(channel);
    Rf_errorcall(R_NilValue, "libssh failure at '%s': %s", what, buf);
  }
}
/__w/r-typing/r-typing/work/sources/ssh/src/command.c:3

assert_or_disconnect typed

[c_false, c_string, *struct ssh_session_struct] -> ()
timing: 0.019 s
source
static void assert_or_disconnect(int rc, const char * what, ssh_session ssh){
  if (rc != SSH_OK){
    char buf[1024];
    strncpy(buf, ssh_get_error(ssh), 1023);
    ssh_disconnect(ssh);
    Rf_errorcall(R_NilValue, "libssh failure at '%s': %s", what, buf);
  }
}
/__w/r-typing/r-typing/work/sources/ssh/src/session.c:32

assert_scp typed

[c_false, c_string, *struct ssh_scp_struct, *struct ssh_session_struct] -> ()
timing: 0.019 s
source
static void assert_scp(int rc, const char * what, ssh_scp scp, ssh_session ssh){
  if (rc != SSH_OK){
    char buf[1024];
    strncpy(buf, ssh_get_error(ssh), 1023);
    ssh_scp_close(scp);
    ssh_scp_free(scp);
    Rf_errorcall(R_NilValue, "SCP failure: %s", buf);
  }
}
/__w/r-typing/r-typing/work/sources/ssh/src/scp.c:12

C_blocking_tunnel typed entry .Call fuzz ok

[externalptr, any_sexp, CHR, any_sexp] -> null
timing: 0.058 s
fuzzing: 8 inside (8 error pkg) · 8 outside (8 rejected)
type drawn from: (x1: externalptr, x2: any_sexp, x3: CHR, x4: any_sexp) -> null

Other calls inside the domain

callverdicterror
C_blocking_tunnel(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), function(...) complex(real = 0, imaginary = 0), "", function(...) function(...) list())error_pkg::C_blocking_tunnel: SSH session pointer is dead
C_blocking_tunnel(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), list(), character(0), new.env())error_pkg::C_blocking_tunnel: attempt access index 0/0 in STRING_ELT
C_blocking_tunnel(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), as.name("x"), NA_character_, quote(f(x)))error_pkg::C_blocking_tunnel: SSH session pointer is dead
C_blocking_tunnel(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), NULL, character(0), list(function(...) NULL, list()))error_pkg::C_blocking_tunnel: attempt access index 0/0 in STRING_ELT
C_blocking_tunnel(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), new.env(), c("é", "a"), new.env())error_pkg::C_blocking_tunnel: SSH session pointer is dead
C_blocking_tunnel(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), function(...) NULL, c("a", "é", "NA", "é", "é"), quote(f(x)))error_pkg::C_blocking_tunnel: SSH session pointer is dead
and 2 more
source
SEXP C_blocking_tunnel(SEXP ptr, SEXP port, SEXP target_host, SEXP target_port){
  open_tunnel(ssh_ptr_get(ptr), Rf_asInteger(port), CHAR(STRING_ELT(target_host, 0)), Rf_asInteger(target_port));
  return R_NilValue;
}
/__w/r-typing/r-typing/work/sources/ssh/src/tunnel.c:219

C_disconnect_session typed entry .Call fuzz ok

[externalptr] -> null
timing: 0.011 s
fuzzing: 1 inside (1 error pkg) · 5 outside (5 rejected)
type drawn from: (x1: externalptr) -> null

Other calls inside the domain

callverdicterror
C_disconnect_session(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }))error_pkg::C_disconnect_session: SSH session pointer is dead
source
SEXP C_disconnect_session(SEXP ptr){
  ssh_disconnect(ssh_ptr_get(ptr));
  return R_NilValue;
}
/__w/r-typing/r-typing/work/sources/ssh/src/session.c:234

call_cb typed

[any_sexp, any_sexp, *(c_string | c_null), c_int] -> ()
timing: 0.068 s
source
static void call_cb(SEXP data, SEXP cb, char * pwd[1000], int depth){
  //REprintf("Running call_cb\n");
  PROTECT(data);
  SEXP dir = PROTECT(dirvec_to_r(pwd, depth + 1));
  SEXP call = PROTECT(Rf_lcons(cb, Rf_lcons(data, Rf_lcons(dir, R_NilValue))));
  Rf_eval(call, R_GlobalEnv);
  UNPROTECT(3);
}
/__w/r-typing/r-typing/work/sources/ssh/src/scp.c:92

dirvec_to_r typed

([*(c_string | c_null), c_int] -> CHR)&([*(c_string | c_null), c_true] -> CHR1)&([c_null, c_true] -> "")
timing: 0.355 s
source
static SEXP dirvec_to_r(char ** dirvec, int depth){
  SEXP out = PROTECT(Rf_allocVector(STRSXP, depth));
  for(int i = 0; i < depth; i++)
    SET_STRING_ELT(out, i, Rf_mkCharCE(dirvec[i], CE_UTF8));
  UNPROTECT(1);
  return out;
}
/__w/r-typing/r-typing/work/sources/ssh/src/scp.c:34

fin_file_writer typed

[externalptr(c_string) \ externalptr(empty)] | [externalptr(empty)] | [externalptr(~c_string) \ externalptr(empty)] -> ()
timing: 0.236 s
source
static void fin_file_writer(SEXP ptr){
  FILE *fp = R_ExternalPtrAddr(ptr);
  if(fp != NULL){
    fclose(fp);
    R_ClearExternalPtr(ptr);
    total_open_writers--;
  }
}
/__w/r-typing/r-typing/work/sources/ssh/src/writer.c:7

getsyserror typed

() -> c_string
timing: 0.004 s
(definition not located in src/)

make_string typed

∀'a. ([c_string('a)] -> ^CHR1('a))&([c_falsy] -> na_string)
timing: 0.073 s
(definition not located in src/)

my_auth_callback typed

[c_string, c_string, c_int_na, c_int_na, c_int_na, c_ptr] -> c_int_na
timing: 0.015 s
source
static int my_auth_callback(const char *prompt, char *buf, size_t len, int echo, int verify, void *rpass){
  return password_cb((SEXP) rpass, prompt, buf, len, "");
}
/__w/r-typing/r-typing/work/sources/ssh/src/session.c:66

pending_interrupt typed

() -> c_bool
timing: 0.007 s
source
int pending_interrupt(void) {
  return !(R_ToplevelExec(check_interrupt_fn, NULL));
}
/__w/r-typing/r-typing/work/sources/ssh/src/tunnel.c:70

print_progress typed

[c(..-1)] | [c_int_na \ c(..-1)] -> ()
timing: 0.126 s
source
static void print_progress(int add){
  static int total;
  if(add < 0)
    total = 0;
  Rprintf("\r%c Tunneled %d bytes...", spinner(), total += add);
}
/__w/r-typing/r-typing/work/sources/ssh/src/tunnel.c:96

R_callback typed

[arrow, c_string, c_int] | [(~arrow)<...> | null | p(CHR) | sym, c_string, c_int_na] -> ()
timing: 0.116 s
source
static void R_callback(SEXP fun, const char * buf, ssize_t len){
  if(!Rf_isFunction(fun)) return;
  int ok;
  SEXP str = PROTECT(Rf_allocVector(RAWSXP, len));
  memcpy(RAW(str), buf, len);
  SEXP call = PROTECT(Rf_lcons(fun, Rf_lcons(str, R_NilValue)));
  R_tryEval(call, R_GlobalEnv, &ok);
  UNPROTECT(2);
}
/__w/r-typing/r-typing/work/sources/ssh/src/command.c:13

R_ssh_total_writers typed entry .Call fuzz ok

() -> INT1
timing: 0.017 s
fuzzing: 1 inside (1 ok) · 1 outside (1 rejected)
source
SEXP R_ssh_total_writers(void){
  return(Rf_ScalarInteger(total_open_writers));
}
/__w/r-typing/r-typing/work/sources/ssh/src/writer.c:43

R_ssh_write_file_writer typed entry .Call no call in domain

[externalptr(c_string, CHR) \ externalptr(empty), raw, any_sexp] | [externalptr(empty, CHR), raw, any_sexp] | [externalptr(~c_string) \ externalptr(empty), raw, any_sexp] -> ^INT1
timing: 1.50 s
fuzzing: 0 inside (none) · 0 outside (none)
type drawn from: (x1: externalptr(c_string, CHR) \ externalptr(empty), x2: raw, x3: any_sexp) | (x1: externalptr(empty, CHR), x2: raw, x3: any_sexp) | (x1: externalptr(~c_string) \ externalptr(empty), x2: raw, x3: any_sexp) -> ^INT1
source
SEXP R_ssh_write_file_writer(SEXP ptr, SEXP buf, SEXP close){
  FILE *fp = R_ExternalPtrAddr(ptr);
  if(fp == NULL){
    SEXP path = R_ExternalPtrTag(ptr);
    fp = fopen(CHAR(STRING_ELT(path, 0)), "wb");
    if(!fp)
      Rf_error("Failed to open file: %s", CHAR(STRING_ELT(path, 0)));
    R_SetExternalPtrAddr(ptr, fp);
    total_open_writers++;
  }
  size_t len = fwrite(RAW(buf), 1, Rf_xlength(buf), fp);
  if(Rf_asLogical(close)){
    fin_file_writer(ptr);
  } else if(Rf_length(buf)) {
    fflush(fp);
  }
  return Rf_ScalarInteger(len);
}
/__w/r-typing/r-typing/work/sources/ssh/src/writer.c:16

ssh_ptr_fin typed

[externalptr] -> ()
timing: 0.079 s
source
static void ssh_ptr_fin(SEXP ptr){
  ssh_session ssh = (ssh_session) R_ExternalPtrAddr(ptr);
  if(ssh == NULL)
    return;
  if(ssh_is_connected(ssh)){
    Rf_warningcall(R_NilValue, "Disconnecting from unused ssh session. Please use ssh_disconnect()\n");
    ssh_disconnect(ssh);
  }
  ssh_free(ssh);
  R_ClearExternalPtr(ptr);
}
/__w/r-typing/r-typing/work/sources/ssh/src/session.c:12

ssh_ptr_get typed

[externalptr] -> *struct ssh_session_struct
timing: 0.066 s
source
ssh_session ssh_ptr_get(SEXP ptr){
  ssh_session ssh = (ssh_session) R_ExternalPtrAddr(ptr);
  if(ssh == NULL)
    Rf_error("SSH session pointer is dead");
  //if(!ssh_is_connected(ssh))
  //  Rf_error("ssh session has been disconnected");
  return ssh;
}
/__w/r-typing/r-typing/work/sources/ssh/src/session.c:3

sys_message typed

[c_string] -> ()
timing: 0.007 s
source
static void sys_message(const char * what){
  Rprintf("%s in %s\n", getsyserror(), what);
}
/__w/r-typing/r-typing/work/sources/ssh/src/tunnel.c:80

syserror_if typed

[c_false, c_string] -> ()
timing: 0.026 s
source
static void syserror_if(int err, const char * what){
  if(err && !NONBLOCK_OK)
    Rf_errorcall(R_NilValue, "System failure for: %s (%s)", what, getsyserror());
}
/__w/r-typing/r-typing/work/sources/ssh/src/tunnel.c:75

auth_interactive C signature

[*struct ssh_session_struct, any_sexp, c_string] --> c_int_na
untypeable application
error detail
function: [*struct ssh_session_struct, c_string, c_string] --> any
argument: [*struct ssh_session_struct & 'I2068, c_null, c_null]
timing: 0.032 s
source
static int auth_interactive(ssh_session ssh, SEXP rpass, const char *user){
  int rc = ssh_userauth_kbdint(ssh, NULL, NULL);
  while (rc == SSH_AUTH_INFO) {
    const char * name = ssh_userauth_kbdint_getname(ssh);
    const char * instruction = ssh_userauth_kbdint_getinstruction(ssh);
    int nprompts = ssh_userauth_kbdint_getnprompts(ssh);
    if (strlen(name) > 0)
      Rprintf("%s\n", name);
    if (strlen(instruction) > 0)
      Rprintf("%s\n", instruction);
    for (int iprompt = 0; iprompt < nprompts; iprompt++) {
      char buf[1024] = {0};
      const char * prompt = ssh_userauth_kbdint_getprompt(ssh, iprompt, NULL);
      char question[1024];
      snprintf(question, 1023, "Authenticating user '%s'. %s", user, prompt);
      password_cb(rpass, question, buf, 1024, user);
      if (ssh_userauth_kbdint_setanswer(ssh, iprompt, buf) < 0)
        return SSH_AUTH_ERROR;
    }
    rc = ssh_userauth_kbdint(ssh, NULL, NULL);
  }
  return rc;
}
/__w/r-typing/r-typing/work/sources/ssh/src/session.c:77

auth_or_disconnect C signature

[*struct ssh_session_struct, *struct ssh_key_struct, any_sexp, c_string] --> c_void
untypeable application
error detail
function: [*struct ssh_session_struct, c_string] --> any
argument: [*struct ssh_session_struct & 'I2118, c_null]
timing: 0.054 s
source
static void auth_or_disconnect(ssh_session ssh, ssh_key privkey, SEXP rpass, const char *user){
  if(ssh_userauth_none(ssh, NULL) == SSH_AUTH_SUCCESS)
    return;
  int method = ssh_userauth_list(ssh, NULL);
  if (method & SSH_AUTH_METHOD_PUBLICKEY){
    if(privkey != NULL && ssh_userauth_publickey(ssh, NULL, privkey) == SSH_AUTH_SUCCESS)
      return;
    // ssh_userauth_publickey_auto() tries both ssh-agent and standard keys in ~/.ssh
    // it also automatically picks up SSH_ASKPASS env var set by 'askpass' package
    if(privkey == NULL && ssh_userauth_publickey_auto(ssh, NULL, NULL) == SSH_AUTH_SUCCESS)
      return;
  }
  if (method & SSH_AUTH_METHOD_INTERACTIVE && auth_interactive(ssh, rpass, user) == SSH_AUTH_SUCCESS)
    return;
  if (method & SSH_AUTH_METHOD_PASSWORD && auth_password(ssh, rpass, user) == SSH_AUTH_SUCCESS)
    return;
  ssh_disconnect(ssh);
  Rf_errorcall(R_NilValue, "Authentication with ssh server failed");
}
/__w/r-typing/r-typing/work/sources/ssh/src/session.c:102

auth_password C signature

[*struct ssh_session_struct, any_sexp, c_string] --> c_int_na
untypeable application
error detail
function: [any_sexp, c_string, c_string, c_int_na, c_string] --> c_int_na
argument: [any_sexp & 'I2057, c_string | c_null, c_string | c_null, c(1024), c_string & 'I2058]
timing: 0.021 s
source
static int auth_password(ssh_session ssh, SEXP rpass, const char *user){
  char buf[1024];
  char prompt[1024];
  snprintf(prompt, 1023, "Please enter ssh password for user '%s'", user ? user : "???");
  return password_cb(rpass, prompt, buf, 1024, user) || ssh_userauth_password(ssh, NULL, buf);
}
/__w/r-typing/r-typing/work/sources/ssh/src/session.c:70

check_interrupt_fn C signature

[c_ptr] --> c_void
unbound variable
error detail
name: R_ProcessEvents
timing: 0.001 s
source
static void check_interrupt_fn(void *dummy) {
  R_ProcessEvents();
  R_CheckUserInterrupt();
}
/__w/r-typing/r-typing/work/sources/ssh/src/tunnel.c:65

enter_directory C signature

[*struct ssh_scp_struct, c_string, *struct ssh_session_struct] --> c_void
unbound variable
error detail
name: strncpy
timing: 0.004 s
source
static void enter_directory(ssh_scp scp, char * path, ssh_session ssh){
  char subdir[4000];
  strncpy(subdir, basename(path), 3999);
  if(strcmp(path, basename(path)))
    enter_directory(scp, dirname(path), ssh);
  assert_scp(ssh_scp_push_directory(scp, subdir, 493L), "ssh_scp_push_directory", scp, ssh);
}
/__w/r-typing/r-typing/work/sources/ssh/src/scp.c:22

host_tunnel C signature

[*struct ssh_channel_struct, c_int_na] --> c_void
untypeable application
error detail
function: ([*any \ c_null] --> c_false) & ([c_false] --> c_true) & ([c_int_na \ c_false] --> c_false) & ([c_null] --> c_true) & ([c_string] --> c_false)
argument: tuple1
timing: 0.071 s
source
static void host_tunnel(ssh_channel tunnel, int connfd){
  char buf[16384];

  //assume connfd is non-blocking
  int avail = 1;
  fd_set rfds;
  struct timeval tv = {0, 100000}; //100ms
  print_progress(-1);
  while(!pending_interrupt() && ssh_channel_is_open(tunnel) && !ssh_channel_is_eof(tunnel)){
    FD_ZERO(&rfds);
    FD_SET(connfd, &rfds);
    ssh_channel channels[2] = {tunnel, 0};
    ssh_channel out[2];
    ssh_select(channels, out, connfd+1, &rfds, &tv);

    /* Pipe local socket data to ssh channel */
    while((avail = recv(connfd, buf, sizeof(buf), 0)) > 0){
      ssh_channel_write(tunnel, buf, avail);
      print_progress(avail);
    }
    syserror_if(avail == -1, "recv() from user");
    if(avail == 0)
      break;

    /* Pipe ssh stdout data to local socket */
    while((avail = ssh_channel_read_nonblocking(tunnel, buf, sizeof(buf), 0)) > 0){
      syserror_if(send(connfd, buf, avail, 0) < avail, "send() to user");
      print_progress(avail);
    }
    syserror_if(avail == -1, "ssh_channel_read_nonblocking()");

    /* Print ssh stderr data to console (not sure if this is needed) */
    while((avail = ssh_channel_read_nonblocking(tunnel, buf, sizeof(buf), 1)) > 0)
      REprintf("%.*s", avail, buf);
    syserror_if(avail == -1, "ssh_channel_read_nonblocking()");
    print_progress(0); //spinner only
  }
  set_blocking(connfd);
  shutdown(connfd, SHUTDOWN_SIGNAL);
  ssh_channel_send_eof(tunnel);
  ssh_channel_close(tunnel);
  ssh_channel_free(tunnel);
  close(connfd);
}
/__w/r-typing/r-typing/work/sources/ssh/src/tunnel.c:151

open_port C signature

[c_int_na] --> c_int_na
untypeable application
error detail
function: [c_ptr, c_int_na, c_int_na] --> c_ptr
argument: [*struct sockaddr_in, c_char, c_int]
timing: 0.007 s
source
static int open_port(int port){

  // define server socket
  struct sockaddr_in serv_addr;
  memset(&serv_addr, '0', sizeof(serv_addr));
  serv_addr.sin_family = AF_INET;
  serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  serv_addr.sin_port = htons(port);

  //creates the listening socket
  int listenfd = socket(AF_INET, SOCK_STREAM, 0);
  syserror_if(listenfd < 0, "socket()");

  //Allows immediate reuse of a port in TIME_WAIT state.
  //for Windows see TcpTimedWaitDelay (doesn't work)
#ifndef _WIN32
  int enable = 1;
  syserror_if(setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) < 0, "SO_REUSEADDR");
#endif

  syserror_if(bind(listenfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0, "bind()");
  syserror_if(listen(listenfd, 0) < 0, "listen()");
  return listenfd;
}
/__w/r-typing/r-typing/work/sources/ssh/src/tunnel.c:126

open_tunnel C signature

[*struct ssh_session_struct, c_int_na, c_string, c_int_na] --> c_void
untypeable application
error detail
function: [c_false, c_string] --> ()
argument: [c_bool, c("accept()")]
timing: 0.020 s
source
static void open_tunnel(ssh_session ssh, int port, const char * outhost, int outport){
  int listenfd = open_port(port);
  if(wait_for_fd(listenfd, port) == 0)
    goto cleanup;
  int connfd = accept(listenfd, NULL, NULL);
  syserror_if(connfd < 0, "accept()");
  Rprintf("client connected!\n");
  set_nonblocking(connfd);
  ssh_channel tunnel = ssh_channel_new(ssh);
  if(tunnel == NULL)
    Rf_error("Error in ssh_channel_new(): %s\n", ssh_get_error(ssh));
  assert_channel(ssh_channel_open_forward(tunnel, outhost, outport, "localhost", port), "channel_open_forward", tunnel);
  host_tunnel(tunnel, connfd);
cleanup:
  Rprintf("tunnel closed!\n");
#ifdef _WIN32
  closesocket(listenfd);
#else
  close(listenfd);
#endif
}
/__w/r-typing/r-typing/work/sources/ssh/src/tunnel.c:196

password_cb C signature

[any_sexp, c_string, c_string, c_int_na, c_string] --> c_int_na
unbound variable
error detail
name: REprintf
timing: 1.42 s
source
static int password_cb(SEXP rpass, const char * prompt, char *buf, int buflen, const char *user){
  if(Rf_isString(rpass) && Rf_length(rpass)){
    strncpy(buf, CHAR(STRING_ELT(rpass, 0)), buflen);
    return SSH_OK;
  } else if(Rf_isFunction(rpass)){
    int err;
    if(strcmp(prompt, "Passphrase") == 0) //nicer wording
      prompt = "Passphrase for reading private key";
    SEXP question = PROTECT(make_string(prompt));
    Rf_setAttrib(question, R_NamesSymbol, make_string(user));
    SEXP call = PROTECT(Rf_lcons(rpass, Rf_lcons(question, R_NilValue)));
    SEXP res = PROTECT(R_tryEval(call, R_GlobalEnv, &err));
    if(err || !Rf_isString(res)){
      UNPROTECT(3);
      REprintf("Password callback did not return a string value\n");
      return SSH_ERROR;
    }
    strncpy(buf, CHAR(STRING_ELT(res, 0)), buflen);
    UNPROTECT(3);
    return SSH_OK;
  }
  REprintf("unsupported password type\n");
  return SSH_ERROR;
}
/__w/r-typing/r-typing/work/sources/ssh/src/session.c:41

set_blocking C signature

[c_int_na] --> c_void
unbound variable
error detail
name: F_GETFL
timing: 0.003 s
source
static void set_blocking(int sockfd){
  u_long nonblocking = 0;
  ioctlsocket(sockfd, FIONBIO, &nonblocking);
}
/__w/r-typing/r-typing/work/sources/ssh/src/tunnel.c:28

set_nonblocking C signature

[c_int_na] --> c_void
unbound variable
error detail
name: F_GETFL
timing: 0.002 s
source
static void set_nonblocking(int sockfd){
  u_long nonblocking = 1;
  ioctlsocket(sockfd, FIONBIO, &nonblocking);
}
/__w/r-typing/r-typing/work/sources/ssh/src/tunnel.c:23

spinner C signature

() --> c_char
untypeable application
error detail
function: [c_int, c_int] --> c_int
argument: [c_int_na, c(4)]
timing: 0.019 s
source
static char spinner(void){
  static int x;
  x = (x + 1) % 4;
  switch(x){
  case 0: return '|';
  case 1: return '/';
  case 2: return '-';
  case 3: return '\\';
  }
  return '?';
}
/__w/r-typing/r-typing/work/sources/ssh/src/tunnel.c:84

ssh_ptr_create C signature

[*struct ssh_session_struct] --> any_sexp
untypeable application
error detail
function: [externalptr, any_sexp --> () | c_void, c_bool] --> c_void
argument: [externalptr('I1909, null) & ~externalptr(empty), [externalptr] -> (), c_true]
timing: 0.053 s
source
static SEXP ssh_ptr_create(ssh_session ssh){
  SEXP ptr = PROTECT(R_MakeExternalPtr(ssh, R_NilValue, R_NilValue));
  R_RegisterCFinalizerEx(ptr, ssh_ptr_fin, TRUE);
  Rf_setAttrib(ptr, R_ClassSymbol, Rf_mkString("ssh_session"));
  UNPROTECT(1);
  return ptr;
}
/__w/r-typing/r-typing/work/sources/ssh/src/session.c:24

stream_to_r C signature

[*struct ssh_scp_struct] --> any_sexp
untypeable application
error detail
function: ([list, any] --> list) & ([p(CHR), c_true] --> "") & ([prim & 'I1633, c_int] --> v('I1633)) & ([prim & 'I1633, c_true] --> v1('I1633))
argument: [p(raw), any]
timing: 0.086 s
source
static SEXP stream_to_r(ssh_scp scp){
  R_xlen_t size = ssh_scp_request_get_size64(scp);
  SEXP out = PROTECT(Rf_allocVector(RAWSXP, size));
  unsigned char * ptr = RAW(out);
  size_t read_bytes = 0;
  do {
    if(pending_interrupt()){
      ssh_scp_deny_request(scp, "user interrupt");
      UNPROTECT(1);
      return NULL;
    }
    read_bytes = ssh_scp_read(scp, ptr, size);
    ptr += read_bytes;
    size -= read_bytes;
    //REprintf("\r Remaining: %lld bytes", size);
  } while(size != 0);
  UNPROTECT(1);
  return out;
}
/__w/r-typing/r-typing/work/sources/ssh/src/scp.c:42

wait_for_fd C signature

[c_int_na, c_int_na] --> c_int_na
untypeable application
error detail
function: [record & 'I1353, any] --> 'I1353
argument: [struct timeval, c_false]
timing: 0.011 s
source
static int wait_for_fd(int fd, int port){
  int waitms = 200;
  struct timeval tv;
  tv.tv_sec = 0;
  tv.tv_usec = waitms * 1000;
  fd_set rfds;
  int active = 0;
  while(active == 0){
    Rprintf("\r%c Waiting for connection on port %d... ", spinner(), port);
    FD_ZERO(&rfds);
    FD_SET(fd, &rfds);
    active = select(fd+1, &rfds, NULL, NULL, &tv);
    if(active < 0){
      sys_message("select()");
      return 0;
    }
    if(active || pending_interrupt())
      break;
  }
  return active;
}
/__w/r-typing/r-typing/work/sources/ssh/src/tunnel.c:104

C_libssh_version untypeable entry .Call

unbound variable
error detail
name: LIBSSH_VERSION
timing: 0.004 s
source
SEXP C_libssh_version(void){
  return Rf_mkString(SSH_STRINGIFY(LIBSSH_VERSION));
}
/__w/r-typing/r-typing/work/sources/ssh/src/session.c:239

C_scp_download_recursive untypeable entry .Call

untypeable application
error detail
function: [c_false, c_string, *struct ssh_scp_struct, *struct ssh_session_struct] --> ()
argument: [any, c("ssh_scp_init"), *struct ssh_scp_struct, *struct ssh_session_struct]
timing: 0.098 s
source
SEXP C_scp_download_recursive(SEXP ptr, SEXP path, SEXP cb){
  ssh_session ssh = ssh_ptr_get(ptr);
  ssh_scp scp = ssh_scp_new(ssh, SSH_SCP_READ | SSH_SCP_RECURSIVE, CHAR(STRING_ELT(path, 0)));
  assert_scp(ssh_scp_init(scp), "ssh_scp_init", scp, ssh);
  int status = SSH_OK;
  int depth = 0;
  char * pwd[1000];
  while(!pending_interrupt()){
    switch((status = ssh_scp_pull_request(scp))){
    case SSH_SCP_REQUEST_NEWFILE:
      assert_scp(ssh_scp_accept_request(scp), "ssh_scp_accept_request", scp, ssh);
      pwd[depth] = strdup(ssh_scp_request_get_filename(scp));
      SEXP data = stream_to_r(scp);
      if(data == NULL)
        goto cleanup;
      call_cb(data, cb, pwd, depth);
      free(pwd[depth]);
      break;
    case SSH_SCP_REQUEST_NEWDIR:
      ssh_scp_accept_request(scp);
      pwd[depth++] = strdup(ssh_scp_request_get_filename(scp));
      call_cb(R_NilValue, cb, pwd, depth - 1);
      break;
    case SSH_SCP_REQUEST_ENDDIR:
      free(pwd[--depth]);
      break;
    case SSH_SCP_REQUEST_WARNING:
      Rf_warningcall_immediate(R_NilValue, "SSH warning: %s\n",ssh_scp_request_get_warning(scp));
      break;
    case SSH_SCP_REQUEST_EOF:
      goto cleanup;
    case SSH_ERROR:
      assert_scp(status, "ssh_scp_pull_request", scp, ssh);
    default :
      Rf_error("Error in ssh_scp_pull_request case: %d\n", status);
    }
  }

cleanup:

  ssh_scp_close(scp);
  ssh_scp_free(scp);
  return R_NilValue;
}
/__w/r-typing/r-typing/work/sources/ssh/src/scp.c:101

C_scp_read_file untypeable entry .Call

untypeable application
error detail
function: [c_false, c_string, *struct ssh_scp_struct, *struct ssh_session_struct] --> ()
argument: [any, c("ssh_scp_init"), *struct ssh_scp_struct, *struct ssh_session_struct]
timing: 0.066 s
source
SEXP C_scp_read_file(SEXP ptr, SEXP path){
  ssh_session ssh = ssh_ptr_get(ptr);
  ssh_scp scp = ssh_scp_new(ssh, SSH_SCP_READ, CHAR(STRING_ELT(path, 0)));
  assert_scp(ssh_scp_init(scp), "ssh_scp_init", scp, ssh);
  assert_scp(ssh_scp_pull_request(scp) != SSH_SCP_REQUEST_NEWFILE, "SSH_SCP_REQUEST_NEWFILE", scp, ssh);
  SEXP out = stream_to_r(scp);
  assert_scp(ssh_scp_pull_request(scp) != SSH_SCP_REQUEST_EOF, "SSH_SCP_REQUEST_EOF", scp, ssh);
  ssh_scp_close(scp);
  ssh_scp_free(scp);
  return out;
}
/__w/r-typing/r-typing/work/sources/ssh/src/scp.c:63

C_scp_write_file untypeable entry .Call

untypeable application
error detail
function: [c_false, c_string, *struct ssh_scp_struct, *struct ssh_session_struct] --> ()
argument: [any, c("ssh_scp_init"), *struct ssh_scp_struct, *struct ssh_session_struct]
timing: 0.053 s
source
SEXP C_scp_write_file(SEXP ptr, SEXP path, SEXP data){
  ssh_session ssh = ssh_ptr_get(ptr);
  ssh_scp scp = ssh_scp_new(ssh, SSH_SCP_WRITE | SSH_SCP_RECURSIVE, ".");
  assert_scp(ssh_scp_init(scp), "ssh_scp_init", scp, ssh);
  char cpath[4000];
  char filename[4000];
  strncpy(cpath, CHAR(STRING_ELT(path, 0)), 3999);
  strncpy(filename, basename(cpath), 3999);
  if(strcmp(cpath, filename))
    enter_directory(scp, dirname(cpath), ssh);
  assert_scp(ssh_scp_push_file(scp, filename, Rf_xlength(data), 420L), "ssh_scp_push_file", scp, ssh);
  assert_scp(ssh_scp_write(scp, RAW(data), Rf_xlength(data)), "ssh_scp_write", scp, ssh);
  ssh_scp_close(scp);
  ssh_scp_free(scp);
  return path;
}
/__w/r-typing/r-typing/work/sources/ssh/src/scp.c:75

C_scp_write_recursive untypeable entry .Call

untypeable application
error detail
function: [c_false, c_string, *struct ssh_scp_struct, *struct ssh_session_struct] --> ()
argument: [any, c("ssh_scp_init"), *struct ssh_scp_struct, *struct ssh_session_struct]
timing: 0.146 s
source
SEXP C_scp_write_recursive(SEXP ptr, SEXP sources, SEXP sizes, SEXP paths, SEXP to, SEXP verbose){
  ssh_session ssh = ssh_ptr_get(ptr);
  ssh_scp scp = ssh_scp_new(ssh, SSH_SCP_WRITE | SSH_SCP_RECURSIVE, CHAR(STRING_ELT(to, 0)));
  assert_scp(ssh_scp_init(scp), "ssh_scp_init", scp, ssh);
  int depth = 0;
  char * pwd[1000];
  for(int i = 0; i < Rf_length(paths); i++){

    // check for SIGINT
    if(pending_interrupt())
      break;

    //calculate common path (find first non common subdir)
    SEXP filevec = VECTOR_ELT(paths, i);
    for(int j = 0; j < fmin(Rf_length(filevec), depth); j++){
      if(strcmp(pwd[j], CHAR(STRING_ELT(filevec, j)))){
        //cd up to here
        while(depth > j){
          ssh_scp_leave_directory(scp);
          free(pwd[--depth]);
        }
        break;
      }
    }

    //enter to subdir (not basename)
    for(int j = depth; j < Rf_length(filevec) - 1; j++){
      pwd[depth++] = strdup(CHAR(STRING_ELT(filevec, j)));
      assert_scp(ssh_scp_push_directory(scp, CHAR(STRING_ELT(filevec, j)), 493L), "ssh_scp_push_directory", scp, ssh);
    }

    //empty directories
    SEXP path = VECTOR_ELT(paths, i);
    SEXP file = STRING_ELT(path, Rf_length(path) - 1);
    if(file == NA_STRING)
      continue;

    // try to retain file mode
    struct stat perm = {0};
    if(stat(CHAR(STRING_ELT(sources, i)), &perm) < 0)
      Rf_error("Failed to get permissions for file %s", CHAR(STRING_ELT(sources, i)));
    int statchmod = perm.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);

    //create new file
    double size = REAL(sizes)[i];
    assert_scp(ssh_scp_push_file(scp, CHAR(file), size, statchmod), "ssh_scp_push_file", scp, ssh);

    //write file to channel
    int read = 0;
    long long total = 0;
    char buf[16384];
    FILE *fp = fopen(CHAR(STRING_ELT(sources, i)), "rb");
    if(!fp)
      Rf_error("Failed to open file %s", CHAR(STRING_ELT(sources, i)));
    do {
      assert_scp(ssh_scp_write(scp, buf, read), "ssh_scp_write", scp, ssh);
      read = fread(buf, sizeof(char), sizeof(buf), fp);
      total = total + read;
      if(size && Rf_asLogical(verbose))
        Rprintf("\r[%d%%] %s", (int) round(100 * total/size), CHAR(STRING_ELT(sources, i)));
    } while (read > 0);
    if(size && Rf_asLogical(verbose))
      Rprintf("\n");
    fclose(fp);
  }

  //cd back to root before exiting scp
  while(depth > 0){
    ssh_scp_leave_directory(scp);
    free(pwd[--depth]);
  }
  ssh_scp_close(scp);
  ssh_scp_free(scp);
  return to;
}
/__w/r-typing/r-typing/work/sources/ssh/src/scp.c:146

C_ssh_exec untypeable entry .Call

untypeable application
error detail
function: [c_false, c_string, *struct ssh_channel_struct] --> ()
argument: [any, c("ssh_channel_open_session"), *struct ssh_channel_struct]
timing: 0.078 s
source
SEXP C_ssh_exec(SEXP ptr, SEXP command, SEXP outfun, SEXP errfun){
  ssh_session ssh = ssh_ptr_get(ptr);
  ssh_channel channel = ssh_channel_new(ssh);
  if(channel == NULL)
    Rf_error("Error in ssh_channel_new(): %s\n", ssh_get_error(ssh));
  assert_channel(ssh_channel_open_session(channel), "ssh_channel_open_session", channel);
  assert_channel(ssh_channel_request_exec(channel, CHAR(STRING_ELT(command, 0))), "ssh_channel_request_exec", channel);

  int nbytes;
  int status = NA_INTEGER;
  static char buffer[1024];
  struct timeval tv = {0, 100000}; //100ms
  while(ssh_channel_is_open(channel) && !ssh_channel_is_eof(channel)){
    ssh_channel readchans[2] = {channel, 0};
    ssh_channel_select(readchans, NULL, NULL, &tv);
    if(pending_interrupt())
      goto cleanup;
    for(int stream = 0; stream < 2; stream++){
      while ((nbytes = ssh_channel_read_nonblocking(channel, buffer, sizeof(buffer), stream)) > 0)
        R_callback(stream ? errfun : outfun, buffer, nbytes);
      assert_channel(nbytes == SSH_ERROR, "ssh_channel_read_nonblocking", channel);
    }
  }
  //this blocks until command has completed
  status = ssh_channel_get_exit_status(channel);

  //jump directly to here for interruptions
cleanup:
  ssh_channel_close(channel);
  ssh_channel_free(channel);
  return Rf_ScalarInteger(status);
}
/__w/r-typing/r-typing/work/sources/ssh/src/command.c:24

C_ssh_info untypeable entry .Call

untypeable application
error detail
function: [c_false, c_string, *struct ssh_session_struct] --> ()
argument: [c_int_na, c("ssh_get_publickey"), *struct ssh_session_struct]
timing: 0.088 s
source
SEXP C_ssh_info(SEXP ptr){
  ssh_session ssh = ssh_ptr_get(ptr);
  unsigned int port;
  char * user = NULL;
  char * host = NULL;
  char * identity = NULL;
  int connected = ssh_is_connected(ssh);
  ssh_options_get_port(ssh, &port);
  ssh_options_get(ssh, SSH_OPTIONS_USER, &user);
  ssh_options_get(ssh, SSH_OPTIONS_HOST, &host);
  ssh_options_get(ssh, SSH_OPTIONS_IDENTITY, &identity);


  ssh_key key;
  unsigned char * hash = NULL;
  size_t hlen = 0;
  if (connected) {
    assert_or_disconnect(myssh_get_publickey(ssh, &key), "ssh_get_publickey", ssh);
    assert_or_disconnect(ssh_get_publickey_hash(key, SSH_PUBLICKEY_HASH_SHA1, &hash, &hlen), "ssh_get_publickey_hash", ssh);
  }

  SEXP out = PROTECT(Rf_allocVector(VECSXP, 6));
  SET_VECTOR_ELT(out, 0, make_string(user));
  SET_VECTOR_ELT(out, 1, make_string(host));
  SET_VECTOR_ELT(out, 2, make_string(identity));
  SET_VECTOR_ELT(out, 3, Rf_ScalarInteger(port));
  SET_VECTOR_ELT(out, 4, Rf_ScalarLogical(connected));
  SET_VECTOR_ELT(out, 5, connected ? make_string(ssh_get_hexa(hash, hlen)) : Rf_ScalarString(NA_STRING));
  if(user) ssh_string_free_char(user);
  if(host) ssh_string_free_char(host);
  if(identity) ssh_string_free_char(identity);
  UNPROTECT(1);
  return out;
}
/__w/r-typing/r-typing/work/sources/ssh/src/session.c:199

C_start_session untypeable entry .Call

unbound variable
error detail
name: ssh_new
timing: 0.665 s
source
SEXP C_start_session(SEXP rhost, SEXP rport, SEXP ruser, SEXP keyfile, SEXP rpass, SEXP verbosity){

  /* try reading private key first */
  ssh_key privkey = NULL;
  if(Rf_length(keyfile))
    if(ssh_pki_import_privkey_file(CHAR(STRING_ELT(keyfile, 0)), NULL, my_auth_callback, rpass, &privkey) != SSH_OK)
      Rf_error("Failed to read private key: %s", CHAR(STRING_ELT(keyfile, 0)));

  /* load options */
  int loglevel = Rf_asInteger(verbosity);
  int port = Rf_asInteger(rport);
  const char * host = CHAR(STRING_ELT(rhost, 0));
  const char * user = CHAR(STRING_ELT(ruser, 0));
  ssh_session ssh = ssh_new();
  SEXP ptr = PROTECT(ssh_ptr_create(ssh));
  assert_or_disconnect(ssh_options_set(ssh, SSH_OPTIONS_HOST, host), "set host", ssh);
  assert_or_disconnect(ssh_options_set(ssh, SSH_OPTIONS_USER, user), "set user", ssh);
  assert_or_disconnect(ssh_options_set(ssh, SSH_OPTIONS_PORT, &port), "set port", ssh);
  assert_or_disconnect(ssh_options_set(ssh, SSH_OPTIONS_LOG_VERBOSITY, &loglevel), "set verbosity", ssh);

  /* sets password callback for default private key */
  struct ssh_callbacks_struct cb = {
    .userdata = rpass,
    .auth_function = my_auth_callback
  };
  ssh_callbacks_init(&cb);
  ssh_set_callbacks(ssh, &cb);

  /* connect */
  assert_or_disconnect(ssh_connect(ssh), "connect", ssh);

  /* get server identity */
  ssh_key key;
  unsigned char * hash = NULL;
  size_t hlen = 0;
  assert_or_disconnect(myssh_get_publickey(ssh, &key), "myssh_get_publickey", ssh);
  assert_or_disconnect(ssh_get_publickey_hash(key, SSH_PUBLICKEY_HASH_SHA1, &hash, &hlen), "ssh_get_publickey_hash", ssh);
#if LIBSSH_VERSION_MINOR < 8
  if(!ssh_is_server_known(ssh)){
    Rprintf("Server fingerprint: %s\n", ssh_get_hexa(hash, hlen));
  }
#else
  switch(ssh_session_is_known_server(ssh)){
  case SSH_KNOWN_HOSTS_OK:
    if(loglevel > 0)
      REprintf("Found known server key: %s\n", ssh_get_hexa(hash, hlen));
    break;
  case SSH_KNOWN_HOSTS_UNKNOWN:
    REprintf("New server key: %s\n", ssh_get_hexa(hash, hlen));
    ssh_session_update_known_hosts(ssh);
    break;
  case SSH_KNOWN_HOSTS_OTHER:
  case SSH_KNOWN_HOSTS_CHANGED:
    REprintf("Server key has changed (possible attack?!): %s\nPlease update your ~/.ssh/known_hosts file\n", ssh_get_hexa(hash, hlen));
    break;
  case SSH_KNOWN_HOSTS_ERROR:
  case SSH_KNOWN_HOSTS_NOT_FOUND:
    if(loglevel > 0)
      REprintf("Could not load a known_hosts file\n");
    break;
  }
#endif

  /* Authenticate client or error */
  auth_or_disconnect(ssh, privkey, rpass, user);

  /* display welcome message */
  char * banner = ssh_get_issue_banner(ssh);
  if(banner != NULL){
    Rprintf("%s\n", banner);
    free(banner);
  }

  UNPROTECT(1);
  return ptr;
}
/__w/r-typing/r-typing/work/sources/ssh/src/session.c:122

R_ssh_new_file_writer untypeable entry .Call

untypeable application
error detail
function: [externalptr, any_sexp --> () | c_void, c_bool] --> c_void
argument: [externalptr(empty, 'I2565), [externalptr(c_string) \ externalptr(empty)] | [externalptr(empty)] | [externalptr(~c_string) \ externalptr(empty)] -> (), c_true]
timing: 0.030 s
source
SEXP R_ssh_new_file_writer(SEXP path){
  SEXP ptr = PROTECT(R_MakeExternalPtr(NULL, path, R_NilValue));
  R_RegisterCFinalizerEx(ptr, fin_file_writer, TRUE);
  Rf_setAttrib(ptr, R_ClassSymbol, Rf_mkString("file_writer"));
  UNPROTECT(1);
  return ptr;
}
/__w/r-typing/r-typing/work/sources/ssh/src/writer.c:35

R definitions 27

R/connect.R

me untypeabletyped

unbound variable (line 109)
unbound: Sys.info — a name the prelude does not declare
error detail
name: Sys.info
gradual mode: typed
(() -> any)<>
timing: 0.005 s
source
me <- function(){
  tolower(Sys.info()[["user"]])
}
R/connect.R:108

parse_host untypeabletyped

unbound variable (line 79)
unbound: utils::head — a name the prelude does not declare
error detail
name: utils::head
gradual mode: typed
((str: CHR, default_port: vec | null) | (str: clx, default_port: vec | null) -> any)<>
timing: 0.425 s
source
parse_host <- function(str, default_port){
  stopifnot(is.character(str) && length(str) == 1)
  str <- sub("^@", "", str)
  str <- sub(":$", "", str)
  x <- strsplit(str, "@", fixed = TRUE)[[1]]
  host <- if(length(x) > 1){
    user <- paste(utils::head(x, -1), collapse = '@')
    utils::tail(x, 1)
  } else {
    user <- me()
    x[1]
  }

  # Check for port
  m <- gregexpr(':[0-9]+$', host, ignore.case = TRUE)
  port <- sub("^:", "", regmatches(host, m)[[1]])
  port <- if(length(port)){
    as.numeric(port)
  } else {
    as.numeric(default_port)
  }
  host <- sub(':[0-9]+$', '', host)
  if(grepl("^\\[.*\\]$", host)){
    host <- sub('\\]$', '', sub('^\\[', "", host))
  } else if(grepl(":", host)){
    stop(sprintf("Invalid hostname '%s'. Use brackets for ipv6 hosts like this: [2001:db8::1]:22", host))
  }

  list(
    user = user,
    host = host,
    port = port
  )
}
R/connect.R:73

ssh_connect untypeable

unbound variable (line 37)
unbound: askpass — a name the prelude does not declare
error detail
name: askpass
timing: 0.049 s
source
ssh_connect <- function(host, keyfile = NULL, passwd = askpass, verbose = FALSE) {
  if(is.logical(verbose))
    verbose <- 2 * verbose # TRUE == 'protocol'
  stopifnot(verbose %in% 0:4)
  stopifnot(is.character(host))
  stopifnot(is.character(passwd) || is.function(passwd))
  details <- parse_host(host, default_port = 22)
  if(length(keyfile))
    keyfile <- normalizePath(keyfile, mustWork = TRUE)
  .Call(C_start_session, details$host, details$port, details$user, keyfile, passwd, verbose)
}
R/connect.R:37

ssh_session_info untypeabletyped

unbound variable (line 56)
unbound: C_ssh_info — a native symbol tyr could not bind
error detail
name: C_ssh_info
gradual mode: typed
((session: any) -> any)<>
timing: 0.030 s
source
ssh_session_info <- function(session){
  if(!inherits(session, "ssh_session"))
    stop('Argument "session" must be an ssh session', call. = FALSE)
  out <- .Call(C_ssh_info, session)
  structure(out, names = c("user", "host", "identity", "port", "connected", "sha1"))
}
R/connect.R:53

ssh_info untypeabletyped

unbound variable (line 61)
unbound: ssh_session_info — one of the package’s own names, itself untyped
error detail
name: ssh_session_info
gradual mode: typed
((session: any) -> any)<>
timing: 0.000 s
source
ssh_info <- ssh_session_info
R/connect.R:61

assert_session untypeable

unbound variable (line 113)
unbound: ssh_info — one of the package’s own names, itself untyped
error detail
name: ssh_info
timing: 0.003 s
source
assert_session <- function(x){
  info <- ssh_info(x)
  if(isFALSE(info$connected))
    stop('SSH session has been disconnected. Please connect to a new session', call. = FALSE)
}
R/connect.R:112

ssh_disconnect untypeabletyped

unbound variable (line 68)
unbound: assert_session — one of the package’s own names, itself untyped
error detail
name: assert_session
gradual mode: typed
((session: externalptr) -> null)<>
timing: 0.002 s
source
ssh_disconnect <- function(session){
  assert_session(session)
  .Call(C_disconnect_session, session)
  invisible()
}
R/connect.R:67

print.ssh_session untypeable

unbound variable (line 120)
unbound: ssh_session_info — one of the package’s own names, itself untyped
error detail
name: ssh_session_info
timing: 0.008 s
source
print.ssh_session <- function(x, ...){
  info <- ssh_session_info(x)
  status <- ifelse(info$connected, 'connected', 'disconnected')
  cat(sprintf("<ssh session>\n%s@%s:%d (%s)\nserver: %s\n", info$user, info$host, info$port, status, info$sha1))
}
R/connect.R:119

libssh_version untypeabletyped

unbound variable (line 129)
unbound: C_libssh_version — a native symbol tyr could not bind
error detail
name: C_libssh_version
gradual mode: typed
(() -> any)<>
timing: 0.000 s
source
libssh_version <- function(){
  .Call(C_libssh_version)
}
R/connect.R:128
R/credentials.R

<statement> untypeabletyped

unbound variable (line 7)
unbound: credentials::ssh_key_info — a name the prelude does not declare
error detail
name: credentials::ssh_key_info
gradual mode: typed
timing: 0.000 s
source
credentials::ssh_key_info
R/credentials.R:7

<statement> untypeabletyped

unbound variable (line 12)
unbound: credentials::ssh_keygen — a name the prelude does not declare
error detail
name: credentials::ssh_keygen
gradual mode: typed
timing: 0.000 s
source
credentials::ssh_keygen
R/credentials.R:12

<statement> untypeabletyped

unbound variable (line 17)
unbound: credentials::ssh_read_key — a name the prelude does not declare
error detail
name: credentials::ssh_read_key
gradual mode: typed
timing: 0.000 s
source
credentials::ssh_read_key
R/credentials.R:17

<statement> untypeabletyped

unbound variable (line 22)
unbound: credentials::ssh_home — a name the prelude does not declare
error detail
name: credentials::ssh_home
gradual mode: typed
timing: 0.000 s
source
credentials::ssh_home
R/credentials.R:22

<statement> untypeabletyped

unbound variable (line 27)
unbound: credentials::ssh_agent_add — a name the prelude does not declare
error detail
name: credentials::ssh_agent_add
gradual mode: typed
timing: 0.000 s
source
credentials::ssh_agent_add
R/credentials.R:27
R/exec.R

ssh_exec_wait untypeabletyped

unbound variable (line 31)
unbound: stderr — a name the prelude does not declare
error detail
name: stderr
gradual mode: typed
((session: any, command: CHR?, std_out: (~(CHR | arrow))<connection, ...>?, std_err: (~(CHR | arrow))<connection, ...>?) | (session: any, command: CHR?, std_out: (~(CHR | arrow))<connection, ...>?, std_err: CHR?) | (session: any, command: CHR?, std_out: (~(CHR | arrow))<connection, ...>?, std_err: arrow<connection, ...>?) -> any)<>
timing: 0.242 s
source
ssh_exec_wait <- function(session, command = "whoami", std_out = stdout(), std_err = stderr()) {
  assert_session(session)
  stopifnot(is.character(command))
  command <- paste(command, collapse = "\n")

  # Convert TRUE or filepath into connection objects
  std_out <- if(isTRUE(std_out) || identical(std_out, "")){
    stdout()
  } else if(is.character(std_out)){
    file(normalizePath(std_out, mustWork = FALSE))
  } else std_out

  std_err <- if(isTRUE(std_err) || identical(std_err, "")){
    stderr()
  } else if(is.character(std_err)){
    file(normalizePath(std_err, mustWork = FALSE))
  } else std_err

  outfun <- if(inherits(std_out, "connection")){
    if(!isOpen(std_out)){
      open(std_out, "wb")
      on.exit(close(std_out), add = TRUE)
    }
    if(identical(summary(std_out)$text, "text")){
      function(x){
        cat(rawToChar(x), file = std_out)
        flush(std_out)
      }
    } else {
      function(x){
        writeBin(x, con = std_out)
        flush(std_out)
      }
    }
  } else if(is.function(std_out)){
    if(!length(formals(std_out)))
      stop("Callback function std_out must have at least one parameter")
    std_out
  }
  errfun <- if(inherits(std_err, "connection")){
    if(!isOpen(std_err)){
      open(std_err, "wb")
      on.exit(close(std_err), add = TRUE)
    }
    if(identical(summary(std_err)$text, "text")){
      function(x){
        cat(rawToChar(x), file = std_err)
        flush(std_err)
      }
    } else {
      function(x){
        writeBin(x, con = std_err)
        flush(std_err)
      }
    }
  } else if(is.function(std_err)){
    if(!length(formals(std_err)))
      stop("Callback function std_err must have at least one parameter")
    std_err
  }
  status <- .Call(C_ssh_exec, session, command, outfun, errfun)
  if(is.na(status))
    return(invisible())
  status
}
R/exec.R:31

ssh_exec_internal untypeabletyped

unbound variable (line 103)
unbound: raw — a name the prelude does not declare
error detail
name: raw
gradual mode: typed
((session: any, command: any?, error: any?) -> any)<>
timing: 0.058 s
source
ssh_exec_internal <- function(session, command = "whoami", error = TRUE){
  outcon <- rawConnection(raw(0), "r+")
  on.exit(close(outcon), add = TRUE)
  errcon <- rawConnection(raw(0), "r+")
  on.exit(close(errcon), add = TRUE)
  status <- ssh_exec_wait(session, command, std_out = outcon, std_err = errcon)
  if (isTRUE(error) && !identical(status, 0L))
    stop(sprintf("Executing '%s' failed with status %d",
                 command, status))
  list(status = status, stdout = rawConnectionValue(outcon),
       stderr = rawConnectionValue(errcon))
}
R/exec.R:102
R/init.R

.onAttach untypeabletyped

unbound variable (line 2)
unbound: ssh::libssh_version — a name the prelude does not declare
error detail
name: ssh::libssh_version
gradual mode: typed
((libname: any, pkg: any) -> any)<>
timing: 0.006 s
source
.onAttach <- function(libname, pkg){
  packageStartupMessage(sprintf("Linking to libssh v%s", ssh::libssh_version()))
}
R/init.R:1
R/writer.R

new_file_writer untypeabletyped

unbound variable (line 13)
unbound: R_ssh_new_file_writer — a native symbol tyr could not bind
error detail
name: R_ssh_new_file_writer
gradual mode: typed
((path: any) -> any)<>
timing: 0.001 s
source
new_file_writer <- function(path){
  .Call(R_ssh_new_file_writer, path)
}
R/writer.R:12

write_file_writer typed no call in domain

((fp: externalptr, data: raw, close: any_sexp) -> ^INT1)<>
timing: 0.099 s
fuzzing: 0 inside (none) · 0 outside (none)
source
write_file_writer <- function(fp, data, close){
  .Call(R_ssh_write_file_writer, fp, data, close)
}
R/writer.R:17

file_writer untypeabletyped

unbound variable (line 4)
unbound: new_file_writer — one of the package’s own names, itself untyped
error detail
name: new_file_writer
gradual mode: typed
((path: vec) -> any)<>
timing: 0.030 s
source
file_writer <- function(path){
  path <- normalizePath(path, mustWork = FALSE)
  fp <- new_file_writer(path)
  structure(function(data = raw(), close = FALSE){
    stopifnot(is.raw(data))
    write_file_writer(fp, data, as.logical(close))
  }, class = "file_writer")
}
R/writer.R:2

total_writers typed fuzz ok

(() -> INT1)<>
timing: 0.007 s
fuzzing: 1 inside (1 ok) · 1 outside (1 rejected)
source
total_writers <- function(){
  .Call(R_ssh_total_writers)
}
R/writer.R:22
R/scp.R

scp_download untypeabletyped

unbound variable (line 43)
unbound: assert_session — one of the package’s own names, itself untyped
error detail
name: assert_session
gradual mode: typed
((session: any, files: CHR, to: vec?, verbose: any?) | (session: any, files: ~CHR, to: vec?, verbose: any?) -> any)<>
timing: 0.062 s
source
scp_download <- function(session, files, to = ".", verbose = TRUE){
  assert_session(session)
  stopifnot(is.character(files))
  to <- normalizePath(to, mustWork = TRUE)
  if(length(files) != 1)
    stop("For scp_download(), the 'files' parameter should be a single file or directory")
  cb <- function(data, filepath){
    target <- do.call(file.path, as.list(c(to, filepath)))
    if(verbose)
      cat(sprintf("%10.0f %s\n", as.double(length(data)), target))
    if(is.null(data))
      return(dir.create(target, recursive = TRUE, showWarnings = FALSE))
    writer <- file_writer(target)
    writer(data = data, close = TRUE)
  }
  .Call(C_scp_download_recursive, session, files, cb)
}
R/scp.R:42

list_all untypeable

unbound variable (line 73)
unbound: file.exists — a name the prelude does not declare
error detail
name: file.exists
timing: 0.068 s
source
list_all <- function(files, hidden = FALSE){
  dfs <- lapply(files, function(path){
    if(!file.exists(path) & !dir.exists(path))
      stop(sprintf("File or directory does not exist: %s", path))
    if(file.info(path)$isdir){
      rel <- list.files(path, recursive = TRUE, all.files = hidden, include.dirs = TRUE)
      abs <- file.path(path, rel)
      target <- file.path(basename(normalizePath(path, mustWork = TRUE)), rel)
    } else {
      target <- basename(path)
      abs <- path
    }
    data.frame(local = normalizePath(abs), target = target, stringsAsFactors = FALSE)
  })
  df <- do.call(rbind.data.frame, c(dfs, make.row.names = FALSE, stringsAsFactors = FALSE, deparse.level = 0))
  df <- cbind(file.info(df$local), df)
  path <- strsplit(df$target, "/")
  path[df$isdir] <- lapply(path[df$isdir], append, NA_character_)
  df$path = path
  df
}
R/scp.R:71

scp_upload untypeabletyped

unbound variable (line 64)
unbound: assert_session — one of the package’s own names, itself untyped
error detail
name: assert_session
gradual mode: typed
((session: any, files: CHR, to: CHR?, verbose: any?) | (session: any, files: ~CHR, to: CHR?, verbose: any?) -> any)<>
timing: 0.022 s
source
scp_upload <- function(session, files, to = ".", verbose = TRUE){
  assert_session(session)
  stopifnot(is.character(files))
  stopifnot(is.character(to))
  info <- list_all(files)
  .Call(C_scp_write_recursive, session, info$local, info$size, info$path, to, verbose)
}
R/scp.R:63

scp_write_file untypeabletyped

unbound variable (line 95)
unbound: assert_session — one of the package’s own names, itself untyped
error detail
name: assert_session
gradual mode: typed
((session: any, path: CHR, data: ~CHR) | (session: any, path: ~CHR, data: ~CHR) -> any)<>
timing: 0.026 s
source
scp_write_file <- function(session, path, data){
  assert_session(session)
  stopifnot(is.character(path))
  if(is.character(data))
    data <- charToRaw(paste(data, collapse = "\n"))
  stopifnot(is.raw(data))
  .Call(C_scp_write_file, session, path, data)
}
R/scp.R:94

scp_read_file untypeabletyped

unbound variable (line 105)
unbound: assert_session — one of the package’s own names, itself untyped
error detail
name: assert_session
gradual mode: typed
((session: any, path: CHR) | (session: any, path: ~CHR) -> any)<>
timing: 0.005 s
source
scp_read_file <- function(session, path){
  assert_session(session)
  stopifnot(is.character(path))
  .Call(C_scp_read_file, session, path)
}
R/scp.R:104
R/tunnel.R

ssh_tunnel untypeable

unbound variable (line 19)
unbound: assert_session — one of the package’s own names, itself untyped
error detail
name: assert_session
timing: 0.019 s
source
ssh_tunnel <- function(session, port = 5555, target = "rainmaker.wunderground.com:23") {
  assert_session(session)
  stopifnot(is.numeric(port))
  target <- parse_host(target, NA)
  if(is.na(target$port))
    stop("No port specified in 'target'")
  .Call(C_blocking_tunnel, session, as.integer(port), target$host, target$port)
  invisible()
}
R/tunnel.R:18