Skip to content

Commit

Permalink
Restrict login to headnodes a user may access
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz committed Jan 10, 2018
1 parent f505b25 commit b5c2d8c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: didehpc
Title: DIDE HPC Support
Version: 0.1.4
Version: 0.1.5
Author: Rich FitzJohn
Maintainer: Rich FitzJohn <rich.fitzjohn@gmail.com>
Description: DIDE HPC support.
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# didehpc 0.1.5

* Check what resources a user has on login ([#50](https://github.com/mrc-ide/didehpc/issues/50))

# didehpc 0.1.4

* Support for machines set up to use `qdrive` ([#48](https://github.com/mrc-ide/didehpc/issues/48))
13 changes: 13 additions & 0 deletions R/queue_didehpc.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,19 @@ queue_didehpc <- function(context, config = didehpc_config(), root = NULL,
message("Already logged in")
} else {
web_login(self$config)
valid <- web_headnodes()
if (!(self$config$cluster %in% valid)) {
web_logout()
if (length(valid) == 0L) {
fmt <- "You do not have access to any cluster"
} else if (length(valid) == 1L) {
fmt <- "You do not have access to '%s'; try '%s'"
} else {
fmt <- "You do not have access to '%s'; try one of %s"
valid <- paste(squote(valid), collapse = ", ")
}
stop(sprintf(fmt, self$config$cluster, valid))
}
}
self$logged_in <- TRUE
}
Expand Down
4 changes: 4 additions & 0 deletions R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ dquote <- function(x) {
sprintf('"%s"', x)
}

squote <- function(x) {
sprintf("'%s'", x)
}

backup <- function(filename, verbose = TRUE, move = FALSE) {
if (file.exists(filename)) {
pat <- sprintf("%s\\.([0-9]+)", basename(filename))
Expand Down

0 comments on commit b5c2d8c

Please sign in to comment.