X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=blobdiff_plain;f=cprogs%2Freally.c;h=ef2fb64dcb94f23b3801b297f8d7b1b7666fd681;hp=4d1f316364ea84fe4c84b201dbb85ce619d88b98;hb=refs%2Ftags%2Fdebian%2F4.4.2;hpb=50505a407d5558883e5242a12ec49d298f4344fe diff --git a/cprogs/really.c b/cprogs/really.c index 4d1f316..ef2fb64 100644 --- a/cprogs/really.c +++ b/cprogs/really.c @@ -1,11 +1,11 @@ /* * really.c - program for gaining privilege * - * Copyright (C) 1992-3 Ian Jackson + * Copyright (C) 1992-3 Ian Jackson * * This 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 2, + * published by the Free Software Foundation; either version 3, * or (at your option) any later version. * * This is distributed in the hope that it will be useful, but @@ -14,8 +14,9 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public - * License along with this file; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this file; if not, consult the Free Software + * Foundation's website at www.fsf.org, or the GNU Project website at + * www.gnu.org. */ #include @@ -42,8 +43,8 @@ void usagemessage(void) { " -g|--group } add this to\n" " -G|--gid } the group list\n" "other really-options:\n" - " -h|--help display this message" - " -R|--chroot chroot (but *not* chdir)", + " -h|--help display this message\n" + " -R|--chroot chroot (but *not* chdir - danger!)\n", stderr) == EOF) { perror("write usage"); exit(-1); } } @@ -98,28 +99,30 @@ static const struct cmdinfo cmdinfos[]= { }; #ifdef REALLY_CHECK_FILE -static void checkroot(void) { +static int checkroot(void) { int r; r= access(REALLY_CHECK_FILE,W_OK); - if (r) { perror("sorry"); exit(-1); } + if (r) return -1; + return 0; } #endif #ifdef REALLY_CHECK_GID -static void checkroot(void) { +static int checkroot(void) { gid_t groups[512]; int r, i; - r= getgid(); if (r==REALLY_CHECK_GID) return; + r= getgid(); if (r==REALLY_CHECK_GID) return 0; if (r<0) { perror("getgid check"); exit(-1); } r= getgroups(sizeof(groups)/sizeof(groups[0]),groups); if (r<0) { perror("getgroups check"); exit(-1); } for (i=0; ipw_gid);