nis-util
1.0.D108
|
00001 // 00002 // nis-util - NIS Administration Utilities 00003 // Copyright (C) 2011, 2012 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 2 of the License, or (at 00008 // your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License along 00016 // with this program. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 00019 #include <lib/config.h> 00020 #include <libexplain/output.h> 00021 00022 #include <lib/colon/passwd/functor/check_group_count.h> 00023 00024 00025 colon_passwd_functor_check_group_count:: 00026 ~colon_passwd_functor_check_group_count() 00027 { 00028 if (error_count) 00029 { 00030 explain_output_error_and_die 00031 ( 00032 "found %d fatal error%s", 00033 error_count, 00034 (error_count == 1 ? "" : "s") 00035 ); 00036 } 00037 } 00038 00039 00040 colon_passwd_functor_check_group_count::colon_passwd_functor_check_group_count( 00041 unsigned a_max 00042 ) : 00043 max(a_max), 00044 error_count(0) 00045 { 00046 } 00047 00048 00049 void 00050 colon_passwd_functor_check_group_count::operator()( 00051 const colon_passwd::record::pointer &rp) 00052 { 00053 if (rp->get_groups().size() > max) 00054 { 00055 explain_output_error 00056 ( 00057 "user %s is a member of %ld groups (%ld too many)", 00058 rp->get_name().quote_c().c_str(), 00059 long(rp->get_groups().size()), 00060 long(rp->get_groups().size() - max) 00061 ); 00062 ++error_count; 00063 } 00064 } 00065 00066 00067 // vim: set ts=8 sw=4 et :