annotate liboctave/system/oct-passwd.h @ 29358:0a5b15007766 stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021.
author John W. Eaton <jwe@octave.org>
date Wed, 10 Feb 2021 09:52:15 -0500
parents bd51beb6205e
children 05d0f3142b8d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
3 // Copyright (C) 1996-2021 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
25
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 19697
diff changeset
26 #if ! defined (octave_oct_passwd_h)
17822
ebb3ef964372 maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents: 17744
diff changeset
27 #define octave_oct_passwd_h 1
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
28
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21102
diff changeset
29 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21102
diff changeset
30
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
31 #include <string>
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
32
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
33 #include <sys/types.h>
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
34
21734
11af9c03400c write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents: 21729
diff changeset
35 namespace octave
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
36 {
21734
11af9c03400c write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents: 21729
diff changeset
37 namespace sys
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2934
diff changeset
38 {
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
39 class
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
40 OCTAVE_API
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
41 password
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
42 {
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
43 public:
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
44
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
45 password (void)
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
46 : 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: 21244
diff changeset
47 m_dir (), m_shell (), valid (false)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
48 { }
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
49
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
50 password (const password& pw)
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
51 : m_name (pw.m_name), m_passwd (pw.m_passwd),
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
52 m_uid (pw.m_uid), m_gid (pw.m_gid), m_gecos (pw.m_gecos),
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
53 m_dir (pw.m_dir), m_shell (pw.m_shell), valid (pw.valid)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
54 { }
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
55
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
56 password& operator = (const password& pw)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
57 {
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
58 if (this != &pw)
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
59 {
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
60 m_name = pw.m_name;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
61 m_passwd = pw.m_passwd;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
62 m_uid = pw.m_uid;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
63 m_gid = pw.m_gid;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
64 m_gecos = pw.m_gecos;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
65 m_dir = pw.m_dir;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
66 m_shell = pw.m_shell;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
67 valid = pw.valid;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
68 }
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
69
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
70 return *this;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
71 }
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
72
22868
87e3163f6c87 use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
73 ~password (void) = default;
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
74
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
75 std::string name (void) const;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
76
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
77 std::string passwd (void) const;
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
78
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
79 uid_t uid (void) const;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
80
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
81 gid_t gid (void) const;
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
82
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
83 std::string gecos (void) const;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
84
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
85 std::string dir (void) const;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
86
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
87 std::string shell (void) const;
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
88
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
89 bool ok (void) const { return valid; }
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
90
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
91 operator bool () const { return ok (); }
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
92
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
93 static password getpwent (void);
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
94 static password getpwent (std::string& msg);
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
95
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
96 static password getpwuid (uid_t uid);
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
97 static password getpwuid (uid_t uid, std::string& msg);
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
98
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
99 static password getpwnam (const std::string& nm);
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
100 static password getpwnam (const std::string& nm, std::string& msg);
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
101
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
102 static int setpwent (void);
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
103 static int setpwent (std::string& msg);
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
104
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
105 static int endpwent (void);
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
106 static int endpwent (std::string& msg);
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
107
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
108 private:
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
109
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
110 // User name.
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
111 std::string m_name;
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
112
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
113 // Encrypted password.
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
114 std::string m_passwd;
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
115
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
116 // Numeric user id.
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
117 uid_t m_uid;
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
118
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
119 // Numeric group id.
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
120 gid_t m_gid;
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
121
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
122 // Miscellaneous junk.
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
123 std::string m_gecos;
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
124
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
125 // Home directory.
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
126 std::string m_dir;
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
127
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
128 // Login shell.
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
129 std::string m_shell;
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
130
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
131 // Flag that says whether we have been properly initialized.
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
132 bool valid;
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
133
21729
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
134 // This is how we will create a password object from a pointer
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
135 // to a struct passwd.
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
136 password (void *p, std::string& msg);
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
137 };
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
138 }
815b2f500fab use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
139 }
2934
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
140
dddc1b5c324e [project @ 1997-05-05 22:56:37 by jwe]
jwe
parents:
diff changeset
141 #endif