X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=blobdiff_plain;f=cprogs%2Freally.c;h=f4cfa08692a99821f9309680d719da7d48456c47;hp=b240ea4702fce00157d2dca9566380aa87d4ac5f;hb=9d5485631fc7a00da86a0380c47d4afe507a6e6c;hpb=c314690b25b449e079fce8b215a3e96924898578;ds=sidebyside diff --git a/cprogs/really.c b/cprogs/really.c index b240ea4..f4cfa08 100644 --- a/cprogs/really.c +++ b/cprogs/really.c @@ -1,4 +1,22 @@ -/**/ +/* + * really.c - program for gaining privilege + * + * 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, + * or (at your option) any later version. + * + * This 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 along with this file; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ #include #include @@ -6,8 +24,8 @@ #include #include #include -#include #include +#include #include "myopt.h" @@ -30,6 +48,15 @@ static const char *opt_user, *opt_useronly; static int opt_groupsclear= 0, opt_ngids= 0, opt_uidonly= -1; static int opt_gids[512]; +static void af_uidonly(const struct cmdinfo *cip, const char *value) { + unsigned long ul; + char *ep; + + ul= strtoul(value,&ep,10); + if (*ep) { fprintf(stderr,"bad uid `%s'\n",value); exit(-1); } + opt_uidonly= ul; +} + static void af_group(const struct cmdinfo *cip, const char *value) { struct group *gr; @@ -58,7 +85,7 @@ static void af_help(const struct cmdinfo *cip, const char *value) { static const struct cmdinfo cmdinfos[]= { { "user", 'u', 1, 0, &opt_user, 0, }, { "useronly", 'i', 1, 0, &opt_useronly, 0 }, - { "uidonly", 'I', 1, &opt_uidonly, 0, 0 }, + { "uidonly", 'I', 1, 0, 0, af_uidonly }, { "groupsclear", 'z', 0, &opt_groupsclear, 0, 0, 1 }, { "group", 'g', 1, 0, 0, af_group }, { "gid", 'G', 1, 0, 0, af_gid }, @@ -76,7 +103,7 @@ static void checkroot(void) { #ifdef REALLY_CHECK_GID static void checkroot(void) { gid_t groups[512]; - int r; + int r, i; r= getgid(); if (r==REALLY_CHECK_GID) return; if (r<0) { perror("getgid check"); exit(-1); }