Mercurial > octave
annotate liboctave/system/oct-passwd.cc @ 21734:11af9c03400c
write namespace keyword and name on same line in C++ files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 19 May 2016 01:00:37 -0400 |
parents | 815b2f500fab |
children | e43d83253e28 |
rev | line source |
---|---|
2934 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
3 Copyright (C) 1996-2015 John W. Eaton |
2934 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2934 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2934 | 20 |
21 */ | |
22 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21202
diff
changeset
|
24 # include "config.h" |
2934 | 25 #endif |
26 | |
2937 | 27 #include <sys/types.h> |
28 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
29 #if defined (HAVE_PWD_H) |
21202
f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
30 # include <pwd.h> |
2934 | 31 #endif |
32 | |
33 #include "lo-error.h" | |
34 #include "oct-passwd.h" | |
35 | |
2937 | 36 #define NOT_SUPPORTED(nm) \ |
4062 | 37 nm ": not supported on this system" |
2937 | 38 |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
39 OCTAVE_NORETURN static |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
40 void |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
41 err_invalid (void) |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
42 { |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
43 (*current_liboctave_error_handler) ("invalid password object"); |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
44 } |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
45 |
21734
11af9c03400c
write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents:
21729
diff
changeset
|
46 namespace octave |
2934 | 47 { |
21734
11af9c03400c
write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents:
21729
diff
changeset
|
48 namespace sys |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
49 { |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
50 std::string |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
51 password::name (void) const |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
52 { |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
53 if (! ok ()) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
54 err_invalid (); |
2934 | 55 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
56 return m_name; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
57 } |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
58 |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
59 std::string |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
60 password::passwd (void) const |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
61 { |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
62 if (! ok ()) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
63 err_invalid (); |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
64 |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
65 return m_passwd; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
66 } |
2934 | 67 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
68 uid_t |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
69 password::uid (void) const |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
70 { |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
71 if (! ok ()) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
72 err_invalid (); |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
73 |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
74 return m_uid; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
75 } |
2934 | 76 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
77 gid_t |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
78 password::gid (void) const |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
79 { |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
80 if (! ok ()) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
81 err_invalid (); |
2934 | 82 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
83 return m_gid; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
84 } |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
85 |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
86 std::string |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
87 password::gecos (void) const |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
88 { |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
89 if (! ok ()) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
90 err_invalid (); |
2934 | 91 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
92 return m_gecos; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
93 } |
2934 | 94 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
95 std::string |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
96 password::dir (void) const |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
97 { |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
98 if (! ok ()) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
99 err_invalid (); |
2934 | 100 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
101 return m_dir; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
102 } |
2934 | 103 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
104 std::string |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
105 password::shell (void) const |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
106 { |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
107 if (! ok ()) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
108 err_invalid (); |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
109 |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
110 return m_shell; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
111 } |
2934 | 112 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
113 password |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
114 password::getpwent (void) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
115 { |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
116 std::string msg; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
117 return getpwent (msg); |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
118 } |
2937 | 119 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
120 password |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
121 password::getpwent (std::string& msg) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
122 { |
2937 | 123 #if defined HAVE_GETPWENT |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
124 msg = ""; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
125 return password (::getpwent (), msg); |
2934 | 126 #else |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
127 msg = NOT_SUPPORTED ("getpwent"); |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
128 return password (); |
2934 | 129 #endif |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
130 } |
2934 | 131 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
132 password |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
133 password::getpwuid (uid_t uid) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
134 { |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
135 std::string msg; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
136 return getpwuid (uid, msg); |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
137 } |
2937 | 138 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
139 password |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
140 password::getpwuid (uid_t uid, std::string& msg) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
141 { |
2937 | 142 #if defined (HAVE_GETPWUID) |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
143 msg = ""; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
144 return password (::getpwuid (uid), msg); |
2934 | 145 #else |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
146 msg = NOT_SUPPORTED ("getpwuid"); |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
147 return password (); |
2934 | 148 #endif |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
149 } |
2934 | 150 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
151 password |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
152 password::getpwnam (const std::string& nm) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
153 { |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
154 std::string msg; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
155 return getpwnam (nm, msg); |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
156 } |
2937 | 157 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
158 password |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
159 password::getpwnam (const std::string& nm, std::string& msg) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
160 { |
2937 | 161 #if defined (HAVE_GETPWNAM) |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
162 msg = ""; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
163 return password (::getpwnam (nm.c_str ()), msg); |
2934 | 164 #else |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
165 msg = NOT_SUPPORTED ("getpwnam"); |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
166 return password (); |
2934 | 167 #endif |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
168 } |
2934 | 169 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
170 int |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
171 password::setpwent (void) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
172 { |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
173 std::string msg; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
174 return setpwent (msg); |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
175 } |
2937 | 176 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
177 int |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
178 password::setpwent (std::string& msg) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
179 { |
2937 | 180 #if defined (HAVE_SETPWENT) |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
181 msg = ""; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
182 ::setpwent (); |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
183 return 0; |
2934 | 184 #else |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
185 msg = NOT_SUPPORTED ("setpwent"); |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
186 return -1; |
2934 | 187 #endif |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
188 } |
2934 | 189 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
190 int |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
191 password::endpwent (void) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
192 { |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
193 std::string msg; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
194 return endpwent (msg); |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
195 } |
2937 | 196 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
197 int |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
198 password::endpwent (std::string& msg) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
199 { |
2937 | 200 #if defined (HAVE_ENDPWENT) |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
201 msg = ""; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
202 ::endpwent (); |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
203 return 0; |
2934 | 204 #else |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
205 msg = NOT_SUPPORTED ("endpwent"); |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
206 return -1; |
2934 | 207 #endif |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
208 } |
2934 | 209 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
210 password::password (void *p, std::string& msg) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
211 : m_name (), m_passwd (), m_uid (0), m_gid (0), m_gecos (), |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
212 m_dir (), m_shell (), valid (false) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
213 { |
2937 | 214 #if defined (HAVE_PWD_H) |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
215 msg = ""; |
2937 | 216 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
217 if (p) |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
218 { |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
219 struct ::passwd *pw = static_cast<struct ::passwd *> (p); |
2934 | 220 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
221 m_name = pw->pw_name; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
222 m_passwd = pw->pw_passwd; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
223 m_uid = pw->pw_uid; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
224 m_gid = pw->pw_gid; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
225 m_gecos = pw->pw_gecos; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
226 m_dir = pw->pw_dir; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
227 m_shell = pw->pw_shell; |
2934 | 228 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
229 valid = true; |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
230 } |
2937 | 231 #else |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
232 msg = NOT_SUPPORTED ("password functions"); |
2934 | 233 #endif |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
234 } |
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
235 } |
2934 | 236 } |