Skip to content

Commit

Permalink
nettrace/netlock
Browse files Browse the repository at this point in the history
  • Loading branch information
netblue30 committed Jan 4, 2022
1 parent 732282e commit 1000c23
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 195 deletions.
12 changes: 6 additions & 6 deletions src/firejail/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2294,12 +2294,6 @@ int main(int argc, char **argv, char **envp) {
//*************************************
// network
//*************************************
else if (strcmp(argv[i], "--netlock") == 0)
arg_netlock = 1;
else if (strncmp(argv[i], "--netlock=", 10) == 0) {
pid_t pid = require_pid(argv[i] + 10);
netfilter_netlock(pid);
}
else if (strcmp(argv[i], "--net=none") == 0) {
arg_nonetwork = 1;
cfg.bridge0.configured = 0;
Expand All @@ -2313,6 +2307,12 @@ int main(int argc, char **argv, char **envp) {
continue;
}
#ifdef HAVE_NETWORK
else if (strcmp(argv[i], "--netlock") == 0)
arg_netlock = 1;
else if (strncmp(argv[i], "--netlock=", 10) == 0) {
pid_t pid = require_pid(argv[i] + 10);
netfilter_netlock(pid);
}
else if (strncmp(argv[i], "--interface=", 12) == 0) {
if (checkcfg(CFG_NETWORK)) {
// checks
Expand Down
3 changes: 3 additions & 0 deletions src/firejail/netfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ void netfilter_netlock(pid_t pid) {
// else if (access("/usr/bin/gnome-terminal", X_OK) == 0)
// terminal = "/usr/bin/gnome-terminal";

if (isatty(STDIN_FILENO))
terminal = NULL;

if (terminal) {
pid_t p = fork();
if (p == -1)
Expand Down
37 changes: 6 additions & 31 deletions src/fnettrace/fnettrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,47 +28,22 @@
#include <time.h>
#include <stdarg.h>

//#define NETLOCK_INTERVAL 60
//#define NETLOCK_INTERVAL 15
#define NETLOCK_INTERVAL 60
#define DISPLAY_INTERVAL 3

void logprintf(char* fmt, ...);

static inline void ansi_topleft(int tolog) {
static inline void ansi_topleft(void) {
char str[] = {0x1b, '[', '1', ';', '1', 'H', '\0'};
if (tolog)
logprintf("%s", str);
else
printf("%s", str);
printf("%s", str);
fflush(0);
}

static inline void ansi_clrscr(int tolog) {
ansi_topleft(tolog);
static inline void ansi_clrscr(void) {
ansi_topleft();
char str[] = {0x1b, '[', '0', 'J', '\0'};
if (tolog)
logprintf("%s", str);
else
printf("%s", str);
fflush(0);
}

static inline void ansi_linestart(int tolog) {
char str[] = {0x1b, '[', '0', 'G', '\0'};
if (tolog)
logprintf("%s", str);
else
printf("%s", str);
fflush(0);
}

static inline void ansi_clrline(int tolog) {
ansi_linestart(tolog);
char str[] = {0x1b, '[', '0', 'K', '\0'};
if (tolog)
logprintf("%s", str);
else
printf("%s", str);
printf("%s", str);
fflush(0);
}

Expand Down
Loading

0 comments on commit 1000c23

Please sign in to comment.