From dbb3038f8f7536a212822555d43442bd4fa5dbcf Mon Sep 17 00:00:00 2001 From: qorg11 Date: Thu, 9 Jun 2022 18:32:18 +0200 Subject: [PATCH] Made the thing better for BSD systems --- doc/sakisafecli.1 | 51 --------------------------------------- sakisafecli/Makefile | 31 ++++++------------------ sakisafecli/sakisafecli.c | 23 +++++++++++------- 3 files changed, 21 insertions(+), 84 deletions(-) delete mode 100644 doc/sakisafecli.1 diff --git a/doc/sakisafecli.1 b/doc/sakisafecli.1 deleted file mode 100644 index 5934c98..0000000 --- a/doc/sakisafecli.1 +++ /dev/null @@ -1,51 +0,0 @@ -.\"Manpage for lainsafe -.TH sakisafecli 1 -.SH NAME -sakisafecli \- File uploader - -.SH DESCRIPTION - -sakisafecli is a file uploader. Intended for lainsafe, but also works -for 0x0.st, i.kalli.st and probably others. - -.SH INSTALLATION -.in +4n -.EX -make -(or gcc sakisafecli.c -lcurl -o sakisafecli) -cp sakisafecli ~/.local/bin -.EE -.SH OPTIONS - -.PP -.B ---server= -Specifies which server to use, can be a lainsafe instance, 0x0.st -instance or i.kalli.st. Probably other similar software. - -.B ---tor -Routes all the traffic on the socks proxy at 127.0.0.1:9050, -which is usually tor. This can be edited in the -.B options.h -file - -.B ---i2p -Routes all the traffic on the http proxy at 127.0.0.1:4444, -which is usually I2P. This can be edited in the -.B options.h -file - -.B ---ipv6 or -6 -Forces curl to use IPv6 only. - -.B ---ipv4 or -4 -Forces curl to use IPv4 only. - -.B ---silent or -S -tells sakisafecli to be silent. This means, it won't -print the progress. diff --git a/sakisafecli/Makefile b/sakisafecli/Makefile index 8c856c7..3fc77c1 100644 --- a/sakisafecli/Makefile +++ b/sakisafecli/Makefile @@ -1,24 +1,7 @@ -# sakisafecli makefile - -TARGET = sakisafecli -OBJS = sakisafecli.o funcs.o -CC = cc -CFLAGSDEF += -MD -std=c11 -Wall -Wextra -lcurl -lconfig -CFLAGS += -O2 -ggdb - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(CC) $(CFLAGS) $(CFLAGSDEF) $(OBJS) -o $(TARGET) - -%.o: %.c - $(CC) -c $(CFLAGS) $(CFLAGSDEF) $< -o $@ - --include *.d - -install: all - @cp sakisafecli /usr/local/bin/ - -.PHONY: clean install -clean: - rm -f *.d *.o sakisafecli +PROG = sakisafecli +SRCS += funcs.c sakisafecli.c +MAN = sakisafecli.1 +LDADD = -lssl -lz -lpthread -lnghttp2 -lcurl -lconfig -lcrypto -L/usr/local/lib +CPPFLAGS = -I/usr/local/include +BINDIR=/usr/local/bin +.include diff --git a/sakisafecli/sakisafecli.c b/sakisafecli/sakisafecli.c index 724dc9a..c415ba4 100644 --- a/sakisafecli/sakisafecli.c +++ b/sakisafecli/sakisafecli.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include @@ -22,6 +22,13 @@ config_t runtime_config; int main(int argc, char **argv) { + #ifdef __OpenBSD__ + if(pledge("stdio rpath cpath inet dns unveil tmppath","") == -1) { + err(1,"pledge"); + _exit(-1); + } + #endif + struct curl_httppost *post = NULL; struct curl_httppost *last = NULL; @@ -36,7 +43,7 @@ main(int argc, char **argv) } char config_location[512]; char *sakisafeclirc_env = getenv("SAKISAFECLIRC"); - + if(sakisafeclirc_env == NULL) { snprintf(config_location, 512, "%s/.sakisafeclirc", getenv("HOME")); FILE *fp = fopen(config_location, "r"); @@ -45,7 +52,11 @@ main(int argc, char **argv) fclose(fp); } } else { + #if defined(__OpenBSD__) || defined(__FreeBSD__) + strlcpy(config_location, sakisafeclirc_env, 512); + #else /* Linux sucks! */ strncpy(config_location, sakisafeclirc_env, 512); + #endif FILE *fp = fopen(config_location, "r"); if(fp != NULL) { parse_config_file(fp); @@ -201,17 +212,11 @@ main(int argc, char **argv) if(!silent_flag) putchar('\n'); - printf("%s", buffer); + puts(buffer); } curl_formfree(post); curl_easy_cleanup(easy_handle); - /* Store link if needed */ - - if(enable_links_history) { - snprintf(history_file_path, 256, "%s/%s", getenv("HOME"), path); - store_link(history_file_path, buffer); - } free(buffer); config_destroy(&runtime_config); return 0;