Partial support for SSL

This commit is contained in:
Emil 2023-08-07 05:13:13 -06:00
parent 6692f11590
commit 937e2536f0
No known key found for this signature in database
GPG Key ID: 5432DB986FDBCF8A
7 changed files with 41 additions and 17 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "lib/libircclient"]
path = lib/libircclient
url = https://git.lain.church/emil/libircclient

View File

@ -15,3 +15,6 @@ VERSION X
Added -identify Added -identify
ircmsg is now more useful ircmsg is now more useful
Fixed some error return values being too high Fixed some error return values being too high
Changed NVULN to NO_VULN
Added ENABLE_SSL=1 to enable SSL incomplete support
Added libircclient submodule

View File

@ -3,9 +3,10 @@
PROGN:=probotic PROGN:=probotic
CFLAGS:=-std=c99 -Wall -Wextra -Wpedantic -Wvla -Wshadow -Wundef CFLAGS:=-std=c99 -Wall -Wextra -Wpedantic -Wvla -Wshadow -Wundef
CPPFLAGS:=-I/usr/include/libircclient/ -Iinclude -D_GNU_SOURCE -DPROGN=\"${PROGN}\" -D_FORTIFY_SOURCE=2 CPPFLAGS:=-I./lib/libircclient/include/ -Iinclude -D_GNU_SOURCE -DPROGN=\"${PROGN}\" -D_FORTIFY_SOURCE=2
LDLIBS:=-lircclient -lsqlite3 LDLIBS:=-lsqlite3
LIB:=./lib/libircclient/src/libircclient.o
SRC := api.c irc.c main.c parse.c unity.c SRC := api.c irc.c main.c parse.c unity.c
HDR := api.h error.h irc.h irccolors.h parse.h stmt.h HDR := api.h error.h irc.h irccolors.h parse.h stmt.h
@ -20,16 +21,27 @@ ifdef SAN
CFLAGS += -fsanitize=${SAN} CFLAGS += -fsanitize=${SAN}
endif endif
ifeq (${NVULN},1) ifeq (${NO_VULN},1)
CPPFLAGS += -DNO_VULN_COMMANDS CPPFLAGS += -DNO_VULN_COMMANDS
endif endif
ifeq (${ENABLE_SSL},1)
LDLIBS += -lssl -lcrypto
CPPFLAGS += -DIRC_SSL_SUPPORT
endif
all: ${PROGN}
${PROGN}: ${HDR} ${SRC} ${PROGN}: ${HDR} ${SRC}
${LINK.c} src/unity.c -o $@ ${LDLIBS} ${LINK.c} -pipe ${LIB} src/unity.c -o $@ ${LDLIBS}
# do nothing but update them... # do nothing but update them...
$(SRC) $(HDR): $(SRC) $(HDR):
.PHONY: clean submodules:
git submodule update --init --recursive
clean: clean:
-rm ${OBJ} -rm ${OBJ}
.PHONY: submodules clean

1
lib/libircclient Submodule

@ -0,0 +1 @@
Subproject commit 76ae5fd5e7a3789756bcf07c42d10a9685987ae9

View File

@ -7,7 +7,8 @@ VARDECL char const * db = DBFILE;
VARDECL sqlite3 * connection = NULL; VARDECL sqlite3 * connection = NULL;
DECL void DBERR(const int l){ DECL void DBERR(const int l)
{
if(l != SQLITE_OK && l != SQLITE_ROW && l != SQLITE_DONE) if(l != SQLITE_OK && l != SQLITE_ROW && l != SQLITE_DONE)
{ {
fprintf(stderr, fprintf(stderr,
@ -34,13 +35,13 @@ api_init(void)
DECL void DECL void
api_rope(void) api_rope(void)
{ {
DBERR(sqlite3_finalize(remind_stmt)); DBERR(sqlite3_finalize(remind_stmt));
DBERR(sqlite3_finalize(set_repo_stmt)); DBERR(sqlite3_finalize(set_repo_stmt));
DBERR(sqlite3_finalize(get_nth_id_stmt)); DBERR(sqlite3_finalize(get_nth_id_stmt));
DBERR(sqlite3_finalize(new_assignment_stmt)); DBERR(sqlite3_finalize(new_assignment_stmt));
DBERR(sqlite3_finalize(purge_assignments_stmt)); DBERR(sqlite3_finalize(purge_assignments_stmt));
DBERR(sqlite3_finalize(is_no_assignment_stmt)); DBERR(sqlite3_finalize(is_no_assignment_stmt));
sqlite3_close(connection); sqlite3_close(connection);
} }
DECL void DECL void

View File

@ -159,13 +159,17 @@ init(void)
ERRMSG("Error creating IRC session"); ERRMSG("Error creating IRC session");
goto fail; goto fail;
} }
atexit(rope);
assert(creds.username != NULL); assert(creds.username != NULL);
assert(creds.server != NULL); assert(creds.server != NULL);
irc_connect(session, if (irc_connect(session,
creds.server, creds.port, creds.password, creds.server, creds.port, creds.password,
creds.username, creds.username, creds.username); creds.username, creds.username, creds.username))
{
fprintf(stderr, "IRC ERROR: %s\n", irc_strerror(irc_errno(session)));
exit(1);
}
FULL_FREE(creds.password); FULL_FREE(creds.password);
atexit(rope);
return 0; return 0;
fail: fail:
FULL_FREE(creds.password); FULL_FREE(creds.password);

BIN
src/unity.o Normal file

Binary file not shown.