X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=secnet.git;a=blobdiff_plain;f=secnet.c;h=8fb8affe43f80d6cebab337e504524b7f3907756;hp=111a1b0886f0c1e11a0d8a367a6aec75136689f9;hb=59a5b098bd17ae3202115e3436343ec6e58da1fb;hpb=8bebb29950d2a3c8558e676575cbff35b4e360c3 diff --git a/secnet.c b/secnet.c index 111a1b0..8fb8aff 100644 --- a/secnet.c +++ b/secnet.c @@ -1,3 +1,22 @@ +/* + * This file is part of secnet. + * See README for full list of copyright holders. + * + * secnet is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version d of the License, or + * (at your option) any later version. + * + * secnet is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * version 3 along with secnet; if not, see + * https://www.gnu.org/licenses/gpl.html. + */ + #include "secnet.h" #include #include @@ -235,7 +254,7 @@ struct poll_interest *register_for_poll(void *st, beforepoll_fn *before, { struct poll_interest *i; - i=safe_malloc(sizeof(*i),"register_for_poll"); + NEW(i); i->before=before; i->after=after; i->state=st; @@ -331,7 +350,7 @@ static void run(void) if (shortfall) { allocdfds *= 2; allocdfds += shortfall; - fds=safe_realloc_ary(fds,sizeof(*fds),allocdfds, "run"); + REALLOC_ARY(fds,allocdfds); } shortfall=0; idx=0; @@ -383,6 +402,12 @@ static void run(void) free(fds); } +bool_t will_droppriv(void) +{ + assert(current_phase >= PHASE_SETUP); + return !!uid; +} + /* Surrender privileges, if necessary */ static void droppriv(void) { @@ -469,6 +494,8 @@ int main(int argc, char **argv) { dict_t *config; + phase_hooks_init(); + enter_phase(PHASE_GETOPTS); parse_options(argc,argv);