Mercurial > octave
annotate liboctave/system/oct-password.h @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | 96a40641d86e |
children | e88a07dec498 |
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 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30072
diff
changeset
|
3 // Copyright (C) 1996-2022 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 | 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 | 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 | 31 #include <string> |
32 | |
33 #include <sys/types.h> | |
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 | 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 | 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 | 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 (), |
30065
05d0f3142b8d
maint: use "m_" prefix for member variable "valid" in class password.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
47 m_dir (), m_shell (), m_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), |
30065
05d0f3142b8d
maint: use "m_" prefix for member variable "valid" in class password.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
53 m_dir (pw.m_dir), m_shell (pw.m_shell), m_valid (pw.m_valid) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
54 { } |
2934 | 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; |
30065
05d0f3142b8d
maint: use "m_" prefix for member variable "valid" in class password.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
67 m_valid = pw.m_valid; |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
68 } |
2934 | 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 | 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 | 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 | 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 | 88 |
30065
05d0f3142b8d
maint: use "m_" prefix for member variable "valid" in class password.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
89 bool ok (void) const { return m_valid; } |
2934 | 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 | 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 | 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 | 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 | 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 | 107 |
21729
815b2f500fab
use namespace for system password wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
108 private: |
2934 | 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 | 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 | 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 | 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 | 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 | 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 | 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. |
30065
05d0f3142b8d
maint: use "m_" prefix for member variable "valid" in class password.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
132 bool m_valid; |
2934 | 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 | 140 |
141 #endif |