00001 #ifndef EDG_WORKLOAD_COMMON_PROCESS_USER_H
00002 #define EDG_WORKLOAD_COMMON_PROCESS_USER_H
00003
00004 #include "edg/workload/common/common_namespace.h"
00005
00006 #include <pwd.h>
00007
00008 COMMON_NAMESPACE_BEGIN {
00009
00010 namespace process {
00011
00012 class User : private passwd {
00013 public:
00014
00015 User( void );
00016 User( const char *name );
00017 User( uid_t uid );
00018 User( const User &u );
00019
00020 ~User( void );
00021
00022
00023 inline const char *name( void ) { return this->pw_name; }
00024 inline const char *passwd( void ) { return this->pw_passwd; }
00025 inline const char *gecos( void ) { return this->pw_gecos; }
00026 inline const char *dir( void ) { return this->pw_dir; }
00027 inline const char *shell( void ) { return this->pw_shell; }
00028
00029
00030 inline bool good( void ) const { return this->u_good; }
00031 inline uid_t uid( void ) const { return this->pw_uid; }
00032 inline gid_t gid( void ) const { return this->pw_gid; }
00033 inline const char *name( void ) const { return this->pw_name; }
00034 inline const char *passwd( void ) const { return this->pw_passwd; }
00035 inline const char *gecos( void ) const { return this->pw_gecos; }
00036 inline const char *dir( void ) const { return this->pw_dir; }
00037 inline const char *shell( void ) const { return this->pw_shell; }
00038
00039
00040 User &uid( uid_t uid );
00041 User &name( const char *name );
00042
00043
00044 inline User &operator=( const User &U ) { if( this != &U ) this->zero()->copy( &U ); return( *this ); }
00045 inline bool operator!( void ) { return( !(this->u_good) ); }
00046 inline operator bool( void ) { return( this->u_good ); }
00047
00048 private:
00049
00050 void copy( const struct passwd *pwd );
00051 void copy( char *&dest, const char *source );
00052 User *remove( void );
00053 User *zero( void );
00054
00055
00056 bool u_good;
00057 };
00058
00059 };
00060
00061 } COMMON_NAMESPACE_END;
00062
00063 #endif
00064
00065
00066
00067