Re: [R] R library highcharter function highchart() execute with exception the apparmor read denied for /etc/passwd and /etc/group
On Tue, 8 Aug 2023 10:39:15 + "Gu, Jay via R-help" wrote: > Then I execute the function highchart() it always throw the > exception that child process has died. And I checked the > /var/log/kern.log and found below error: > > Aug 7 08:37:50 ip-172-31-27-249 kernel: [2251703.494866] audit: > type=1400 audit(1691397470.399:739): apparmor="DENIED" > operation="open" profile="managedr-profile" name="/etc/passwd" > pid=159930 comm="R" requested_mask="r" denied_mask="r" fsuid=1000 > ouid=0 It's not that terrible to let a program access /etc/passwd. It does contain the list of the users, which is a privacy risk, true, but at least the passwords are safely hashed and hidden away in /etc/shadow. Searching the CRAN mirror on GitHub for "/etc/passwd" gives quite a few hits, and so does "getpwuid". There are likely other POSIX functions that read /etc/passwd too. Any of highcharter's 68 dependencies could be trying to read /etc/passwd directly or indirectly. (Could be fs, could be some other package.) If you run R -d gdb and let it crash, what does the backtrace say? I think it's likely that the /etc/passwd access won't be easy to get rid of, so if you don't want to give R access to it, you might want to run it inside a container or a virtual machine. -- Best regards, Ivan __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R library highcharter function highchart() execute with exception the apparmor read denied for /etc/passwd and /etc/group
If you don't get a satisfactory answer here in due course, you can try contacting the package maintainer, who you can find via ?maintainer. Cheers, Bert On Tue, Aug 8, 2023 at 7:50 AM Gu, Jay via R-help wrote: > > Dears, > > > I use the R library highcharter with ubuntu 18.04 and R 3.6.3. Recently, I > upgraded to ubuntu 20.04 and R 4.3.1. And the version of library highcharter > are both 0.9.4. Then I execute the function highchart() it always throw the > exception that child process has died. And I checked the /var/log/kern.log > and found below error: > > Aug 7 08:37:50 ip-172-31-27-249 kernel: [2251703.494866] audit: type=1400 > audit(1691397470.399:739): apparmor="DENIED" operation="open" > profile="managedr-profile" name="/etc/passwd" pid=159930 comm="R" > requested_mask="r" denied_mask="r" fsuid=1000 ouid=0 > Aug 7 08:37:50 ip-172-31-27-249 kernel: [2251703.494871] audit: type=1400 > audit(1691397470.399:740): apparmor="DENIED" operation="open" > profile="managedr-profile" name="/etc/group" pid=159930 comm="R" > requested_mask="r" denied_mask="r" fsuid=1000 ouid=0 > > If I add below two lines in my apparmor profile it will resolve this issue. > But I don't like to expose these two files to end user as it has potential > risk. > /etc/passwd r, > /etc/group r, > > I'd like to know if there is any solution to fix it without giving the read > access for these two files /etc/passwd and /etc/group in the apparmor profile > as I did with ubuntu 18.04 and R 3.6.3. Thanks! > Best Regards! > Jay Gu > > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R library highcharter function highchart() execute with exception the apparmor read denied for /etc/passwd and /etc/group
Dears, I use the R library highcharter with ubuntu 18.04 and R 3.6.3. Recently, I upgraded to ubuntu 20.04 and R 4.3.1. And the version of library highcharter are both 0.9.4. Then I execute the function highchart() it always throw the exception that child process has died. And I checked the /var/log/kern.log and found below error: Aug 7 08:37:50 ip-172-31-27-249 kernel: [2251703.494866] audit: type=1400 audit(1691397470.399:739): apparmor="DENIED" operation="open" profile="managedr-profile" name="/etc/passwd" pid=159930 comm="R" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0 Aug 7 08:37:50 ip-172-31-27-249 kernel: [2251703.494871] audit: type=1400 audit(1691397470.399:740): apparmor="DENIED" operation="open" profile="managedr-profile" name="/etc/group" pid=159930 comm="R" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0 If I add below two lines in my apparmor profile it will resolve this issue. But I don't like to expose these two files to end user as it has potential risk. /etc/passwd r, /etc/group r, I'd like to know if there is any solution to fix it without giving the read access for these two files /etc/passwd and /etc/group in the apparmor profile as I did with ubuntu 18.04 and R 3.6.3. Thanks! Best Regards! Jay Gu [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Merge with closest (not equal) time stamps
On Mon, 07 Aug 2023, Naresh Gurbuxani writes: > I have two dataframes, each with a column for timestamp. I want to > merge the two dataframes such that each row from first dataframe > is matched with the row in the second dataframe with most recent but > preceding timestamp. Here is an example. > > option.trades <- data.frame(timestamp = as.POSIXct(c("2023-08-07 10:23:22", > "2023-08-07 10:25:33", "2023-08-07 10:28:41")), option.price = c(2.5, 2.7, > 1.8)) > > stock.trades <- data.frame(timestamp = > as.POSIXct(c("2023-08-07 10:23:21", "2023-08-07 > 10:23:34", "2023-08-07 10:24:57", "2023-08-07 > 10:28:37", "2023-08-07 10:29:01")), stock.price = > c(102.2, 102.9, 103.1, 101.8, 101.7)) > > stock.trades <- stock.trades[order(stock.trades$timestamp),] > > library(plyr) > mystock.prices <- ldply(option.trades$timestamp, function(tstamp) > tail(subset(stock.trades, timestamp <= tstamp), 1)) > names(mystock.prices)[1] <- "stock.timestamp" > myres <- cbind(option.trades, mystock.prices) > > This method works. But for large dataframes, it is very slow. Is there > a way to speed up the merge? > > Thanks, > Naresh > If the timestamps are sorted (or you can sort them), function ?findInterval might be helpful: i <- findInterval(option.trades$timestamp, stock.trades$timestamp) cbind(option.trades, stock.trades[i, ]) ## timestamp option.price timestamp stock.price ## 1 2023-08-07 10:23:22 2.5 2023-08-07 10:23:21 102.2 ## 3 2023-08-07 10:25:33 2.7 2023-08-07 10:24:57 103.1 ## 4 2023-08-07 10:28:41 1.8 2023-08-07 10:28:37 101.8 -- Enrico Schumann Lucerne, Switzerland http://enricoschumann.net __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Merge with closest (not equal) time stamps
I was able to adapt your solution using packages with which I am more familiar. myres2 <- merge(option.trades, stock.trades, by = "timestamp", all = TRUE) myres2[,"stock.timestamp"] <- ifelse(is.na(myres2$stock.price), NA, myres2$timestamp) myres2$stock.timestamp <- as.POSIXct(myres2$stock.timestamp, origin = "1970-01-01") library(zoo) myres2$stock.price <- na.locf(myres2$stock.price) myres2$stock.timestamp <- na.locf(myres2$stock.timestamp) myres2 <- myres2[!is.na(myres2$option.price),] row.names(myres2) <- NULL all.equal(myres, myres2[,c(1, 2, 4, 3)]) # TRUE This calculation is indeed faster. Thanks for your help, Naresh > On Aug 8, 2023, at 5:39 AM, Eric Berger wrote: > > Hi Naresh, > Perhaps the below is faster than your approach > > library(dplyr) > library(tidyr) > merge(option.trades, stock.trades, by="timestamp", all=TRUE) |> > dplyr::arrange(timestamp) |> > dplyr::mutate(stock.timestamp = > as.POSIXct(ifelse(is.na(option.price), timestamp, NA))) |> > tidyr::fill(stock.price, stock.timestamp) |> > dplyr::filter(!is.na(option.price)) |> > dplyr::select(1,2,4,3) -> > myres2 > > identical(myres, myres2) ## TRUE > > > On Tue, Aug 8, 2023 at 5:32 AM Naresh Gurbuxani > wrote: >> >> >> I have two dataframes, each with a column for timestamp. I want to >> merge the two dataframes such that each row from first dataframe >> is matched with the row in the second dataframe with most recent but >> preceding timestamp. Here is an example. >> >> option.trades <- data.frame(timestamp = as.POSIXct(c("2023-08-07 10:23:22", >> "2023-08-07 10:25:33", "2023-08-07 10:28:41")), option.price = c(2.5, 2.7, >> 1.8)) >> >> stock.trades <- data.frame(timestamp = as.POSIXct(c("2023-08-07 10:23:21", >> "2023-08-07 10:23:34", "2023-08-07 10:24:57", "2023-08-07 10:28:37", >> "2023-08-07 10:29:01")), stock.price = c(102.2, 102.9, 103.1, 101.8, 101.7)) >> >> stock.trades <- stock.trades[order(stock.trades$timestamp),] >> >> library(plyr) >> mystock.prices <- ldply(option.trades$timestamp, function(tstamp) >> tail(subset(stock.trades, timestamp <= tstamp), 1)) >> names(mystock.prices)[1] <- "stock.timestamp" >> myres <- cbind(option.trades, mystock.prices) >> >> This method works. But for large dataframes, it is very slow. Is there >> a way to speed up the merge? >> >> Thanks, >> Naresh >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Merge with closest (not equal) time stamps
Hi Naresh, Perhaps the below is faster than your approach library(dplyr) library(tidyr) merge(option.trades, stock.trades, by="timestamp", all=TRUE) |> dplyr::arrange(timestamp) |> dplyr::mutate(stock.timestamp = as.POSIXct(ifelse(is.na(option.price), timestamp, NA))) |> tidyr::fill(stock.price, stock.timestamp) |> dplyr::filter(!is.na(option.price)) |> dplyr::select(1,2,4,3) -> myres2 identical(myres, myres2) ## TRUE On Tue, Aug 8, 2023 at 5:32 AM Naresh Gurbuxani wrote: > > > I have two dataframes, each with a column for timestamp. I want to > merge the two dataframes such that each row from first dataframe > is matched with the row in the second dataframe with most recent but > preceding timestamp. Here is an example. > > option.trades <- data.frame(timestamp = as.POSIXct(c("2023-08-07 10:23:22", > "2023-08-07 10:25:33", "2023-08-07 10:28:41")), option.price = c(2.5, 2.7, > 1.8)) > > stock.trades <- data.frame(timestamp = as.POSIXct(c("2023-08-07 10:23:21", > "2023-08-07 10:23:34", "2023-08-07 10:24:57", "2023-08-07 10:28:37", > "2023-08-07 10:29:01")), stock.price = c(102.2, 102.9, 103.1, 101.8, 101.7)) > > stock.trades <- stock.trades[order(stock.trades$timestamp),] > > library(plyr) > mystock.prices <- ldply(option.trades$timestamp, function(tstamp) > tail(subset(stock.trades, timestamp <= tstamp), 1)) > names(mystock.prices)[1] <- "stock.timestamp" > myres <- cbind(option.trades, mystock.prices) > > This method works. But for large dataframes, it is very slow. Is there > a way to speed up the merge? > > Thanks, > Naresh > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.