From b48d0d607ce3e4cf344dec5c94392b2a84f7f649 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Thu, 24 Jun 2021 18:07:30 -0400 Subject: FreeBSD: Limit rights on save file --- ui.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ui.c b/ui.c index 9d67387..a3003df 100644 --- a/ui.c +++ b/ui.c @@ -48,6 +48,10 @@ #include #include +#ifdef __FreeBSD__ +#include +#endif + #include "chat.h" // Annoying stuff from : @@ -1181,11 +1185,19 @@ static ssize_t readString(FILE *file, char **buf, size_t *cap) { } void uiLoad(const char *name) { + int error; saveFile = dataOpen(name, "a+e"); if (!saveFile) exit(EX_CANTCREAT); rewind(saveFile); - int error = flock(fileno(saveFile), LOCK_EX | LOCK_NB); +#ifdef __FreeBSD__ + cap_rights_t rights; + cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FLOCK, CAP_FTRUNCATE); + error = cap_rights_limit(fileno(saveFile), &rights); + if (error) err(EX_OSERR, "cap_rights_limit"); +#endif + + error = flock(fileno(saveFile), LOCK_EX | LOCK_NB); if (error && errno == EWOULDBLOCK) { errx(EX_CANTCREAT, "%s: save file in use", name); } -- cgit 1.4.1 '>log tree commit diff
Commit message (Collapse)Author
2013-03-24Add paredit.vimJune McEnroe
2013-03-14Update base16-vimJune McEnroe
It's still crap
2013-03-12Hide mode from below statuslineJune McEnroe
2013-03-12Switch to powerlineJune McEnroe
Which I'm not going to bother configuring because it thinks it's all fancy and for other things that aren't Vim so it stores its config file in ~/.config which I keep in a different repo and I only want to use it for Vim so fuck you, Powerline. </rant>
2013-03-12Remove vim-powerlineJune McEnroe
2013-02-03Update base16 and refheapJune McEnroe
2013-02-03Ignore plugin/private.vimJune McEnroe
2012-09-29Disable GUI dialogsJune McEnroe