Skip to content

Commit 86f06e8

Browse files
committed
Set a default whitelist in the example SewerRat instance.
So that the examples work with any links in or to the temporary directory.
1 parent 8ceca34 commit 86f06e8

4 files changed

Lines changed: 29 additions & 6 deletions

File tree

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: SewerRat
2-
Version: 0.4.0
3-
Date: 2025-06-09
2+
Version: 0.4.1
3+
Date: 2025-08-15
44
Title: Client for the SewerRat API
55
Description:
66
Search metadata files across a shared filesystem via the SewerRat API.

R/startSewerRat.R

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#' @param port Integer specifying the port to use for hosting the service.
88
#' If \code{NULL}, a free port is randomly selected.
99
#' @param wait Integer specifying the number of seconds to wait for service initialization.
10+
#' @param whitelist Character vector of users who are allowed to create symbolic links.
11+
#' If \code{NULL}, it defaults to the current user and all owners of \code{\link{tempdir}}.
1012
#' @param overwrite Logical scalar indicating whether to redownload the Gobbler binary.
1113
#' @param version String containing the desired version of the Gobbler binary.
1214
#'
@@ -25,7 +27,7 @@
2527
#' startSewerRat() # initialize a new instance.
2628
#'
2729
#' @export
28-
startSewerRat <- function(db=tempfile(fileext=".sqlite3"), port=NULL, wait = 1, version = "1.2.0", overwrite = FALSE) {
30+
startSewerRat <- function(db=tempfile(fileext=".sqlite3"), port=NULL, wait = 1, version = "1.3.1", whitelist = NULL, overwrite = FALSE) {
2931
if (!is.null(running$active)) {
3032
return(list(new=FALSE, port=running$port, url=assemble_url(running$port)))
3133
}
@@ -73,9 +75,12 @@ startSewerRat <- function(db=tempfile(fileext=".sqlite3"), port=NULL, wait = 1,
7375
if (is.null(port)) {
7476
port <- choose_port()
7577
}
78+
if (is.null(whitelist)) {
79+
whitelist <- choose_whitelist()
80+
}
7681

7782
script <- system.file("scripts", "deploy.sh", package="SewerRat", mustWork=TRUE)
78-
pid <- system2(script, c(shQuote(exe), shQuote(db), shQuote(port)), stdout=TRUE)
83+
pid <- system2(script, c(shQuote(exe), shQuote(db), shQuote(port), shQuote(paste(whitelist, collapse=","))), stdout=TRUE)
7984
Sys.sleep(wait)
8085

8186
process <- new.env()
@@ -103,6 +108,20 @@ choose_port <- function() {
103108
}
104109
}
105110

111+
choose_whitelist <- function() {
112+
whitelist <- Sys.info()[["user"]]
113+
tmp <- tempdir()
114+
repeat {
115+
whitelist <- union(whitelist, file.info(tmp)[["uname"]])
116+
parent <- dirname(tmp)
117+
if (parent == tmp) {
118+
break
119+
}
120+
tmp <- parent
121+
}
122+
whitelist
123+
}
124+
106125
assemble_url <- function(port) {
107126
paste0("http://0.0.0.0:", port)
108127
}

inst/scripts/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# We shovel this into a shell script as system(2) doesn't like multiple
44
# statements, especially if one of them is backgrounded. We need to do
55
# multiple statements so that we can run `$!` to get the PID.
6-
"$1" -db "$2" -port "$3" > /dev/null &
6+
"$1" -db "$2" -port "$3" -whitelist "$4" > /dev/null &
77
PID=$!
88

99
sleep 1 # Give it a second to set up before it's considered 'ready'.

man/startSewerRat.Rd

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)