nis-util
1.0.D108
|
00001 // 00002 // nis-util - NIS Administration Utilities 00003 // Copyright (C) 2001, 2008, 2009, 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 00016 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 00019 #ifndef LIB_COLON_PASSWD_H 00020 #define LIB_COLON_PASSWD_H 00021 00022 #include <boost/shared_ptr.hpp> 00023 00024 #include <lib/colon.h> 00025 00030 class colon_passwd: 00031 public colon 00032 { 00033 public: 00034 typedef boost::shared_ptr<colon_passwd> pointer; 00035 00039 virtual ~colon_passwd(); 00040 00048 static pointer create(const rcstring &filename); 00049 00054 class record 00055 { 00056 public: 00057 typedef boost::shared_ptr<record> pointer; 00058 00062 ~record(); 00063 00068 static pointer create(const source_location &locn, const rcstring &name, 00069 const rcstring &passwd, const rcstring &uid, const rcstring &gid, 00070 const rcstring &gecos, const rcstring &home, const rcstring &shell); 00071 00072 const source_location &get_source_location(void) const { return locn; } 00073 rcstring get_name(void) const { return name; } 00074 rcstring get_password(void) const { return password; } 00075 rcstring get_uid(void) const { return uid; } 00076 long get_uid_binary(void) const; 00077 rcstring get_gid(void) const { return gid; } 00078 long get_gid_binary(void) const; 00079 rcstring get_gecos(void) const { return gecos; } 00080 rcstring get_home(void) const { return home; } 00081 rcstring get_shell(void) const { return shell; } 00082 00089 rcstring representation(void) const; 00090 00091 typedef std::vector<rcstring> groups_t; 00092 00093 const groups_t &get_groups(void) const { return groups; } 00094 00095 void append_group(const rcstring &gid); 00096 00097 private: 00102 record(const source_location &locn, const rcstring &name, 00103 const rcstring &passwd, const rcstring &uid, const rcstring &gid, 00104 const rcstring &gecos, const rcstring &home, const rcstring &shell); 00105 00110 source_location locn; 00111 00112 rcstring name; 00113 rcstring password; 00114 rcstring uid; 00115 rcstring gid; 00116 rcstring gecos; 00117 rcstring home; 00118 rcstring shell; 00119 00125 groups_t groups; 00126 00130 record(); 00131 00135 record(const record &rhs); 00136 00140 record &operator=(const record &rhs); 00141 }; 00142 00153 record::pointer get(void); 00154 00161 static rcstring is_ok_user_name(const rcstring &text); 00162 00163 protected: 00171 colon_passwd(const rcstring &filename); 00172 00173 private: 00180 bool validate(const record::pointer &rp); 00181 00187 long last_uid; 00188 00192 colon_passwd(); 00193 00197 colon_passwd(const colon_passwd &); 00198 00202 colon_passwd &operator=(const colon_passwd &); 00203 }; 00204 00205 // vim: set ts=8 sw=4 et : 00206 #endif // LIB_COLON_PASSWD_H