vul_user_info.cxx
Go to the documentation of this file.
1 // This is core/vul/vul_user_info.cxx
2 //:
3 // \file
4 // \author Andrew W. Fitzgibbon, Oxford RRG
5 // \date 08 Apr 99
6 //
7 //-----------------------------------------------------------------------------
8 
9 #include <iostream>
10 #include "vul_user_info.h"
11 
12 
13 #if defined(_WIN32) && !defined(__CYGWIN__)
14 #include <direct.h>
15 #else
16 #include <unistd.h>
17 #include <pwd.h>
18 #endif
19 
20 #ifdef _MSC_VER
21 # include <vcl_msvc_warnings.h>
22 #endif
23 
24 // uid_type uid;
25 // uid_type gid;
26 // std::string name; // login name
27 // std::string home_directory;
28 // std::string full_name;
29 // std::string shell;
30 // std::string passwd;
31 
32 void vul_user_info::init(uid_type /*uid*/)
33 {
34  std::cerr << "Not implemented\n";
35 }
36 
37 void vul_user_info::init(char const* name_)
38 {
39 #if !defined(_WIN32) || defined(__CYGWIN__)
40  struct passwd* pw = getpwnam(name_);
41  if (!pw) {
42 #endif
43  this->ok = false;
44  this->uid = 0;
45  this->gid = 0;
46  this->name = name_;
47 #if !defined(_WIN32) || defined(__CYGWIN__)
48  } else {
49  this->ok = true;
50  this->uid = pw->pw_uid;
51  this->gid = pw->pw_gid;
52  this->name = pw->pw_name; // login name
53  this->home_directory = pw->pw_dir;
54  this->full_name = pw->pw_gecos;
55  this->shell = pw->pw_shell;
56  this->passwd = pw->pw_passwd;
57  }
58 #endif
59 }
Reads information about a user from the password file.
uid_type gid
Definition: vul_user_info.h:29
std::string passwd
Definition: vul_user_info.h:34
void init(uid_type)
NYI.
std::string name
Definition: vul_user_info.h:30
unsigned long uid_type
Definition: vul_user_info.h:25
std::string full_name
Definition: vul_user_info.h:32
uid_type uid
Definition: vul_user_info.h:28
std::string shell
Definition: vul_user_info.h:33
std::string home_directory
Definition: vul_user_info.h:31