|
xrootd
|
00001 #ifndef __XRDSYSPWD_HH__ 00002 #define __XRDSYSPWD_HH__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d S y s P w d . h h */ 00006 /* */ 00007 /* (c) 2011 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /******************************************************************************/ 00012 00013 #include <sys/types.h> 00014 #include <pwd.h> 00015 00016 class XrdSysPwd 00017 { 00018 public: 00019 00020 int rc; 00021 00022 struct passwd *Get(const char *Usr) 00023 {rc = getpwnam_r(Usr,&pwStruct,pwBuff,sizeof(pwBuff),&Ppw); 00024 return Ppw; 00025 } 00026 00027 struct passwd *Get(uid_t Uid) 00028 {rc = getpwuid_r(Uid,&pwStruct,pwBuff,sizeof(pwBuff),&Ppw); 00029 return Ppw; 00030 } 00031 00032 XrdSysPwd() : rc(2) {} 00033 00034 XrdSysPwd(const char *Usr, struct passwd **pwP) 00035 {rc = getpwnam_r(Usr,&pwStruct,pwBuff,sizeof(pwBuff),pwP);} 00036 00037 XrdSysPwd(uid_t Uid, struct passwd **pwP) 00038 {rc = getpwuid_r(Uid,&pwStruct,pwBuff,sizeof(pwBuff),pwP);} 00039 00040 ~XrdSysPwd() {} 00041 00042 private: 00043 00044 struct passwd pwStruct, *Ppw; 00045 char pwBuff[4096]; 00046 }; 00047 #endif
1.7.5