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
ircmsg is now more useful
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
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
HDR := api.h error.h irc.h irccolors.h parse.h stmt.h
@ -20,16 +21,27 @@ ifdef SAN
CFLAGS += -fsanitize=${SAN}
endif
ifeq (${NVULN},1)
ifeq (${NO_VULN},1)
CPPFLAGS += -DNO_VULN_COMMANDS
endif
ifeq (${ENABLE_SSL},1)
LDLIBS += -lssl -lcrypto
CPPFLAGS += -DIRC_SSL_SUPPORT
endif
all: ${PROGN}
${PROGN}: ${HDR} ${SRC}
${LINK.c} src/unity.c -o $@ ${LDLIBS}
${LINK.c} -pipe ${LIB} src/unity.c -o $@ ${LDLIBS}
# do nothing but update them...
$(SRC) $(HDR):
.PHONY: clean
submodules:
git submodule update --init --recursive
clean:
-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;
DECL void DBERR(const int l){
DECL void DBERR(const int l)
{
if(l != SQLITE_OK && l != SQLITE_ROW && l != SQLITE_DONE)
{
fprintf(stderr,
@ -34,13 +35,13 @@ api_init(void)
DECL void
api_rope(void)
{
DBERR(sqlite3_finalize(remind_stmt));
DBERR(sqlite3_finalize(set_repo_stmt));
DBERR(sqlite3_finalize(get_nth_id_stmt));
DBERR(sqlite3_finalize(new_assignment_stmt));
DBERR(sqlite3_finalize(purge_assignments_stmt));
DBERR(sqlite3_finalize(is_no_assignment_stmt));
sqlite3_close(connection);
DBERR(sqlite3_finalize(remind_stmt));
DBERR(sqlite3_finalize(set_repo_stmt));
DBERR(sqlite3_finalize(get_nth_id_stmt));
DBERR(sqlite3_finalize(new_assignment_stmt));
DBERR(sqlite3_finalize(purge_assignments_stmt));
DBERR(sqlite3_finalize(is_no_assignment_stmt));
sqlite3_close(connection);
}
DECL void

View File

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

BIN
src/unity.o Normal file

Binary file not shown.