core/vul/vul_user_info.cxx
Go to the documentation of this file.
00001 // This is core/vul/vul_user_info.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 //:
00006 // \file
00007 // \author Andrew W. Fitzgibbon, Oxford RRG
00008 // \date   08 Apr 99
00009 //
00010 //-----------------------------------------------------------------------------
00011 
00012 #include "vul_user_info.h"
00013 
00014 
00015 #if defined(VCL_WIN32) && !defined(__CYGWIN__)
00016 #include <direct.h>
00017 #else
00018 #include <unistd.h>
00019 #include <pwd.h>
00020 #endif
00021 
00022 #include <vcl_iostream.h>
00023 
00024 //  uid_type uid;
00025 //  uid_type gid;
00026 //  vcl_string name; // login name
00027 //  vcl_string home_directory;
00028 //  vcl_string full_name;
00029 //  vcl_string shell;
00030 //  vcl_string passwd;
00031 
00032 void vul_user_info::init(uid_type /*uid*/)
00033 {
00034   vcl_cerr << "Not implemented\n";
00035 }
00036 
00037 void vul_user_info::init(char const* name_)
00038 {
00039 #if !defined(VCL_WIN32) || defined(__CYGWIN__)
00040   struct passwd* pw = getpwnam(name_);
00041   if (!pw) {
00042 #endif
00043     this->ok = false;
00044     this->uid = 0;
00045     this->gid = 0;
00046     this->name = name_;
00047 #if !defined(VCL_WIN32) || defined(__CYGWIN__)
00048   } else {
00049     this->ok = true;
00050     this->uid = pw->pw_uid;
00051     this->gid = pw->pw_gid;
00052     this->name = pw->pw_name; // login name
00053     this->home_directory = pw->pw_dir;
00054     this->full_name = pw->pw_gecos;
00055     this->shell = pw->pw_shell;
00056     this->passwd = pw->pw_passwd;
00057   }
00058 #endif
00059 }